source: CIVL/mods/dev.civl.abc/examples/contract/isRecvBufEmpty_OK.c

main
Last change on this file was aad342c, checked in by Stephen Siegel <siegel@…>, 3 years ago

Performing huge refactor to incorporate ABC, GMC, and SARL into CIVL repo and use Java modules.

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

  • Property mode set to 100644
File size: 674 bytes
Line 
1#include<assert.h>
2#include<mpi.h>
3#include<civl-mpi.cvh>
4#include<stdio.h>
5#pragma CIVL ACSL
6
7MPI_Comm comm = MPI_COMM_WORLD;
8int rank, nprocs, left, right;
9
10/*@ \mpi_collective(comm, P2P):
11 @ ensures \mpi_empty_in(left) && left == \result;
12 @*/
13int sendrecv()
14{
15 int message = rank;
16 int recvBuf;
17
18 MPI_Sendrecv(&message, 1, MPI_INT, right, 0, &recvBuf, 1, MPI_INT, left, 0, comm, MPI_STATUS_IGNORE);
19 return recvBuf;
20}
21
22int main(int argc, char * argv[]) {
23 int x;
24
25 MPI_Init(&argc, &argv);
26 MPI_Comm_size(comm, &nprocs);
27 MPI_Comm_rank(comm, &rank);
28 left = (rank-1) % nprocs;
29 right = (rank+1) % nprocs;
30 x = sendrecv();
31 MPI_Finalize();
32 return 0;
33}
Note: See TracBrowser for help on using the repository browser.