Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
26749287107116d41438134dcd78323cddce160f
[simgrid.git] / src / smpi / include / smpi.h
1 #include <xbt/function_types.h>
2 #include <simix/simix.h>
3
4 #define SMPI_RAND_SEED 5
5
6 #define MPI_ANY_SOURCE -1
7
8 // errorcodes
9 #define MPI_SUCCESS     0
10 #define MPI_ERR_COMM    1
11 #define MPI_ERR_ARG     2
12 #define MPI_ERR_TYPE    3
13 #define MPI_ERR_REQUEST 4
14 #define MPI_ERR_INTERN  5
15 #define MPI_ERR_COUNT   6
16 #define MPI_ERR_RANK    7
17 #define MPI_ERR_TAG     8
18
19 // MPI_Comm
20 struct smpi_mpi_communicator_t {
21   int            size;
22   smx_host_t    *hosts;
23
24   smx_process_t *processes;
25   int            barrier_count;
26   smx_mutex_t    barrier_mutex;
27   smx_cond_t     barrier_cond;
28 };
29 typedef struct smpi_mpi_communicator_t smpi_mpi_communicator_t;
30 typedef smpi_mpi_communicator_t *MPI_Comm;
31
32 // MPI_Status
33 struct smpi_mpi_status_t {
34   int MPI_SOURCE;
35 };
36 typedef struct smpi_mpi_status_t smpi_mpi_status_t;
37 typedef smpi_mpi_status_t MPI_Status;
38
39 // MPI_Datatype
40 struct smpi_mpi_datatype_t {
41   size_t size;
42 };
43 typedef struct smpi_mpi_datatype_t smpi_mpi_datatype_t;
44 typedef smpi_mpi_datatype_t *MPI_Datatype;
45
46 // MPI_Request
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         smx_mutex_t mutex;
59         smx_cond_t  cond;
60         xbt_fifo_t waitlist;
61 };
62 typedef struct smpi_mpi_request_t smpi_mpi_request_t;
63 typedef smpi_mpi_request_t *MPI_Request;
64
65 // MPI_Op
66 struct smpi_mpi_op_t {
67   void (*func)(void *x, void *y, void *z);
68 };
69 typedef struct smpi_mpi_op_t smpi_mpi_op_t;
70 typedef smpi_mpi_op_t *MPI_Op;
71
72 // global SMPI data structure
73 typedef struct SMPI_MPI_Global {
74
75         smpi_mpi_communicator_t mpi_comm_world;
76
77         smpi_mpi_status_t       mpi_status_ignore;
78
79         smpi_mpi_datatype_t     mpi_byte;
80         smpi_mpi_datatype_t     mpi_int;
81         smpi_mpi_datatype_t     mpi_double;
82
83         smpi_mpi_op_t           mpi_land;
84         smpi_mpi_op_t           mpi_sum;
85
86 } s_SMPI_MPI_Global_t, *SMPI_MPI_Global_t;
87 exterm SMPI_MPI_Global_t smpi_mpi_global;
88
89 #define MPI_COMM_WORLD    (smpi_mpi_global->mpi_comm_world)
90
91 #define MPI_STATUS_IGNORE (smpi_mpi_global->mpi_status_ignore)
92
93 #define MPI_BYTE          (smpi_mpi_global->mpi_byte)
94 #define MPI_DOUBLE        (smpi_mpi_global->mpi_double)
95 #define MPI_INT           (smpi_mpi_global->mpi_int)
96
97 #define MPI_LAND          (smpi_mpi_global->mpi_land)
98 #define MPI_SUM           (smpi_mpi_glboal->mpi_sum)
99
100 // smpi functions
101 extern int smpi_simulated_main(int argc, char **argv);
102 unsigned int smpi_sleep(unsigned int);
103 void smpi_exit(int);