source: CIVL/examples/mpi/simple/ooogather.c@ a0b7ab5

1.23 2.0 main test-branch
Last change on this file since a0b7ab5 was a9a9973, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

added test for examples from tass/examples/simpleMPI.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2147 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.