From: Frederic Suter Date: Thu, 17 Mar 2016 10:35:35 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_13~390 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/089f75c8f83b841c91e74cdfd4e925d027ff7769?hp=102eee116018d7c6e9f4b9301421b137272d84fb Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/examples/msg/parallel_task/CMakeLists.txt b/examples/msg/parallel_task/CMakeLists.txt index 257ddc3597..82379e01df 100644 --- a/examples/msg/parallel_task/CMakeLists.txt +++ b/examples/msg/parallel_task/CMakeLists.txt @@ -3,5 +3,8 @@ target_link_libraries(parallel_task simgrid) ADD_TESH_FACTORIES(msg-ptask "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_task/parallel_task.tesh) +ADD_TESH_FACTORIES(msg-ptask-energy "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/parallel_task/parallel_task_energy.tesh) + set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/parallel_task.tesh PARENT_SCOPE) +set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/parallel_task_energy.tesh PARENT_SCOPE) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/parallel_task.c PARENT_SCOPE) diff --git a/examples/msg/parallel_task/parallel_task.c b/examples/msg/parallel_task/parallel_task.c index 3308119ff1..46990fa126 100644 --- a/examples/msg/parallel_task/parallel_task.c +++ b/examples/msg/parallel_task/parallel_task.c @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/msg.h" +#include "simgrid/plugins/energy.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); @@ -70,7 +71,12 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); MSG_config("host/model", "ptask_L07"); - xbt_assert(argc > 1, "Usage: %s ", argv[0]); + xbt_assert(argc <= 3, "1Usage: %s [--energy]", argv[0]); + xbt_assert(argc >= 2, "2Usage: %s [--energy]", argv[0]); + + if(argc == 3 && argv[2][2] == 'e') + sg_energy_plugin_init(); + MSG_create_environment(argv[1]); /* Pick a process, no matter which, from the platform file */ diff --git a/examples/msg/parallel_task/parallel_task_energy.tesh b/examples/msg/parallel_task/parallel_task_energy.tesh new file mode 100644 index 0000000000..d0d2d913ee --- /dev/null +++ b/examples/msg/parallel_task/parallel_task_energy.tesh @@ -0,0 +1,12 @@ +#! ./tesh + +$ $SG_TEST_EXENV parallel_task/parallel_task$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml --energy "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (0:maestro@) Switching to the L07 model to handle parallel tasks. +> [ 0.000000] (1:test@MyHost1) First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair +> [300.000000] (1:test@MyHost1) Then, build a parallel task involving only computations and no communication (1 Gflop per node) +> [310.000000] (1:test@MyHost1) Finally, trick the ptask to do a 'remote execution', on host MyHost2 +> [320.000000] (1:test@MyHost1) Goodbye now! +> [320.000000] (0:maestro@) Simulation done. +> [320.000000] (0:maestro@) Total energy of host MyHost1: 34000.000000 Joules +> [320.000000] (0:maestro@) Total energy of host MyHost2: 35000.000000 Joules +> [320.000000] (0:maestro@) Total energy of host MyHost3: 34000.000000 Joules diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index 86a0c9825e..9840855a42 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -7,7 +7,8 @@ #ifndef SIMGRID_XBT_STRING_HPP #define SIMGRID_XBT_STRING_HPP -#include "src/internal_config.h" +#include + #if HAVE_MC #include diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index e084657416..ccdad63294 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -26,10 +26,15 @@ namespace surf { * Callbacks * *************/ -Cpu *getActionCpu(CpuAction *action) { - return static_cast(lmm_constraint_id(lmm_get_cnst_from_var - (action->getModel()->getMaxminSystem(), - action->getVariable(), 0))); +std::list getActionCpus(CpuAction *action) { + std::list retlist; + lmm_system_t sys = action->getModel()->getMaxminSystem(); + int llen = lmm_get_number_of_cnst_from_var(sys, action->getVariable()); + + for(int i = 0; igetVariable(), i) )) ); + } + return retlist; } simgrid::xbt::signal cpuActionStateChangedCallbacks; diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 5aa2b4bd4b..bb4ceecacf 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -25,7 +25,7 @@ class CpuPlugin; /************* * Callbacks * *************/ -XBT_PUBLIC(Cpu*) getActionCpu(CpuAction *action); +XBT_PUBLIC(std::list) getActionCpus(CpuAction *action); /********* * Model * diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index c972873381..c0aa3570ce 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -206,16 +206,22 @@ static void onCreation(simgrid::s4u::Host& host) { } static void onActionStateChange(simgrid::surf::CpuAction *action, e_surf_action_state_t previous) { - const char *name = getActionCpu(action)->getName(); - simgrid::surf::HostImpl *host = sg_host_by_name(name)->extension(); - simgrid::surf::VirtualMachine *vm = dynamic_cast(host); - if (vm) // If it's a VM, take the corresponding PM - host = vm->getPm()->extension(); - - HostEnergy *host_energy = host->p_host->extension(); - - if(host_energy->last_updated < surf_get_clock()) - host_energy->update(); + std::list cpus = getActionCpus(action); + for(simgrid::surf::Cpu* cpu : cpus) { + const char *name = cpu->getName(); + sg_host_t sghost = sg_host_by_name(name); + if(sghost == NULL) + continue; + simgrid::surf::HostImpl *host = sghost->extension(); + simgrid::surf::VirtualMachine *vm = dynamic_cast(host); + if (vm) // If it's a VM, take the corresponding PM + host = vm->getPm()->extension(); + + HostEnergy *host_energy = host->p_host->extension(); + + if(host_energy->last_updated < surf_get_clock()) + host_energy->update(); + } } static void onHostStateChange(simgrid::s4u::Host &host) {