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:
636 bytes
|
| Line | |
|---|
| 1 | #include<assert.h>
|
|---|
| 2 | #include<mpi.h>
|
|---|
| 3 | #include<civl-mpi.cvh>
|
|---|
| 4 | #include<stdio.h>
|
|---|
| 5 |
|
|---|
| 6 | #define comm MPI_COMM_WORLD
|
|---|
| 7 | int rank, nprocs, left, right;
|
|---|
| 8 |
|
|---|
| 9 | int sendrecv()
|
|---|
| 10 | $ensures {$collective(comm) ($mpi_isRecvBufEmpty(left) && left == $result)}
|
|---|
| 11 | {
|
|---|
| 12 | int message = rank;
|
|---|
| 13 | int recvBuf;
|
|---|
| 14 |
|
|---|
| 15 | MPI_Sendrecv(&message, 1, MPI_INT, right, 0, &recvBuf, 1, MPI_INT, left, 0, comm, MPI_STATUS_IGNORE);
|
|---|
| 16 | return recvBuf;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | int main(int argc, char * argv[]) {
|
|---|
| 20 | int x;
|
|---|
| 21 |
|
|---|
| 22 | MPI_Init(&argc, &argv);
|
|---|
| 23 | MPI_Comm_size(comm, &nprocs);
|
|---|
| 24 | MPI_Comm_rank(comm, &rank);
|
|---|
| 25 | left = (rank-1) % nprocs;
|
|---|
| 26 | right = (rank+1) % nprocs;
|
|---|
| 27 | x = sendrecv();
|
|---|
| 28 | MPI_Finalize();
|
|---|
| 29 | return 0;
|
|---|
| 30 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.