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, 2 Oct 2018 20:26:09 +0000 (22:26 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 2 Oct 2018 20:26:09 +0000 (22:26 +0200)
19 files changed:
examples/s4u/platform-failures/s4u-platform-failures.cpp
include/simgrid/plugins/energy.h
include/smpi/sampi.h
src/msg/msg_gos.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/plugins/ampi/ampi.cpp
src/smpi/plugins/ampi/ampi.hpp
src/smpi/plugins/ampi/instr_ampi.hpp
src/smpi/plugins/load_balancer/LoadBalancer.cpp
src/smpi/plugins/load_balancer/load_balancer.hpp
src/smpi/plugins/sampi_loadbalancer.cpp
src/xbt/exception.cpp
teshsuite/msg/cloud-two-tasks/cloud-two-tasks.c
teshsuite/msg/energy-ptask/energy-ptask.c
teshsuite/msg/io-raw-storage/io-raw-storage.c
teshsuite/msg/platform-properties/platform-properties.c
teshsuite/simix/generic-simcalls/generic-simcalls.cpp

index f52f8d6..0d57421 100644 (file)
@@ -34,13 +34,9 @@ static int master(int argc, char* argv[])
       delete payload;
       XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
     } catch (xbt_ex& e) {
-      switch (e.category) {
-        case network_error:
-          XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
-          break;
-        default:
-          xbt_die("Unexpected behavior");
-      }
+      if (e.category != network_error)
+        xbt_die("Unexpected behavior");
+      XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
       delete payload;
     }
   }
@@ -61,13 +57,9 @@ static int master(int argc, char* argv[])
       XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
     } catch (xbt_ex& e) {
       delete payload;
-      switch (e.category) {
-        case network_error:
-          XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
-          break;
-        default:
-          xbt_die("Unexpected behavior");
-      }
+      if (e.category != network_error)
+        xbt_die("Unexpected behavior");
+      XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
     }
   }
 
@@ -94,28 +86,18 @@ static int worker(int argc, char* argv[])
         break;
       }
       /*  - Otherwise, process the task */
-      try {
-        XBT_INFO("Start execution...");
-        simgrid::s4u::this_actor::execute(comp_size);
-        XBT_INFO("Execution complete.");
-        delete payload;
-      } catch (simgrid::HostFailureException& e) {
-        delete payload;
-        XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
-        return -1;
-      }
+      XBT_INFO("Start execution...");
+      simgrid::s4u::this_actor::execute(comp_size);
+      XBT_INFO("Execution complete.");
+      delete payload;
     } catch (simgrid::HostFailureException& e) {
       XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
       delete payload;
       return -1;
     } catch (xbt_ex& e) {
-      switch (e.category) {
-        case network_error:
-          XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
-          break;
-        default:
-          xbt_die("Unexpected behavior. Category: %s", xbt_ex_catname(e.category));
-      }
+      if (e.category != network_error)
+        xbt_die("Unexpected behavior. Category: %s", xbt_ex_catname(e.category));
+      XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
     }
   }
   return 0;
