main
test-branch
| Rev | Line | |
|---|
| [9074a6e] | 1 | #include<mpi.h>
|
|---|
| 2 | #include<assert.h>
|
|---|
| 3 | #include<civlc.cvh>
|
|---|
| 4 |
|
|---|
| 5 | double * u;
|
|---|
| 6 | int nx = 10;
|
|---|
| 7 |
|
|---|
| 8 | /*@ requires \valid(x);
|
|---|
| 9 | @ ensures \result == *x + 1;
|
|---|
| 10 | @
|
|---|
| 11 | */
|
|---|
| 12 | int add(int * x)
|
|---|
| 13 | {
|
|---|
| 14 | return *x + 1;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | /*@
|
|---|
| 18 | @ \mpi_collective(MPI_COMM_WORLD, P2P):
|
|---|
| 19 | @ requires \mpi_comm_size == 2;
|
|---|
| 20 | @ requires \mpi_comm_rank == x;
|
|---|
| 21 | @ ensures \remote(nx, 0) == 10;
|
|---|
| 22 | @*/
|
|---|
| 23 | void exchange(int x) {
|
|---|
| 24 | int y;
|
|---|
| 25 | int neighbor = 1 - x;
|
|---|
| 26 |
|
|---|
| 27 | MPI_Sendrecv(&x, 1, MPI_INT, neighbor, 0, &y,
|
|---|
| 28 | 1, MPI_INT, neighbor, 0,
|
|---|
| 29 | MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 30 | y = add(&y);
|
|---|
| 31 | assert(x + y == 1);
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | int main() {
|
|---|
| 36 | int dummy = 7;
|
|---|
| 37 | exchange(0);
|
|---|
| 38 | dummy=8;
|
|---|
| 39 | $havoc(NULL);
|
|---|
| 40 | return 0;
|
|---|
| 41 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.