MPIHelloWorld
From Parawiki
MPIHelloWorld.c
//compilation: //$ mpicc -o program MPIHelloWorld.c //$ mpirun -np number_of_processes program //If you want to use multiple processors you have to use lamboot before! //if mpi.h cannot be found by the compiler, try to locate mpi.h: //open a terminal and: $ locate mpi.h //and then include by giving the whole path to mpi.h #include <stdio.h> #include "mpi.h" int main(int argc, char* argv[]){ int rank, size; //process rank and number of processes MPI_Init(&argc, &argv); //MPI initialize MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); printf("Hello world from process %d of %d\n", rank, size); MPI_Finalize(); //MPI finalize return 0; }