Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : new comparison of region (program data and libsimgrid data)
[simgrid.git] / src / simix / smx_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 /********************************* Simcalls *********************************/
11
12 /* we want to build the e_smx_simcall_t enumeration and the table of the
13  * corresponding strings automatically, using macros */
14
15 #define SIMCALL_LIST1 \
16 SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
17 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_BY_NAME),\
18 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_NAME),\
19 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_PROPERTIES),\
20 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_SPEED),\
21 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_AVAILABLE_SPEED),\
22 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_STATE),\
23 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_DATA),\
24 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_SET_DATA),\
25 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTE),\
26 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_PARALLEL_EXECUTE),\
27 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_DESTROY),\
28 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_CANCEL),\
29 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_REMAINS),\
30 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_STATE),\
31 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_SET_PRIORITY),\
32 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_WAIT),\
33 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CREATE),\
34 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILL),\
35 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILLALL),\
36 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CLEANUP),\
37 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CHANGE_HOST),\
38 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SUSPEND),\
39 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESUME),\
40 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_COUNT),\
41 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_DATA),\
42 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SET_DATA),\
43 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_HOST),\
44 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_NAME),\
45 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_IS_SUSPENDED),\
46 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_PROPERTIES),\
47 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SLEEP),\
48 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_CREATE),\
49 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\
50 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\
51 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\
52 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\
53 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\
54 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\
55 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\
56 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IRECV),\
57 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_DESTROY),\
58 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_CANCEL),\
59 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\
60 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\
61 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\
62 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\
63 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\
64 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\
65 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\
66 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_DATA),\
67 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_PROC),\
68 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_PROC),\
69 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_INIT),\
70 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_DESTROY),\
71 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_LOCK),\
72 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_TRYLOCK),\
73 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_UNLOCK),\
74 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_INIT),\
75 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_DESTROY),\
76 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_SIGNAL),\
77 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT),\
78 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT_TIMEOUT),\
79 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_BROADCAST),\
80 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_INIT),\
81 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_DESTROY),\
82 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_RELEASE),\
83 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_WOULD_BLOCK),\
84 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
85 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
86 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
87 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
88 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
89 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
90 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
91 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT)
92
93
94 /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
95  * because they are not always present */
96 #ifdef HAVE_LATENCY_BOUND_TRACKING
97 #define SIMCALL_LIST2 \
98 ,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED)
99 #else
100 #define SIMCALL_LIST2
101 #endif
102
103 #ifdef HAVE_TRACING
104 #define SIMCALL_LIST3 \
105 ,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY)
106 #else
107 #define SIMCALL_LIST3
108 #endif
109
110 /* SIMCALL_LIST is the final macro to use */
111 #define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3
112
113 /* you can redefine the following macro differently to generate something else
114  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
115 #define SIMCALL_ENUM_ELEMENT(x) x
116
117 /**
118  * \brief All possible simcalls.
119  */
120 typedef enum {
121 SIMCALL_LIST
122 } e_smx_simcall_t;
123
124 /**
125  * \brief Represents a simcall to the kernel.
126  */
127 typedef struct s_smx_simcall {
128   e_smx_simcall_t call;
129   smx_process_t issuer;
130
131   union {
132
133     struct {
134       const char *name;
135       smx_host_t result;
136     } host_get_by_name;
137
138     struct {
139       smx_host_t host;
140       const char* result;
141     } host_get_name;
142
143     struct {
144       smx_host_t host;
145       xbt_dict_t result;
146     } host_get_properties;
147
148     struct {
149       smx_host_t host;
150       double result;
151     } host_get_speed;
152
153     struct {
154       smx_host_t host;
155       double result;
156     } host_get_available_speed;
157
158     struct {
159       smx_host_t host;
160       int result;
161     } host_get_state;
162
163     struct {
164       smx_host_t host;
165       void* result;
166     } host_get_data;
167
168     struct {
169       smx_host_t host;
170       void* data;
171     } host_set_data;
172
173     struct {
174       const char* name;
175       smx_host_t host;
176       double computation_amount;
177       double priority;
178       smx_action_t result;
179     } host_execute;
180
181     struct {
182       const char *name;
183       int host_nb;
184       smx_host_t *host_list;
185       double *computation_amount;
186       double *communication_amount;
187       double amount;
188       double rate;
189       smx_action_t result;
190     } host_parallel_execute;
191
192     struct {
193       smx_action_t execution;
194     } host_execution_destroy;
195
196     struct {
197       smx_action_t execution;
198     } host_execution_cancel;
199
200     struct {
201       smx_action_t execution;
202       double result;
203     } host_execution_get_remains;
204
205     struct {
206       smx_action_t execution;
207       e_smx_state_t result;
208     } host_execution_get_state;
209
210     struct {
211       smx_action_t execution;
212       double priority;
213     } host_execution_set_priority;
214
215     struct {
216       smx_action_t execution;
217       e_smx_state_t result;
218     } host_execution_wait;
219
220     struct {
221       smx_process_t *process;
222       const char *name;
223       xbt_main_func_t code;
224       void *data;
225       const char *hostname;
226       double kill_time;
227       int argc;
228       char **argv;
229       xbt_dict_t properties;
230     } process_create;
231
232     struct {
233       smx_process_t process;
234     } process_kill;
235
236     struct {
237       smx_process_t process;
238     } process_cleanup;
239
240     struct {
241       smx_process_t process;
242       smx_host_t dest;
243     } process_change_host;
244
245     struct {
246       smx_process_t process;
247     } process_suspend;
248
249     struct {
250       smx_process_t process;
251     } process_resume;
252
253     struct {
254       int result;
255     } process_count;
256
257     struct {
258       smx_process_t process;
259       void* result;
260     } process_get_data;
261
262     struct {
263       smx_process_t process;
264       void* data;
265     } process_set_data;
266
267     struct {
268       smx_process_t process;
269       smx_host_t result;
270     } process_get_host;
271
272     struct {
273       smx_process_t process;
274       const char *result;
275     } process_get_name;
276
277     struct {
278       smx_process_t process;
279       int result;
280     } process_is_suspended;
281
282     struct {
283       smx_process_t process;
284       xbt_dict_t result;
285     } process_get_properties;
286
287     struct {
288       double duration;
289       e_smx_state_t result;
290     } process_sleep;
291
292     struct {
293       const char *name;
294       smx_rdv_t result;
295     } rdv_create;
296
297     struct {
298       smx_rdv_t rdv;
299     } rdv_destroy;
300
301     struct {
302       const char* name;
303       smx_rdv_t result;
304     } rdv_get_by_name;
305
306     struct {
307       smx_rdv_t rdv;
308       smx_host_t host;
309       unsigned int result; 
310     } rdv_comm_count_by_host;
311
312     struct {
313       smx_rdv_t rdv;
314       smx_action_t result;
315     } rdv_get_head;
316
317     struct {
318       smx_rdv_t rdv;
319       double task_size;
320       double rate;
321       void *src_buff;
322       size_t src_buff_size;
323       int (*match_fun)(void *, void *);
324       void *data;
325       double timeout;
326     } comm_send;
327
328     struct {
329       smx_rdv_t rdv;
330       double task_size;
331       double rate;
332       void *src_buff;
333       size_t src_buff_size;
334       int (*match_fun)(void *, void *);
335       void (*clean_fun)(void *);
336       void *data;
337       int detached;
338       smx_action_t result;
339     } comm_isend;
340
341     struct {
342       smx_rdv_t rdv;
343       void *dst_buff;
344       size_t *dst_buff_size;
345       int (*match_fun)(void *, void *);
346       void *data;
347       double timeout;
348     } comm_recv;
349
350     struct {
351       smx_rdv_t rdv;
352       void *dst_buff;
353       size_t *dst_buff_size;
354       int (*match_fun)(void *, void *);
355           void *data;
356       smx_action_t result;
357     } comm_irecv;
358
359     struct {
360       smx_action_t comm;
361     } comm_destroy;
362
363     struct {
364       smx_action_t comm;
365     } comm_cancel;
366
367     struct {
368       xbt_dynar_t comms;
369       unsigned int result;
370     } comm_waitany;
371
372     struct {
373       smx_action_t comm;
374       double timeout;
375     } comm_wait;
376
377     struct {
378       smx_action_t comm;
379       int result;
380     } comm_test;
381
382     struct {
383       xbt_dynar_t comms;
384       int result;
385     } comm_testany;
386
387     struct {
388       smx_action_t comm;
389       double result;
390     } comm_get_remains;
391
392     struct {
393       smx_action_t comm;
394       e_smx_state_t result;
395     } comm_get_state;
396
397     struct {
398       smx_action_t comm;
399       void *result;
400     } comm_get_src_data;
401
402     struct {
403       smx_action_t comm;
404       void *result;
405     } comm_get_dst_data;
406
407     struct {
408       smx_action_t comm;
409       smx_process_t result;
410     } comm_get_src_proc;
411
412     struct {
413       smx_action_t comm;
414       smx_process_t result;
415     } comm_get_dst_proc;
416
417 #ifdef HAVE_LATENCY_BOUND_TRACKING
418     struct {
419       smx_action_t comm;
420       int result;
421     } comm_is_latency_bounded;
422 #endif
423
424 #ifdef HAVE_TRACING
425     struct {
426       smx_action_t action;
427       const char *category;
428     } set_category;
429 #endif
430
431     struct {
432       smx_mutex_t result;
433     } mutex_init;
434
435     struct {
436       smx_mutex_t mutex;
437     } mutex_lock;
438
439     struct {
440       smx_mutex_t mutex;
441       int result;
442     } mutex_trylock;
443
444     struct {
445       smx_mutex_t mutex;
446     } mutex_unlock;
447
448     struct {
449       smx_mutex_t mutex;
450     } mutex_destroy;
451
452     struct {
453       smx_cond_t result;
454     } cond_init;
455
456     struct {
457       smx_cond_t cond;
458     } cond_destroy;
459
460     struct {
461       smx_cond_t cond;
462     } cond_signal;
463
464     struct {
465       smx_cond_t cond;
466       smx_mutex_t mutex;
467     } cond_wait;
468
469     struct {
470       smx_cond_t cond;
471       smx_mutex_t mutex;
472       double timeout;
473     } cond_wait_timeout;
474
475     struct {
476       smx_cond_t cond;
477     } cond_broadcast;
478
479     struct {
480       int capacity;
481       smx_sem_t result;
482     } sem_init;
483
484     struct {
485       smx_sem_t sem;
486     } sem_destroy;
487
488     struct {
489       smx_sem_t sem;
490     } sem_release;
491
492     struct {
493       smx_sem_t sem;
494       int result;
495     } sem_would_block;
496
497     struct {
498       smx_sem_t sem;
499     } sem_acquire;
500
501     struct {
502       smx_sem_t sem;
503       double timeout;
504     } sem_acquire_timeout;
505
506     struct {
507       smx_sem_t sem;
508       int result;
509     } sem_get_capacity;
510
511     struct {
512       const char* storage;
513       void *ptr;
514       size_t size;
515       size_t nmemb;
516       smx_file_t stream;
517       size_t result;
518     } file_read;
519
520     struct {
521       const char* storage;
522       const void *ptr;
523       size_t size;
524       size_t nmemb;
525       smx_file_t stream;
526       size_t result;
527     } file_write;
528
529     struct {
530       const char* storage;
531       const char* path;
532       const char* mode;
533       smx_file_t result;
534     } file_open;
535
536     struct {
537       const char* storage;
538       smx_file_t fp;
539       int result;
540     } file_close;
541
542     struct {
543       const char* storage;
544       smx_file_t fd;
545       s_file_stat_t buf;
546       int result;
547     } file_stat;
548
549   };
550 } s_smx_simcall_t, *smx_simcall_t;
551
552 /******************************** General *************************************/
553
554 void SIMIX_simcall_push(smx_process_t self);
555 void SIMIX_simcall_answer(smx_simcall_t);
556 void SIMIX_simcall_pre(smx_simcall_t, int);
557 void SIMIX_simcall_post(smx_action_t);
558 smx_simcall_t SIMIX_simcall_mine(void);
559 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
560
561 #endif
562