2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-25 14:28:05 +02:00
LaTeX-examples/documents/Programmierparadigmen/scripts/mpi/for-example.c
Martin Thoma deea4832fe MPI
2014-03-16 15:49:25 +01:00

20 lines
No EOL
458 B
C

#include <stdio.h>
#include <mpi.h>
int main (int argc, char** args) {
int size, i;
int myrank;
MPI_Init(&argc, &args);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
for (i=0; i<size; i++) {
MPI_Barrier(MPI_COMM_WORLD);
if (i == myrank) {
printf("Hello World, I have rank %d out of %d.\n",
myrank, size);
}
}
MPI_Finalize();
return 0;
}