Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some preliminary additions to implement more collectives
[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
25 // MPI_Comm
26      typedef struct smpi_mpi_communicator_t *smpi_mpi_communicator_t;
27      typedef smpi_mpi_communicator_t MPI_Comm;
28
29 // MPI_Datatype
30      typedef struct smpi_mpi_datatype_t *smpi_mpi_datatype_t;
31      typedef smpi_mpi_datatype_t MPI_Datatype;
32
33 // MPI_Request
34      typedef struct smpi_mpi_request_t *smpi_mpi_request_t;
35      typedef smpi_mpi_request_t MPI_Request;
36
37 // MPI_Op
38      typedef struct smpi_mpi_op_t *smpi_mpi_op_t;
39      typedef smpi_mpi_op_t MPI_Op;
40
41 // MPI_Status
42      struct smpi_mpi_status_t {
43        int MPI_SOURCE;
44        int MPI_TAG;
45        int MPI_ERROR;
46      };
47      typedef struct smpi_mpi_status_t smpi_mpi_status_t;
48      typedef smpi_mpi_status_t MPI_Status;
49
50 // global SMPI data structure
51      typedef struct smpi_mpi_global_t {
52
53        smpi_mpi_communicator_t mpi_comm_world;
54
55        smpi_mpi_datatype_t mpi_byte;
56        smpi_mpi_datatype_t mpi_int;
57        smpi_mpi_datatype_t mpi_float;
58        smpi_mpi_datatype_t mpi_double;
59
60        smpi_mpi_op_t mpi_land;
61        smpi_mpi_op_t mpi_sum;
62        smpi_mpi_op_t mpi_min;
63        smpi_mpi_op_t mpi_max;
64
65      } s_smpi_mpi_global_t;
66      typedef struct smpi_mpi_global_t *smpi_mpi_global_t;
67      extern smpi_mpi_global_t smpi_mpi_global;
68
69 #define MPI_COMM_WORLD    (smpi_mpi_global->mpi_comm_world)
70 #define MPI_COMM_NULL     NULL
71
72 #define MPI_STATUS_IGNORE NULL
73
74 #define MPI_BYTE          (smpi_mpi_global->mpi_byte)
75 #define MPI_INT           (smpi_mpi_global->mpi_int)
76 #define MPI_FLOAT         (smpi_mpi_global->mpi_float)
77 #define MPI_DOUBLE        (smpi_mpi_global->mpi_double)
78
79 #define MPI_LAND          (smpi_mpi_global->mpi_land)
80 #define MPI_SUM           (smpi_mpi_global->mpi_sum)
81 #define MPI_MIN           (smpi_mpi_global->mpi_min)
82 #define MPI_MAX           (smpi_mpi_global->mpi_max)
83
84 // MPI macros
85 #define MPI_Init(a, b) SMPI_MPI_Init(a, b)
86 #define MPI_Finalize() SMPI_MPI_Finalize()
87 #define MPI_Abort(a, b) SMPI_MPI_Abort(a, b)
88 #define MPI_Comm_size(a, b) SMPI_MPI_Comm_size(a, b)
89 #define MPI_Comm_rank(a, b) SMPI_MPI_Comm_rank(a, b)
90 #define MPI_Type_size(a, b) SMPI_MPI_Type_size(a, b)
91 #define MPI_Barrier(a) SMPI_MPI_Barrier(a)
92 #define MPI_Irecv(a, b, c, d, e, f, g) SMPI_MPI_Irecv(a, b, c, d, e, f, g)
93 #define MPI_Recv(a, b, c, d, e, f, g) SMPI_MPI_Recv(a, b, c, d, e, f, g)
94 #define MPI_Isend(a, b, c, d, e, f, g) SMPI_MPI_Isend(a, b, c, d, e, f, g)
95 #define MPI_Send(a, b, c, d, e, f) SMPI_MPI_Send(a, b, c, d, e, f)
96 #define MPI_Bcast(a, b, c, d, e) SMPI_MPI_Bcast(a, b, c, d, e)
97 #define MPI_Wait(a, b) SMPI_MPI_Wait(a, b)
98 #define MPI_Comm_split(a, b, c, d) SMPI_MPI_Comm_split(a, b, c, d)
99 #define MPI_Wtime() SMPI_MPI_Wtime()
100 #define MPI_Reduce( a, b, c, d, e, f, g) SMPI_MPI_Reduce( a, b, c, d, e, f, g) 
101
102 // SMPI Functions
103 XBT_PUBLIC(int) SMPI_MPI_Init(int *argc, char ***argv);
104 XBT_PUBLIC(int) SMPI_MPI_Finalize(void);
105 XBT_PUBLIC(int) SMPI_MPI_Abort(MPI_Comm comm, int errorcode);
106 XBT_PUBLIC(int) SMPI_MPI_Comm_size(MPI_Comm comm, int *size);
107 XBT_PUBLIC(int) SMPI_MPI_Comm_rank(MPI_Comm comm, int *rank);
108 XBT_PUBLIC(int) SMPI_MPI_Type_size(MPI_Datatype datatype, size_t * size);
109 XBT_PUBLIC(int) SMPI_MPI_Barrier(MPI_Comm comm);
110 XBT_PUBLIC(int) SMPI_MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
111                                int src, int tag, MPI_Comm comm,
112                                MPI_Request * request);
113 XBT_PUBLIC(int) SMPI_MPI_Recv(void *buf, int count, MPI_Datatype datatype,
114                               int src, int tag, MPI_Comm comm,
115                               MPI_Status * status);
116 XBT_PUBLIC(int) SMPI_MPI_Isend(void *buf, int count, MPI_Datatype datatype,
117                                int dst, int tag, MPI_Comm comm,
118                                MPI_Request * request);
119 XBT_PUBLIC(int) SMPI_MPI_Send(void *buf, int count, MPI_Datatype datatype,
120                               int dst, int tag, MPI_Comm comm);
121 XBT_PUBLIC(int) SMPI_MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
122                                int root, MPI_Comm comm);
123 XBT_PUBLIC(int) SMPI_MPI_Wait(MPI_Request * request, MPI_Status * status);
124 XBT_PUBLIC(int) SMPI_MPI_Comm_split(MPI_Comm comm, int color, int key,
125                                     MPI_Comm * comm_out);
126 XBT_PUBLIC(double) SMPI_MPI_Wtime(void);
127
128 XBT_PUBLIC(int) SMPI_MPI_Reduce(void *sendbuf, void *recvbuf, int count, 
129                                     MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
130
131 // smpi functions
132 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
133 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int);
134 XBT_PUBLIC(void) smpi_exit(int);
135 XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
136
137 XBT_PUBLIC(void) smpi_do_once_1(const char *file, int line);
138 XBT_PUBLIC(int) smpi_do_once_2(void);
139 XBT_PUBLIC(void) smpi_do_once_3(void);
140
141 #define SMPI_DO_ONCE for (smpi_do_once_1(__FILE__, __LINE__); smpi_do_once_2(); smpi_do_once_3())
142
143 SG_END_DECL()
144 #endif