Logo AND Algorithmique Numérique Distribuée

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