1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | /* Create NPROCS processes. Have them exchange data in a cycle.
|
|---|
| 2 | * Command line verification example:
|
|---|
| 3 | * civl verify -inputNPROCS_BOUND=10 -inputN_BOUND=5 ring.cvl
|
|---|
| 4 | */
|
|---|
| 5 | #include<comm.cvh>
|
|---|
| 6 | #define TAG 0
|
|---|
| 7 |
|
|---|
| 8 | $gcomm GCOMM_WORLD = $gcomm_create($here, 2); // global comm object
|
|---|
| 9 |
|
|---|
| 10 | void MPI_Process (int rank) {
|
|---|
| 11 | $comm comm = $comm_create($here, GCOMM_WORLD, rank);
|
|---|
| 12 | int dest = 1-rank;
|
|---|
| 13 | int *x, *y;
|
|---|
| 14 | $message in, out;
|
|---|
| 15 |
|
|---|
| 16 | x = (int*)$malloc($here, sizeof(int));
|
|---|
| 17 | y = (int*)$malloc($here, sizeof(int));
|
|---|
| 18 | *x = rank;
|
|---|
| 19 | out = $message_pack(rank, dest, TAG, x, sizeof(int));
|
|---|
| 20 | $comm_enqueue(comm, out);
|
|---|
| 21 | in = $comm_dequeue(comm, dest, TAG);
|
|---|
| 22 | $message_unpack(in, y, sizeof(int));
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | void main() {
|
|---|
| 26 | for (int i=0; i<2; i++) $spawn MPI_Process(i);
|
|---|
| 27 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.