Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 9 Jun 2015 15:07:54 +0000 (17:07 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 9 Jun 2015 15:07:54 +0000 (17:07 +0200)
35 files changed:
.gitignore
ChangeLog
buildtools/Cmake/AddTests.cmake
buildtools/Cmake/MakeExe.cmake
examples/msg/energy/onoff/CMakeLists.txt [new file with mode: 0644]
examples/msg/energy/onoff/deployment_onoff.xml [new file with mode: 0644]
examples/msg/energy/onoff/onoff.c [new file with mode: 0644]
examples/msg/energy/onoff/onoff.tesh [new file with mode: 0644]
examples/msg/energy/onoff/platform_onoff.xml [new file with mode: 0644]
include/simgrid/msg.h
include/simgrid/simix.h
include/smpi/smpi.h
src/bindings/java/org/simgrid/surf/Cpu.java
src/bindings/java/org/simgrid/surf/SurfJNI.java
src/bindings/java/surf.i
src/include/surf/surf.h
src/msg/msg_host.c
src/simix/libsmx.c
src/simix/popping_accessors.h
src/simix/popping_bodies.c
src/simix/popping_enum.h
src/simix/popping_generated.c
src/simix/simcalls.in
src/simix/smx_host.c
src/simix/smx_host_private.h
src/smpi/smpi_dvfs.c
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.hpp
src/surf/surf_c_bindings.cpp
src/surf/workstation_interface.cpp
src/surf/workstation_interface.hpp
src/surf/workstation_ptask_L07.cpp
src/surf/workstation_ptask_L07.hpp

index a3bc468..f39dd86 100644 (file)
@@ -139,6 +139,7 @@ examples/msg/cloud/scale
 examples/msg/cloud/simple_vm
 examples/msg/cloud/two_tasks_vm
 examples/msg/energy/pstate/pstate
+examples/msg/energy/onoff/onoff
 examples/msg/energy/e2/e2
 examples/msg/energy/e3/e3
 examples/msg/pastry/pastry
index 61dbb2d..565fe29 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@ SimGrid (3.12) NOT RELEASED; urgency=low
        get_data_size(t) -> get_bytes_amount(t)
    - Massive cleanups in the functions related to the energy
      - MSG_host_get_pstate_number() -> MSG_host_get_nb_pstates()
+   - New: MSG_host_get_pstate()
+ * New example:
+   - msg/energy/onoff: switching hosts on and off
  jMSG:
  * Interface improvement:
    - Rename Host.isAvail() to Host.isOn()
@@ -65,8 +68,9 @@ SimGrid (3.12) NOT RELEASED; urgency=low
    - [#17799] : have mpi_group_range_incl and mpi_group_range_excl better test some corner cases
    - Correctly use loopback on fat-tree clusters
    - Asynchronous small messages shouldn't trigger deadlocks anymore
- * Interface cleanup
-   - smpi_set_host_power_peak_at -> smpi_set_host_pstate
+ * Energy/DVFS cleanup and improvement
+   - smpi_set_host_power_peak_at() -> smpi_set_host_pstate()
+   - new: smpi_get_host_pstate()
  SURF
   * Bug fixes 
    - "Full" network optimization flag was broken since Surf++
index a44b366..a622fd1 100644 (file)
@@ -235,6 +235,7 @@ IF(NOT enable_memcheck)
   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-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)
   ADD_TESH_FACTORIES(msg-migration               "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/migration/migration.tesh)
index 926e241..4848c99 100644 (file)
@@ -36,6 +36,7 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/cloud)
 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)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gpu)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gtnets)