index 3cfe6e7..67e5a26 100644 (file)
@@ -14,6 +14,7 @@ SG_BEGIN_DECL()
 XBT_PUBLIC void sg_host_energy_plugin_init();
 XBT_PUBLIC void sg_host_energy_update_all();
 XBT_PUBLIC double sg_host_get_consumed_energy(sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption(sg_host_t host);
 XBT_PUBLIC double sg_host_get_wattmin_at(sg_host_t host, int pstate);
 XBT_PUBLIC double sg_host_get_wattmax_at(sg_host_t host, int pstate);
 XBT_PUBLIC double sg_host_get_current_consumption(sg_host_t host);
index c3087a8..6e8a536 100644 (file)
 
 #ifndef HAVE_SMPI
 #define malloc(nbytes) _sampi_malloc(nbytes)
+#define calloc(n_elm,elm_size) _sampi_calloc(n_elm,elm_size)
+#define realloc(ptr,nbytes) _sampi_realloc(ptr,nbytes)
 #define free(ptr) _sampi_free(ptr)
 #endif
 
 SG_BEGIN_DECL()
 
 XBT_PUBLIC void* _sampi_malloc(size_t size);
+XBT_PUBLIC void* _sampi_calloc(size_t n_elm, size_t elm_size);
+XBT_PUBLIC void* _sampi_realloc(void *ptr, size_t size);
 XBT_PUBLIC void _sampi_free(void* ptr);
 
 AMPI_CALL(XBT_PUBLIC int, MPI_Iteration_in, (MPI_Comm comm))
index d393195..d77e1b7 100644 (file)
@@ -522,14 +522,10 @@ int MSG_comm_testany(xbt_dynar_t comms)
     status         = MSG_TIMEOUT;
   }
   catch (xbt_ex& e) {
-    switch (e.category) {
-      case network_error:
-        finished_index = e.value;
-        status = MSG_TRANSFER_FAILURE;
-        break;
-      default:
-        throw;
-    }
+    if (e.category != network_error)
+      throw;
+    finished_index = e.value;
+    status         = MSG_TRANSFER_FAILURE;
   }
 
   if (finished_index != -1) {
index e5a2f47..9399cdf 100644 (file)
 #endif
 #include <xbt/config.hpp>
 
+#include "src/internal_config.h"
+
 #include <boost/algorithm/string.hpp>
+#if HAVE_SMPI
+#include "src/smpi/include/smpi_request.hpp"
+#endif
 
 SIMGRID_REGISTER_PLUGIN(host_dvfs, "Dvfs support", &sg_host_dvfs_plugin_init)
 
@@ -26,7 +31,9 @@ static simgrid::config::Flag<std::string> cfg_governor("plugin/dvfs/governor",
     "Which Governor should be used that adapts the CPU frequency?", "performance",
 
     std::map<std::string, std::string>({
+#if HAVE_SMPI
         {"adagio", "TODO: Doc"},
+#endif
         {"conservative", "TODO: Doc"},
         {"ondemand", "TODO: Doc"},
         {"performance", "TODO: Doc"},
@@ -254,6 +261,7 @@ public:
   }
 };
 
+#if HAVE_SMPI
 class Adagio : public Governor {
 private:
   int best_pstate     = 0;
@@ -261,7 +269,7 @@ private:
   double comp_counter = 0;
   double comp_timer   = 0;
 
-  std::vector<std::vector<double>> rates;
+  std::vector<std::vector<double>> rates; // Each host + all frequencies of that host
 
   unsigned int task_id   = 0;
   bool iteration_running = false; /*< Are we currently between iteration_in and iteration_out calls? */
@@ -270,7 +278,6 @@ public:
   explicit Adagio(simgrid::s4u::Host* ptr)
       : Governor(ptr), rates(100, std::vector<double>(ptr->get_pstate_count(), 0.0))
   {
-#if HAVE_SMPI
     simgrid::smpi::plugin::ampi::on_iteration_in.connect([this](simgrid::s4u::ActorPtr actor) {
       // Every instance of this class subscribes to this event, so one per host
       // This means that for any actor, all 'hosts' are normally notified of these
@@ -286,7 +293,6 @@ public:
         task_id           = 0;
       }
     });
-#endif
     simgrid::kernel::activity::ExecImpl::on_creation.connect([this](simgrid::kernel::activity::ExecImplPtr activity) {
       if (activity->host_ == get_host())
         pre_task();
@@ -298,6 +304,8 @@ public:
         comp_timer += activity->surf_action_->get_finish_time() - activity->surf_action_->get_start_time();
       }
     });
+    // FIXME I think that this fires at the same time for all hosts, so when the src sends something,
+    // the dst will be notified even though it didn't even arrive at the recv yet
     simgrid::s4u::Link::on_communicate.connect(
         [this](kernel::resource::NetworkAction* action, s4u::Host* src, s4u::Host* dst) {
           if ((get_host() == src || get_host() == dst) && iteration_running) {
@@ -350,6 +358,7 @@ public:
 
   virtual void update() override {}
 };
+#endif
 } // namespace dvfs
 } // namespace plugin
 } // namespace simgrid
@@ -388,10 +397,14 @@ static void on_host_added(simgrid::s4u::Host& host)
       } else if (dvfs_governor == "ondemand") {
         return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
             new simgrid::plugin::dvfs::OnDemand(daemon_proc->get_host()));
