Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
967fb64a8cbc83a60283afc6c8461827738cdcb3
[simgrid.git] / src / smpi / smpi.h
1 #ifndef SMPI_H
2 #define SMPI_H
3
4 #include <sys/time.h>
5 #include <xbt/function_types.h>
6
7 #define SMPI_RAND_SEED 5
8
9 #define MPI_ANY_SOURCE -1
10
11 // errorcodes
12 #define MPI_SUCCESS     0
13 #define MPI_ERR_COMM    1
14 #define MPI_ERR_ARG     2
15 #define MPI_ERR_TYPE    3
16 #define MPI_ERR_REQUEST 4
17 #define MPI_ERR_INTERN  5
18 #define MPI_ERR_COUNT   6
19 #define MPI_ERR_RANK    7
20 #define MPI_ERR_TAG     8
21
22 // MPI_Comm
23 typedef struct smpi_mpi_communicator_simdata *smpi_mpi_communicator_simdata_t;
24 struct smpi_mpi_communicator_t {
25   int            size;
26   smpi_mpi_communicator_simdata_t simdata;
27 };
28 typedef struct smpi_mpi_communicator_t smpi_mpi_communicator_t;
29 typedef smpi_mpi_communicator_t *MPI_Comm;
30
31 // MPI_Status
32 struct smpi_mpi_status_t {
33   int MPI_SOURCE;
34 };
35 typedef struct smpi_mpi_status_t smpi_mpi_status_t;
36 typedef smpi_mpi_status_t MPI_Status;
37
38 // MPI_Datatype
39 struct smpi_mpi_datatype_t {
40   size_t size;
41 };
42 typedef struct smpi_mpi_datatype_t smpi_mpi_datatype_t;
43 typedef smpi_mpi_datatype_t *MPI_Datatype;
44
45 // MPI_Request
46 typedef struct smpi_mpi_request_simdata *smpi_mpi_request_simdata_t;
47 struct smpi_mpi_request_t {
48         smpi_mpi_communicator_t *comm;
49         int src;
50         int dst;
51         int tag;
52
53         void *buf;
54         smpi_mpi_datatype_t *datatype;
55         int count;
56
57         short int completed :1;
58
59         smpi_mpi_request_simdata_t simdata;
60 };
61 typedef struct smpi_mpi_request_t smpi_mpi_request_t;
62 typedef smpi_mpi_request_t *MPI_Request;
63
64 // MPI_Op
65 struct smpi_mpi_op_t {
66   void (*func)(void *x, void *y, void *z);
67 };
68 typedef struct smpi_mpi_op_t smpi_mpi_op_t;
69 typedef smpi_mpi_op_t *MPI_Op;
70
71 // global SMPI data structure
72 typedef struct SMPI_MPI_Global {
73
74         smpi_mpi_communicator_t *mpi_comm_world;
75
76         smpi_mpi_datatype_t     *mpi_byte;
77         smpi_mpi_datatype_t     *mpi_int;
78         smpi_mpi_datatype_t     *mpi_double;
79
80         smpi_mpi_op_t           *mpi_land;
81         smpi_mpi_op_t           *mpi_sum;
82
83 } s_SMPI_MPI_Global_t, *SMPI_MPI_Global_t;
84 extern SMPI_MPI_Global_t smpi_mpi_global;
85
86 #define MPI_COMM_WORLD    (smpi_mpi_global->mpi_comm_world)
87
88 #define MPI_STATUS_IGNORE NULL
89
90 #define MPI_BYTE          (smpi_mpi_global->mpi_byte)
91 #define MPI_DOUBLE        (smpi_mpi_global->mpi_double)
92 #define MPI_INT           (smpi_mpi_global->mpi_int)
93
94 #define MPI_LAND          (smpi_mpi_global->mpi_land)
95 #define MPI_SUM           (smpi_mpi_glboal->mpi_sum)
96
97 // MPI Functions
98 int MPI_Init(int *argc, char ***argv);
99 int MPI_Finalize(void);
100 int MPI_Abort(MPI_Comm comm, int errorcode);
101 int MPI_Comm_size(MPI_Comm comm, int *size);
102 int MPI_Comm_rank(MPI_Comm comm, int *rank);
103 int MPI_Type_size(MPI_Datatype datatype, size_t *size);
104 int MPI_Barrier(MPI_Comm comm);
105 int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request);
106 int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status *status);
107 int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request *request);
108 int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
109
110 // smpi functions
111 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
112 unsigned int smpi_sleep(unsigned int);
113 void smpi_exit(int);
114 int smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
115
116 #endif