diff --git a/examples/msg/energy/onoff/CMakeLists.txt b/examples/msg/energy/onoff/CMakeLists.txt
new file mode 100644 (file)
index 0000000..06ca5a6
--- /dev/null
@@ -0,0 +1,31 @@
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(onoff onoff.c)
+
+### Add definitions for compile
+target_link_libraries(onoff simgrid )
+
+set(tesh_files
+  ${tesh_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/energy_consumption.tesh
+  PARENT_SCOPE
+  )
+
+set(xml_files
+  ${xml_files}
+  ${CMAKE_CURRENT_SOURCE_DIR}/deployment_onoff.xml
+  PARENT_SCOPE
+  )
+
+set(examples_src
+  ${examples_src}
+  ${CMAKE_CURRENT_SOURCE_DIR}/onoff.c
+  PARENT_SCOPE
+  )
+
+set(bin_files
+  ${bin_files}
+  PARENT_SCOPE
+  )
diff --git a/examples/msg/energy/onoff/deployment_onoff.xml b/examples/msg/energy/onoff/deployment_onoff.xml
new file mode 100644 (file)
index 0000000..b3e8d26
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+  <process host="MyHost2" function="onoff_test" />
+
+</platform>
diff --git a/examples/msg/energy/onoff/onoff.c b/examples/msg/energy/onoff/onoff.c
new file mode 100644 (file)
index 0000000..2a03378
--- /dev/null
@@ -0,0 +1,128 @@
+/* Copyright (c) 2007-2010, 2013-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* 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<stdio.h>
+
+#include "simgrid/msg.h"
+#include "xbt/sysdep.h"         /* calloc */
+#include "simgrid/plugins.h"
+
+/* Create a log channel to have nice outputs. */
+#include "xbt/log.h"
+#include "xbt/asserts.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+               "Messages specific for this msg example");
+
+static void simulate_bootup(msg_host_t host) {
+
+       int previous_pstate = MSG_host_get_pstate(host);
+
+       XBT_INFO("Switch to virtual pstate 3, that encodes the shutting down state in the XML file of that example");
+       MSG_host_set_pstate(host,3);
+
+       msg_host_t host_list[1] = {host};
+       double flops_amount[1] = {1};
+       double bytes_amount[1] = {0};
+
+       XBT_INFO("Actually start the host");
+       MSG_host_on(host);
+
+       XBT_INFO("Simulate the boot up by executing one flop on that host");
+       // We use a parallel task to run some task on a remote host.
+       msg_task_t bootup = MSG_parallel_task_create("boot up", 1, host_list, flops_amount, bytes_amount, NULL);
+       MSG_task_execute(bootup);
+       MSG_task_destroy(bootup);
+
+       XBT_INFO("Switch back to previously selected pstate %d", previous_pstate);
+       MSG_host_set_pstate(host, previous_pstate);
+}
+
+static void simulate_shutdown(msg_host_t host) {
+
+       int previous_pstate = MSG_host_get_pstate(host);
+
+       XBT_INFO("Switch to virtual pstate 4, that encodes the shutting down state in the XML file of that example");
+       MSG_host_set_pstate(host,4);
+
+       msg_host_t host_list[1] = {host};
+       double flops_amount[1] = {1};
+       double bytes_amount[1] = {0};
+
+       XBT_INFO("Simulate the shutdown by executing one flop on that remote host (using a parallel task)");
+       msg_task_t shutdown = MSG_parallel_task_create("shutdown", 1, host_list, flops_amount, bytes_amount, NULL);
+       MSG_task_execute(shutdown);
+       MSG_task_destroy(shutdown);
+
+       XBT_INFO("Switch back to previously selected pstate %d", previous_pstate);
+       MSG_host_set_pstate(host, previous_pstate);
+
+       XBT_INFO("Actually shutdown the host");
+       MSG_host_off(host);
+}
+
+static int onoff(int argc, char *argv[]) {
+       msg_host_t host1 = MSG_get_host_by_name("MyHost1");
+
+       XBT_INFO("Energetic profile: %s",
+                       MSG_host_get_property_value(host1,"watt_per_state"));
+       XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J",
+                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+
+       XBT_INFO("Sleep for 10 seconds");
+       MSG_process_sleep(10);
+       XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
+                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+
+       simulate_shutdown(host1);
+       XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
+                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+
+       XBT_INFO("Sleep for 10 seconds");
+       MSG_process_sleep(10);
+       XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J",
+                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+
+       simulate_bootup(host1);
+       XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
+                       MSG_host_get_current_power_peak(host1), MSG_host_get_consumed_energy(host1));
+
+
+       return 0;
+}
+
+int main(int argc, char *argv[])
+{
+       msg_error_t res = MSG_OK;
+       sg_energy_plugin_init();
+       MSG_init(&argc, argv);
+
+       if (argc != 3) {
+               XBT_CRITICAL("Usage: %s platform_file deployment_file\n",
+                               argv[0]);
+               XBT_CRITICAL
+               ("example: %s msg_platform.xml msg_deployment.xml\n",
+                               argv[0]);
+               exit(1);
+       }
+
+       MSG_create_environment(argv[1]);
+
+       /*   Application deployment */
+       MSG_function_register("onoff_test", onoff);
+
+       MSG_launch_application(argv[2]);
+
+       res = MSG_main();
+
+       XBT_INFO("Total simulation time: %.2f", MSG_get_clock());
+
+       if (res == MSG_OK)
+               return 0;
+       else
+               return 1;
+}
+
diff --git a/examples/msg/energy/onoff/onoff.tesh b/examples/msg/energy/onoff/onoff.tesh
new file mode 100644 (file)
index 0000000..ed6091c
--- /dev/null
@@ -0,0 +1,25 @@
+#! ./tesh
+
+p Testing the mechanism for computing host energy consumption
+
+! output sort
+$ $SG_TEST_EXENV energy/onoff/onoff$EXEEXT ${srcdir:=.}/energy/onoff/platform_onoff.xml ${srcdir:=.}/energy/onoff/deployment_onoff.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:onoff_test@MyHost2) Energetic profile: 95.0:200.0,93.0:170.0,90.0:150.0,       120:120,110:110
+> [  0.000000] (1:onoff_test@MyHost2) Initial peak speed=1E+08 flop/s; Energy dissipated =0E+00 J
+> [  0.000000] (1:onoff_test@MyHost2) Sleep for 10 seconds
+> [ 10.000000] (1:onoff_test@MyHost2) Done sleeping. Current peak speed=1E+08; Energy dissipated=950.00 J
+> [ 10.000000] (1:onoff_test@MyHost2) Switch to virtual pstate 4, that encodes the shutting down state in the XML file of that example
+> [ 10.000000] (1:onoff_test@MyHost2) Simulate the shutdown by executing one flop on that remote host (using a parallel task)
+> [ 16.997901] (1:onoff_test@MyHost2) Switch back to previously selected pstate 0
+> [ 16.997901] (1:onoff_test@MyHost2) Actually shutdown the host
+> [ 16.997901] (1:onoff_test@MyHost2) Host1 is now OFF. Current peak speed=1E+08 flop/s; Energy dissipated=1720 J
+> [ 16.997901] (1:onoff_test@MyHost2) Sleep for 10 seconds
+> [ 26.997901] (1:onoff_test@MyHost2) Done sleeping. Current peak speed=1E+08; Energy dissipated=1819.77 J
+> [ 26.997901] (1:onoff_test@MyHost2) Switch to virtual pstate 3, that encodes the shutting down state in the XML file of that example
+> [ 26.997901] (1:onoff_test@MyHost2) Actually start the host
+> [ 26.997901] (1:onoff_test@MyHost2) Simulate the boot up by executing one flop on that host
+> [176.997893] (0:@) Total simulation time: 177.00
+> [176.997893] (0:@) Total energy of host MyHost1: 19819.768169 Joules
+> [176.997893] (0:@) Total energy of host MyHost2: 17699.789313 Joules
+> [176.997893] (1:onoff_test@MyHost2) Switch back to previously selected pstate 0
+> [176.997893] (1:onoff_test@MyHost2) Host1 is now ON again. Current peak speed=1E+08 flop/s; Energy dissipated=19820 J
diff --git a/examples/msg/energy/onoff/platform_onoff.xml b/examples/msg/energy/onoff/platform_onoff.xml
new file mode 100644 (file)
index 0000000..64a58a5
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS  id="AS0"  routing="Full">
+
+  <!-- Use the pstate mechanism to encode the boot/shutdown time and energy -->
+  
+  <!-- That may be seen as a misuse of the pstate mechanism and crude hack, 
+       but this is efficient: we can do what we want without too much burden, 
+       and since the whole intelligence is at user level, we do control the model. 
+       
+       The same could be done to encode the time and energy to switch
+       between pstates. These times seem negligeable in our
+       experiments, but if they are important to you, now you know how
+       to do that. -->
+       
+  <!-- pstate values:
+         * 0-2: real pstates
+          0: p1 100 MFlops/s, [idle: 95W -> full burning: 200W]
+          1: p2  50 MFlops/s, [idle: 93W -> full burning: 170W]
+          2: p3  20 MFlops/s, [idel: 90W -> full burning: 150W]
+        * 3: booting up was measured to take 150s and 18000J.
+             So we create a pstate with 1 flop/150 s so that the
+                application burns 1 flop in that virtual pstate to
+                simulate a boot.             
+             Multiply everything by 1000 or whatever if this trick is
+               too painful to you, that's the same by the end.
+              The energy consumption is 18000/150=120W
+        * 4: shuting down was measured to take 7 s and 770 J
+        
+       Please note that we tried to put sensible values in this file
+       but you should still take them with a grain of salt. If you
+       want a realistic simulation, you have to actually benchmark
+       your platform and application, and use the values that are
+       right for you. -->
+    
+    
+  <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf,                         0.006666667f,0.1429f" pstate="0" >
+        <prop id="watt_per_state"value="95.0:200.0,93.0:170.0,90.0:150.0,       120:120,110:110" />
+        <prop id="watt_off" value="10" />
+  </host>
+  <host id="MyHost2" power="100.0Mf" >
+        <prop id="watt_per_state" value="100.0:200.0" />
+        <prop id="watt_off" value="10" />
+  </host>
+
+  <link id="link1" bandwidth="100kBps" latency="0"/>
+  <route src="MyHost1" dst="MyHost2"><link_ctn id="link1"/></route>
+  
+</AS>
+</platform>
index de58a7c..e2d19de 100644 (file)
@@ -329,6 +329,8 @@ XBT_PUBLIC(double) MSG_host_get_power_peak_at(msg_host_t h, int pstate);
 XBT_PUBLIC(double) MSG_host_get_current_power_peak(msg_host_t h);
 XBT_PUBLIC(int)    MSG_host_get_nb_pstates(msg_host_t h);
 XBT_PUBLIC(void)   MSG_host_set_pstate(msg_host_t h, int pstate);
