Logo AND Algorithmique Numérique Distribuée

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