Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d5ef3c1e3f3e747162ebbc92016cd7ad890de4a3
[simgrid.git] / include / smpi / smpi.h
1 #ifndef SMPI_H
2 #define SMPI_H
3
4 #include <stddef.h>
5 #include <sys/time.h>
6 #include <xbt/misc.h>
7 #include <xbt/function_types.h>
8
9 SG_BEGIN_DECL()
10
11 #define SMPI_RAND_SEED 5
12
13 #define MPI_ANY_SOURCE -1
14
15 #define MPI_ANY_TAG -1
16
17 #define MPI_UNDEFINED -1
18
19 // errorcodes
20 #define MPI_SUCCESS     0
21 #define MPI_ERR_COMM    1
22 #define MPI_ERR_ARG     2
23 #define MPI_ERR_TYPE    3
24 #define MPI_ERR_REQUEST 4
25 #define MPI_ERR_INTERN  5
26 #define MPI_ERR_COUNT   6
27 #define MPI_ERR_RANK    7
28 #define MPI_ERR_TAG     8
29
30 // MPI_Comm
31 typedef struct smpi_mpi_communicator_t *smpi_mpi_communicator_t;
32 typedef smpi_mpi_communicator_t MPI_Comm;
33
34 // MPI_Datatype
35 typedef struct smpi_mpi_datatype_t *smpi_mpi_datatype_t;
36 typedef smpi_mpi_datatype_t MPI_Datatype;
37
38 // MPI_Request
39 typedef struct smpi_mpi_request_t *smpi_mpi_request_t;
40 typedef smpi_mpi_request_t MPI_Request;
41
42 // MPI_Op
43 typedef struct smpi_mpi_op_t *smpi_mpi_op_t;
44 typedef smpi_mpi_op_t MPI_Op;
45
46 // MPI_Status
47 struct smpi_mpi_status_t {
48   int MPI_SOURCE;
49   int MPI_TAG;
50   int MPI_ERROR;
51 };
52 typedef struct smpi_mpi_status_t smpi_mpi_status_t;
53 typedef smpi_mpi_status_t MPI_Status;
54
55 // global SMPI data structure
56 typedef struct smpi_mpi_global_t {
57
58         smpi_mpi_communicator_t mpi_comm_world;
59
60         smpi_mpi_datatype_t     mpi_byte;
61         smpi_mpi_datatype_t     mpi_int;
62         smpi_mpi_datatype_t     mpi_double;
63
64         smpi_mpi_op_t           mpi_land;
65         smpi_mpi_op_t           mpi_sum;
66
67 } s_smpi_mpi_global_t;
68 typedef struct smpi_mpi_global_t *smpi_mpi_global_t;
69 extern smpi_mpi_global_t smpi_mpi_global;
70
71 #define MPI_COMM_WORLD    (smpi_mpi_global->mpi_comm_world)
72 #define MPI_COMM_NULL     NULL
73
74 #define MPI_STATUS_IGNORE NULL
75
76 #define MPI_BYTE          (smpi_mpi_global->mpi_byte)
77 #define MPI_DOUBLE        (smpi_mpi_global->mpi_double)
78 #define MPI_INT           (smpi_mpi_global->mpi_int)
79
80 #define MPI_LAND          (smpi_mpi_global->mpi_land)
81 #define MPI_SUM           (smpi_mpi_glboal->mpi_sum)
82
83 // MPI macros
84 #define MPI_Init(a, b) SMPI_MPI_Init(a, b)
85 #define MPI_Finalize() SMPI_MPI_Finalize()
86 #define MPI_Abort(a, b) SMPI_MPI_Abort(a, b)
87 #define MPI_Comm_size(a, b) SMPI_MPI_Comm_size(a, b)
88 #define MPI_Comm_rank(a, b) SMPI_MPI_Comm_rank(a, b)
89 #define MPI_Type_size(a, b) SMPI_MPI_Type_size(a, b)
90 #define MPI_Barrier(a) SMPI_MPI_Barrier(a)
91 #define MPI_Irecv(a, b, c, d, e, f, g) SMPI_MPI_Irecv(a, b, c, d, e, f, g)
92 #define MPI_Recv(a, b, c, d, e, f, g) SMPI_MPI_Recv(a, b, c, d, e, f, g)
93 #define MPI_Isend(a, b, c, d, e, f, g) SMPI_MPI_Isend(a, b, c, d, e, f, g)
94 #define MPI_Send(a, b, c, d, e, f) SMPI_MPI_Send(a, b, c, d, e, f)
95 #define MPI_Bcast(a, b, c, d, e) SMPI_MPI_Bcast(a, b, c, d, e)
96 #define MPI_Comm_split(a, b, c, d) SMPI_MPI_Comm_split(a, b, c, d)
97
98 // SMPI Functions
99 XBT_PUBLIC(int) SMPI_MPI_Init(int *argc, char ***argv);
100 XBT_PUBLIC(int) SMPI_MPI_Finalize(void);
101 XBT_PUBLIC(int) SMPI_MPI_Abort(MPI_Comm comm, int errorcode);
102 XBT_PUBLIC(int) SMPI_MPI_Comm_size(MPI_Comm comm, int *size);
103 XBT_PUBLIC(int) SMPI_MPI_Comm_rank(MPI_Comm comm, int *rank);
104 XBT_PUBLIC(int) SMPI_MPI_Type_size(MPI_Datatype datatype, size_t *size);
105 XBT_PUBLIC(int) SMPI_MPI_Barrier(MPI_Comm comm);
106 XBT_PUBLIC(int) SMPI_MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request);
107 XBT_PUBLIC(int) SMPI_MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status *status);
108 XBT_PUBLIC(int) SMPI_MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request *request);
109 XBT_PUBLIC(int) SMPI_MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
110 XBT_PUBLIC(int) SMPI_MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
111 XBT_PUBLIC(int) SMPI_MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out);
112
113 // smpi functions
114 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
115 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int);
116 XBT_PUBLIC(void) smpi_exit(int);
117 XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
118
119 XBT_PUBLIC(void) smpi_do_once_1(const char *file, int line);
120 XBT_PUBLIC(int)  smpi_do_once_2(void);
121 XBT_PUBLIC(void) smpi_do_once_3(void);
122
123 #define SMPI_DO_ONCE for (smpi_do_once_1(__FILE__, __LINE__); smpi_do_once_2(); smpi_do_once_3())
124
125 SG_END_DECL()
126
127 #endif