+XBT_PUBLIC(int)    MSG_host_get_pstate(msg_host_t host);
+
 XBT_PUBLIC(double) MSG_host_get_consumed_energy(msg_host_t h);
 
 /*property handlers*/
index 1cb3fd6..099966d 100644 (file)
@@ -320,6 +320,7 @@ XBT_PUBLIC(double) simcall_host_get_current_power_peak(smx_host_t host);
 XBT_PUBLIC(double) simcall_host_get_power_peak_at(smx_host_t host, int pstate_index);
 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(smx_synchro_t) simcall_host_execute(const char *name, smx_host_t host,
index ef0e55b..5eaf7ac 100644 (file)
@@ -835,6 +835,8 @@ XBT_PUBLIC(double) smpi_get_host_power_peak_at(int pstate_index);
 XBT_PUBLIC(double) smpi_get_host_current_power_peak(void);
 XBT_PUBLIC(int) smpi_get_host_nb_pstates(void);
 XBT_PUBLIC(void) smpi_set_host_pstate(int pstate_index);
+XBT_PUBLIC(int)  smpi_get_host_pstate(void);
+
 XBT_PUBLIC(double) smpi_get_host_consumed_energy(void);
 
 XBT_PUBLIC(int) smpi_usleep(useconds_t usecs);
index 3ddad07..0fec4c4 100644 (file)
@@ -162,6 +162,10 @@ public class Cpu extends Resource {
     SurfJNI.Cpu_setPstate(swigCPtr, this, pstate_index);
   }
 
+  public int getPstate() {
+    return SurfJNI.Cpu_getPstate(swigCPtr, this);
+  }
+
   
   /**
     * @param state The new state of the cpu
index 08169d6..3502cf5 100644 (file)
@@ -111,6 +111,7 @@ public class SurfJNI {
   public final static native double Cpu_getPowerPeakAt(long jarg1, Cpu jarg1_, int jarg2);
   public final static native int Cpu_getNbPstates(long jarg1, Cpu jarg1_);
   public final static native void Cpu_setPstate(long jarg1, Cpu jarg1_, int jarg2);
+  public final static native int Cpu_getPstate(long jarg1, Cpu jarg1_);
   public final static native void Cpu_setState(long jarg1, Cpu jarg1_, int jarg2);
   public final static native void Cpu_director_connect(Cpu obj, long cptr, boolean mem_own, boolean weak_global);
   public final static native void Cpu_change_ownership(Cpu obj, long cptr, boolean take_or_release);
@@ -250,6 +251,9 @@ public class SurfJNI {
   public static void SwigDirector_Cpu_setPstate(Cpu self, int pstate_index) {
     self.setPstate(pstate_index);
   }
+  public static int SwigDirector_Cpu_getPstate(Cpu self) {
+    return self.getPstate();
+  }
   public static double SwigDirector_CpuAction_getRemains(CpuAction self) {
     return self.getRemains();
   }
index e35cff6..660d85b 100644 (file)
@@ -294,6 +294,7 @@ public:
   virtual double getPowerPeakAt(int pstate_index)=0;
   virtual int getNbPstates()=0;
   virtual void setPstate(int pstate_index)=0;
+  virtual int  getPstate()=0;
   void setState(e_surf_resource_state_t state);
 };
 
index 6aadfc3..0ddc491 100644 (file)
@@ -620,14 +620,8 @@ XBT_PUBLIC(double) surf_workstation_get_power_peak_at(surf_resource_t host, int
  */
 XBT_PUBLIC(int) surf_workstation_get_nb_pstates(surf_resource_t host);
 
-/**
- * @brief [brief description]
- * @details [long description]
- *
- * @param host [description]
- * @param pstate_index [description]
- */
 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);
 
 /**
  * @brief Get the consumed energy (in joules) of a workstation
index bce361c..21d7ee2 100644 (file)
@@ -394,6 +394,14 @@ void MSG_host_set_pstate(msg_host_t host, int pstate_index) {
 
          simcall_host_set_pstate(host, pstate_index);
 }
+/** \ingroup m_host_management
+ * \brief Gets the pstate at which the given host is currently running. See also @ref SURF_plugin_energy.
+ *
+ * \param  host host to test
+ */
+int MSG_host_get_pstate(msg_host_t host) {
+         return simcall_host_get_pstate(host);
+}
 
 /** \ingroup m_host_management
  * \brief Return the total energy consumed by a host (in Joules). See also @ref SURF_plugin_energy.
index fb73b7a..36f75fd 100644 (file)
@@ -193,7 +193,7 @@ 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
@@ -202,6 +202,16 @@ void simcall_host_set_pstate(smx_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(smx_host_t host)
+{
+       return simcall_BODY_host_get_pstate(host);
+}
 
 /**
  * \ingroup simix_host_management
index 5ce8372..f520b3c 100644 (file)
@@ -190,6 +190,19 @@ static inline void simcall_host_set_pstate__set__pstate_index(smx_simcall_t simc
     simcall->args[1].i = arg;
 }
 
+static inline smx_host_t simcall_host_get_pstate__get__host(smx_simcall_t simcall) {
+  return (smx_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 smx_host_t simcall_host_get_consumed_energy__get__host(smx_simcall_t simcall) {
   return (smx_host_t) simcall->args[0].dp;
 }
index 7c4ea3b..0f233fe 100644 (file)
@@ -313,6 +313,27 @@ inline static void simcall_BODY_host_set_pstate(smx_host_t host, int pstate_inde
     
   }
   
+inline static int simcall_BODY_host_get_pstate(smx_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(smx_host_t host) {
     smx_process_t self = SIMIX_process_self();
 
index 0225d19..e662c5e 100644 (file)
@@ -32,6 +32,7 @@ typedef enum {
   SIMCALL_HOST_GET_POWER_PEAK_AT,
   SIMCALL_HOST_GET_NB_PSTATES,
   SIMCALL_HOST_SET_PSTATE,
+  SIMCALL_HOST_GET_PSTATE,
   SIMCALL_HOST_GET_CONSUMED_ENERGY,
   SIMCALL_HOST_EXECUTE,
   SIMCALL_HOST_PARALLEL_EXECUTE,
index e34eae3..ba0638a 100644 (file)
@@ -36,6 +36,7 @@ const char* simcall_names[] = {
   [SIMCALL_HOST_GET_POWER_PEAK_AT] = "SIMCALL_HOST_GET_POWER_PEAK_AT",
   [SIMCALL_HOST_GET_NB_PSTATES] = "SIMCALL_HOST_GET_NB_PSTATES",
   [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_EXECUTE] = "SIMCALL_HOST_EXECUTE",
   [SIMCALL_HOST_PARALLEL_EXECUTE] = "SIMCALL_HOST_PARALLEL_EXECUTE",
@@ -235,6 +236,11 @@ case SIMCALL_HOST_SET_PSTATE:
       SIMIX_simcall_answer(simcall);
       break;  
 
+case SIMCALL_HOST_GET_PSTATE:
+      simcall->result.i = SIMIX_host_get_pstate((smx_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((smx_host_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
index 1f4e7b9..09ed723 100644 (file)
@@ -60,6 +60,7 @@ 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)
 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)
 
 Func - host_execute (void*, smx_synchro_t) (name, const char*) (host, void*, smx_host_t) (flops_amount, double) (priority, double) (bound, double) (affinity_mask, unsigned long)
index 5126b2d..ad2874c 100644 (file)
@@ -237,6 +237,9 @@ void SIMIX_host_set_pstate(smx_host_t host, int pstate_index) {
 
          surf_workstation_set_pstate(host, pstate_index);
 }
+int SIMIX_host_get_pstate(smx_host_t host) {
+         return surf_workstation_get_pstate(host);
+}
 
 double SIMIX_host_get_consumed_energy(smx_host_t host) {
          xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
index 9c108af..63a2f81 100644 (file)
@@ -52,6 +52,7 @@ 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);
 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,
     smx_host_t host, double flops_amount, double priority, double bound, unsigned long affinity_mask);
 smx_synchro_t SIMIX_host_parallel_execute(const char *name,
index 395f84e..a0129f2 100644 (file)
@@ -42,7 +42,7 @@ int smpi_get_host_nb_pstates(void)
 }
 
 /**
- * \brief Sets the speed of the processor (in flop/s) at a given pstate
+ * \brief Sets the pstate at which the processor should run
  *
  * \param pstate_index pstate to switch to
  */
