From: Martin Quinson Date: Wed, 10 Jun 2015 15:49:17 +0000 (+0200) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3_12~624 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a59a47d79fe092f559a4a03de102402d7085bca9?hp=c0ae635db715a7d6f260872689f27a75e0ce4b98 Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/.gitignore b/.gitignore index f0e286e3de..ccf5ab7293 100644 --- a/.gitignore +++ b/.gitignore @@ -140,9 +140,9 @@ examples/msg/cloud/multicore examples/msg/cloud/scale examples/msg/cloud/simple_vm examples/msg/cloud/two_tasks_vm -examples/msg/energy/pstate/pstate +examples/msg/energy/consumption/energy_consumption examples/msg/energy/onoff/onoff -examples/msg/energy/e2/e2 +examples/msg/energy/pstate/pstate examples/msg/energy/e3/e3 examples/msg/pastry/pastry examples/msg/semaphores/synchro diff --git a/ChangeLog b/ChangeLog index 565fe293c8..310c4af495 100644 --- a/ChangeLog +++ b/ChangeLog @@ -80,6 +80,8 @@ SimGrid (3.12) NOT RELEASED; urgency=low * Improvement of the Energy plugin. - Always update the consumption before returning that value - New property: watt_off to denote the disipation when the host is off + - New functions getWattMinAt and getWattMaxAt to retrieve the + dissipation of pstates that we are not currently at. XBT * New functions - Add a xbt_heap_update function, to avoid costly xbt_heap_remove+xbt_heap_insert use diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index a622fd1917..ec39e2a056 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -234,7 +234,7 @@ IF(NOT enable_memcheck) ADD_TESH_FACTORIES(msg-cloud-two-tasks-vm "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/two_tasks_vm.tesh) ADD_TESH_FACTORIES(msg-cloud-simple-vm "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/simple_vm.tesh) ADD_TESH_FACTORIES(msg-energy-pstates "thread;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/pstate/pstate.tesh) - ADD_TESH_FACTORIES(msg-energy-consumption "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e2/energy_consumption.tesh) + ADD_TESH_FACTORIES(msg-energy-consumption "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/consumption/energy_consumption.tesh) ADD_TESH_FACTORIES(msg-energy-onoff "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/onoff/onoff.tesh) ADD_TESH_FACTORIES(msg-energy-concurrent-tasks "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e3/concurrent_tasks.tesh) ADD_TESH_FACTORIES(msg-token-ring "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_BINARY_DIR}/examples/msg/token_ring ${CMAKE_HOME_DIRECTORY}/examples/msg/token_ring/token_ring.tesh) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 9cb9f740cf..289aadb395 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -1029,7 +1029,7 @@ set(EXAMPLES_CMAKEFILES_TXT examples/msg/chord/CMakeLists.txt examples/msg/cloud/CMakeLists.txt examples/msg/energy/pstate/CMakeLists.txt - examples/msg/energy/e2/CMakeLists.txt + examples/msg/energy/consumption/CMakeLists.txt examples/msg/energy/e3/CMakeLists.txt examples/msg/energy/onoff/CMakeLists.txt examples/msg/exception/CMakeLists.txt diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index 4848c99b16..673c354b4a 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -33,8 +33,8 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/bittorrent) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/chainsend) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/chord) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/cloud) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/consumption) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/pstate) -add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e2) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/e3) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/energy/onoff) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/exception) diff --git a/examples/msg/energy/e2/CMakeLists.txt b/examples/msg/energy/consumption/CMakeLists.txt similarity index 64% rename from examples/msg/energy/e2/CMakeLists.txt rename to examples/msg/energy/consumption/CMakeLists.txt index 28d2e97a9d..c3273d8f46 100644 --- a/examples/msg/energy/e2/CMakeLists.txt +++ b/examples/msg/energy/consumption/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.6) set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") -add_executable(e2 e2.c) +add_executable(energy_consumption energy_consumption.c) ### Add definitions for compile -target_link_libraries(e2 simgrid ) +target_link_libraries(energy_consumption simgrid) set(tesh_files ${tesh_files} @@ -15,13 +15,13 @@ set(tesh_files set(xml_files ${xml_files} - ${CMAKE_CURRENT_SOURCE_DIR}/deployment_e2.xml + ${CMAKE_CURRENT_SOURCE_DIR}/deployment_consumption.xml PARENT_SCOPE ) set(examples_src ${examples_src} - ${CMAKE_CURRENT_SOURCE_DIR}/e2.c + ${CMAKE_CURRENT_SOURCE_DIR}/energy_consumption.c PARENT_SCOPE ) diff --git a/examples/msg/energy/e2/deployment_e2.xml b/examples/msg/energy/consumption/deployment_consumption.xml similarity index 100% rename from examples/msg/energy/e2/deployment_e2.xml rename to examples/msg/energy/consumption/deployment_consumption.xml diff --git a/examples/msg/energy/e2/e2.c b/examples/msg/energy/consumption/energy_consumption.c similarity index 100% rename from examples/msg/energy/e2/e2.c rename to examples/msg/energy/consumption/energy_consumption.c diff --git a/examples/msg/energy/e2/energy_consumption.tesh b/examples/msg/energy/consumption/energy_consumption.tesh similarity index 88% rename from examples/msg/energy/e2/energy_consumption.tesh rename to examples/msg/energy/consumption/energy_consumption.tesh index 8f1e1ce57a..c5ff2fbb45 100644 --- a/examples/msg/energy/e2/energy_consumption.tesh +++ b/examples/msg/energy/consumption/energy_consumption.tesh @@ -3,7 +3,7 @@ p Testing the mechanism for computing host energy consumption ! output sort -$ $SG_TEST_EXENV energy/e2/e2$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml ${srcdir:=.}/energy/e2/deployment_e2.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV energy/consumption/energy_consumption$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml ${srcdir:=.}/energy/consumption/deployment_consumption.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:dvfs_test@MyHost1) Energetic profile: 95.0:200.0, 93.0:170.0, 90.0:150.0 > [ 0.000000] (1:dvfs_test@MyHost1) Initial peak speed=1E+08 flop/s; Energy dissipated =0E+00 J > [ 0.000000] (1:dvfs_test@MyHost1) Sleep for 10 seconds diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index 0f294624c3..de6861ee29 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -322,6 +322,9 @@ XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h); XBT_PUBLIC(xbt_swag_t) MSG_host_get_process_list(msg_host_t h); XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h); XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h); +XBT_PUBLIC(double) MSG_host_get_wattmin_at(msg_host_t host, int pstate); +XBT_PUBLIC(double) MSG_host_get_wattmax_at(msg_host_t host, int pstate); + XBT_PUBLIC(void) __MSG_host_priv_free(msg_host_priv_t priv); XBT_PUBLIC(void) __MSG_host_destroy(msg_host_t host); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 79bf716bb9..6eb6aaac91 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -322,6 +322,8 @@ XBT_PUBLIC(int) simcall_host_get_nb_pstates(smx_host_t host); XBT_PUBLIC(void) simcall_host_set_pstate(smx_host_t host, int pstate_index); XBT_PUBLIC(int) simcall_host_get_pstate(smx_host_t host); XBT_PUBLIC(double) simcall_host_get_consumed_energy(smx_host_t host); +XBT_PUBLIC(double) simcall_host_get_wattmin_at(smx_host_t host, int pstate); +XBT_PUBLIC(double) simcall_host_get_wattmax_at(smx_host_t host, int pstate); XBT_PUBLIC(smx_synchro_t) simcall_host_execute(const char *name, smx_host_t host, double flops_amount, diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 623eed164b..fd80b13813 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -622,6 +622,8 @@ XBT_PUBLIC(int) surf_workstation_get_nb_pstates(surf_resource_t host); XBT_PUBLIC(void) surf_workstation_set_pstate(surf_resource_t host, int pstate_index); XBT_PUBLIC(int) surf_workstation_get_pstate(surf_resource_t host); +XBT_PUBLIC(double) surf_workstation_get_wattmin_at(surf_resource_t resource, int pstate); +XBT_PUBLIC(double) surf_workstation_get_wattmax_at(surf_resource_t resource, int pstate); /** * @brief Get the consumed energy (in joules) of a workstation diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index f745ee81be..074ed17fd4 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -425,6 +425,26 @@ 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); } +/** \ingroup m_host_management + * \brief Returns the amount of watt dissipated at the given pstate when the host is idling + * + */ +double MSG_host_get_wattmin_at(msg_host_t host, int pstate){ + return simcall_host_get_wattmin_at(host, pstate); +} +/** \ingroup m_host_management + * \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100% + * + */ +double MSG_host_get_wattmax_at(msg_host_t host, int pstate){ + return simcall_host_get_wattmax_at(host, pstate); +} +/** \ingroup m_host_management + * \brief Set the parameters of a given host + * + * \param host a host + * \param params a prameter object + */ /** \ingroup m_host_management * \brief Return the list of mount point names on an host. diff --git a/src/simix/libsmx.c b/src/simix/libsmx.c index 36f75fd774..0e63140dea 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@ -224,6 +224,19 @@ 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); +} + /** diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index f520b3c78e..e16c91f01a 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -177,6 +177,44 @@ static inline void simcall_host_get_nb_pstates__set__result(smx_simcall_t simcal simcall->result.i = result; } +static inline smx_host_t simcall_host_get_wattmin_at__get__host(smx_simcall_t simcall) { + return (smx_host_t) simcall->args[0].dp; +} +static inline void simcall_host_get_wattmin_at__set__host(smx_simcall_t simcall, void* arg) { + simcall->args[0].dp = arg; +} +static inline int simcall_host_get_wattmin_at__get__pstate_index(smx_simcall_t simcall) { + return simcall->args[1].i; +} +static inline void simcall_host_get_wattmin_at__set__pstate_index(smx_simcall_t simcall, int arg) { + simcall->args[1].i = arg; +} +static inline double simcall_host_get_wattmin_at__get__result(smx_simcall_t simcall){ + return simcall->result.d; +} +static inline void simcall_host_get_wattmin_at__set__result(smx_simcall_t simcall, double result){ + simcall->result.d = result; +} + +static inline smx_host_t simcall_host_get_wattmax_at__get__host(smx_simcall_t simcall) { + return (smx_host_t) simcall->args[0].dp; +} +static inline void simcall_host_get_wattmax_at__set__host(smx_simcall_t simcall, void* arg) { + simcall->args[0].dp = arg; +} +static inline int simcall_host_get_wattmax_at__get__pstate_index(smx_simcall_t simcall) { + return simcall->args[1].i; +} +static inline void simcall_host_get_wattmax_at__set__pstate_index(smx_simcall_t simcall, int arg) { + simcall->args[1].i = arg; +} +static inline double simcall_host_get_wattmax_at__get__result(smx_simcall_t simcall){ + return simcall->result.d; +} +static inline void simcall_host_get_wattmax_at__set__result(smx_simcall_t simcall, double result){ + simcall->result.d = result; +} + static inline smx_host_t simcall_host_set_pstate__get__host(smx_simcall_t simcall) { return (smx_host_t) simcall->args[0].dp; } diff --git a/src/simix/popping_bodies.c b/src/simix/popping_bodies.c index 0f233fe3d1..6f0afeeda4 100644 --- a/src/simix/popping_bodies.c +++ b/src/simix/popping_bodies.c @@ -291,6 +291,50 @@ inline static int simcall_BODY_host_get_nb_pstates(smx_host_t host) { return self->simcall.result.i; } +inline static double simcall_BODY_host_get_wattmin_at(smx_host_t host, int pstate_index) { + 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_wattmin_at(host, pstate_index); + /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ + + self->simcall.call = SIMCALL_HOST_GET_WATTMIN_AT; + 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; + self->simcall.args[1].i = (int) pstate_index; + 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 double simcall_BODY_host_get_wattmax_at(smx_host_t host, int pstate_index) { + 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_wattmax_at(host, pstate_index); + /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ + + self->simcall.call = SIMCALL_HOST_GET_WATTMAX_AT; + 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; + self->simcall.args[1].i = (int) pstate_index; + 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 void simcall_BODY_host_set_pstate(smx_host_t host, int pstate_index) { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index e662c5e44c..a025c25550 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -31,6 +31,8 @@ typedef enum { SIMCALL_HOST_GET_CURRENT_POWER_PEAK, SIMCALL_HOST_GET_POWER_PEAK_AT, SIMCALL_HOST_GET_NB_PSTATES, + SIMCALL_HOST_GET_WATTMIN_AT, + SIMCALL_HOST_GET_WATTMAX_AT, SIMCALL_HOST_SET_PSTATE, SIMCALL_HOST_GET_PSTATE, SIMCALL_HOST_GET_CONSUMED_ENERGY, diff --git a/src/simix/popping_generated.c b/src/simix/popping_generated.c index ba0638a849..d7eb3668c1 100644 --- a/src/simix/popping_generated.c +++ b/src/simix/popping_generated.c @@ -35,6 +35,8 @@ const char* simcall_names[] = { [SIMCALL_HOST_GET_CURRENT_POWER_PEAK] = "SIMCALL_HOST_GET_CURRENT_POWER_PEAK", [SIMCALL_HOST_GET_POWER_PEAK_AT] = "SIMCALL_HOST_GET_POWER_PEAK_AT", [SIMCALL_HOST_GET_NB_PSTATES] = "SIMCALL_HOST_GET_NB_PSTATES", + [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", @@ -231,6 +233,16 @@ case SIMCALL_HOST_GET_NB_PSTATES: SIMIX_simcall_answer(simcall); break; +case SIMCALL_HOST_GET_WATTMIN_AT: + simcall->result.d = SIMIX_host_get_wattmin_at((smx_host_t) simcall->args[0].dp, simcall->args[1].i); + SIMIX_simcall_answer(simcall); + break; + +case SIMCALL_HOST_GET_WATTMAX_AT: + simcall->result.d = SIMIX_host_get_wattmax_at((smx_host_t) simcall->args[0].dp, simcall->args[1].i); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_HOST_SET_PSTATE: SIMIX_host_set_pstate((smx_host_t) simcall->args[0].dp, simcall->args[1].i); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 09ed723a8c..44465ba4e2 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -59,6 +59,8 @@ Func - host_get_state (int) (host, void*, smx_host_t) Func - host_get_current_power_peak (double) (host, void*, smx_host_t) Func - host_get_power_peak_at (double) (host, void*, smx_host_t) (pstate_index, int) Func - host_get_nb_pstates (int) (host, void*, smx_host_t) +Func - host_get_wattmin_at (double) (host, void*, smx_host_t) (pstate_index, int) +Func - host_get_wattmax_at (double) (host, void*, smx_host_t) (pstate_index, int) Proc - host_set_pstate (void) (host, void*, smx_host_t) (pstate_index, int) Func - host_get_pstate (int) (host, void*, smx_host_t) Func - host_get_consumed_energy (double) (host, void*, smx_host_t) diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index ad2874c53f..c11c7046ba 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -245,6 +245,12 @@ double SIMIX_host_get_consumed_energy(smx_host_t host) { xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)"); return surf_workstation_get_consumed_energy(host); } +double SIMIX_host_get_wattmin_at(smx_host_t host,int pstate) { + return surf_workstation_get_wattmin_at(host,pstate); +} +double SIMIX_host_get_wattmax_at(smx_host_t host,int pstate) { + return surf_workstation_get_wattmax_at(host,pstate); +} int SIMIX_host_get_state(smx_host_t host){ xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)"); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 63a2f81ccf..ecd0d25cc8 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -51,6 +51,8 @@ double SIMIX_host_get_current_power_peak(smx_host_t host); double SIMIX_host_get_power_peak_at(smx_host_t host, int pstate_index); int SIMIX_host_get_nb_pstates(smx_host_t host); double SIMIX_host_get_consumed_energy(smx_host_t host); +double SIMIX_host_get_wattmin_at(smx_host_t host,int pstate); +double SIMIX_host_get_wattmax_at(smx_host_t host,int pstate); void SIMIX_host_set_pstate(smx_host_t host, int pstate_index); int SIMIX_host_get_pstate(smx_host_t host); smx_synchro_t SIMIX_host_execute(const char *name, diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 702372318a..627ad9b0ae 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -168,6 +168,22 @@ CpuEnergy::~CpuEnergy(){ xbt_dynar_free(&power_range_watts_list); } + +double CpuEnergy::getWattMinAt(int pstate) { + xbt_dynar_t power_range_list = power_range_watts_list; + xbt_assert(power_range_watts_list, "No power range properties specified for host %s", cpu->getName()); + xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); + double min_power = xbt_dynar_get_as(current_power_values, 0, double); + return min_power; +} +double CpuEnergy::getWattMaxAt(int pstate) { + xbt_dynar_t power_range_list = power_range_watts_list; + xbt_assert(power_range_watts_list, "No power range properties specified for host %s", cpu->getName()); + xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); + double max_power = xbt_dynar_get_as(current_power_values, 1, double); + return max_power; +} + /** * Computes the power consumed by the host according to the current pstate and processor load * @@ -175,15 +191,7 @@ CpuEnergy::~CpuEnergy(){ double CpuEnergy::getCurrentWattsValue(double cpu_load) { xbt_dynar_t power_range_list = power_range_watts_list; - - if (power_range_list == NULL) - { - XBT_DEBUG("No power range properties specified for host %s", cpu->getName()); - return 0; - } - /*xbt_assert(xbt_dynar_length(power_range_list) == xbt_dynar_length(cpu->p_powerPeakList), - "The number of power ranges in the properties does not match the number of pstates for host %s", - cpu->getName());*/ + xbt_assert(power_range_watts_list, "No power range properties specified for host %s", cpu->getName()); /* retrieve the power values associated with the current pstate */ xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 682ae46d83..9b776be2a4 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -22,6 +22,8 @@ public: double getCurrentWattsValue(double cpu_load); double getConsumedEnergy(); + double getWattMinAt(int pstate); + double getWattMaxAt(int pstate); xbt_dynar_t getWattsRangeList(); xbt_dynar_t power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 2d7b613530..5ab27f216f 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -362,9 +362,19 @@ void surf_workstation_set_pstate(surf_resource_t resource, int pstate_index){ int surf_workstation_get_pstate(surf_resource_t resource){ return get_casted_workstation(resource)->getPstate(); } +double surf_workstation_get_wattmin_at(surf_resource_t resource, int pstate){ + xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization."); + std::map::iterator cpuIt = surf_energy->find(get_casted_workstation(resource)->p_cpu); + return cpuIt->second->getWattMinAt(pstate); +} +double surf_workstation_get_wattmax_at(surf_resource_t resource, int pstate){ + xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization."); + std::map::iterator cpuIt = surf_energy->find(get_casted_workstation(resource)->p_cpu); + return cpuIt->second->getWattMaxAt(pstate); +} double surf_workstation_get_consumed_energy(surf_resource_t resource){ - xbt_assert(surf_energy!=NULL, "The Energy plugin is not active."); + xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization."); std::map::iterator cpuIt = surf_energy->find(get_casted_workstation(resource)->p_cpu); return cpuIt->second->getConsumedEnergy(); }