source: CIVL/examples/mpi/simple/ooogather.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: 740 bytes
Line 
1/* Out of order gathers. Error should be detected
2 * with -deadlock=potential.
3 */
4#include<mpi.h>
5#include<stdlib.h>
6
7int nprocs;
8int myrank;
9
10void main() {
11 int argc;
12 char **argv;
13 double x;
14 double *buf;
15
16 MPI_Init(&argc, &argv);
17 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
18 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
19 x=myrank;
20 buf = (double*)malloc(nprocs*sizeof(double));
21 if (myrank == 0) {
22 MPI_Gather(&x, 1, MPI_DOUBLE, buf, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
23 MPI_Gather(&x, 1, MPI_DOUBLE, buf, 1, MPI_DOUBLE, 1, MPI_COMM_WORLD);
24 } else {
25 MPI_Gather(&x, 1, MPI_DOUBLE, buf, 1, MPI_DOUBLE, 1, MPI_COMM_WORLD);
26 MPI_Gather(&x, 1, MPI_DOUBLE, buf, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
27 }
28 MPI_Finalize();
29}
Note: See TracBrowser for help on using the repository browser.