source: CIVL/examples/mpi/mpiFeature/Test_nonblocking/bug.cvl@ 7d77e64

main test-branch
Last change on this file since 7d77e64 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: 1.0 KB
Line 
1#include "mpi.h"
2#include "assert.h"
3
4int many_to_one () {
5 int comm_size;
6 int comm_rank;
7 MPI_Comm comm = MPI_COMM_WORLD;
8 MPI_Datatype type = MPI_INT;
9
10 MPI_Comm_size (comm, &comm_size);
11 MPI_Comm_rank (comm, &comm_rank);
12
13 int rbuf[comm_size];
14 MPI_Request reqs[comm_size];
15 MPI_Status statuses[comm_size];
16
17 MPI_Send(&comm_rank, 1, type, 0, comm_rank, comm);
18 if (comm_rank == 0) {
19 for (int i = 0; i < comm_size; i++) {
20 $choose {
21 $when ($true) {
22 MPI_Irecv(rbuf + i, 1, type, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, reqs + i);
23 assert (reqs[i] != MPI_REQUEST_NULL);
24 }
25 $when ($true) {
26 MPI_Recv(rbuf + i, 1, type, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, statuses + i);
27 reqs[i] = MPI_REQUEST_NULL;
28 }
29 }
30 }
31 MPI_Waitall(comm_size, reqs, statuses);
32 for (int i = 0; i < comm_size; i++) {
33 int src = statuses[i].MPI_SOURCE;
34
35 assert (statuses[i].MPI_TAG == src);
36 assert (rbuf[i] == src);
37 }
38 }
39 return 0;
40}
41
42int main() {
43 MPI_Init(NULL, NULL);
44 many_to_one();
45 MPI_Finalize();
46 return 0;
47}
Note: See TracBrowser for help on using the repository browser.