1 /* libsmx.c - public interface to simix */
3 /* These functions are the only ones that are visible from the higher levels */
4 /* (most of them simply add some documentation to the generated simcall body) */
6 /* This is somehow the "libc" of SimGrid */
8 /* Copyright (c) 2010-2015. The SimGrid Team.
9 * All rights reserved. */
11 /* This program is free software; you can redistribute it and/or modify it
12 * under the terms of the license (GNU LGPL) which comes with this package. */
14 #include "src/mc/mc_replay.h"
15 #include "smx_private.h"
16 #include "src/mc/mc_forward.h"
18 #include <math.h> /* isfinite() */
21 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
23 #include "popping_bodies.c"
26 * \ingroup simix_host_management
27 * \brief Start the host if it is off
29 * \param host A SIMIX host
31 void simcall_host_on(sg_host_t host)
33 simcall_BODY_host_on(host);
37 * \ingroup simix_host_management
38 * \brief Stop the host if it is on
40 * \param host A SIMIX host
42 void simcall_host_off(sg_host_t host)
44 simcall_BODY_host_off(host);
48 * \ingroup simix_host_management
49 * \brief Returns a dict of the properties assigned to a host.
52 * \return The properties of this host
54 xbt_dict_t simcall_host_get_properties(sg_host_t host)
56 return simcall_BODY_host_get_properties(host);
60 * \ingroup simix_host_management
61 * \brief Returns a dict of the properties assigned to a router or AS.
63 * \param name The name of the router or AS
64 * \return The properties
66 xbt_dict_t simcall_asr_get_properties(const char *name)
68 return simcall_BODY_asr_get_properties(name);
72 * \ingroup simix_host_management
73 * \brief Returns the number of core of the processor.
75 * \param host A SIMIX host
76 * \return The number of core
78 int simcall_host_get_core(sg_host_t host)
80 return simcall_BODY_host_get_core(host);
84 * \ingroup simix_host_management
85 * \brief Returns the list of processes attached to the host.
87 * \param host A SIMIX host
88 * \return the swag of attached processes
90 xbt_swag_t simcall_host_get_process_list(sg_host_t host)
92 return simcall_BODY_host_get_process_list(host);
96 * \ingroup simix_host_management
97 * \brief Returns the state of a host.
99 * Two states are possible: 1 if the host is active or 0 if it has crashed.
100 * \param host A SIMIX host
101 * \return 1 if the host is available, 0 otherwise
103 int simcall_host_get_state(sg_host_t host)
105 return simcall_BODY_host_get_state(host);
109 * \ingroup simix_host_management
110 * \brief Returns the power peak of a host.
112 * \param host A SIMIX host
113 * \return the current power peak value (double)
115 double simcall_host_get_current_power_peak(sg_host_t host)
117 return simcall_BODY_host_get_current_power_peak(host);
121 * \ingroup simix_host_management
122 * \brief Returns one power peak (in flops/s) of a host at a given pstate
124 * \param host A SIMIX host
125 * \param pstate_index pstate to test
126 * \return the current power peak value (double) for pstate_index
128 double simcall_host_get_power_peak_at(sg_host_t host, int pstate_index)
130 return simcall_BODY_host_get_power_peak_at(host, pstate_index);
134 * \ingroup simix_host_management
135 * \brief Returns the number of power states for a host.
137 * \param host A SIMIX host
138 * \return the number of power states
140 int simcall_host_get_nb_pstates(sg_host_t host)
142 return simcall_BODY_host_get_nb_pstates(host);
146 * \ingroup simix_host_management
147 * \brief Sets the pstate at which the host should run
149 * \param host A SIMIX host
150 * \param pstate_index The pstate to which the CPU power will be set
152 void simcall_host_set_pstate(sg_host_t host, int pstate_index)
154 simcall_BODY_host_set_pstate(host, pstate_index);
157 * \ingroup simix_host_management
158 * \brief Gets the pstate at which that host currently runs.
160 * \param host A SIMIX host
162 int simcall_host_get_pstate(sg_host_t host)
164 return simcall_BODY_host_get_pstate(host);
168 * \ingroup simix_host_management
169 * \brief Returns the total energy consumed by the host (in Joules)
171 * \param host A SIMIX host
172 * \return the energy consumed by the host (double)
174 double simcall_host_get_consumed_energy(sg_host_t host)
176 return simcall_BODY_host_get_consumed_energy(host);
178 /** \ingroup simix_host_management
179 * \brief Returns the amount of watt dissipated at the given pstate when the host is idling
181 double simcall_host_get_wattmin_at(msg_host_t host, int pstate){
182 return simcall_BODY_host_get_wattmin_at(host, pstate);
184 /** \ingroup simix_host_management
185 * \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
187 double simcall_host_get_wattmax_at(msg_host_t host, int pstate){
188 return simcall_BODY_host_get_wattmax_at(host, pstate);
194 * \ingroup simix_process_management
195 * \brief Creates a synchro that executes some computation of an host.
197 * This function creates a SURF action and allocates the data necessary
198 * to create the SIMIX synchro. It can raise a host_error exception if the host crashed.
200 * \param name Name of the execution synchro to create
201 * \param flops_amount amount Computation amount (in flops)
202 * \param priority computation priority
204 * \param affinity_mask
205 * \return A new SIMIX execution synchronization
207 smx_synchro_t simcall_process_execute(const char *name,
209 double priority, double bound, unsigned long affinity_mask)
211 /* checking for infinite values */
212 xbt_assert(isfinite(flops_amount), "flops_amount is not finite!");
213 xbt_assert(isfinite(priority), "priority is not finite!");
215 return simcall_BODY_process_execute(name, flops_amount, priority, bound, affinity_mask);
219 * \ingroup simix_process_management
220 * \brief Creates a synchro that may involve parallel computation on
221 * several hosts and communication between them.
223 * \param name Name of the execution synchro to create
224 * \param host_nb Number of hosts where the synchro will be executed
225 * \param host_list Array (of size host_nb) of hosts where the synchro will be executed
226 * \param flops_amount Array (of size host_nb) of computation amount of hosts (in bytes)
227 * \param bytes_amount Array (of size host_nb * host_nb) representing the communication
228 * amount between each pair of hosts
229 * \param amount the SURF action amount
230 * \param rate the SURF action rate
231 * \return A new SIMIX execution synchronization
233 smx_synchro_t simcall_process_parallel_execute(const char *name,
235 sg_host_t *host_list,
236 double *flops_amount,
237 double *bytes_amount,
242 /* checking for infinite values */
243 for (i = 0 ; i < host_nb ; ++i) {
244 xbt_assert(isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
245 for (j = 0 ; j < host_nb ; ++j) {
246 xbt_assert(isfinite(bytes_amount[i + host_nb * j]),
247 "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
251 xbt_assert(isfinite(amount), "amount is not finite!");
252 xbt_assert(isfinite(rate), "rate is not finite!");
254 return simcall_BODY_process_parallel_execute(name, host_nb, host_list,
262 * \ingroup simix_process_management
263 * \brief Destroys an execution synchro.
265 * Destroys a synchro, freeing its memory. This function cannot be called if there are a conditional waiting for it.
266 * \param execution The execution synchro to destroy
268 void simcall_process_execution_destroy(smx_synchro_t execution)
270 simcall_BODY_process_execution_destroy(execution);
274 * \ingroup simix_process_management
275 * \brief Cancels an execution synchro.
277 * This functions stops the execution. It calls a surf function.
278 * \param execution The execution synchro to cancel
280 void simcall_process_execution_cancel(smx_synchro_t execution)
282 simcall_BODY_process_execution_cancel(execution);
286 * \ingroup simix_process_management
287 * \brief Returns how much of an execution synchro remains to be done.
289 * \param execution The execution synchro
290 * \return The remaining amount
292 double simcall_process_execution_get_remains(smx_synchro_t execution)
294 return simcall_BODY_process_execution_get_remains(execution);
298 * \ingroup simix_process_management
299 * \brief Returns the state of an execution synchro.
301 * \param execution The execution synchro
304 e_smx_state_t simcall_process_execution_get_state(smx_synchro_t execution)
306 return simcall_BODY_process_execution_get_state(execution);
310 * \ingroup simix_process_management
311 * \brief Changes the priority of an execution synchro.
313 * This functions changes the priority only. It calls a surf function.
314 * \param execution The execution synchro
315 * \param priority The new priority
317 void simcall_process_execution_set_priority(smx_synchro_t execution, double priority)
319 /* checking for infinite values */
320 xbt_assert(isfinite(priority), "priority is not finite!");
322 simcall_BODY_process_execution_set_priority(execution, priority);
326 * \ingroup simix_process_management
327 * \brief Changes the capping (the maximum CPU utilization) of an execution synchro.
329 * This functions changes the capping only. It calls a surf function.
330 * \param execution The execution synchro
331 * \param bound The new bound
333 void simcall_process_execution_set_bound(smx_synchro_t execution, double bound)
335 simcall_BODY_process_execution_set_bound(execution, bound);
339 * \ingroup simix_process_management
340 * \brief Changes the CPU affinity of an execution synchro.
342 * This functions changes the CPU affinity of an execution synchro. See taskset(1) on Linux.
343 * \param execution The execution synchro
345 * \param mask Affinity mask
347 void simcall_process_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask)
349 simcall_BODY_process_execution_set_affinity(execution, host, mask);
353 * \ingroup simix_host_management
354 * \brief Waits for the completion of an execution synchro and destroy it.
356 * \param execution The execution synchro
358 e_smx_state_t simcall_process_execution_wait(smx_synchro_t execution)
360 return simcall_BODY_process_execution_wait(execution);
365 * \ingroup simix_vm_management
366 * \brief Create a VM on the given physical host.
368 * \param name VM name
369 * \param host Physical host
371 * \return The host object of the VM
373 void* simcall_vm_create(const char *name, sg_host_t phys_host){
374 return simcall_BODY_vm_create(name, phys_host);
378 * \ingroup simix_vm_management
379 * \brief Start the given VM to the given physical host
383 void simcall_vm_start(sg_host_t vm)
385 simcall_BODY_vm_start(vm);
389 * \ingroup simix_vm_management
390 * \brief Get the state of the given VM
393 * \return The state of the VM
395 int simcall_vm_get_state(sg_host_t vm)
397 return simcall_BODY_vm_get_state(vm);
401 * \ingroup simix_vm_management
402 * \brief Get the name of the physical host on which the given VM runs.
405 * \return The name of the physical host
407 void *simcall_vm_get_pm(sg_host_t vm)
409 return simcall_BODY_vm_get_pm(vm);
412 void simcall_vm_set_bound(sg_host_t vm, double bound)
414 simcall_BODY_vm_set_bound(vm, bound);
417 void simcall_vm_set_affinity(sg_host_t vm, sg_host_t pm, unsigned long mask)
419 simcall_BODY_vm_set_affinity(vm, pm, mask);
422 void simcall_host_get_params(sg_host_t vm, vm_params_t params)
424 simcall_BODY_host_get_params(vm, params);
427 void simcall_host_set_params(sg_host_t vm, vm_params_t params)
429 simcall_BODY_host_set_params(vm, params);
433 * \ingroup simix_vm_management
434 * \brief Migrate the given VM to the given physical host
437 * \param host Destination physical host
439 void simcall_vm_migrate(sg_host_t vm, sg_host_t host)
441 simcall_BODY_vm_migrate(vm, host);
445 * \ingroup simix_vm_management
446 * \brief Suspend the given VM
450 void simcall_vm_suspend(sg_host_t vm)
452 simcall_BODY_vm_suspend(vm);
456 * \ingroup simix_vm_management
457 * \brief Resume the given VM
461 void simcall_vm_resume(sg_host_t vm)
463 simcall_BODY_vm_resume(vm);
467 * \ingroup simix_vm_management
468 * \brief Save the given VM
472 void simcall_vm_save(sg_host_t vm)
474 simcall_BODY_vm_save(vm);
478 * \ingroup simix_vm_management
479 * \brief Restore the given VM
483 void simcall_vm_restore(sg_host_t vm)
485 simcall_BODY_vm_restore(vm);
489 * \ingroup simix_vm_management
490 * \brief Shutdown the given VM
494 void simcall_vm_shutdown(sg_host_t vm)
496 simcall_BODY_vm_shutdown(vm);
500 * \ingroup simix_vm_management
501 * \brief Destroy the given VM
505 void simcall_vm_destroy(sg_host_t vm)
507 simcall_BODY_vm_destroy(vm);
511 * \ingroup simix_vm_management
512 * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration
513 * The simcall actually invokes the following calls:
514 * simcall_vm_set_affinity(vm, src_pm, 0);
515 * simcall_vm_migrate(vm, dst_pm);
516 * simcall_vm_resume(vm);
518 * It is called at the end of the migration_rx_fun function from msg/msg_vm.c
520 * \param vm VM to migrate
521 * \param src_pm Source physical host
522 * \param dst_pmt Destination physical host
524 void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t dst_pm)
526 simcall_BODY_vm_migratefrom_resumeto(vm, src_pm, dst_pm);
530 * \ingroup simix_process_management
531 * \brief Creates and runs a new SIMIX process.
533 * The structure and the corresponding thread are created and put in the list of ready processes.
535 * \param name a name for the process. It is for user-level information and can be NULL.
536 * \param code the main function of the process
537 * \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.
538 * It can be retrieved with the function \ref simcall_process_get_data.
539 * \param hostname name of the host where the new agent is executed.
540 * \param kill_time time when the process is killed
541 * \param argc first argument passed to \a code
542 * \param argv second argument passed to \a code
543 * \param properties the properties of the process
544 * \param auto_restart either it is autorestarting or not.
546 smx_process_t simcall_process_create(const char *name,
547 xbt_main_func_t code,
549 const char *hostname,
551 int argc, char **argv,
552 xbt_dict_t properties,
555 return (smx_process_t) simcall_BODY_process_create(name, code, data, hostname,
556 kill_time, argc, argv, properties,
561 * \ingroup simix_process_management
562 * \brief Kills a SIMIX process.
564 * This function simply kills a process.
566 * \param process poor victim
568 void simcall_process_kill(smx_process_t process)
570 simcall_BODY_process_kill(process);
574 * \ingroup simix_process_management
575 * \brief Kills all SIMIX processes.
577 void simcall_process_killall(int reset_pid)
579 simcall_BODY_process_killall(reset_pid);
583 * \ingroup simix_process_management
584 * \brief Cleans up a SIMIX process.
585 * \param process poor victim (must have already been killed)
587 void simcall_process_cleanup(smx_process_t process)
589 simcall_BODY_process_cleanup(process);
593 * \ingroup simix_process_management
594 * \brief Migrates an agent to another location.
596 * This function changes the value of the host on which \a process is running.
598 * \param process the process to migrate
599 * \param dest name of the new host
601 void simcall_process_set_host(smx_process_t process, sg_host_t dest)
603 simcall_BODY_process_set_host(process, dest);
606 void simcall_process_join(smx_process_t process, double timeout)
608 simcall_BODY_process_join(process, timeout);
612 * \ingroup simix_process_management
613 * \brief Suspends a process.
615 * This function suspends the process by suspending the synchro
616 * it was waiting for completion.
618 * \param process a SIMIX process
620 void simcall_process_suspend(smx_process_t process)
622 xbt_assert(process, "Invalid parameters");
624 simcall_BODY_process_suspend(process);
628 * \ingroup simix_process_management
629 * \brief Resumes a suspended process.
631 * This function resumes a suspended process by resuming the synchro
632 * it was waiting for completion.
634 * \param process a SIMIX process
636 void simcall_process_resume(smx_process_t process)
638 simcall_BODY_process_resume(process);
642 * \ingroup simix_process_management
643 * \brief Returns the amount of SIMIX processes in the system
645 * Maestro internal process is not counted, only user code processes are
647 int simcall_process_count(void)
649 return simcall_BODY_process_count();
653 * \ingroup simix_process_management
654 * \brief Return the PID of a #smx_process_t.
655 * \param process a SIMIX process
656 * \return the PID of this process
658 int simcall_process_get_PID(smx_process_t process)
660 if (process == SIMIX_process_self()) {
661 /* avoid a simcall if this function is called by the process itself */
662 return SIMIX_process_get_PID(process);
665 return simcall_BODY_process_get_PID(process);
669 * \ingroup simix_process_management
670 * \brief Return the parent PID of a #smx_process_t.
671 * \param process a SIMIX process
672 * \return the PID of this process parenrt
674 int simcall_process_get_PPID(smx_process_t process)
676 if (process == SIMIX_process_self()) {
677 /* avoid a simcall if this function is called by the process itself */
678 return SIMIX_process_get_PPID(process);
681 return simcall_BODY_process_get_PPID(process);
685 * \ingroup simix_process_management
686 * \brief Return the user data of a #smx_process_t.
687 * \param process a SIMIX process
688 * \return the user data of this process
690 void* simcall_process_get_data(smx_process_t process)
692 if (process == SIMIX_process_self()) {
693 /* avoid a simcall if this function is called by the process itself */
694 return SIMIX_process_get_data(process);
697 return simcall_BODY_process_get_data(process);
701 * \ingroup simix_process_management
702 * \brief Set the user data of a #smx_process_t.
704 * This functions sets the user data associated to \a process.
705 * \param process SIMIX process
706 * \param data User data
708 void simcall_process_set_data(smx_process_t process, void *data)
710 if (process == SIMIX_process_self()) {
711 /* avoid a simcall if this function is called by the process itself */
712 SIMIX_process_self_set_data(process, data);
715 simcall_BODY_process_set_data(process, data);
720 * \ingroup simix_process_management
721 * \brief Set the kill time of a process.
723 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
726 if (kill_time > SIMIX_get_clock()) {
727 if (simix_global->kill_process_function) {
728 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
729 sg_host_name(process->host));
730 process->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
735 * \ingroup simix_process_management
736 * \brief Get the kill time of a process (or 0 if unset).
738 double simcall_process_get_kill_time(smx_process_t process) {
739 return SIMIX_timer_get_date(process->kill_timer);
743 * \ingroup simix_process_management
744 * \brief Return the location on which an agent is running.
746 * This functions returns the sg_host_t corresponding to the location on which
747 * \a process is running.
748 * \param process SIMIX process
751 sg_host_t simcall_process_get_host(smx_process_t process)
753 return simcall_BODY_process_get_host(process);
757 * \ingroup simix_process_management
758 * \brief Return the name of an agent.
760 * This functions checks whether \a process is a valid pointer or not and return its name.
761 * \param process SIMIX process
762 * \return The process name
764 const char* simcall_process_get_name(smx_process_t process)
766 if (process == SIMIX_process_self()) {
767 /* avoid a simcall if this function is called by the process itself */
768 return process->name;
770 return simcall_BODY_process_get_name(process);
774 * \ingroup simix_process_management
775 * \brief Returns true if the process is suspended .
777 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
778 * \param process SIMIX process
779 * \return 1, if the process is suspended, else 0.
781 int simcall_process_is_suspended(smx_process_t process)
783 return simcall_BODY_process_is_suspended(process);
787 * \ingroup simix_process_management
788 * \brief Return the properties
790 * This functions returns the properties associated with this process
792 xbt_dict_t simcall_process_get_properties(smx_process_t process)
794 return simcall_BODY_process_get_properties(process);
797 * \ingroup simix_process_management
798 * \brief Add an on_exit function
799 * Add an on_exit function which will be executed when the process exits/is killed.
801 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data)
803 simcall_BODY_process_on_exit(process, fun, data);
806 * \ingroup simix_process_management
807 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
808 * Will restart the process when the host comes back up if auto_restart is set to 1.
811 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
813 simcall_BODY_process_auto_restart_set(process, auto_restart);
817 * \ingroup simix_process_management
818 * \brief Restarts the process, killing it and starting it again from scratch.
820 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
822 return simcall_BODY_process_restart(process);
825 * \ingroup simix_process_management
826 * \brief Creates a new sleep SIMIX synchro.
828 * This function creates a SURF action and allocates the data necessary
829 * to create the SIMIX synchro. It can raise a host_error exception if the
830 * host crashed. The default SIMIX name of the synchro is "sleep".
832 * \param duration Time duration of the sleep.
833 * \return A result telling whether the sleep was successful
835 e_smx_state_t simcall_process_sleep(double duration)
837 /* checking for infinite values */
838 xbt_assert(isfinite(duration), "duration is not finite!");
839 return simcall_BODY_process_sleep(duration);
843 * \ingroup simix_rdv_management
844 * \brief Creates a new rendez-vous point
845 * \param name The name of the rendez-vous point
846 * \return The created rendez-vous point
848 smx_rdv_t simcall_rdv_create(const char *name)
850 return simcall_BODY_rdv_create(name);
855 * \ingroup simix_rdv_management
856 * \brief Destroy a rendez-vous point
857 * \param rdv The rendez-vous point to destroy
859 void simcall_rdv_destroy(smx_rdv_t rdv)
861 simcall_BODY_rdv_destroy(rdv);
864 * \ingroup simix_rdv_management
865 * \brief Returns a rendez-vous point knowing its name
867 smx_rdv_t simcall_rdv_get_by_name(const char *name)
869 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
871 /* FIXME: this is a horrible loss of performance, so we hack it out by
872 * skipping the simcall (for now). It works in parallel, it won't work on
873 * distributed but probably we will change MSG for that. */
875 return SIMIX_rdv_get_by_name(name);
879 * \ingroup simix_rdv_management
880 * \brief Counts the number of communication synchros of a given host pending
881 * on a rendez-vous point.
882 * \param rdv The rendez-vous point
883 * \param host The host to be counted
884 * \return The number of comm synchros pending in the rdv
886 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, sg_host_t host)
888 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
892 * \ingroup simix_rdv_management
893 * \brief returns the communication at the head of the rendez-vous
894 * \param rdv The rendez-vous point
895 * \return The communication or NULL if empty
897 smx_synchro_t simcall_rdv_get_head(smx_rdv_t rdv)
899 return simcall_BODY_rdv_get_head(rdv);
902 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
904 simcall_BODY_rdv_set_receiver(rdv, process);
907 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
909 return simcall_BODY_rdv_get_receiver(rdv);
913 * \ingroup simix_comm_management
915 void simcall_comm_send(smx_process_t sender, smx_rdv_t rdv, double task_size, double rate,
916 void *src_buff, size_t src_buff_size,
917 int (*match_fun)(void *, void *, smx_synchro_t),
918 void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data,
921 /* checking for infinite values */
922 xbt_assert(isfinite(task_size), "task_size is not finite!");
923 xbt_assert(isfinite(rate), "rate is not finite!");
924 xbt_assert(isfinite(timeout), "timeout is not finite!");
926 xbt_assert(rdv, "No rendez-vous point defined for send");
928 if (MC_is_active() || MC_record_replay_is_active()) {
929 /* the model-checker wants two separate simcalls */
930 smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
931 comm = simcall_comm_isend(sender, rdv, task_size, rate,
932 src_buff, src_buff_size, match_fun, NULL, copy_data_fun, data, 0);
933 simcall_comm_wait(comm, timeout);
937 simcall_BODY_comm_send(sender, rdv, task_size, rate, src_buff, src_buff_size,
938 match_fun, copy_data_fun, data, timeout);
943 * \ingroup simix_comm_management
945 smx_synchro_t simcall_comm_isend(smx_process_t sender, smx_rdv_t rdv, double task_size, double rate,
946 void *src_buff, size_t src_buff_size,
947 int (*match_fun)(void *, void *, smx_synchro_t),
948 void (*clean_fun)(void *),
949 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
953 /* checking for infinite values */
954 xbt_assert(isfinite(task_size), "task_size is not finite!");
955 xbt_assert(isfinite(rate), "rate is not finite!");
957 xbt_assert(rdv, "No rendez-vous point defined for isend");
959 return simcall_BODY_comm_isend(sender, rdv, task_size, rate, src_buff,
960 src_buff_size, match_fun,
961 clean_fun, copy_data_fun, data, detached);
965 * \ingroup simix_comm_management
967 void simcall_comm_recv(smx_process_t receiver, smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
968 int (*match_fun)(void *, void *, smx_synchro_t),
969 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
970 void *data, double timeout, double rate)
972 xbt_assert(isfinite(timeout), "timeout is not finite!");
973 xbt_assert(rdv, "No rendez-vous point defined for recv");
975 if (MC_is_active() || MC_record_replay_is_active()) {
976 /* the model-checker wants two separate simcalls */
977 smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
978 comm = simcall_comm_irecv(receiver, rdv, dst_buff, dst_buff_size,
979 match_fun, copy_data_fun, data, rate);
980 simcall_comm_wait(comm, timeout);
984 simcall_BODY_comm_recv(receiver, rdv, dst_buff, dst_buff_size,
985 match_fun, copy_data_fun, data, timeout, rate);
989 * \ingroup simix_comm_management
991 smx_synchro_t simcall_comm_irecv(smx_process_t receiver, smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
992 int (*match_fun)(void *, void *, smx_synchro_t),
993 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
994 void *data, double rate)
996 xbt_assert(rdv, "No rendez-vous point defined for irecv");
998 return simcall_BODY_comm_irecv(receiver, rdv, dst_buff, dst_buff_size,
999 match_fun, copy_data_fun, data, rate);
1003 * \ingroup simix_comm_management
1005 smx_synchro_t simcall_comm_iprobe(smx_rdv_t rdv, int type, int src, int tag,
1006 int (*match_fun)(void *, void *, smx_synchro_t), void *data)
1008 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
1010 return simcall_BODY_comm_iprobe(rdv, type, src, tag, match_fun, data);
1014 * \ingroup simix_comm_management
1016 void simcall_comm_cancel(smx_synchro_t comm)
1018 simcall_BODY_comm_cancel(comm);
1022 * \ingroup simix_comm_management
1024 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
1026 return simcall_BODY_comm_waitany(comms);
1030 * \ingroup simix_comm_management
1032 int simcall_comm_testany(xbt_dynar_t comms)
1034 if (xbt_dynar_is_empty(comms))
1036 return simcall_BODY_comm_testany(comms);
1040 * \ingroup simix_comm_management
1042 void simcall_comm_wait(smx_synchro_t comm, double timeout)
1044 xbt_assert(isfinite(timeout), "timeout is not finite!");
1045 simcall_BODY_comm_wait(comm, timeout);
1049 * \brief Set the category of an synchro.
1051 * This functions changes the category only. It calls a surf function.
1052 * \param execution The execution synchro
1053 * \param category The tracing category
1055 void simcall_set_category(smx_synchro_t synchro, const char *category)
1057 if (category == NULL) {
1060 simcall_BODY_set_category(synchro, category);
1064 * \ingroup simix_comm_management
1067 int simcall_comm_test(smx_synchro_t comm)
1069 return simcall_BODY_comm_test(comm);
1073 * \ingroup simix_comm_management
1076 double simcall_comm_get_remains(smx_synchro_t comm)
1078 return simcall_BODY_comm_get_remains(comm);
1082 * \ingroup simix_comm_management
1085 e_smx_state_t simcall_comm_get_state(smx_synchro_t comm)
1087 return simcall_BODY_comm_get_state(comm);
1091 * \ingroup simix_comm_management
1094 void *simcall_comm_get_src_data(smx_synchro_t comm)
1096 return simcall_BODY_comm_get_src_data(comm);
1100 * \ingroup simix_comm_management
1103 void *simcall_comm_get_dst_data(smx_synchro_t comm)
1105 return simcall_BODY_comm_get_dst_data(comm);
1109 * \ingroup simix_comm_management
1112 smx_process_t simcall_comm_get_src_proc(smx_synchro_t comm)
1114 return simcall_BODY_comm_get_src_proc(comm);
1118 * \ingroup simix_comm_management
1121 smx_process_t simcall_comm_get_dst_proc(smx_synchro_t comm)
1123 return simcall_BODY_comm_get_dst_proc(comm);
1126 #ifdef HAVE_LATENCY_BOUND_TRACKING
1127 int simcall_comm_is_latency_bounded(smx_synchro_t comm)
1129 return simcall_BODY_comm_is_latency_bounded(comm);
1134 * \ingroup simix_synchro_management
1137 smx_mutex_t simcall_mutex_init(void)
1140 fprintf(stderr,"You must run MSG_init before using MSG\n"); // We can't use xbt_die since we may get there before the initialization
1143 return simcall_BODY_mutex_init();
1147 * \ingroup simix_synchro_management
1150 void simcall_mutex_destroy(smx_mutex_t mutex)
1152 simcall_BODY_mutex_destroy(mutex);
1156 * \ingroup simix_synchro_management
1159 void simcall_mutex_lock(smx_mutex_t mutex)
1161 simcall_BODY_mutex_lock(mutex);
1165 * \ingroup simix_synchro_management
1168 int simcall_mutex_trylock(smx_mutex_t mutex)
1170 return simcall_BODY_mutex_trylock(mutex);
1174 * \ingroup simix_synchro_management
1177 void simcall_mutex_unlock(smx_mutex_t mutex)
1179 simcall_BODY_mutex_unlock(mutex);
1183 * \ingroup simix_synchro_management
1186 smx_cond_t simcall_cond_init(void)
1188 return simcall_BODY_cond_init();
1192 * \ingroup simix_synchro_management
1195 void simcall_cond_destroy(smx_cond_t cond)
1197 simcall_BODY_cond_destroy(cond);
1201 * \ingroup simix_synchro_management
1204 void simcall_cond_signal(smx_cond_t cond)
1206 simcall_BODY_cond_signal(cond);
1210 * \ingroup simix_synchro_management
1213 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1215 simcall_BODY_cond_wait(cond, mutex);
1219 * \ingroup simix_synchro_management
1222 void simcall_cond_wait_timeout(smx_cond_t cond,
1226 xbt_assert(isfinite(timeout), "timeout is not finite!");
1227 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1231 * \ingroup simix_synchro_management
1234 void simcall_cond_broadcast(smx_cond_t cond)
1236 simcall_BODY_cond_broadcast(cond);
1240 * \ingroup simix_synchro_management
1243 smx_sem_t simcall_sem_init(int capacity)
1245 return simcall_BODY_sem_init(capacity);
1249 * \ingroup simix_synchro_management
1252 void simcall_sem_destroy(smx_sem_t sem)
1254 simcall_BODY_sem_destroy(sem);
1258 * \ingroup simix_synchro_management
1261 void simcall_sem_release(smx_sem_t sem)
1263 simcall_BODY_sem_release(sem);
1267 * \ingroup simix_synchro_management
1270 int simcall_sem_would_block(smx_sem_t sem)
1272 return simcall_BODY_sem_would_block(sem);
1276 * \ingroup simix_synchro_management
1279 void simcall_sem_acquire(smx_sem_t sem)
1281 simcall_BODY_sem_acquire(sem);
1285 * \ingroup simix_synchro_management
1288 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1290 xbt_assert(isfinite(timeout), "timeout is not finite!");
1291 simcall_BODY_sem_acquire_timeout(sem, timeout);
1295 * \ingroup simix_synchro_management
1298 int simcall_sem_get_capacity(smx_sem_t sem)
1300 return simcall_BODY_sem_get_capacity(sem);
1304 * \ingroup simix_file_management
1307 sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
1309 return simcall_BODY_file_read(fd, size, host);
1313 * \ingroup simix_file_management
1316 sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
1318 return simcall_BODY_file_write(fd, size, host);
1322 * \ingroup simix_file_management
1325 smx_file_t simcall_file_open(const char* fullpath, sg_host_t host)
1327 return simcall_BODY_file_open(fullpath, host);
1331 * \ingroup simix_file_management
1334 int simcall_file_close(smx_file_t fd, sg_host_t host)
1336 return simcall_BODY_file_close(fd, host);
1340 * \ingroup simix_file_management
1343 int simcall_file_unlink(smx_file_t fd, sg_host_t host)
1345 return simcall_BODY_file_unlink(fd, host);
1349 * \ingroup simix_file_management
1352 sg_size_t simcall_file_get_size(smx_file_t fd){
1353 return simcall_BODY_file_get_size(fd);
1357 * \ingroup simix_file_management
1360 sg_size_t simcall_file_tell(smx_file_t fd){
1361 return simcall_BODY_file_tell(fd);
1365 * \ingroup simix_file_management
1368 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
1370 return simcall_BODY_file_get_info(fd);
1374 * \ingroup simix_file_management
1377 int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){
1378 return simcall_BODY_file_seek(fd, offset, origin);
1382 * \ingroup simix_file_management
1383 * \brief Move a file to another location on the *same mount point*.
1386 int simcall_file_move(smx_file_t fd, const char* fullpath)
1388 return simcall_BODY_file_move(fd, fullpath);
1392 * \ingroup simix_storage_management
1393 * \brief Returns the free space size on a given storage element.
1394 * \param storage a storage
1395 * \return Return the free space size on a given storage element (as sg_size_t)
1397 sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
1398 return simcall_BODY_storage_get_free_size(storage);
1402 * \ingroup simix_storage_management
1403 * \brief Returns the used space size on a given storage element.
1404 * \param storage a storage
1405 * \return Return the used space size on a given storage element (as sg_size_t)
1407 sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
1408 return simcall_BODY_storage_get_used_size(storage);
1412 * \ingroup simix_storage_management
1413 * \brief Returns the list of storages mounted on an host.
1414 * \param host A SIMIX host
1415 * \return a dict containing all storages mounted on the host
1417 xbt_dict_t simcall_host_get_mounted_storage_list(sg_host_t host)
1419 return simcall_BODY_host_get_mounted_storage_list(host);
1423 * \ingroup simix_storage_management
1424 * \brief Returns the list of storages attached to an host.
1425 * \param host A SIMIX host
1426 * \return a dict containing all storages attached to the host
1428 xbt_dynar_t simcall_host_get_attached_storage_list(sg_host_t host)
1430 return simcall_BODY_host_get_attached_storage_list(host);
1434 * \ingroup simix_storage_management
1435 * \brief Returns a dict of the properties assigned to a storage element.
1437 * \param storage A storage element
1438 * \return The properties of this storage element
1440 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
1442 return simcall_BODY_storage_get_properties(storage);
1446 * \ingroup simix_storage_management
1447 * \brief Returns a dict containing the content of a storage element.
1449 * \param storage A storage element
1450 * \return The content of this storage element as a dict (full path file => size)
1452 xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
1454 return simcall_BODY_storage_get_content(storage);
1461 void *simcall_mc_snapshot(void) {
1462 return simcall_BODY_mc_snapshot();
1465 int simcall_mc_compare_snapshots(void *s1, void *s2) {
1466 return simcall_BODY_mc_compare_snapshots(s1, s2);
1469 #endif /* HAVE_MC */
1471 int simcall_mc_random(int min, int max) {
1472 return simcall_BODY_mc_random(min, max);
1475 /* ************************************************************************** */
1477 /** @brief returns a printable string representing a simcall */
1478 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1479 return simcall_names[kind];