Getting started with "Hello World"

 

"Hello World"

 

 



1.Write a program that uses MPI and has each MPI process print the following:

       Hello world from process i of n

using the rank in MPI_COMM_WORLD for i and the size of MPI_COMM_WORLD for n.

You may want to use these MPI routines in your solution:



2. Correct the following parallel code

#include < stdio.h >
int main( argc, argv )
int  argc;
char **argv;
{
    int rank, size;
    MPI_Init( &argc, &argv );
    MPI_Comm_size( MPI_COMM_WORLD, &size );
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    printf( "Hello world from process %d of %d
", rank, size );
    MPI_Finalize();
    return 0;
}