-      } else if (dvfs_governor == "adagio") {
+      }
+#if HAVE_SMPI
+      else if (dvfs_governor == "adagio") {
         return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
             new simgrid::plugin::dvfs::Adagio(daemon_proc->get_host()));
-      } else if (dvfs_governor == "performance") {
+      }
+#endif
+      else if (dvfs_governor == "performance") {
         return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
             new simgrid::plugin::dvfs::Performance(daemon_proc->get_host()));
       } else if (dvfs_governor == "powersave") {
index be43b29..763b905 100644 (file)
@@ -134,6 +134,7 @@ public:
   double get_current_watts_value();
   double get_current_watts_value(double cpu_load);
   double get_consumed_energy();
+  double get_idle_consumption();
   double get_watt_min_at(int pstate);
   double get_watt_max_at(int pstate);
   void update();
@@ -212,6 +213,14 @@ HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr), last_updated_(surf
 
 HostEnergy::~HostEnergy() = default;
 
+double HostEnergy::get_idle_consumption()
+{
+  xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
+             host_->get_cname());
+
+  return power_range_watts_list_[0].idle_;
+}
+
 double HostEnergy::get_watt_min_at(int pstate)
 {
   xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
@@ -351,13 +360,13 @@ void HostEnergy::init_watts_range_list()
         // In this case, 1core == AllCores
         current_power_values.push_back(current_power_values.at(1));
       } else { // size == 3
-        current_power_values[2] = current_power_values.at(1);
+        current_power_values[1] = current_power_values.at(2);
+        current_power_values[2] = current_power_values.at(2);
         static bool displayed_warning = false;
         if (not displayed_warning) { // Otherwise we get in the worst case no_pstate*no_hosts warnings
           XBT_WARN("Host %s is a single-core machine and part of the power profile is '%s'"
                    ", which is in the 'Idle:OneCore:AllCores' format."
-                   " Since this is a single-core machine, AllCores and OneCore are identical."
-                   " Here, only the value for 'OneCore' is used.", host_->get_cname(), current_power_values_str.c_str());
+                   " Here, only the value for 'AllCores' is used.", host_->get_cname(), current_power_values_str.c_str());
           displayed_warning = true;
         }
       }
@@ -526,6 +535,16 @@ double sg_host_get_consumed_energy(sg_host_t host)
   return host->extension<HostEnergy>()->get_consumed_energy();
 }
 
+/** @ingroup plugin_energy
+ *  @brief Get the amount of watt dissipated when the host is idling
+ */
+double sg_host_get_idle_consumption(sg_host_t host)
+{
+  xbt_assert(HostEnergy::EXTENSION_ID.valid(),
+             "The Energy plugin is not active. Please call sg_host_energy_plugin_init() during initialization.");
+  return host->extension<HostEnergy>()->get_idle_consumption();
+}
+
 /** @ingroup plugin_energy
  *  @brief Get the amount of watt dissipated at the given pstate when the host is idling
  */
