Write an MPI program, countprimes which will count the number of prime numbers in the numbers from 1 to n inclusive where n is a long integer. The value for n which should be set in the program using a constant should be 50,000. Each process will test its share of the cases. Each process should not print out any primes that it finds, but it should keep a running total. Before the process finishes, it should print out its ID number and its count of primes that it found. The master process should end with printing a total for the count of the number of primes and the total amount of time taken to find all the primes.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

MPI Lab Directions

 

Write an MPI program, countprimes which will count the number of prime numbers in the numbers from 1 to n inclusive where n is a long integer. The value for n which should be set in the program using a constant should be 50,000.

Each process will test its share of the cases.

Each process should not print out any primes that it finds, but it should keep a running total. Before the process finishes, it should print out its ID number and its count of primes that it found.

The master process should end with printing a total for the count of the number of primes and the total amount of time taken to find all the primes.

Take a screenshot of the output for running this with 5 processes.

Before submission, make sure you clean up the directories so that no miscellaneous files are kept around in the submission. (Grade would be deducted if useless files are found in the homework directories.) Include the source code, screenshot, and the Makefile in the submission. Your Makefile can assume that the path to the MPI compiler is found in the path.

If the program does not compile using MPICC and do something useful when it runs it will not earn any credit.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr