source: CIVL/examples/concurrency/ring3Bad.cvl

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: 846 bytes
Line 
1/* Create 2 processes. Have them exchange data in a cycle.
2 * Command line verification example:
3 * civl verify ring3.cvl
4 */
5#include<comm.cvh>
6#define TAG 0
7
8$gcomm GCOMM_WORLD = $gcomm_create($here, 2); // global comm object
9
10void 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 $free(x);
24 $free(y);
25 $comm_destroy(comm);
26}
27
28void main() {
29 // for (int i=0; i<2; i++) $spawn MPI_Process(i);
30 $parfor (int i : ($domain){0 .. 1}) MPI_Process(i);
31 $gcomm_destroy(GCOMM_WORLD, NULL);
32}
Note: See TracBrowser for help on using the repository browser.