X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1d8f0c4dd4000a44d53f4ba97bd2a657deb18213..8734addee4efb8501991834fb99c2da15e9f8482:/src/simix/libsmx.c diff --git a/src/simix/libsmx.c b/src/simix/libsmx.c index 07bf397190..0e63140dea 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@ -10,10 +10,12 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "mc/mc_replay.h" #include "smx_private.h" -#include "mc/mc_interface.h" +#include "mc/mc_forward.h" #include "xbt/ex.h" #include /* isfinite() */ +#include "mc/mc.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); @@ -191,14 +193,24 @@ int simcall_host_get_nb_pstates(smx_host_t host) /** * \ingroup simix_host_management - * \brief Sets a new power peak for a host. + * \brief Sets the pstate at which the host should run * * \param host A SIMIX host * \param pstate_index The pstate to which the CPU power will be set */ -void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index) +void simcall_host_set_pstate(smx_host_t host, int pstate_index) { - simcall_BODY_host_set_power_peak_at(host, pstate_index); + simcall_BODY_host_set_pstate(host, pstate_index); +} +/** + * \ingroup simix_host_management + * \brief Gets the pstate at which that host currently runs. + * + * \param host A SIMIX host + */ +int simcall_host_get_pstate(smx_host_t host) +{ + return simcall_BODY_host_get_pstate(host); } /** @@ -212,64 +224,77 @@ double simcall_host_get_consumed_energy(smx_host_t host) { return simcall_BODY_host_get_consumed_energy(host); } +/** \ingroup simix_host_management + * \brief Returns the amount of watt dissipated at the given pstate when the host is idling + */ +double simcall_host_get_wattmin_at(msg_host_t host, int pstate){ + return simcall_BODY_host_get_wattmin_at(host, pstate); +} +/** \ingroup simix_host_management + * \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100% + */ +double simcall_host_get_wattmax_at(msg_host_t host, int pstate){ + return simcall_BODY_host_get_wattmax_at(host, pstate); +} + /** * \ingroup simix_host_management - * \brief Creates an action that executes some computation of an host. + * \brief Creates a synchro that executes some computation of an host. * * This function creates a SURF action and allocates the data necessary - * to create the SIMIX action. It can raise a host_error exception if the host crashed. + * to create the SIMIX synchro. It can raise a host_error exception if the host crashed. * - * \param name Name of the execution action to create - * \param host SIMIX host where the action will be executed - * \param computation_amount amount Computation amount (in bytes) + * \param name Name of the execution synchro to create + * \param host SIMIX host where the synchro will be executed + * \param flops_amount amount Computation amount (in flops) * \param priority computation priority * \param bound * \param affinity_mask - * \return A new SIMIX execution action + * \return A new SIMIX execution synchronization */ -smx_action_t simcall_host_execute(const char *name, smx_host_t host, - double computation_amount, +smx_synchro_t simcall_host_execute(const char *name, smx_host_t host, + double flops_amount, double priority, double bound, unsigned long affinity_mask) { /* checking for infinite values */ - xbt_assert(isfinite(computation_amount), "computation_amount is not finite!"); + xbt_assert(isfinite(flops_amount), "flops_amount is not finite!"); xbt_assert(isfinite(priority), "priority is not finite!"); - return simcall_BODY_host_execute(name, host, computation_amount, priority, bound, affinity_mask); + return simcall_BODY_host_execute(name, host, flops_amount, priority, bound, affinity_mask); } /** * \ingroup simix_host_management - * \brief Creates an action that may involve parallel computation on + * \brief Creates a synchro that may involve parallel computation on * several hosts and communication between them. * - * \param name Name of the execution action to create - * \param host_nb Number of hosts where the action will be executed - * \param host_list Array (of size host_nb) of hosts where the action will be executed - * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes) - * \param communication_amount Array (of size host_nb * host_nb) representing the communication + * \param name Name of the execution synchro to create + * \param host_nb Number of hosts where the synchro will be executed + * \param host_list Array (of size host_nb) of hosts where the synchro will be executed + * \param flops_amount Array (of size host_nb) of computation amount of hosts (in bytes) + * \param bytes_amount Array (of size host_nb * host_nb) representing the communication * amount between each pair of hosts * \param amount the SURF action amount * \param rate the SURF action rate - * \return A new SIMIX execution action + * \return A new SIMIX execution synchronization */ -smx_action_t simcall_host_parallel_execute(const char *name, +smx_synchro_t simcall_host_parallel_execute(const char *name, int host_nb, smx_host_t *host_list, - double *computation_amount, - double *communication_amount, + double *flops_amount, + double *bytes_amount, double amount, double rate) { int i,j; /* checking for infinite values */ for (i = 0 ; i < host_nb ; ++i) { - xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i); + xbt_assert(isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i); for (j = 0 ; j < host_nb ; ++j) { - xbt_assert(isfinite(communication_amount[i + host_nb * j]), - "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j); + xbt_assert(isfinite(bytes_amount[i + host_nb * j]), + "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j); } } @@ -277,69 +302,69 @@ smx_action_t simcall_host_parallel_execute(const char *name, xbt_assert(isfinite(rate), "rate is not finite!"); return simcall_BODY_host_parallel_execute(name, host_nb, host_list, - computation_amount, - communication_amount, + flops_amount, + bytes_amount, amount, rate); } /** * \ingroup simix_host_management - * \brief Destroys an execution action. + * \brief Destroys an execution synchro. * - * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it. - * \param execution The execution action to destroy + * Destroys a synchro, freeing its memory. This function cannot be called if there are a conditional waiting for it. + * \param execution The execution synchro to destroy */ -void simcall_host_execution_destroy(smx_action_t execution) +void simcall_host_execution_destroy(smx_synchro_t execution) { simcall_BODY_host_execution_destroy(execution); } /** * \ingroup simix_host_management - * \brief Cancels an execution action. + * \brief Cancels an execution synchro. * * This functions stops the execution. It calls a surf function. - * \param execution The execution action to cancel + * \param execution The execution synchro to cancel */ -void simcall_host_execution_cancel(smx_action_t execution) +void simcall_host_execution_cancel(smx_synchro_t execution) { simcall_BODY_host_execution_cancel(execution); } /** * \ingroup simix_host_management - * \brief Returns how much of an execution action remains to be done. + * \brief Returns how much of an execution synchro remains to be done. * - * \param execution The execution action + * \param execution The execution synchro * \return The remaining amount */ -double simcall_host_execution_get_remains(smx_action_t execution) +double simcall_host_execution_get_remains(smx_synchro_t execution) { return simcall_BODY_host_execution_get_remains(execution); } /** * \ingroup simix_host_management - * \brief Returns the state of an execution action. + * \brief Returns the state of an execution synchro. * - * \param execution The execution action + * \param execution The execution synchro * \return The state */ -e_smx_state_t simcall_host_execution_get_state(smx_action_t execution) +e_smx_state_t simcall_host_execution_get_state(smx_synchro_t execution) { return simcall_BODY_host_execution_get_state(execution); } /** * \ingroup simix_host_management - * \brief Changes the priority of an execution action. + * \brief Changes the priority of an execution synchro. * * This functions changes the priority only. It calls a surf function. - * \param execution The execution action + * \param execution The execution synchro * \param priority The new priority */ -void simcall_host_execution_set_priority(smx_action_t execution, double priority) +void simcall_host_execution_set_priority(smx_synchro_t execution, double priority) { /* checking for infinite values */ xbt_assert(isfinite(priority), "priority is not finite!"); @@ -349,38 +374,38 @@ void simcall_host_execution_set_priority(smx_action_t execution, double priority /** * \ingroup simix_host_management - * \brief Changes the capping (the maximum CPU utilization) of an execution action. + * \brief Changes the capping (the maximum CPU utilization) of an execution synchro. * * This functions changes the capping only. It calls a surf function. - * \param execution The execution action + * \param execution The execution synchro * \param bound The new bound */ -void simcall_host_execution_set_bound(smx_action_t execution, double bound) +void simcall_host_execution_set_bound(smx_synchro_t execution, double bound) { simcall_BODY_host_execution_set_bound(execution, bound); } /** * \ingroup simix_host_management - * \brief Changes the CPU affinity of an execution action. + * \brief Changes the CPU affinity of an execution synchro. * - * This functions changes the CPU affinity of an execution action. See taskset(1) on Linux. - * \param execution The execution action + * This functions changes the CPU affinity of an execution synchro. See taskset(1) on Linux. + * \param execution The execution synchro * \param host Host * \param mask Affinity mask */ -void simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask) +void simcall_host_execution_set_affinity(smx_synchro_t execution, smx_host_t host, unsigned long mask) { simcall_BODY_host_execution_set_affinity(execution, host, mask); } /** * \ingroup simix_host_management - * \brief Waits for the completion of an execution action and destroy it. + * \brief Waits for the completion of an execution synchro and destroy it. * - * \param execution The execution action + * \param execution The execution synchro */ -e_smx_state_t simcall_host_execution_wait(smx_action_t execution) +e_smx_state_t simcall_host_execution_wait(smx_synchro_t execution) { return simcall_BODY_host_execution_wait(execution); } @@ -532,6 +557,24 @@ void simcall_vm_destroy(smx_host_t vm) simcall_BODY_vm_destroy(vm); } +/** + * \ingroup simix_vm_management + * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration + * The simcall actually invokes the following calls: + * simcall_vm_set_affinity(vm, src_pm, 0); + * simcall_vm_migrate(vm, dst_pm); + * simcall_vm_resume(vm); + * + * It is called at the end of the migration_rx_fun function from msg/msg_vm.c + * + * \param vm VM to migrate + * \param src_pm Source physical host + * \param dst_pmt Destination physical host + */ +void simcall_vm_migratefrom_resumeto(smx_host_t vm, smx_host_t src_pm, smx_host_t dst_pm) +{ + simcall_BODY_vm_migratefrom_resumeto(vm, src_pm, dst_pm); +} /** * \ingroup simix_process_management @@ -620,7 +663,7 @@ void simcall_process_join(smx_process_t process, double timeout) * \ingroup simix_process_management * \brief Suspends a process. * - * This function suspends the process by suspending the action + * This function suspends the process by suspending the synchro * it was waiting for completion. * * \param process a SIMIX process @@ -636,7 +679,7 @@ void simcall_process_suspend(smx_process_t process) * \ingroup simix_process_management * \brief Resumes a suspended process. * - * This function resumes a suspended process by resuming the action + * This function resumes a suspended process by resuming the synchro * it was waiting for completion. * * \param process a SIMIX process @@ -737,7 +780,7 @@ void simcall_process_set_kill_time(smx_process_t process, double kill_time) if (simix_global->kill_process_function) { XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name, sg_host_name(process->smx_host)); - SIMIX_timer_set(kill_time, simix_global->kill_process_function, process); + process->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, process); } } } @@ -826,11 +869,11 @@ XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process) } /** * \ingroup simix_process_management - * \brief Creates a new sleep SIMIX action. + * \brief Creates a new sleep SIMIX synchro. * * This function creates a SURF action and allocates the data necessary - * to create the SIMIX action. It can raise a host_error exception if the - * host crashed. The default SIMIX name of the action is "sleep". + * to create the SIMIX synchro. It can raise a host_error exception if the + * host crashed. The default SIMIX name of the synchro is "sleep". * * \param duration Time duration of the sleep. * \return A result telling whether the sleep was successful @@ -880,11 +923,11 @@ smx_rdv_t simcall_rdv_get_by_name(const char *name) /** * \ingroup simix_rdv_management - * \brief Counts the number of communication actions of a given host pending + * \brief Counts the number of communication synchros of a given host pending * on a rendez-vous point. * \param rdv The rendez-vous point * \param host The host to be counted - * \return The number of comm actions pending in the rdv + * \return The number of comm synchros pending in the rdv */ int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host) { @@ -897,7 +940,7 @@ int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host) * \param rdv The rendez-vous point * \return The communication or NULL if empty */ -smx_action_t simcall_rdv_get_head(smx_rdv_t rdv) +smx_synchro_t simcall_rdv_get_head(smx_rdv_t rdv) { return simcall_BODY_rdv_get_head(rdv); } @@ -917,8 +960,8 @@ smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv) */ void simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *, smx_action_t), - void (*copy_data_fun)(smx_action_t, void*, size_t), void *data, + int (*match_fun)(void *, void *, smx_synchro_t), + void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, double timeout) { /* checking for infinite values */ @@ -928,9 +971,9 @@ void simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size, doubl xbt_assert(rdv, "No rendez-vous point defined for send"); - if (MC_is_active()) { + if (MC_is_active() || MC_record_replay_is_active()) { /* the model-checker wants two separate simcalls */ - smx_action_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */ + smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */ comm = simcall_comm_isend(src, rdv, task_size, rate, src_buff, src_buff_size, match_fun, NULL, copy_data_fun, data, 0); simcall_comm_wait(comm, timeout); @@ -945,11 +988,11 @@ void simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size, doubl /** * \ingroup simix_comm_management */ -smx_action_t simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, double task_size, double rate, +smx_synchro_t simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *, smx_action_t), + int (*match_fun)(void *, void *, smx_synchro_t), void (*clean_fun)(void *), - void (*copy_data_fun)(smx_action_t, void*, size_t), + void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, int detached) { @@ -968,16 +1011,16 @@ smx_action_t simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, double task_si * \ingroup simix_comm_management */ void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, - int (*match_fun)(void *, void *, smx_action_t), - void (*copy_data_fun)(smx_action_t, void*, size_t), + int (*match_fun)(void *, void *, smx_synchro_t), + void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, double timeout, double rate) { xbt_assert(isfinite(timeout), "timeout is not finite!"); xbt_assert(rdv, "No rendez-vous point defined for recv"); - if (MC_is_active()) { + if (MC_is_active() || MC_record_replay_is_active()) { /* the model-checker wants two separate simcalls */ - smx_action_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */ + smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */ comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); simcall_comm_wait(comm, timeout); @@ -991,9 +1034,9 @@ void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size, /** * \ingroup simix_comm_management */ -smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size, - int (*match_fun)(void *, void *, smx_action_t), - void (*copy_data_fun)(smx_action_t, void*, size_t), +smx_synchro_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size, + int (*match_fun)(void *, void *, smx_synchro_t), + void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, double rate) { xbt_assert(rdv, "No rendez-vous point defined for irecv"); @@ -1005,8 +1048,8 @@ smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_ /** * \ingroup simix_comm_management */ -smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int type, int src, int tag, - int (*match_fun)(void *, void *, smx_action_t), void *data) +smx_synchro_t simcall_comm_iprobe(smx_rdv_t rdv, int type, int src, int tag, + int (*match_fun)(void *, void *, smx_synchro_t), void *data) { xbt_assert(rdv, "No rendez-vous point defined for iprobe"); @@ -1016,7 +1059,7 @@ smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int type, int src, int tag, /** * \ingroup simix_comm_management */ -void simcall_comm_cancel(smx_action_t comm) +void simcall_comm_cancel(smx_synchro_t comm) { simcall_BODY_comm_cancel(comm); } @@ -1042,34 +1085,32 @@ int simcall_comm_testany(xbt_dynar_t comms) /** * \ingroup simix_comm_management */ -void simcall_comm_wait(smx_action_t comm, double timeout) +void simcall_comm_wait(smx_synchro_t comm, double timeout) { xbt_assert(isfinite(timeout), "timeout is not finite!"); simcall_BODY_comm_wait(comm, timeout); } -#ifdef HAVE_TRACING /** - * \brief Set the category of an action. + * \brief Set the category of an synchro. * * This functions changes the category only. It calls a surf function. - * \param execution The execution action + * \param execution The execution synchro * \param category The tracing category */ -void simcall_set_category(smx_action_t action, const char *category) +void simcall_set_category(smx_synchro_t synchro, const char *category) { if (category == NULL) { return; } - simcall_BODY_set_category(action, category); + simcall_BODY_set_category(synchro, category); } -#endif /** * \ingroup simix_comm_management * */ -int simcall_comm_test(smx_action_t comm) +int simcall_comm_test(smx_synchro_t comm) { return simcall_BODY_comm_test(comm); } @@ -1078,7 +1119,7 @@ int simcall_comm_test(smx_action_t comm) * \ingroup simix_comm_management * */ -double simcall_comm_get_remains(smx_action_t comm) +double simcall_comm_get_remains(smx_synchro_t comm) { return simcall_BODY_comm_get_remains(comm); } @@ -1087,7 +1128,7 @@ double simcall_comm_get_remains(smx_action_t comm) * \ingroup simix_comm_management * */ -e_smx_state_t simcall_comm_get_state(smx_action_t comm) +e_smx_state_t simcall_comm_get_state(smx_synchro_t comm) { return simcall_BODY_comm_get_state(comm); } @@ -1096,7 +1137,7 @@ e_smx_state_t simcall_comm_get_state(smx_action_t comm) * \ingroup simix_comm_management * */ -void *simcall_comm_get_src_data(smx_action_t comm) +void *simcall_comm_get_src_data(smx_synchro_t comm) { return simcall_BODY_comm_get_src_data(comm); } @@ -1105,7 +1146,7 @@ void *simcall_comm_get_src_data(smx_action_t comm) * \ingroup simix_comm_management * */ -void *simcall_comm_get_dst_data(smx_action_t comm) +void *simcall_comm_get_dst_data(smx_synchro_t comm) { return simcall_BODY_comm_get_dst_data(comm); } @@ -1114,7 +1155,7 @@ void *simcall_comm_get_dst_data(smx_action_t comm) * \ingroup simix_comm_management * */ -smx_process_t simcall_comm_get_src_proc(smx_action_t comm) +smx_process_t simcall_comm_get_src_proc(smx_synchro_t comm) { return simcall_BODY_comm_get_src_proc(comm); } @@ -1123,13 +1164,13 @@ smx_process_t simcall_comm_get_src_proc(smx_action_t comm) * \ingroup simix_comm_management * */ -smx_process_t simcall_comm_get_dst_proc(smx_action_t comm) +smx_process_t simcall_comm_get_dst_proc(smx_synchro_t comm) { return simcall_BODY_comm_get_dst_proc(comm); } #ifdef HAVE_LATENCY_BOUND_TRACKING -int simcall_comm_is_latency_bounded(smx_action_t comm) +int simcall_comm_is_latency_bounded(smx_synchro_t comm) { return simcall_BODY_comm_is_latency_bounded(comm); } @@ -1471,12 +1512,12 @@ int simcall_mc_compare_snapshots(void *s1, void *s2) { return simcall_BODY_mc_compare_snapshots(s1, s2); } +#endif /* HAVE_MC */ + int simcall_mc_random(int min, int max) { return simcall_BODY_mc_random(min, max); } -#endif /* HAVE_MC */ - /* ************************************************************************** */ /** @brief returns a printable string representing a simcall */