Question: Consider the following helloworld.c MPI program IN C: #include #include mpi.h int main(int argc, char* argv[]) { int rank, size, len; char version[MPI_MAX_LIBRARY_VERSION_STRING]; MPI_Init(&argc, &argv);

Consider the following helloworld.c MPI program IN C:

#include

#include "mpi.h"

int main(int argc, char* argv[])

{

int rank, size, len;

char version[MPI_MAX_LIBRARY_VERSION_STRING];

MPI_Init(&argc, &argv);

MPI_Comm_rank(MPI_COMM_WORLD, &rank);

MPI_Comm_size(MPI_COMM_WORLD, &size);

MPI_Get_library_version(version, &len);

printf("Hello world, I am %d of %d, (%s, %d) ",

rank, size, version, len);

MPI_Finalize();

return 0;

}

This program takes an integer n as a command line argument and prints for each process the following output: Hello world, I am process i of n processes, where i is the rank of the process, and n is the size.

Compile and run this MPI program and verify its output by following these steps:

  • Open a new file in Notepad++ and copy the code above. Save your file with YourName_Prob1.c.
  • In Cygwin, use emacs to create and save your program.
  • In Cygwin, first compile your program by using the command: mpicc o Problem1 YourName_Prob1.c
  • Then, run your MPI program by typing the command: mpirun np 4 Problem1
  • Verify that your program gives the correct output

THANKS IN HELPING ME

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!