source: CIVL/examples/mpi/simple/commDup.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: 591 bytes
RevLine 
[1079bef]1/* commDup.c : A simple example shows how to use the MPI_Routine
2 MPI_Comm_dup(MPI_Comm*).
3 */
4#include <mpi.h>
5#include <assert.h>
6
7int main(int argc, char * argv[]) {
8 int size, rank, buf;
9 MPI_Comm anotherComm;
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 MPI_Reduce(&rank, &buf, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
17 MPI_Bcast(&buf, 1, MPI_INT, 0, anotherComm);
18 assert(buf == ((size - 1) * size / 2));
19 MPI_Comm_free(&anotherComm);
20 MPI_Finalize();
21 return 0;
22}
Note: See TracBrowser for help on using the repository browser.