source: CIVL/examples/mpi/simple/commDupBad.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 635 bytes
Line 
1/* commDupBad.c : A simple buggy example related to the MPI routine:
2 MPI_Comm_dup(MPI_Comm *).
3 */
4#include <mpi.h>
5
6int main(int argc, char * argv[]) {
7 int size, rank;
8 MPI_Comm anotherComm;
9 double buf;
10
11 MPI_Init(&argc, &argv);
12 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
13 MPI_Comm_size(MPI_COMM_WORLD, &size);
14 MPI_Comm_dup(MPI_COMM_WORLD, &anotherComm);
15
16 buf = 2.0;
17 if(rank == 0) {
18 for(int i = 1 ; i < size; i++)
19 MPI_Send(&buf, 1, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
20 }else
21 MPI_Recv(&buf, 1, MPI_DOUBLE, 0, 0, anotherComm, MPI_STATUS_IGNORE);
22 MPI_Comm_free(&anotherComm);
23 MPI_Finalize();
24 return 0;
25}
Note: See TracBrowser for help on using the repository browser.