Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
109ce231a59f04301d4f3deab5d6113d4b373e62
[simgrid.git] / src / smpi / private.h
1 #ifndef SMPI_PRIVATE_H
2 #define SMPI_PRIVATE_H
3
4 #include "xbt/mallocator.h"
5 #include "xbt/xbt_os_time.h"
6
7 #include "simix/simix.h"
8
9 #include "smpi/smpi.h"
10
11 #define SMPI_DEFAULT_SPEED 100
12 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
13 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
14
15 // smpi mpi communicator
16 typedef struct smpi_mpi_communicator_t {
17   int size;
18   int barrier_count;
19   smx_mutex_t barrier_mutex;
20   smx_cond_t barrier_cond;
21
22   int *rank_to_index_map;
23   int *index_to_rank_map;
24
25 } s_smpi_mpi_communicator_t;
26
27 // smpi mpi datatype
28 typedef struct smpi_mpi_datatype_t {
29   size_t size;
30 } s_smpi_mpi_datatype_t;
31
32 // smpi mpi request
33 typedef struct smpi_mpi_request_t {
34   smpi_mpi_communicator_t comm;
35   int src;
36   int dst;
37   int tag;
38
39   void *buf;
40   int count;
41   smpi_mpi_datatype_t datatype;
42
43   short int completed:1;
44
45   smx_mutex_t mutex;
46   smx_cond_t cond;
47
48   void *data;
49   int forward;
50
51 } s_smpi_mpi_request_t;
52
53 // smpi mpi op
54 typedef struct smpi_mpi_op_t {
55   void (*func) (void *a, void *b, int *length, MPI_Datatype * datatype);
56 } s_smpi_mpi_op_t;
57
58 // smpi received message
59 typedef struct smpi_received_message_t {
60   smpi_mpi_communicator_t comm;
61   int src;
62   int tag;
63
64   void *buf;
65
66   void *data;
67   int forward;
68
69 } s_smpi_received_message_t;
70 typedef struct smpi_received_message_t *smpi_received_message_t;
71
72 typedef struct smpi_do_once_duration_node_t {
73   char *file;
74   int line;
75   double duration;
76   struct smpi_do_once_duration_node_t *next;
77 } s_smpi_do_once_duration_node_t;
78 typedef struct smpi_do_once_duration_node_t *smpi_do_once_duration_node_t;
79
80 typedef struct smpi_global_t {
81
82   // config vars
83   double reference_speed;
84
85   // state vars
86
87   smx_host_t *hosts; //FIXME:killme
88   int host_count;
89   xbt_mallocator_t request_mallocator;
90   xbt_mallocator_t message_mallocator;
91
92   smx_process_t *main_processes;
93
94   xbt_os_timer_t timer;
95   smx_mutex_t timer_mutex;
96   smx_cond_t timer_cond;
97
98   // keeps track of previous times
99   smpi_do_once_duration_node_t do_once_duration_nodes;
100   smx_mutex_t do_once_mutex;
101   double *do_once_duration;
102
103 } s_smpi_global_t;
104 typedef struct smpi_global_t *smpi_global_t;
105 extern smpi_global_t smpi_global;
106
107 typedef struct smpi_host_data_t {
108   int index;
109   smx_mutex_t mutex;
110   smx_cond_t cond;
111
112   smx_process_t main;
113   smx_process_t sender;
114   smx_process_t receiver;
115
116   int finalize; /* so that main process stops its sender&receiver */
117
118   xbt_fifo_t pending_recv_request_queue;
119   xbt_fifo_t pending_send_request_queue;
120   xbt_fifo_t received_message_queue;
121 } s_smpi_host_data_t;
122 typedef struct smpi_host_data_t *smpi_host_data_t;
123
124 // function prototypes
125 void smpi_process_init(void);
126 void smpi_process_finalize(void);
127 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
128
129 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
130 int smpi_mpi_isend(smpi_mpi_request_t request);
131 int smpi_mpi_irecv(smpi_mpi_request_t request);
132 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t * status);
133
134 void smpi_execute(double duration);
135 void smpi_start_timer(void);
136 double smpi_stop_timer(void);
137 void smpi_bench_begin(void);
138 void smpi_bench_end(void);
139 void smpi_bench_skip(void);
140
141 void smpi_global_init(void);
142 void smpi_global_destroy(void);
143 int smpi_host_index(void);
144 smx_mutex_t smpi_host_mutex(void);
145 smx_cond_t smpi_host_cond(void);
146 int smpi_run_simulation(int *argc, char **argv);
147 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
148                         int src, int dst, int tag,
149                         smpi_mpi_communicator_t comm,
150                         smpi_mpi_request_t * request);
151
152 int smpi_sender(int argc,char*argv[]);
153 int smpi_receiver(int argc, char*argv[]);
154
155 #endif