forked from MartinThoma/LaTeX-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2db412
commit deea483
Showing
7 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
18 changes: 18 additions & 0 deletions
18
documents/Programmierparadigmen/scripts/mpi/mpi-receive-example.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "mpi.h" | ||
|
||
int msglen, again=1; | ||
void *buf; | ||
MPI_Datatype datatype | ||
MPI_Comm comm; | ||
MPI_Status status; | ||
|
||
... | ||
while (again) { | ||
MPI_Probe(ROOT, MPI_ANY_TAG, comm, &status); | ||
MPI_Get_count(&status, datatype, &msglen); | ||
buf=malloc(msglen*sizeof(int)); | ||
MPI_Recv(buf, msglen, datatype, status.MPI_SOURCE, | ||
status.MPI_TAG, comm, &status); | ||
... | ||
} | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int MPI_Recv(void *buf, int count, | ||
MPI_Datatype datatype, int source, int tag, | ||
MPI_Comm comm, MPI_Status *status) |
18 changes: 18 additions & 0 deletions
18
documents/Programmierparadigmen/scripts/mpi/mpi-send-example.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "mpi.h" | ||
... | ||
int signal, i, numprogs, me; | ||
MPI_Status stat; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &me); | ||
MPI_Comm_size(MPI_COMM_WORLD, | ||
&numprocs); | ||
if (me==ROOT) { | ||
... | ||
for (i=1; i<numprocs; i++) { | ||
MPI_Send(&signal, 1, MPI_INT, i, 0, MPI_COMM_WORLD); | ||
} | ||
... | ||
else { | ||
MPI_Recv(&sig, 1, MPI_INT, ROOT, MPI_ANY_TAG, | ||
MPI_COMM_WORLD, &stat); | ||
... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int MPI_Send(void *buf, int count, | ||
MPI_Datatype datatype, int dest, | ||
int tag, MPI_Comm comm) |