main
test-branch
|
Last change
on this file since 397ae5f 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:
812 bytes
|
| Line | |
|---|
| 1 | #include<mpi.h>
|
|---|
| 2 | #include<assert.h>
|
|---|
| 3 | #include<stdio.h>
|
|---|
| 4 | #include<civlc.cvh>
|
|---|
| 5 |
|
|---|
| 6 | double * u;
|
|---|
| 7 | int nx = 10;
|
|---|
| 8 |
|
|---|
| 9 | /*@
|
|---|
| 10 | @ \mpi_collective(MPI_COMM_WORLD, P2P):
|
|---|
| 11 | @ requires \mpi_comm_size >= 2;
|
|---|
| 12 | @ requires \mpi_comm_rank == x;
|
|---|
| 13 | @*/
|
|---|
| 14 | void exchange(int x) {
|
|---|
| 15 | int y;
|
|---|
| 16 | int left, right;
|
|---|
| 17 | int nprocs;
|
|---|
| 18 |
|
|---|
| 19 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 20 | left = x - 1 >=0 ? x - 1 : nprocs - 1;
|
|---|
| 21 | right = x + 1 < nprocs ? x + 1 : 0;
|
|---|
| 22 | //printf("rank x=%d, send to %d, recv from %d\n", x, left, right);
|
|---|
| 23 | MPI_Sendrecv(&x, 1, MPI_INT, left, 0, &y,
|
|---|
| 24 | 1, MPI_INT, right, 0,
|
|---|
| 25 | MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 26 | MPI_Sendrecv(&x, 1, MPI_INT, left, 0, &y,
|
|---|
| 27 | 1, MPI_INT, right, 0,
|
|---|
| 28 | MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | int main() {
|
|---|
| 33 | int dummy = 7;
|
|---|
| 34 | exchange(0);
|
|---|
| 35 | dummy=8;
|
|---|
| 36 | $havoc(NULL);
|
|---|
| 37 | return 0;
|
|---|
| 38 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.