@@ -50,6 +50,15 @@ void smpi_set_host_pstate(int pstate_index)
 {
   simcall_host_set_pstate(SIMIX_host_self(), pstate_index);
 }
+/**
+ * \brief Gets the pstate at which the processor currently running
+ *
+ * \param pstate_index pstate to switch to
+ */
+int smpi_get_host_pstate()
+{
+  return simcall_host_get_pstate(SIMIX_host_self());
+}
 
 /**
  * \brief Return the total energy consumed by a host (in Joules)
index f5182c3..d5fb355 100644 (file)
@@ -351,6 +351,11 @@ void CpuCas01::setPstate(int pstate_index)
   m_powerPeak = new_pstate;
 }
 
+int CpuCas01::getPstate()
+{
+  return m_pstate;
+}
+
 /**********
  * Action *
  **********/
index 46e9caf..b40cd04 100644 (file)
@@ -59,6 +59,7 @@ public:
   double getPowerPeakAt(int pstate_index);
   int getNbPstates();
   void setPstate(int pstate_index);
+  int  getPstate();
   bool isUsed();
   void setStateEvent(tmgr_trace_event_t stateEvent);
   void setPowerEvent(tmgr_trace_event_t stateEvent);
index 7e7ff09..de6859a 100644 (file)
@@ -200,6 +200,7 @@ public:
   virtual int getNbPstates()=0;
 
   virtual void setPstate(int pstate_index)=0;
