I am a beginner trying to learn MPI. I have tried to run the following program downloaded from internet:
#include <stdio.h>
#include <mpi.h>
int main (argc, argv)
int argc;
char *argv[];
{
int rank, size;
MPI_Init (&argc, &argv); /* starts MPI */
MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */
printf( "Hello world from process %d of %d\n", rank, size );
MPI_Finalize();
return 0;
}
The code has been compiled with mpicc
and executed with mpirun
.
mpicc HelloWorld.c
mpirun -np 4 a.out
The output is as follows:
Hello world from process 0 of 1
Hello world from process 0 of 1
Hello world from process 0 of 1
Hello world from process 0 of 1
My question is, why the output has generated only one process and not 4 processes as requested?