Logo AND Algorithmique Numérique Distribuée

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