+  virtual int  getPstate()=0;
 
   void setState(e_surf_resource_state_t state);
 
index 3cb1199..80679ad 100644 (file)
@@ -140,6 +140,7 @@ public:
   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
   int getNbPstates() {THROW_UNIMPLEMENTED;};
   void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
+  int  getPstate() { THROW_UNIMPLEMENTED;}
   void modified(bool modified);
 
   CpuTiTgmrPtr p_availTrace;       /*< Structure with data needed to integrate trace file */
index 3387974..2d7b613 100644 (file)
@@ -357,7 +357,10 @@ int surf_workstation_get_nb_pstates(surf_resource_t resource){
 }
 
 void surf_workstation_set_pstate(surf_resource_t resource, int pstate_index){
-  return get_casted_workstation(resource)->setPstate(pstate_index);
+  get_casted_workstation(resource)->setPstate(pstate_index);
+}
+int surf_workstation_get_pstate(surf_resource_t resource){
+  return get_casted_workstation(resource)->getPstate();
 }
 
 double surf_workstation_get_consumed_energy(surf_resource_t resource){
index 3a5472b..fc2bcde 100644 (file)
@@ -159,6 +159,10 @@ void Workstation::setPstate(int pstate_index)
 {
        p_cpu->setPstate(pstate_index);
 }
+int Workstation::getPstate()
+{
+       return p_cpu->getPstate();
+}
 
 xbt_dict_t Workstation::getProperties()
 {
index 4c39287..eb6c8dc 100644 (file)
@@ -238,6 +238,7 @@ public:
   virtual double getPowerPeakAt(int pstate_index);
   virtual int getNbPstates();
   virtual void setPstate(int pstate_index);
+  virtual int  getPstate();
 
   /**
    * @brief Return the storage of corresponding mount point
index 0904cf5..4bb17ad 100644 (file)
@@ -433,25 +433,27 @@ WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_
 
 double WorkstationL07::getPowerPeakAt(int /*pstate_index*/)
 {
-       XBT_DEBUG("[ws_get_power_peak_at] Not implemented for workstation_ptask_L07");
-       return 0.0;
+       THROW_UNIMPLEMENTED;
 }
 
 int WorkstationL07::getNbPstates()
 {
-       XBT_DEBUG("[ws_get_nb_pstates] Not implemented for workstation_ptask_L07");
-       return 0.0;
+       THROW_UNIMPLEMENTED;
 }
 
 void WorkstationL07::setPstate(int /*pstate_index*/)
 {
-       XBT_DEBUG("[ws_set_power_peak_at] Not implemented for workstation_ptask_L07");
+       THROW_UNIMPLEMENTED;
+}
+
+int WorkstationL07::getPstate()
+{
+       THROW_UNIMPLEMENTED;
 }
 
 double WorkstationL07::getConsumedEnergy()
 {
-       XBT_DEBUG("[ws_get_consumed_energy] Not implemented for workstation_ptask_L07");
-       return 0.0;
+       THROW_UNIMPLEMENTED;
 }
 
 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
index 39cb5fe..dc94987 100644 (file)
@@ -111,6 +111,7 @@ public:
   double getPowerPeakAt(int pstate_index);
   int getNbPstates();
   void setPstate(int pstate_index);
+  int  getPstate();
   double getConsumedEnergy();
 };
 
@@ -132,6 +133,7 @@ public:
   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
   int getNbPstates() {THROW_UNIMPLEMENTED;};
   void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
+  int  getPstate() {THROW_UNIMPLEMENTED;};
   double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
 };