Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Chord: display the number of messages created
[simgrid.git] / src / simix / smurf_private.h
1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SIMIX_SMURF_PRIVATE_H
8 #define _SIMIX_SMURF_PRIVATE_H
9
10 /********************************* Requests ***********************************/
11
12 /* we want to build the e_smx_t enumeration and the table of the corresponding
13  * strings automatically, using macros */
14
15 #define SIMIX_REQ_LIST1 \
16 SIMIX_REQ_ENUM_ELEMENT(REQ_NO_REQ),\
17 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_BY_NAME),\
18 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_NAME),\
19 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_PROPERTIES),\
20 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_SPEED),\
21 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_AVAILABLE_SPEED),\
22 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_STATE),\
23 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_GET_DATA),\
24 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_SET_DATA),\
25 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTE),\
26 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_PARALLEL_EXECUTE),\
27 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTION_DESTROY),\
28 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTION_CANCEL),\
29 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTION_GET_REMAINS),\
30 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTION_GET_STATE),\
31 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTION_SET_PRIORITY),\
32 SIMIX_REQ_ENUM_ELEMENT(REQ_HOST_EXECUTION_WAIT),\
33 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_CREATE),\
34 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_KILL),\
35 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_CHANGE_HOST),\
36 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_SUSPEND),\
37 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_RESUME),\
38 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_COUNT),\
39 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_DATA),\
40 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_SET_DATA),\
41 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_HOST),\
42 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_NAME),\
43 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_IS_SUSPENDED),\
44 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_PROPERTIES),\
45 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_SLEEP),\
46 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_CREATE),\
47 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_DESTROY),\
48 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_GEY_BY_NAME),\
49 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_COMM_COUNT_BY_HOST),\
50 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_GET_HEAD),\
51 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_ISEND),\
52 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_IRECV),\
53 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_DESTROY),\
54 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_CANCEL),\
55 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_WAITANY),\
56 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_WAIT),\
57 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_TEST),\
58 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_TESTANY),\
59 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_REMAINS),\
60 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_STATE),\
61 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_SRC_DATA),\
62 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_DST_DATA),\
63 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_SRC_PROC),\
64 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_DST_PROC),\
65 SIMIX_REQ_ENUM_ELEMENT(REQ_MUTEX_INIT),\
66 SIMIX_REQ_ENUM_ELEMENT(REQ_MUTEX_DESTROY),\
67 SIMIX_REQ_ENUM_ELEMENT(REQ_MUTEX_LOCK),\
68 SIMIX_REQ_ENUM_ELEMENT(REQ_MUTEX_TRYLOCK),\
69 SIMIX_REQ_ENUM_ELEMENT(REQ_MUTEX_UNLOCK),\
70 SIMIX_REQ_ENUM_ELEMENT(REQ_COND_INIT),\
71 SIMIX_REQ_ENUM_ELEMENT(REQ_COND_DESTROY),\
72 SIMIX_REQ_ENUM_ELEMENT(REQ_COND_SIGNAL),\
73 SIMIX_REQ_ENUM_ELEMENT(REQ_COND_WAIT),\
74 SIMIX_REQ_ENUM_ELEMENT(REQ_COND_WAIT_TIMEOUT),\
75 SIMIX_REQ_ENUM_ELEMENT(REQ_COND_BROADCAST),\
76 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_INIT),\
77 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_DESTROY),\
78 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_RELEASE),\
79 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_WOULD_BLOCK),\
80 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_ACQUIRE),\
81 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_ACQUIRE_TIMEOUT),\
82 SIMIX_REQ_ENUM_ELEMENT(REQ_SEM_GET_CAPACITY)
83
84 /* REQ_COMM_IS_LATENCY_BOUNDED and REQ_SET_CATEGORY make things complicated
85  * because they are not always present */
86 #ifdef HAVE_LATENCY_BOUND_TRACKING
87 #define SIMIX_REQ_LIST2 \
88 ,SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_IS_LATENCY_BOUNDED)
89 #else
90 #define SIMIX_REQ_LIST2
91 #endif
92
93 #ifdef HAVE_TRACING
94 #define SIMIX_REQ_LIST3 \
95 ,SIMIX_REQ_ENUM_ELEMENT(REQ_SET_CATEGORY)
96 #else
97 #define SIMIX_REQ_LIST3
98 #endif
99
100 /* SIMIX_REQ_LIST is the final macro to use */
101 #define SIMIX_REQ_LIST SIMIX_REQ_LIST1 SIMIX_REQ_LIST2 SIMIX_REQ_LIST3
102
103 /* you can redefine the following macro differently to generate something else
104  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
105 #define SIMIX_REQ_ENUM_ELEMENT(x) x
106
107 /**
108  * \brief All possible SIMIX requests.
109  */
110 typedef enum {
111 SIMIX_REQ_LIST
112 } e_smx_req_t;
113
114 /**
115  * \brief Represents a SIMIX request.
116  */
117 typedef struct s_smx_req {
118   s_xbt_swag_hookup_t reqtable_hookup;
119   e_smx_req_t call;
120   smx_process_t issuer;
121
122   union {
123
124     struct {
125       const char *name;
126       smx_host_t result;
127     } host_get_by_name;
128
129     struct {
130       smx_host_t host;
131       const char* result;
132     } host_get_name;
133
134     struct {
135       smx_host_t host;
136       xbt_dict_t result;
137     } host_get_properties;
138
139     struct {
140       smx_host_t host;
141       double result;
142     } host_get_speed;
143
144     struct {
145       smx_host_t host;
146       double result;
147     } host_get_available_speed;
148
149     struct {
150       smx_host_t host;
151       int result;
152     } host_get_state;
153
154     struct {
155       smx_host_t host;
156       void* result;
157     } host_get_data;
158
159     struct {
160       smx_host_t host;
161       void* data;
162     } host_set_data;
163
164     struct {
165       const char* name;
166       smx_host_t host;
167       double computation_amount;
168       double priority;
169       smx_action_t result;
170     } host_execute;
171
172     struct {
173       const char *name;
174       int host_nb;
175       smx_host_t *host_list;
176       double *computation_amount;
177       double *communication_amount;
178       double amount;
179       double rate;
180       smx_action_t result;
181     } host_parallel_execute;
182
183     struct {
184       smx_action_t execution;
185     } host_execution_destroy;
186
187     struct {
188       smx_action_t execution;
189     } host_execution_cancel;
190
191     struct {
192       smx_action_t execution;
193       double result;
194     } host_execution_get_remains;
195
196     struct {
197       smx_action_t execution;
198       e_smx_state_t result;
199     } host_execution_get_state;
200
201     struct {
202       smx_action_t execution;
203       double priority;
204     } host_execution_set_priority;
205
206     struct {
207       smx_action_t execution;
208       e_smx_state_t result;
209     } host_execution_wait;
210
211     struct {
212       smx_process_t *process;
213       const char *name;
214       xbt_main_func_t code;
215       void *data;
216       const char *hostname;
217       int argc;
218       char **argv;
219       xbt_dict_t properties;
220     } process_create;
221
222     struct {
223       smx_process_t process;
224     } process_kill;
225
226     struct {
227       smx_process_t process;
228       const char *source;
229       const char *dest;
230     } process_change_host;
231
232     struct {
233       smx_process_t process;
234     } process_suspend;
235
236     struct {
237       smx_process_t process;
238     } process_resume;
239
240     struct {
241       int result;
242     } process_count;
243
244     struct {
245       smx_process_t process;
246       void* result;
247     } process_get_data;
248
249     struct {
250       smx_process_t process;
251       void* data;
252     } process_set_data;
253
254     struct {
255       smx_process_t process;
256       smx_host_t result;
257     } process_get_host;
258
259     struct {
260       smx_process_t process;
261       const char *result;
262     } process_get_name;
263
264     struct {
265       smx_process_t process;
266       int result;
267     } process_is_suspended;
268
269     struct {
270       smx_process_t process;
271       xbt_dict_t result;
272     } process_get_properties;
273
274     struct {
275       double duration;
276       e_smx_state_t result;
277     } process_sleep;
278
279     struct {
280       const char *name;
281       smx_rdv_t result;
282     } rdv_create;
283
284     struct {
285       smx_rdv_t rdv;
286     } rdv_destroy;
287
288     struct {
289       const char* name;
290       smx_rdv_t result;
291     } rdv_get_by_name;
292
293     struct {
294       smx_rdv_t rdv;
295       smx_host_t host;
296       unsigned int result; 
297     } rdv_comm_count_by_host;
298
299     struct {
300       smx_rdv_t rdv;
301       smx_action_t result;
302     } rdv_get_head;
303
304     struct {
305       smx_rdv_t rdv;
306       double task_size;
307       double rate;
308       void *src_buff;
309       size_t src_buff_size;
310       int (*match_fun)(void *, void *);
311       void *data;
312       int detached;
313       smx_action_t result;
314     } comm_isend;
315
316     struct {
317       smx_rdv_t rdv;
318       void *dst_buff;
319       size_t *dst_buff_size;
320       int (*match_fun)(void *, void *);
321           void *data;
322       smx_action_t result;
323     } comm_irecv;
324
325     struct {
326       smx_action_t comm;
327     } comm_destroy;
328
329     struct {
330       smx_action_t comm;
331     } comm_cancel;
332
333     struct {
334       xbt_dynar_t comms;
335       unsigned int result;
336     } comm_waitany;
337
338     struct {
339       smx_action_t comm;
340       double timeout;
341     } comm_wait;
342
343     struct {
344       smx_action_t comm;
345       int result;
346     } comm_test;
347
348     struct {
349       xbt_dynar_t comms;
350       int result;
351     } comm_testany;
352
353     struct {
354       smx_action_t comm;
355       double result;
356     } comm_get_remains;
357
358     struct {
359       smx_action_t comm;
360       e_smx_state_t result;
361     } comm_get_state;
362
363     struct {
364       smx_action_t comm;
365       void *result;
366     } comm_get_src_data;
367
368     struct {
369       smx_action_t comm;
370       void *result;
371     } comm_get_dst_data;
372
373     struct {
374       smx_action_t comm;
375       smx_process_t result;
376     } comm_get_src_proc;
377
378     struct {
379       smx_action_t comm;
380       smx_process_t result;
381     } comm_get_dst_proc;
382
383 #ifdef HAVE_LATENCY_BOUND_TRACKING
384     struct {
385       smx_action_t comm;
386       int result;
387     } comm_is_latency_bounded;
388 #endif
389
390 #ifdef HAVE_TRACING
391     struct {
392       smx_action_t action;
393       const char *category;
394     } set_category;
395 #endif
396
397     struct {
398       smx_mutex_t result;
399     } mutex_init;
400
401     struct {
402       smx_mutex_t mutex;
403     } mutex_lock;
404
405     struct {
406       smx_mutex_t mutex;
407       int result;
408     } mutex_trylock;
409
410     struct {
411       smx_mutex_t mutex;
412     } mutex_unlock;
413
414     struct {
415       smx_mutex_t mutex;
416     } mutex_destroy;
417
418     struct {
419       smx_cond_t result;
420     } cond_init;
421
422     struct {
423       smx_cond_t cond;
424     } cond_destroy;
425
426     struct {
427       smx_cond_t cond;
428     } cond_signal;
429
430     struct {
431       smx_cond_t cond;
432       smx_mutex_t mutex;
433     } cond_wait;
434
435     struct {
436       smx_cond_t cond;
437       smx_mutex_t mutex;
438       double timeout;
439     } cond_wait_timeout;
440
441     struct {
442       smx_cond_t cond;
443     } cond_broadcast;
444
445     struct {
446       int capacity;
447       smx_sem_t result;
448     } sem_init;
449
450     struct {
451       smx_sem_t sem;
452     } sem_destroy;
453
454     struct {
455       smx_sem_t sem;
456     } sem_release;
457
458     struct {
459       smx_sem_t sem;
460       int result;
461     } sem_would_block;
462
463     struct {
464       smx_sem_t sem;
465     } sem_acquire;
466
467     struct {
468       smx_sem_t sem;
469       double timeout;
470     } sem_acquire_timeout;
471
472     struct {
473       smx_sem_t sem;
474       int result;
475     } sem_get_capacity;
476   };
477 } s_smx_req_t, *smx_req_t;
478
479 /******************************** General *************************************/
480
481 void SIMIX_request_init(void);
482 void SIMIX_request_destroy(void);
483 xbt_swag_t SIMIX_request_get_reqlist(int thread_pid);
484 void SIMIX_request_push(void);
485 smx_req_t SIMIX_request_pop(void);
486 void SIMIX_request_answer(smx_req_t);
487 void SIMIX_request_pre(smx_req_t, int);
488 void SIMIX_request_post(smx_action_t);
489 XBT_INLINE smx_req_t SIMIX_req_mine(void);
490
491 #endif
492