#include <stdio.h> #include <mpi.h> int main(int argc, char **argv) { int my_rank, numprocs; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&id); /*printf("Hello! It is processor %d.\n", id);*/ if (my_rank == 0) { printf("Hello! It is processor 0. There are %d processors in this communication world.\n", numprocs); printf ("I am process %i out of %i: Hello world!\n",my_rank, size); } else { printf("I am process %i out of %i: Hello world!\n", my_rank, size); } MPI_Finalize(); return 0; }
char* my_name = "Cem Ozdogan"; MPI_Send(&my_name, 11, MPI_CHAR, dest, 2, MPI_COMM_WORLD); MPI_Recv(&recv_my_name, 11, MPI_CHAR, 0, 2, MPI_COMM_WORLD, &status);