Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9f67528043cafc47fa692c237ecce5f23320c24e
[simgrid.git] / src / smpi / include / smpi.h
1 #define DEFAULT_POWER 100
2
3 #define MPI_ANY_SOURCE -1
4
5 // errorcodes
6 #define MPI_SUCCESS     0
7 #define MPI_ERR_COMM    1
8 #define MPI_ERR_ARG     2
9 #define MPI_ERR_TYPE    3
10 #define MPI_ERR_REQUEST 4
11 #define MPI_ERR_INTERN  5
12 #define MPI_ERR_COUNT   6
13 #define MPI_ERR_RANK    7
14 #define MPI_ERR_TAG     8
15
16 #include <stdlib.h>
17 #include <msg/msg.h>
18
19 typedef enum { MPI_PORT = 0, SEND_SYNC_PORT, RECV_SYNC_PORT, MAX_CHANNEL } channel_t;
20
21 // MPI_Comm
22 struct smpi_mpi_communicator_t {
23   int id;
24   int size;
25   int barrier;
26   smx_host_t *hosts;
27   smx_process_t *processes;
28 };
29 typedef struct smpi_mpi_communicator_t smpi_mpi_communicator_t;
30 typedef smpi_mpi_communicator_t *MPI_Comm;
31 extern smpi_mpi_communicator_t smpi_mpi_comm_world;
32 #define MPI_COMM_WORLD (&smpi_mpi_comm_world)
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 extern smpi_mpi_status_t smpi_mpi_status_ignore;
41 #define MPI_STATUS_IGNORE (&smpi_mpi_status_ignore)
42
43 // MPI_Datatype
44 struct smpi_mpi_datatype_t {
45 //  int type;
46   size_t size;
47 };
48 typedef struct smpi_mpi_datatype_t smpi_mpi_datatype_t;
49 typedef smpi_mpi_datatype_t *MPI_Datatype;
50 // FIXME: add missing datatypes
51 extern smpi_mpi_datatype_t smpi_mpi_byte;
52 #define MPI_BYTE (&smpi_mpi_byte)
53 extern smpi_mpi_datatype_t smpi_mpi_int;
54 #define MPI_INT (&smpi_mpi_int)
55 extern smpi_mpi_datatype_t smpi_mpi_double;
56 #define MPI_DOUBLE (&smpi_mpi_double)
57
58 struct smpi_waitlist_node_t {
59   smx_process_t process;
60   struct smpi_waitlist_node_t *next;
61 };
62 typedef struct smpi_waitlist_node_t smpi_waitlist_node_t;
63
64 // FIXME: maybe it isn't appropriate to have the next pointer inside
65 // MPI_Request
66 struct smpi_mpi_request_t {
67   void *buf;
68   int count;
69   smpi_mpi_datatype_t *datatype;
70   int src;
71   int dst;
72   int tag;
73   smpi_mpi_communicator_t *comm;
74   short int completed;
75   smpi_waitlist_node_t *waitlist;
76   struct smpi_mpi_request_t *next;
77   int fwdthrough;
78 };
79 typedef struct smpi_mpi_request_t smpi_mpi_request_t;
80 typedef smpi_mpi_request_t *MPI_Request;
81
82 // MPI_Op
83 struct smpi_mpi_op_t {
84   void (*func)(void *x, void *y, void *z);
85 };
86 typedef struct smpi_mpi_op_t smpi_mpi_op_t;
87 typedef smpi_mpi_op_t *MPI_Op;
88 extern smpi_mpi_op_t smpi_mpi_land;
89 #define MPI_LAND (&smpi_mpi_land)
90 extern smpi_mpi_op_t smpi_mpi_sum;
91 #define MPI_SUM (&smpi_mpi_sum)
92
93 // smpi_received_t
94 struct smpi_received_t {
95   int commid;
96   int src;
97   int dst;
98   int tag;
99   int fwdthrough;
100   void *data;
101   struct smpi_received_t *next;
102 };
103 typedef struct smpi_received_t smpi_received_t;
104
105 // sender/receiver (called by main routine)
106 int smpi_sender(int argc, char *argv[]);
107 int smpi_receiver(int argc, char *argv[]);
108
109 // smpi functions
110 int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
111 void smpi_isend(smpi_mpi_request_t*);
112 void smpi_irecv(smpi_mpi_request_t*);
113 void smpi_barrier(smpi_mpi_communicator_t *comm);
114 void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status);
115 void smpi_wait_all(int count, smpi_mpi_request_t **requests, smpi_mpi_status_t *statuses);
116 void smpi_wait_all_nostatus(int count, smpi_mpi_request_t **requests);
117 void smpi_bench_begin();
118 void smpi_bench_end();
119 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t *datatype, int src, int dst, int tag, smpi_mpi_communicator_t *comm, smpi_mpi_request_t **request);
120 unsigned int smpi_sleep(unsigned int);
121 void smpi_exit(int);