source: CIVL/examples/experimental/ring3ModelBug.cvl@ 51cc2e3

1.23 2.0 main test-branch
Last change on this file since 51cc2e3 was 51cc2e3, checked in by Ziqing Luo <ziqing@…>, 11 years ago

add a bug example

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2245 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.0 KB
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 GCOMMS[];
9$gcomm GCOMM_WORLD = $gcomm_create($here, 2); // global comm object
10
11$seq_init(&GCOMMS, 1, &GCOMM_WORLD);
12void MPI_Process (int rank) {
13 $comm comm = $comm_create($here, GCOMM_WORLD, rank);
14 int dest = 1-rank;
15 int *x, *y;
16 $message in, out;
17
18 x = (int*)$malloc($here, sizeof(int));
19 y = (int*)$malloc($here, sizeof(int));
20 *x = rank;
21 out = $message_pack(rank, dest, TAG, x, sizeof(int));
22 $choose {
23 $when (1){
24 $comm_enqueue(comm, out);
25 in = $comm_dequeue(comm, dest, TAG);
26 }
27 $when (1){
28 in = $comm_dequeue(comm, dest, TAG);
29 $comm_enqueue(comm, out);
30 }
31 }
32 $message_unpack(in, y, sizeof(int));
33 $free(x);
34 $free(y);
35 $comm_destroy(comm);
36}
37
38void main() {
39 // for (int i=0; i<2; i++) $spawn MPI_Process(i);
40 $parfor (int i : ($domain){0 .. 1}) MPI_Process(i);
41 $gcomm_destroy(GCOMM_WORLD);
42}
Note: See TracBrowser for help on using the repository browser.