source: CIVL/mods/dev.civl.abc/examples/contract/remoteAccess.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: 742 bytes
RevLine 
[c8d748e]1#include<assert.h>
2#include<mpi.h>
3#include<civl-mpi.cvh>
[52ad99c]4#include<stdio.h>
[aad342c]5#pragma CIVL ACSL
6MPI_Comm comm = MPI_COMM_WORLD;
[c8d748e]7int rank, nprocs, left, right;
8
[aad342c]9/*@ \mpi_collective(comm, P2P):
10 @ ensures \mpi_empty_in(left) && \on(left, nprocs) == \result;
11 @ ensures \on(left, nprocs) == \on(right, nprocs);
12 @*/
[c8d748e]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.