Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: The purpose of this programming project is to become familiar with the MPI API and write basic communication programs. This can be accomplished by

image text in transcribed

Objective: The purpose of this programming project is to become familiar with the MPI API and write basic communication programs. This can be accomplished by developing simple computer programs that use the MPI parallel communications library. Part B. Generating Prime Numbers (25 points) 1. Initialize MPI 2. Get the size of MPI_COMM_WORLD communicator and rank of the current process(es). 3. Have process 0 to receive an input from the keyboard how many prime numbers are to be generated. 4. Process 0 will divide the total number of prime numbers to be generated by the number of processes and accordingly, will send a message to each process to produce that many prime numbers. 5. Each process will receive the message of how many prime numbers needs to be generated. To produce a prime number, each process can use the random number generation function and check whether a random number is a prime or not and accordingly, can fill an array. At the end each process will send an array of prime numbers to process 0 . 6. Process 0 will receive an array of prime numbers from each process and put them together in a large array. 7. Process 0 will write all the prime numbers generated in a file named as "prime.dat" with each number on a separate line. Save your program with a filename as prog 2b.c or prog 2b.cpp. Note: To work on this assignment, you need to know how to use the random number generator function. Remember, in the first project we used the random number generator function in the computation of PI. You also need to know how to test whether a positive integer is a prime number or not. A prime number is a number which is only divisible by 1 or by the number itself. If any number other than 1 or the number itself divides the number evenly (i.e, with a remainder of 0 ), then the number is not a prime number. For any given number n, you may try to divide the number by 2,3,,n1 and see whether it is divisible. A more efficient solution is to try to divide n by 2,3,4,,n. You may find many code examples online. Be sure to include the source in your "readme" file or mention the source as a comment in your program if you copy code from any online sources

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Describe contextual influences on direct financial compensation.

Answered: 1 week ago

Question

=+Are there shop stewards?

Answered: 1 week ago