Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add extra argument "priority" to SIMIX_req_host_execute.
[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_CHANGE_HOST),\
36 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_SUSPEND),\
37 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_RESUME),\
38 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_COUNT),\
39 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_DATA),\
40 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_SET_DATA),\
41 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_HOST),\
42 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_NAME),\
43 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_IS_SUSPENDED),\
44 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_GET_PROPERTIES),\
45 SIMIX_REQ_ENUM_ELEMENT(REQ_PROCESS_SLEEP),\
46 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_CREATE),\
47 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_DESTROY),\
48 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_GEY_BY_NAME),\
49 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_COMM_COUNT_BY_HOST),\
50 SIMIX_REQ_ENUM_ELEMENT(REQ_RDV_GET_HEAD),\
51 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_ISEND),\
52 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_IRECV),\
53 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_DESTROY),\
54 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_CANCEL),\
55 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_WAITANY),\
56 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_WAIT),\
57 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_TEST),\
58 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_TESTANY),\
59 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_REMAINS),\
60 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_STATE),\
61 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_SRC_DATA),\
62 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_DST_DATA),\
63 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_SRC_BUFF),\
64 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_DST_BUFF),\
65 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_SRC_BUFF_SIZE),\
66 SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_GET_DST_BUFF_SIZE),\
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
88 /* REQ_COMM_IS_LATENCY_BOUNDED and REQ_SET_CATEGORY make things complicated
89  * because they are not always present */
90 #ifdef HAVE_LATENCY_BOUND_TRACKING
91 #define SIMIX_REQ_LIST2 \
92 ,SIMIX_REQ_ENUM_ELEMENT(REQ_COMM_IS_LATENCY_BOUNDED)
93 #else
94 #define SIMIX_REQ_LIST2
95 #endif
96
97 #ifdef HAVE_TRACING
98 #define SIMIX_REQ_LIST3 \
99 ,SIMIX_REQ_ENUM_ELEMENT(REQ_SET_CATEGORY)
100 #else
101 #define SIMIX_REQ_LIST3
102 #endif
103
104 /* SIMIX_REQ_LIST is the final macro to use */
105 #define SIMIX_REQ_LIST SIMIX_REQ_LIST1 SIMIX_REQ_LIST2 SIMIX_REQ_LIST3
106
107 /* you can redefine the following macro differently to generate something else
108  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
109 #define SIMIX_REQ_ENUM_ELEMENT(x) x
110
111 /**
112  * \brief All possible SIMIX requests.
113  */
114 typedef enum {
115 SIMIX_REQ_LIST
116 } e_smx_req_t;
117
118 /**
119  * \brief Represents a SIMIX request.
120  */
121 typedef struct s_smx_req {
122   s_xbt_swag_hookup_t state_hookup;
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     } host_execution_wait;
213
214     struct {
215       const char *name;
216       xbt_main_func_t code;
217       void *data;
218       const char *hostname;
219       int argc;
220       char **argv;
221       xbt_dict_t properties;
222       smx_process_t result;
223     } process_create;
224
225     struct {
226       smx_process_t process;
227     } process_kill;
228
229     struct {
230       smx_process_t process;
231       const char *source;
232       const char *dest;
233     } process_change_host;
234
235     struct {
236       smx_process_t process;
237     } process_suspend;
238
239     struct {
240       smx_process_t process;
241     } process_resume;
242
243     struct {
244       int result;
245     } process_count;
246
247     struct {
248       smx_process_t process;
249       void* result;
250     } process_get_data;
251
252     struct {
253       smx_process_t process;
254       void* data;
255     } process_set_data;
256
257     struct {
258       smx_process_t process;
259       smx_host_t result;
260     } process_get_host;
261
262     struct {
263       smx_process_t process;
264       const char *result;
265     } process_get_name;
266
267     struct {
268       smx_process_t process;
269       int result;
270     } process_is_suspended;
271
272     struct {
273       smx_process_t process;
274       xbt_dict_t result;
275     } process_get_properties;
276
277     struct {
278       double duration;
279       e_smx_state_t result;
280     } process_sleep;
281
282     struct {
283       const char *name;
284       smx_rdv_t result;
285     } rdv_create;
286
287     struct {
288       smx_rdv_t rdv;
289     } rdv_destroy;
290
291     struct {
292       const char* name;
293       smx_rdv_t result;
294     } rdv_get_by_name;
295
296     struct {
297       smx_rdv_t rdv;
298       smx_host_t host;
299       unsigned int result; 
300     } rdv_comm_count_by_host;
301
302     struct {
303       smx_rdv_t rdv;
304       smx_action_t result;
305     } rdv_get_head;
306
307     struct {
308       smx_rdv_t rdv;
309       double task_size;
310       double rate;
311       void *src_buff;
312       size_t src_buff_size;
313       int (*match_fun)(void *, void *);
314       void *data;
315       smx_action_t result;
316     } comm_isend;
317
318     struct {
319       smx_rdv_t rdv;
320       void *dst_buff;
321       size_t *dst_buff_size;
322       int (*match_fun)(void *, void *);
323           void *data;
324       smx_action_t result;
325     } comm_irecv;
326
327     struct {
328       smx_action_t comm;
329     } comm_destroy;
330
331     struct {
332       smx_action_t comm;
333     } comm_cancel;
334
335     struct {
336       xbt_dynar_t comms;
337       unsigned int result;
338     } comm_waitany;
339
340     struct {
341       smx_action_t comm;
342       double timeout;
343     } comm_wait;
344
345     struct {
346       smx_action_t comm;
347       int result;
348     } comm_test;
349
350     struct {
351       xbt_dynar_t comms;
352       int result;
353     } comm_testany;
354
355     struct {
356       smx_action_t comm;
357       double result;
358     } comm_get_remains;
359
360     struct {
361       smx_action_t comm;
362       e_smx_state_t result;
363     } comm_get_state;
364
365     struct {
366       smx_action_t comm;
367       void *result;
368     } comm_get_src_data;
369
370     struct {
371       smx_action_t comm;
372       void *result;
373     } comm_get_dst_data;
374
375     struct {
376       smx_action_t comm;
377       void *result;
378     } comm_get_src_buff;
379
380     struct {
381       smx_action_t comm;
382       void *result;
383     } comm_get_dst_buff;
384
385     struct {
386       smx_action_t comm;
387       size_t result;
388     } comm_get_src_buff_size;
389
390     struct {
391       smx_action_t comm;
392       size_t result;
393     } comm_get_dst_buff_size;
394
395     struct {
396       smx_action_t comm;
397       smx_process_t result;
398     } comm_get_src_proc;
399
400     struct {
401       smx_action_t comm;
402       smx_process_t result;
403     } comm_get_dst_proc;
404
405 #ifdef HAVE_LATENCY_BOUND_TRACKING
406     struct {
407       smx_action_t comm;
408       int result;
409     } comm_is_latency_bounded;
410 #endif
411
412 #ifdef HAVE_TRACING
413     struct {
414       smx_action_t action;
415       const char *category;
416     } set_category;
417 #endif
418
419     struct {
420       smx_mutex_t result;
421     } mutex_init;
422
423     struct {
424       smx_mutex_t mutex;
425     } mutex_lock;
426
427     struct {
428       smx_mutex_t mutex;
429       int result;
430     } mutex_trylock;
431
432     struct {
433       smx_mutex_t mutex;
434     } mutex_unlock;
435
436     struct {
437       smx_mutex_t mutex;
438     } mutex_destroy;
439
440     struct {
441       smx_cond_t result;
442     } cond_init;
443
444     struct {
445       smx_cond_t cond;
446     } cond_destroy;
447
448     struct {
449       smx_cond_t cond;
450     } cond_signal;
451
452     struct {
453       smx_cond_t cond;
454       smx_mutex_t mutex;
455     } cond_wait;
456
457     struct {
458       smx_cond_t cond;
459       smx_mutex_t mutex;
460       double timeout;
461     } cond_wait_timeout;
462
463     struct {
464       smx_cond_t cond;
465     } cond_broadcast;
466
467     struct {
468       int capacity;
469       smx_sem_t result;
470     } sem_init;
471
472     struct {
473       smx_sem_t sem;
474     } sem_destroy;
475
476     struct {
477       smx_sem_t sem;
478     } sem_release;
479
480     struct {
481       smx_sem_t sem;
482       int result;
483     } sem_would_block;
484
485     struct {
486       smx_sem_t sem;
487     } sem_acquire;
488
489     struct {
490       smx_sem_t sem;
491       double timeout;
492     } sem_acquire_timeout;
493
494     struct {
495       smx_sem_t sem;
496       int result;
497     } sem_get_capacity;
498   };
499 } s_smx_req_t, *smx_req_t;
500
501 /******************************** General *************************************/
502
503 void SIMIX_request_init(void);
504 void SIMIX_request_destroy(void);
505 void SIMIX_request_push(void);
506 smx_req_t SIMIX_request_pop(void);
507 void SIMIX_request_answer(smx_req_t);
508 void SIMIX_request_pre(smx_req_t, int);
509 void SIMIX_request_post(smx_action_t);
510 XBT_INLINE smx_req_t SIMIX_req_mine(void);
511
512 #endif
513