mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
MPI
This commit is contained in:
parent
c2db4122e7
commit
deea4832fe
7 changed files with 104 additions and 5 deletions
20
documents/Programmierparadigmen/scripts/mpi/for-example.c
Normal file
20
documents/Programmierparadigmen/scripts/mpi/for-example.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue