Logo AND Algorithmique Numérique Distribuée

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