index ebd900a..6a66dbf 100644 (file)
@@ -687,7 +687,9 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
                                     source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(),
                                     simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_PERSISTENT | MPI_REQ_RECV);
   if (smpi_iprobe_sleep > 0) {
-    s4u::this_actor::exec_init(/* flops to execute */ nsleeps * smpi_iprobe_sleep * speed * maxrate)
+    /** Compute the number of flops we will sleep **/
+    s4u::this_actor::exec_init(/*nsleeps: See comment above */ nsleeps *
+                               /*(in seconds)*/ smpi_iprobe_sleep * speed * maxrate)
         ->set_name("iprobe")
         ->start()
         ->wait();
index d2780de..b076290 100644 (file)
@@ -1,3 +1,8 @@
+/* Copyright (c) 2018.      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 <simgrid/plugins/load_balancer.h>
 #include <simgrid/s4u/Actor.hpp>
 #include <src/smpi/include/smpi_comm.hpp>
@@ -10,8 +15,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(plugin_pampi, smpi, "Logging specific to the AMP
 
 static std::vector<size_t> memory_size(500, 0); // FIXME cheinrich This needs to be dynamic
 static std::map</*address*/ void*, size_t> alloc_table; // Keep track of all allocations
-extern "C" XBT_PUBLIC void* _sampi_malloc(size_t);
+extern "C" XBT_PUBLIC void* _sampi_malloc(size_t); // FIXME Use declarations from sampi.h instead
 extern "C" XBT_PUBLIC void _sampi_free(void* ptr);
+extern "C" XBT_PUBLIC void* _sampi_calloc(size_t num_elm, size_t elem_size);
+extern "C" XBT_PUBLIC void* _sampi_realloc(void* ptr, size_t size);
 extern "C" void* _sampi_malloc(size_t size)
 {
   void* result = malloc (size); // We need the space here to prevent recursive substitution
@@ -30,6 +37,27 @@ extern "C" void _sampi_free(void* ptr)
   free(ptr);
 }
 
+extern "C" void* _sampi_calloc(size_t num_elm, size_t elem_size)
+{
+  void* result = calloc (num_elm, elem_size); // We need the space here to prevent recursive substitution
+  alloc_table.insert({result, num_elm * elem_size});
+  if (not simgrid::s4u::this_actor::is_maestro()) {
+    memory_size[simgrid::s4u::this_actor::get_pid()] += num_elm * elem_size;
+  }
+  return result;
+}
+extern "C" void* _sampi_realloc(void* ptr, size_t size)
+{
+  void* result = realloc (ptr, size); // We need the space here to prevent recursive substitution
+  int old_size = alloc_table.at(ptr);
+  alloc_table.erase(ptr);
+  alloc_table.insert({result, size});
+  if (not simgrid::s4u::this_actor::is_maestro()) {
+    memory_size[simgrid::s4u::this_actor::get_pid()] += size - old_size;
+  }
+  return result;
+}
+
 #include "ampi.hpp"
 #include <smpi/sampi.h>
 namespace simgrid {
index 7f3912e..cee44a3 100644 (file)
@@ -3,8 +3,8 @@
 /* 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. */
 
-#ifndef AMPI_HPP
-#define AMPI_HPP
+#ifndef INSTR_AMPI_HPP_
+#define INSTR_AMPI_HPP_
 
 #include <simgrid/s4u.hpp>
 
index 3fc2f74..0ab89c9 100644 (file)
@@ -3,8 +3,8 @@
 /* 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. */
 
-#ifndef INSTR_AMPI_HPP_
-#define INSTR_AMPI_HPP_
+#ifndef INSTR_INSTR_AMPI_HPP_
+#define INSTR_INSTR_AMPI_HPP_
 
 #include "smpi/smpi.h"
 #include "src/instr/instr_private.hpp"
index bf993dc..dde6fa6 100644 (file)
@@ -18,7 +18,8 @@ namespace simgrid {
 namespace plugin {
 namespace loadbalancer {
 
-struct XBT_PRIVATE compare_hosts {
+class XBT_PRIVATE compare_hosts {
+public:
   bool operator()(simgrid::s4u::Host* const a, simgrid::s4u::Host* const b) const;
 };
 
@@ -82,11 +83,14 @@ void LoadBalancer::run()
   for (auto& host : available_hosts) {
     std::vector<simgrid::s4u::ActorPtr> actors = host->get_all_actors();
     heap_handle update_handle                  = usable_hosts.push(host); // Required to update elements in the heap
-    additional_load[host]                      = {update_handle, 0}; // Save the handle for later
+    additional_load[host]                      = {update_handle, 0};      // Save the handle for later
+    const double total_flops_computed          = sg_host_get_computed_flops(host);
     for (auto& actor : actors) {
-      additional_load[host].load += actor_computation[actor->get_pid()];
+      additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
+                                                                                                // even between hosts with different frequencies
       XBT_DEBUG("Actor %li -> %f", actor->get_pid(), actor_computation[actor->get_pid()]);
     }
+    usable_hosts.increase(update_handle);
     XBT_DEBUG("Host %s initialized to %f", host->get_cname(), additional_load[host].load);
   }
 
index 44a2d08..2d1ec8d 100644 (file)
@@ -72,7 +72,6 @@ public:
    */
   simgrid::s4u::Host* get_mapping(simgrid::s4u::ActorPtr);
   void record_actor_computation(simgrid::s4u::ActorPtr actor, double load);
-private:
 };
 
 }
index b201830..375a624 100644 (file)
@@ -92,6 +92,7 @@ public:
       smpi_execute(xbt_os_timer_elapsed(timer));
 
       // Update the process and host mapping in SimGrid.
+      XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname());
       TRACE_smpi_process_change_host(my_proc_id, migrate_to_host);
       simgrid::s4u::this_actor::migrate(migrate_to_host);
     }
index c14e9ae..0a0f335 100644 (file)
@@ -21,7 +21,8 @@ xbt_ex::~xbt_ex() = default;
 
 void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
 {
-  xbt_ex e(simgrid::xbt::ThrowPoint(XBT_THROW_POINT), message);
+  xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func, simgrid::xbt::backtrace(), xbt_procname(), xbt_getpid()),
+           message);
   xbt_free(message);
   e.category = errcat;
   e.value    = value;
index d7a2e35..6ea6bf7 100644 (file)
@@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
 
 msg_task_t atask = NULL;
 
-static int computation_fun(int argc, char* argv[])
+static int computation_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   const char* pr_name   = MSG_process_get_name(MSG_process_self());
   const char* host_name = MSG_host_get_name(MSG_host_self());
@@ -41,7 +41,7 @@ static int computation_fun(int argc, char* argv[])
   return 0;
 }
 
