Logo AND Algorithmique Numérique Distribuée

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