4 * \brief Returns a host given its name.
6 * \param name The name of the host to get
7 * \return The corresponding host
9 smx_host_t SIMIX_req_host_get_by_name(const char *name)
13 req.call = REQ_HOST_GET_BY_NAME;
14 req.host_get_by_name.name = name;
15 SIMIX_request_push(&req);
16 return req.host_get_by_name.result;
20 * \brief Returns the name of a host.
22 * \param host A SIMIX host
23 * \return The name of this host
25 const char* SIMIX_req_host_get_name(smx_host_t host)
29 req.call = REQ_HOST_GET_NAME;
30 req.host_get_name.host = host;
31 SIMIX_request_push(&req);
32 return req.host_get_name.result;
36 * \brief Returns a dict of the properties assigned to a host.
39 * \return The properties of this host
41 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
45 req.call = REQ_HOST_GET_PROPERTIES;
46 req.host_get_properties.host = host;
47 SIMIX_request_push(&req);
48 return req.host_get_properties.result;
52 * \brief Returns the speed of the processor.
54 * The speed returned does not take into account the current load on the machine.
55 * \param host A SIMIX host
56 * \return The speed of this host (in Mflop/s)
58 double SIMIX_req_host_get_speed(smx_host_t host)
62 req.call = REQ_HOST_GET_SPEED;
63 req.host_get_speed.host = host;
64 SIMIX_request_push(&req);
65 return req.host_get_speed.result;
69 * \brief Returns the available speed of the processor.
71 * \return Speed currently available (in Mflop/s)
73 double SIMIX_req_host_get_available_speed(smx_host_t host)
77 req.call = REQ_HOST_GET_AVAILABLE_SPEED;
78 req.host_get_available_speed.host = host;
79 SIMIX_request_push(&req);
80 return req.host_get_available_speed.result;
84 * \brief Returns the state of a host.
86 * Two states are possible: 1 if the host is active or 0 if it has crashed.
87 * \param host A SIMIX host
88 * \return 1 if the host is available, 0 otherwise
90 int SIMIX_req_host_get_state(smx_host_t host)
94 req.call = REQ_HOST_GET_STATE;
95 req.host_get_state.host = host;
96 SIMIX_request_push(&req);
97 return req.host_get_state.result;
101 * \brief Returns the user data associated to a host.
103 * \param host SIMIX host
104 * \return the user data of this host
106 void* SIMIX_req_host_get_data(smx_host_t host)
110 req.call = REQ_HOST_GET_DATA;
111 req.host_get_data.host = host;
112 SIMIX_request_push(&req);
113 return req.host_get_data.result;
117 * \brief Sets the user data associated to a host.
119 * The host must not have previous user data associated to it.
120 * \param A host SIMIX host
121 * \param data The user data to set
123 void SIMIX_req_host_set_data(smx_host_t host, void *data)
127 req.call = REQ_HOST_SET_DATA;
128 req.host_set_data.host = host;
129 req.host_set_data.data = data;
130 SIMIX_request_push(&req);
133 /** \brief Creates an action that executes some computation of an host.
135 * This function creates a SURF action and allocates the data necessary
136 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
138 * \param name Name of the execution action to create
139 * \param host SIMIX host where the action will be executed
140 * \param amount Computation amount (in bytes)
141 * \return A new SIMIX execution action
143 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
144 double computation_amount)
148 req.call = REQ_HOST_EXECUTE;
149 req.host_execute.name = name;
150 req.host_execute.host = host;
151 req.host_execute.computation_amount = computation_amount;
152 SIMIX_request_push(&req);
153 return req.host_execute.result;
156 /** \brief Creates an action that may involve parallel computation on
157 * several hosts and communication between them.
159 * \param name Name of the execution action to create
160 * \param host_nb Number of hosts where the action will be executed
161 * \param host_list Array (of size host_nb) of hosts where the action will be executed
162 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
163 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
164 * amount between each pair of hosts
165 * \param amount the SURF action amount
166 * \param rate the SURF action rate
167 * \return A new SIMIX execution action
169 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
171 smx_host_t *host_list,
172 double *computation_amount,
173 double *communication_amount,
179 req.call = REQ_HOST_PARALLEL_EXECUTE;
180 req.host_parallel_execute.name = name;
181 req.host_parallel_execute.host_nb = host_nb;
182 req.host_parallel_execute.host_list = host_list;
183 req.host_parallel_execute.computation_amount = computation_amount;
184 req.host_parallel_execute.communication_amount = communication_amount;
185 req.host_parallel_execute.amount = amount;
186 req.host_parallel_execute.rate = rate;
187 SIMIX_request_push(&req);
188 return req.host_parallel_execute.result;
192 * \brief Destroys an execution action.
194 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
195 * \param action The execution action to destroy
197 void SIMIX_req_host_execution_destroy(smx_action_t execution)
201 req.call = REQ_HOST_EXECUTION_DESTROY;
202 req.host_execution_destroy.execution = execution;
203 SIMIX_request_push(&req);
207 * \brief Cancels an execution action.
209 * This functions stops the execution. It calls a surf function.
210 * \param action The execution action to cancel
212 void SIMIX_req_host_execution_cancel(smx_action_t execution)
216 req.call = REQ_HOST_EXECUTION_CANCEL;
217 req.host_execution_cancel.execution = execution;
218 SIMIX_request_push(&req);
222 * \brief Returns how much of an execution action remains to be done.
224 * \param Action The execution action
225 * \return The remaining amount
227 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
231 req.call = REQ_HOST_EXECUTION_GET_REMAINS;
232 req.host_execution_get_remains.execution = execution;
233 SIMIX_request_push(&req);
234 return req.host_execution_get_remains.result;
238 * \brief Returns the state of an execution action.
240 * \param execution The execution action
243 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
247 req.call = REQ_HOST_EXECUTION_GET_STATE;
248 req.host_execution_get_state.execution = execution;
249 SIMIX_request_push(&req);
250 return req.host_execution_get_state.result;
254 * \brief Changes the priority of an execution action.
256 * This functions changes the priority only. It calls a surf function.
257 * \param execution The execution action
258 * \param priority The new priority
260 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
264 req.call = REQ_HOST_EXECUTION_SET_PRIORITY;
265 req.host_execution_set_priority.execution = execution;
266 req.host_execution_set_priority.priority = priority;
267 SIMIX_request_push(&req);
271 * \brief Waits for the completion of an execution action.
273 * \param execution The execution action
275 void SIMIX_req_host_execution_wait(smx_action_t execution)
279 req.call = REQ_HOST_EXECUTION_WAIT;
280 req.host_execution_wait.execution = execution;
281 SIMIX_request_push(&req);
285 * \brief Creates and runs a new SIMIX process.
287 * The structure and the corresponding threada are created and put in the list of ready processes.
289 * \param name a name for the process. It is for user-level information and can be NULL.
290 * \param code the main function of the process
291 * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
292 * It can be retrieved with the function \ref SIMIX_req_process_get_data.
293 * \param hostname name of the host where the new agent is executed.
294 * \param argc first argument passed to \a code
295 * \param argv second argument passed to \a code
296 * \param properties the properties of the process
297 * \return The new process
299 smx_process_t SIMIX_req_process_create(const char *name,
300 xbt_main_func_t code,
302 const char *hostname,
303 int argc, char **argv,
304 xbt_dict_t properties)
308 req.call = REQ_PROCESS_CREATE;
309 req.process_create.name = name;
310 req.process_create.code = code;
311 req.process_create.data = data;
312 req.process_create.hostname = hostname;
313 req.process_create.argc = argc;
314 req.process_create.argv = argv;
315 req.process_create.properties = properties;
316 SIMIX_request_push(&req);
317 return req.process_create.result;
320 /** \brief Kills a SIMIX process.
322 * This function simply kills a process.
324 * \param process poor victim
326 void SIMIX_req_process_kill(smx_process_t process)
330 req.call = REQ_PROCESS_KILL;
331 req.process_kill.process = process;
332 SIMIX_request_push(&req);
336 * \brief Migrates an agent to another location.
338 * This function changes the value of the host on which \a process is running.
340 * \param process the process to migrate
341 * \param source name of the previous host
342 * \param dest name of the new host
344 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
348 req.call = REQ_PROCESS_CHANGE_HOST;
349 req.process_change_host.process = process;
350 req.process_change_host.source = source;
351 req.process_change_host.dest = dest;
352 SIMIX_request_push(&req);
356 * \brief Suspends a process.
358 * This function suspends the process by suspending the action
359 * it was waiting for completion.
361 * \param process a SIMIX process
363 void SIMIX_req_process_suspend(smx_process_t process)
367 req.call = REQ_PROCESS_SUSPEND;
368 req.process_suspend.process = process;
369 SIMIX_request_push(&req);
373 * \brief Resumes a suspended process.
375 * This function resumes a suspended process by resuming the action
376 * it was waiting for completion.
378 * \param process a SIMIX process
380 void SIMIX_req_process_resume(smx_process_t process)
384 req.call = REQ_PROCESS_RESUME;
385 req.process_resume.process = process;
386 SIMIX_request_push(&req);
390 * \brief Returns the amount of SIMIX processes in the system
392 * Maestro internal process is not counted, only user code processes are
394 int SIMIX_req_process_count(void)
398 req.call = REQ_PROCESS_COUNT;
399 SIMIX_request_push(&req);
400 return req.process_count.result;
404 * \brief Return the user data of a #smx_process_t.
406 * This functions checks whether \a process is a valid pointer or not and return the user data associated to \a process if it is possible.
407 * \param process SIMIX process
408 * \return A void pointer to the user data
410 void* SIMIX_req_process_get_data(smx_process_t process)
414 req.call = REQ_PROCESS_GET_DATA;
415 req.process_get_data.process = process;
416 SIMIX_request_push(&req);
417 return req.process_get_data.result;
421 * \brief Set the user data of a #m_process_t.
423 * This functions checks whether \a process is a valid pointer or not and set the user data associated to \a process if it is possible.
424 * \param process SIMIX process
425 * \param data User data
427 void SIMIX_req_process_set_data(smx_process_t process, void *data)
431 req.call = REQ_PROCESS_SET_DATA;
432 req.process_set_data.process = process;
433 req.process_set_data.data = data;
434 SIMIX_request_push(&req);
438 * \brief Return the location on which an agent is running.
440 * This functions checks whether \a process is a valid pointer or not and return the m_host_t corresponding to the location on which \a process is running.
441 * \param process SIMIX process
444 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
448 req.call = REQ_PROCESS_GET_HOST;
449 req.process_get_host.process = process;
450 SIMIX_request_push(&req);
451 return req.process_get_host.result;
455 * \brief Return the name of an agent.
457 * This functions checks whether \a process is a valid pointer or not and return its name.
458 * \param process SIMIX process
459 * \return The process name
461 const char* SIMIX_req_process_get_name(smx_process_t process)
465 req.call = REQ_PROCESS_GET_NAME;
466 req.process_get_name.process = process;
467 SIMIX_request_push(&req);
468 return req.process_get_name.result;
472 * \brief Returns true if the process is suspended .
474 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
475 * \param process SIMIX process
476 * \return 1, if the process is suspended, else 0.
478 int SIMIX_req_process_is_suspended(smx_process_t process)
482 req.call = REQ_PROCESS_IS_SUSPENDED;
483 req.process_is_suspended.process = process;
484 SIMIX_request_push(&req);
485 return req.process_is_suspended.result;
488 /** \ingroup m_process_management
489 * \brief Return the properties
491 * This functions returns the properties associated with this process
493 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
497 req.call = REQ_PROCESS_GET_PROPERTIES;
498 req.process_get_properties.process = process;
499 SIMIX_request_push(&req);
500 return req.process_get_properties.result;
503 /** \brief Creates a new sleep SIMIX action.
505 * This function creates a SURF action and allocates the data necessary
506 * to create the SIMIX action. It can raise a host_error exception if the
507 * host crashed. The default SIMIX name of the action is "sleep".
509 * \param duration Time duration of the sleep.
510 * \return A result telling whether the sleep was successful
512 e_smx_state_t SIMIX_req_process_sleep(double duration)
516 req.call = REQ_PROCESS_SLEEP;
517 req.process_sleep.duration = duration;
518 SIMIX_request_push(&req);
519 return req.process_sleep.result;
523 * \brief Creates a new rendez-vous point
524 * \param name The name of the rendez-vous point
525 * \return The created rendez-vous point
527 smx_rdv_t SIMIX_req_rdv_create(const char *name)
531 req.call = REQ_RDV_CREATE;
532 req.rdv_create.name = name;
534 SIMIX_request_push(&req);
535 return req.rdv_create.result;
540 * \brief Destroy a rendez-vous point
541 * \param name The rendez-vous point to destroy
543 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
547 req.call = REQ_RDV_DESTROY;
548 req.rdv_destroy.rdv = rdv;
550 SIMIX_request_push(&req);
553 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
557 req.call = REQ_RDV_GEY_BY_NAME;
558 req.rdv_get_by_name.name = name;
559 SIMIX_request_push(&req);
560 return req.rdv_get_by_name.result;
564 * \brief counts the number of communication requests of a given host pending
565 * on a rendez-vous point
566 * \param rdv The rendez-vous point
567 * \param host The host to be counted
568 * \return The number of comm request pending in the rdv
570 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
574 req.call = REQ_RDV_COMM_COUNT_BY_HOST;
575 req.rdv_comm_count_by_host.rdv = rdv;
576 req.rdv_comm_count_by_host.host = host;
578 SIMIX_request_push(&req);
579 return req.rdv_comm_count_by_host.result;
583 * \brief returns the communication at the head of the rendez-vous
584 * \param rdv The rendez-vous point
585 * \return The communication or NULL if empty
587 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
591 req.call = REQ_RDV_GET_HEAD;
592 req.rdv_get_head.rdv = rdv;
594 SIMIX_request_push(&req);
595 return req.rdv_get_head.result;
598 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
599 void *src_buff, size_t src_buff_size, void *data)
603 xbt_assert0(rdv, "No rendez-vous point defined for isend");
605 req.call = REQ_COMM_ISEND;
606 req.comm_isend.rdv = rdv;
607 req.comm_isend.task_size = task_size;
608 req.comm_isend.rate = rate;
609 req.comm_isend.src_buff = src_buff;
610 req.comm_isend.src_buff_size = src_buff_size;
611 req.comm_isend.data = data;
613 SIMIX_request_push(&req);
614 return req.comm_isend.result;
617 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size)
621 xbt_assert0(rdv, "No rendez-vous point defined for isend");
623 req.call = REQ_COMM_IRECV;
624 req.comm_irecv.rdv = rdv;
625 req.comm_irecv.dst_buff = dst_buff;
626 req.comm_irecv.dst_buff_size = dst_buff_size;
628 SIMIX_request_push(&req);
629 return req.comm_irecv.result;
632 void SIMIX_req_comm_destroy(smx_action_t comm)
636 req.call = REQ_COMM_DESTROY;
637 req.comm_destroy.comm = comm;
639 SIMIX_request_push(&req);
642 void SIMIX_req_comm_cancel(smx_action_t comm)
646 req.call = REQ_COMM_CANCEL;
647 req.comm_cancel.comm = comm;
649 SIMIX_request_push(&req);
652 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
656 req.call = REQ_COMM_WAITANY;
657 req.comm_waitany.comms = comms;
659 SIMIX_request_push(&req);
660 return req.comm_waitany.result;
663 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
667 req.call = REQ_COMM_WAIT;
668 req.comm_wait.comm = comm;
669 req.comm_wait.timeout = timeout;
671 SIMIX_request_push(&req);
674 int SIMIX_req_comm_test(smx_action_t comm)
678 req.call = REQ_COMM_TEST;
679 req.comm_test.comm = comm;
681 SIMIX_request_push(&req);
682 return req.comm_test.result;
685 double SIMIX_req_comm_get_remains(smx_action_t comm)
689 req.call = REQ_COMM_GET_REMAINS;
690 req.comm_get_remains.comm = comm;
692 SIMIX_request_push(&req);
693 return req.comm_get_remains.result;
696 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
700 req.call = REQ_COMM_GET_STATE;
701 req.comm_get_state.comm = comm;
703 SIMIX_request_push(&req);
704 return req.comm_get_state.result;
707 void *SIMIX_req_comm_get_data(smx_action_t comm)
711 req.call = REQ_COMM_GET_DATA;
712 req.comm_get_data.comm = comm;
714 SIMIX_request_push(&req);
715 return req.comm_get_data.result;
718 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
722 req.call = REQ_COMM_GET_SRC_BUFF;
723 req.comm_get_src_buff.comm = comm;
725 SIMIX_request_push(&req);
726 return req.comm_get_src_buff.result;
729 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
733 req.call = REQ_COMM_GET_DST_BUFF;
734 req.comm_get_dst_buff.comm = comm;
736 SIMIX_request_push(&req);
737 return req.comm_get_dst_buff.result;
740 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
744 req.call = REQ_COMM_GET_SRC_BUFF_SIZE;
745 req.comm_get_src_buff_size.comm = comm;
747 SIMIX_request_push(&req);
748 return req.comm_get_src_buff_size.result;
751 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
755 req.call = REQ_COMM_GET_DST_BUFF_SIZE;
756 req.comm_get_dst_buff_size.comm = comm;
758 SIMIX_request_push(&req);
759 return req.comm_get_dst_buff_size.result;
762 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
766 req.call = REQ_COMM_GET_SRC_PROC;
767 req.comm_get_src_proc.comm = comm;
769 SIMIX_request_push(&req);
770 return req.comm_get_src_proc.result;
773 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
777 req.call = REQ_COMM_GET_DST_PROC;
778 req.comm_get_dst_proc.comm = comm;
780 SIMIX_request_push(&req);
781 return req.comm_get_dst_proc.result;
784 #ifdef HAVE_LATENCY_BOUND_TRACKING
785 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
789 req.call = REQ_COMM_IS_LATENCY_BOUNDED;
790 req.comm_is_latency_bounded.comm = comm;
792 SIMIX_request_push(&req);
793 return req.comm_is_latency_bounded.result;
797 smx_mutex_t SIMIX_req_mutex_init(void)
801 req.call = REQ_MUTEX_INIT;
803 SIMIX_request_push(&req);
804 return req.mutex_init.result;
807 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
811 req.call = REQ_MUTEX_DESTROY;
812 req.mutex_destroy.mutex = mutex;
814 SIMIX_request_push(&req);
817 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
821 req.call = REQ_MUTEX_LOCK;
822 req.mutex_lock.mutex = mutex;
824 SIMIX_request_push(&req);
827 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
831 req.call = REQ_MUTEX_TRYLOCK;
832 req.mutex_trylock.mutex = mutex;
834 SIMIX_request_push(&req);
835 return req.mutex_trylock.result;
838 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
842 req.call = REQ_MUTEX_UNLOCK;
843 req.mutex_unlock.mutex = mutex;
845 SIMIX_request_push(&req);
849 smx_cond_t SIMIX_req_cond_init(void)
853 req.call = REQ_COND_INIT;
855 SIMIX_request_push(&req);
856 return req.cond_init.result;
859 void SIMIX_req_cond_destroy(smx_cond_t cond)
863 req.call = REQ_COND_DESTROY;
864 req.cond_destroy.cond = cond;
866 SIMIX_request_push(&req);
869 void SIMIX_req_cond_signal(smx_cond_t cond)
873 req.call = REQ_COND_SIGNAL;
874 req.cond_signal.cond = cond;
876 SIMIX_request_push(&req);
879 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
883 req.call = REQ_COND_WAIT;
884 req.cond_wait.cond = cond;
885 req.cond_wait.mutex = mutex;
887 SIMIX_request_push(&req);
890 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
896 req.call = REQ_COND_WAIT_TIMEOUT;
897 req.cond_wait_timeout.cond = cond;
898 req.cond_wait_timeout.mutex = mutex;
899 req.cond_wait_timeout.timeout = timeout;
901 SIMIX_request_push(&req);
904 void SIMIX_req_cond_broadcast(smx_cond_t cond)
908 req.call = REQ_COND_BROADCAST;
909 req.cond_broadcast.cond = cond;
911 SIMIX_request_push(&req);
915 smx_sem_t SIMIX_req_sem_init(int capacity)
919 req.call = REQ_SEM_INIT;
920 req.sem_init.capacity = capacity;
922 SIMIX_request_push(&req);
923 return req.sem_init.result;
926 void SIMIX_req_sem_destroy(smx_sem_t sem)
930 req.call = REQ_SEM_DESTROY;
931 req.sem_destroy.sem = sem;
933 SIMIX_request_push(&req);
936 void SIMIX_req_sem_release(smx_sem_t sem)
940 req.call = REQ_SEM_RELEASE;
941 req.sem_release.sem = sem;
943 SIMIX_request_push(&req);
946 int SIMIX_req_sem_would_block(smx_sem_t sem)
950 req.call = REQ_SEM_WOULD_BLOCK;
951 req.sem_would_block.sem = sem;
953 SIMIX_request_push(&req);
954 return req.sem_would_block.result;
957 void SIMIX_req_sem_acquire(smx_sem_t sem)
961 req.call = REQ_SEM_ACQUIRE;
962 req.sem_acquire.sem = sem;
964 SIMIX_request_push(&req);
967 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
971 req.call = REQ_SEM_ACQUIRE_TIMEOUT;
972 req.sem_acquire_timeout.sem = sem;
973 req.sem_acquire_timeout.timeout = timeout;
975 SIMIX_request_push(&req);
978 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
982 req.call = REQ_SEM_GET_CAPACITY;
983 req.sem_get_capacity.sem = sem;
985 SIMIX_request_push(&req);
986 return req.sem_get_capacity.result;