Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a93fc44357792fa35083f5455af6e678312bd3e2
[simgrid.git] / include / 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 #define MPI_ANY_TAG -1
12
13 #define MPI_UNDEFINED -1
14
15 // errorcodes
16 #define MPI_SUCCESS     0
17 #define MPI_ERR_COMM    1
18 #define MPI_ERR_ARG     2
19 #define MPI_ERR_TYPE    3
20 #define MPI_ERR_REQUEST 4
21 #define MPI_ERR_INTERN  5
22 #define MPI_ERR_COUNT   6
23 #define MPI_ERR_RANK    7
24 #define MPI_ERR_TAG     8
25
26 // MPI_Comm
27 typedef struct smpi_mpi_communicator_t *smpi_mpi_communicator_t;
28 typedef smpi_mpi_communicator_t MPI_Comm;
29
30 // MPI_Datatype
31 typedef struct smpi_mpi_datatype_t *smpi_mpi_datatype_t;
32 typedef smpi_mpi_datatype_t MPI_Datatype;
33
34 // MPI_Request
35 typedef struct smpi_mpi_request_t *smpi_mpi_request_t;
36 typedef smpi_mpi_request_t MPI_Request;
37
38 // MPI_Op
39 typedef struct smpi_mpi_op_t *smpi_mpi_op_t;
40 typedef smpi_mpi_op_t MPI_Op;
41
42 // MPI_Status
43 struct smpi_mpi_status_t {
44   int MPI_SOURCE;
45   int MPI_TAG;
46   int MPI_ERROR;
47 };
48 typedef struct smpi_mpi_status_t smpi_mpi_status_t;
49 typedef smpi_mpi_status_t MPI_Status;
50
51 // global SMPI data structure
52 typedef struct smpi_mpi_global_t {
53
54         smpi_mpi_communicator_t mpi_comm_world;
55
56         smpi_mpi_datatype_t     mpi_byte;
57         smpi_mpi_datatype_t     mpi_int;
58         smpi_mpi_datatype_t     mpi_double;
59
60         smpi_mpi_op_t           mpi_land;
61         smpi_mpi_op_t           mpi_sum;
62
63 } s_smpi_mpi_global_t;
64 typedef struct smpi_mpi_global_t *smpi_mpi_global_t;
65 extern smpi_mpi_global_t smpi_mpi_global;
66
67 #define MPI_COMM_WORLD    (smpi_mpi_global->mpi_comm_world)
68 #define MPI_COMM_NULL     NULL
69
70 #define MPI_STATUS_IGNORE NULL
71
72 #define MPI_BYTE          (smpi_mpi_global->mpi_byte)
73 #define MPI_DOUBLE        (smpi_mpi_global->mpi_double)
74 #define MPI_INT           (smpi_mpi_global->mpi_int)
75
76 #define MPI_LAND          (smpi_mpi_global->mpi_land)
77 #define MPI_SUM           (smpi_mpi_glboal->mpi_sum)
78
79 // MPI Functions
80 int MPI_Init(int *argc, char ***argv);
81 int MPI_Finalize(void);
82 int MPI_Abort(MPI_Comm comm, int errorcode);
83 int MPI_Comm_size(MPI_Comm comm, int *size);
84 int MPI_Comm_rank(MPI_Comm comm, int *rank);
85 int MPI_Type_size(MPI_Datatype datatype, size_t *size);
86 int MPI_Barrier(MPI_Comm comm);
87 int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request);
88 int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status *status);
89 int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request *request);
90 int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
91 int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
92 int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out);
93
94 // smpi functions
95 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
96 unsigned int smpi_sleep(unsigned int);
97 void smpi_exit(int);
98 int smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
99
100 void smpi_do_once_1(const char *file, int line);
101 int  smpi_do_once_2(void);
102 void smpi_do_once_3(void);
103 #define DO_ONCE for (smpi_do_once_1(__FILE__, __LINE__); smpi_do_once_2(); smpi_do_once_3())
104
105 #endif