source: CIVL/examples/concurrency/mp_root2.cvh@ bb03188

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