source: CIVL/examples/messagePassing/mp_root2.cvh@ 4fb92cb

1.23 2.0 main test-branch
Last change on this file since 4fb92cb was 1450740, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

updated ring2, getting rid of interleaving.

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

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#define MPI_ANY_SOURCE $COMM_ANY_SOURCE
2#define MPI_ANY_TAG $COMM_ANY_TAG
3$input int NPROCS;
4$proc __procs[NPROCS];
5_Bool __start = 0;
6$gcomm __MPI_Comm_World = $gcomm_create($root, NPROCS);
7
8typedef $comm MPI_Comm;
9
10typedef int MPI_Datatype;
11
12#define MPI_INT 1
13#define MPI_DOUBLE 2
14#define MPI_FLOAT 3
15#define MPI_CHAR 4
16
17struct __MPI_Status {
18 int MPI_SOURCE;
19 int MPI_TAG;
20 int MPI_ERROR;
21 int size;
22};
23
24typedef struct __MPI_Status MPI_Status;
25
26//MPI_Status __MPI_Status_ignore;
27
28MPI_Status *MPI_STATUS_IGNORE = (MPI_Status*) NULL;
29
30int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype,
31 int *count) {
32 int size;
33
34 switch (datatype) {
35 case MPI_INT:
36 size = sizeof(int);
37 break;
38 case MPI_FLOAT:
39 size = sizeof(float);
40 break;
41 case MPI_DOUBLE:
42 size = sizeof(double);
43 break;
44 case MPI_CHAR:
45 size = sizeof(char);
46 break;
47 default:
48 printf("Unsupported datatype %d\n", datatype);
49 $assert($false);
50 }
51 $assert(status->size % size == 0);
52 *count = status->size / size;
53 return 0;
54}
55
56void MPI_Process (int __rank);
57
58void init() {
59 for (int i=0; i<NPROCS; i++)
60 __procs[i] = $spawn MPI_Process(i);
61 __start=1;
62}
63
64void finalize() {
65 for (int i=0; i<NPROCS; i++)
66 $wait(__procs[i]);
67}
68
69void main() {
70 init();
71 finalize();
72}
Note: See TracBrowser for help on using the repository browser.