From: Martin Quinson Date: Mon, 2 Nov 2015 17:54:52 +0000 (+0100) Subject: inline two more simcalls: host_get_pstate and host_get_consumed_energy X-Git-Tag: v3_13~1603 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1ee944880f9f0d58499e4eaf2ee486d77a6bb0ae?ds=sidebyside inline two more simcalls: host_get_pstate and host_get_consumed_energy --- diff --git a/include/simgrid/host.h b/include/simgrid/host.h index 46a7f53c67..f3fa3a661b 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -67,6 +67,9 @@ XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host); XBT_PUBLIC(int) sg_host_get_core(sg_host_t host); XBT_PUBLIC(int) sg_host_get_state(sg_host_t host); +XBT_PUBLIC(int) sg_host_get_pstate(sg_host_t host); +XBT_PUBLIC(double) sg_host_get_consumed_energy(sg_host_t host); + SG_END_DECL() diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index e05a1565c9..00ff99a6bc 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -309,8 +309,6 @@ XBT_PUBLIC(double) simcall_host_get_current_power_peak(sg_host_t host); XBT_PUBLIC(double) simcall_host_get_power_peak_at(sg_host_t host, int pstate_index); XBT_PUBLIC(int) simcall_host_get_nb_pstates(sg_host_t host); XBT_PUBLIC(void) simcall_host_set_pstate(sg_host_t host, int pstate_index); -XBT_PUBLIC(int) simcall_host_get_pstate(sg_host_t host); -XBT_PUBLIC(double) simcall_host_get_consumed_energy(sg_host_t host); XBT_PUBLIC(double) simcall_host_get_wattmin_at(sg_host_t host, int pstate); XBT_PUBLIC(double) simcall_host_get_wattmax_at(sg_host_t host, int pstate); diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index bd937c8d6e..0cbac256a7 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -405,7 +405,7 @@ void MSG_host_set_pstate(msg_host_t host, int pstate_index) { * \param host host to test */ int MSG_host_get_pstate(msg_host_t host) { - return simcall_host_get_pstate(host); + return sg_host_get_pstate(host); } /** \ingroup m_host_management @@ -416,7 +416,7 @@ int MSG_host_get_pstate(msg_host_t host) { */ double MSG_host_get_consumed_energy(msg_host_t host) { xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); - return simcall_host_get_consumed_energy(host); + return sg_host_get_consumed_energy(host); } /** \ingroup m_host_management * \brief Returns the amount of watt dissipated at the given pstate when the host is idling diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 14ef0cd773..76695e1661 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -139,5 +139,15 @@ int sg_host_get_core(sg_host_t host) { * @return 1 if the host is active or 0 if it has crashed. */ int sg_host_get_state(sg_host_t host) { - return surf_host_get_state(surf_host_resource_priv(host)); + return surf_host_get_state(surf_host_resource_priv(host)); +} + +/** @brief Returns the total energy consumed by the host (in Joules) */ +double sg_host_get_consumed_energy(sg_host_t host) { + return surf_host_get_consumed_energy(host); +} + +/** @brief Gets the pstate at which that host currently runs */ +int sg_host_get_pstate(sg_host_t host) { + return surf_host_get_pstate(host); } diff --git a/src/simix/libsmx.c b/src/simix/libsmx.c index ae76c1ea56..44efe35991 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@ -128,28 +128,7 @@ void simcall_host_set_pstate(sg_host_t host, int 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(sg_host_t host) -{ - return simcall_BODY_host_get_pstate(host); -} -/** - * \ingroup simix_host_management - * \brief Returns the total energy consumed by the host (in Joules) - * - * \param host A SIMIX host - * \return the energy consumed by the host (double) - */ -double simcall_host_get_consumed_energy(sg_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 */ diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index e812ee3ce0..ae6c431c68 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -150,32 +150,6 @@ static inline void simcall_host_set_pstate__set__pstate_index(smx_simcall_t simc simcall->args[1].i = arg; } -static inline sg_host_t simcall_host_get_pstate__get__host(smx_simcall_t simcall) { - return (sg_host_t) simcall->args[0].dp; -} -static inline void simcall_host_get_pstate__set__host(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline int simcall_host_get_pstate__get__result(smx_simcall_t simcall){ - return simcall->result.i; -} -static inline void simcall_host_get_pstate__set__result(smx_simcall_t simcall, int result){ - simcall->result.i = result; -} - -static inline sg_host_t simcall_host_get_consumed_energy__get__host(smx_simcall_t simcall) { - return (sg_host_t) simcall->args[0].dp; -} -static inline void simcall_host_get_consumed_energy__set__host(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline double simcall_host_get_consumed_energy__get__result(smx_simcall_t simcall){ - return simcall->result.d; -} -static inline void simcall_host_get_consumed_energy__set__result(smx_simcall_t simcall, double result){ - simcall->result.d = result; -} - static inline sg_host_t simcall_host_get_mounted_storage_list__get__host(smx_simcall_t simcall) { return (sg_host_t) simcall->args[0].dp; } diff --git a/src/simix/popping_bodies.c b/src/simix/popping_bodies.c index a8b91c41da..779dbb0a76 100644 --- a/src/simix/popping_bodies.c +++ b/src/simix/popping_bodies.c @@ -231,48 +231,6 @@ inline static void simcall_BODY_host_set_pstate(sg_host_t host, int pstate_index } -inline static int simcall_BODY_host_get_pstate(sg_host_t host) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_host_get_pstate(host); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_HOST_GET_PSTATE; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) host; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return self->simcall.result.i; - } - -inline static double simcall_BODY_host_get_consumed_energy(sg_host_t host) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_host_get_consumed_energy(host); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_HOST_GET_CONSUMED_ENERGY; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) host; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return self->simcall.result.d; - } - inline static xbt_dict_t simcall_BODY_host_get_mounted_storage_list(sg_host_t host) { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index eba24c15e6..937605d866 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -28,8 +28,6 @@ typedef enum { SIMCALL_HOST_GET_WATTMIN_AT, SIMCALL_HOST_GET_WATTMAX_AT, SIMCALL_HOST_SET_PSTATE, - SIMCALL_HOST_GET_PSTATE, - SIMCALL_HOST_GET_CONSUMED_ENERGY, SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST, SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST, SIMCALL_HOST_GET_PARAMS, diff --git a/src/simix/popping_generated.c b/src/simix/popping_generated.c index b86f5e9812..0a8f7e6aaf 100644 --- a/src/simix/popping_generated.c +++ b/src/simix/popping_generated.c @@ -33,8 +33,6 @@ const char* simcall_names[] = { [SIMCALL_HOST_GET_WATTMIN_AT] = "SIMCALL_HOST_GET_WATTMIN_AT", [SIMCALL_HOST_GET_WATTMAX_AT] = "SIMCALL_HOST_GET_WATTMAX_AT", [SIMCALL_HOST_SET_PSTATE] = "SIMCALL_HOST_SET_PSTATE", - [SIMCALL_HOST_GET_PSTATE] = "SIMCALL_HOST_GET_PSTATE", - [SIMCALL_HOST_GET_CONSUMED_ENERGY] = "SIMCALL_HOST_GET_CONSUMED_ENERGY", [SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST] = "SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST", [SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST] = "SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST", [SIMCALL_HOST_GET_PARAMS] = "SIMCALL_HOST_GET_PARAMS", @@ -213,16 +211,6 @@ case SIMCALL_HOST_SET_PSTATE: SIMIX_simcall_answer(simcall); break; -case SIMCALL_HOST_GET_PSTATE: - simcall->result.i = SIMIX_host_get_pstate((sg_host_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_HOST_GET_CONSUMED_ENERGY: - simcall->result.d = SIMIX_host_get_consumed_energy((sg_host_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST: simcall->result.dp = SIMIX_host_get_mounted_storage_list((sg_host_t) simcall->args[0].dp); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 0149fbd641..8337d273f7 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -56,8 +56,6 @@ Func - host_get_nb_pstates (int) (host, void*, sg_host_t) Func - host_get_wattmin_at (double) (host, void*, sg_host_t) (pstate_index, int) Func - host_get_wattmax_at (double) (host, void*, sg_host_t) (pstate_index, int) Proc - host_set_pstate (void) (host, void*, sg_host_t) (pstate_index, int) -Func - host_get_pstate (int) (host, void*, sg_host_t) -Func - host_get_consumed_energy (double) (host, void*, sg_host_t) Func - host_get_mounted_storage_list (void*, xbt_dict_t) (host, void*, sg_host_t) Func - host_get_attached_storage_list (void*, xbt_dynar_t) (host, void*, sg_host_t) diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index a1bb7c5a86..1fb5227446 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -167,10 +167,6 @@ xbt_dict_t SIMIX_host_get_properties(sg_host_t host){ } -int SIMIX_host_get_core(sg_host_t host){ - return surf_host_get_core(host); -} - xbt_swag_t SIMIX_host_get_process_list(sg_host_t host){ smx_host_priv_t host_priv = sg_host_simix(host); @@ -194,13 +190,6 @@ int SIMIX_host_get_nb_pstates(sg_host_t host) { void SIMIX_host_set_pstate(sg_host_t host, int pstate_index) { surf_host_set_pstate(host, pstate_index); } -int SIMIX_host_get_pstate(sg_host_t host) { - return surf_host_get_pstate(host); -} - -double SIMIX_host_get_consumed_energy(sg_host_t host) { - return surf_host_get_consumed_energy(host); -} double SIMIX_host_get_wattmin_at(sg_host_t host,int pstate) { return surf_host_get_wattmin_at(host,pstate); } @@ -208,10 +197,6 @@ double SIMIX_host_get_wattmax_at(sg_host_t host,int pstate) { return surf_host_get_wattmax_at(host,pstate); } -int SIMIX_host_get_state(sg_host_t host){ - return surf_host_get_state(surf_host_resource_priv(host)); -} - void _SIMIX_host_free_process_arg(void *data) { smx_process_arg_t arg = *(void**)data; @@ -261,7 +246,7 @@ void SIMIX_host_add_auto_restart_process(sg_host_t host, arg->properties = properties; arg->auto_restart = auto_restart; - if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF + if( sg_host_get_state(host) == SURF_RESOURCE_OFF && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_name(host))){ xbt_dict_set(watched_hosts_lib,sg_host_name(host),host,NULL); XBT_DEBUG("Have pushed host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_name(host)); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 7ee41717ab..50c8a8e648 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -38,17 +38,13 @@ XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host, XBT_PRIVATE void SIMIX_host_restart_processes(sg_host_t host); XBT_PRIVATE void SIMIX_host_autorestart(sg_host_t host); XBT_PRIVATE xbt_dict_t SIMIX_host_get_properties(sg_host_t host); -XBT_PRIVATE int SIMIX_host_get_core(sg_host_t host); XBT_PRIVATE xbt_swag_t SIMIX_host_get_process_list(sg_host_t host); -XBT_PRIVATE int SIMIX_host_get_state(sg_host_t host); XBT_PRIVATE double SIMIX_host_get_current_power_peak(sg_host_t host); XBT_PRIVATE double SIMIX_host_get_power_peak_at(sg_host_t host, int pstate_index); XBT_PRIVATE int SIMIX_host_get_nb_pstates(sg_host_t host); -XBT_PRIVATE double SIMIX_host_get_consumed_energy(sg_host_t host); XBT_PRIVATE double SIMIX_host_get_wattmin_at(sg_host_t host,int pstate); XBT_PRIVATE double SIMIX_host_get_wattmax_at(sg_host_t host,int pstate); XBT_PRIVATE void SIMIX_host_set_pstate(sg_host_t host, int pstate_index); -XBT_PRIVATE int SIMIX_host_get_pstate(sg_host_t host); XBT_PRIVATE smx_synchro_t SIMIX_process_execute(smx_process_t issuer, const char *name, double flops_amount, double priority, double bound, unsigned long affinity_mask); XBT_PRIVATE smx_synchro_t SIMIX_process_parallel_execute(const char *name, diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 2fac9cf337..57d32af1a7 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -163,7 +163,7 @@ void SIMIX_process_stop(smx_process_t arg) { /* Add the process to the list of process to restart, only if * the host is down */ - if (arg->auto_restart && !SIMIX_host_get_state(arg->host)) { + if (arg->auto_restart && !sg_host_get_state(arg->host)) { SIMIX_host_add_auto_restart_process(arg->host,arg->name,arg->code, arg->data, sg_host_name(arg->host), SIMIX_timer_get_date(arg->kill_timer), @@ -236,7 +236,7 @@ smx_process_t SIMIX_process_create( XBT_DEBUG("Start process %s on host '%s'", name, hostname); - if (!SIMIX_host_get_state(host)) { + if (!sg_host_get_state(host)) { int i; XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname); diff --git a/src/smpi/smpi_dvfs.c b/src/smpi/smpi_dvfs.c index 04d2bcf502..3c16f526c2 100644 --- a/src/smpi/smpi_dvfs.c +++ b/src/smpi/smpi_dvfs.c @@ -55,9 +55,8 @@ void smpi_set_host_pstate(int pstate_index) * * \param pstate_index pstate to switch to */ -int smpi_get_host_pstate() -{ - return simcall_host_get_pstate(SIMIX_host_self()); +int smpi_get_host_pstate() { + return sg_host_get_pstate(SIMIX_host_self()); } /** @@ -65,9 +64,8 @@ int smpi_get_host_pstate() * * \return Returns the consumed energy */ -double smpi_get_host_consumed_energy(void) -{ - return simcall_host_get_consumed_energy(SIMIX_host_self()); +double smpi_get_host_consumed_energy(void) { + return sg_host_get_consumed_energy(SIMIX_host_self()); }