-static int master_main(int argc, char* argv[])
+static int master_main(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   msg_host_t pm0 = MSG_host_by_name("Fafard");
   msg_vm_t vm0   = MSG_vm_create_core(pm0, "VM0");
index 8075c58..f70f90e 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
  *   interfaces, but it's not possible ATM).
  */
 
-static int runner(int argc, char* argv[])
+static int runner(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   /* Retrieve the list of all hosts as an array of hosts */
   int host_count    = MSG_get_host_number();
index f1ddfbf..1b7fddd 100644 (file)
@@ -7,7 +7,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
 
-static int host(int argc, char* argv[])
+static int host(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   const char* host_name = MSG_host_get_name(MSG_host_self());
 
index 58ed491..67c06bf 100644 (file)
@@ -47,27 +47,27 @@ static void test_host(const char* hostname)
   xbt_dict_free(&props);
 }
 
-static int alice(int argc, char* argv[])
+static int alice(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 { /* Dump what we have on the current host */
   test_host("host1");
   return 0;
 }
 
-static int carole(int argc, char* argv[])
+static int carole(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {                       /* Dump what we have on a remote host */
   MSG_process_sleep(1); // Wait for alice to be done with its experiment
   test_host("host1");
   return 0;
 }
 
-static int david(int argc, char* argv[])
+static int david(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {                       /* Dump what we have on a remote host */
   MSG_process_sleep(2); // Wait for alice and carole to be done with its experiment
   test_host("node-0.simgrid.org");
   return 0;
 }
 
-static int bob(int argc, char* argv[])
+static int bob(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   /* this host also tests the properties of the AS*/
   msg_as_t root = MSG_zone_get_root();
index 6bc8cf5..c21b12d 100644 (file)
@@ -31,7 +31,7 @@ static simgrid::kernel::Future<void> kernel_wait_until(double date)
   return future;
 }
 
-static int master(int argc, char* argv[])
+static int master(int /*argc*/, char** /*argv*/)
 {
   // Test the simple immediate execution:
   XBT_INFO("Start");