source: CIVL/text/include/mpi.h@ 3cf40e5

1.23 2.0 main test-branch
Last change on this file since 3cf40e5 was 8a9124e, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

added a simple test for MPI Translation in CIVL.

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

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[8a9124e]1#ifdef __MPI__
2#else
3 #include<mpi-common.h>
4 #include<civlc.h>
5 #define __MPI__
6
7int sizeofDatatype(MPI_Datatype datatype) {
8 switch (datatype) {
9 case MPI_INT:
10 return sizeof(int);
11 case MPI_FLOAT:
12 return sizeof(float);
13 case MPI_DOUBLE:
14 return sizeof(double);
15 case MPI_CHAR:
16 return sizeof(char);
17 default:
18 $assert(0, "Unreachable");
19 }
20}
21
22int __MPI_Init() {
23 return 0;
24}
25
26int MPI_Finalize() {
27 return 0;
28}
29
30int MPI_Comm_size(MPI_Comm comm, int *size) {
31 *size = $comm_size(comm);
32 return 0;
33}
34
35int MPI_Comm_rank(MPI_Comm comm, int *rank) {
36 *rank = $comm_place(comm);
37 return 0;
38}
39
40int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest,
41 int tag, MPI_Comm comm) {
42 if (dest >= 0) {
43 int size = count*sizeofDatatype(datatype);
44 int place = $comm_place(comm);
45 $message out = $message_pack(place, dest, tag, buf, size);
46
47 $comm_enqueue(comm, out);
48 }
49 return 0;
50}
51
52int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source,
53 int tag, MPI_Comm comm, MPI_Status *status) {
54 if (source >= 0) {
55 $message in = $comm_dequeue(comm, source, tag);
56 int size = count*sizeofDatatype(datatype);
57
58 $message_unpack(in, buf, size);
59 if (status != MPI_STATUS_IGNORE) {
60 status->size = $message_size(in);
61 status->MPI_SOURCE = $message_source(in);
62 status->MPI_TAG = $message_tag(in);
63 status->MPI_ERROR = 0;
64 }
65 }
66 return 0;
67}
68#endif
Note: See TracBrowser for help on using the repository browser.