Logo AND Algorithmique Numérique Distribuée

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