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>
Mon, 14 May 2018 20:52:59 +0000 (22:52 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 14 May 2018 20:52:59 +0000 (22:52 +0200)
17 files changed:
include/simgrid/s4u/Host.hpp
src/instr/instr_platform.cpp
src/kernel/routing/NetZoneImpl.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Host.cpp
src/simix/smx_global.cpp
src/simix/smx_host.cpp
src/simix/smx_network.cpp
src/smpi/internals/smpi_global.cpp
src/surf/cpu_interface.cpp
src/surf/network_ib.cpp
src/surf/plugins/host_dvfs.cpp
src/surf/plugins/host_energy.cpp
src/surf/plugins/host_load.cpp
teshsuite/simix/generic-simcalls/generic-simcalls.cpp

index 0a3c3c9..b62ab7a 100644 (file)
@@ -123,12 +123,16 @@ public:
   /** Block the calling actor on an execution located on the called host (with explicit priority) */
   void execute(double flops, double priority);
 
-  /** @brief Returns the current computation load (in flops per second) */
+  /** @brief Returns the current computation load (in flops per second)
+   * The external load (coming from an availability trace) is not taken in account.
+   *
+   * @return      The number of activities currently running on a host (an activity at priority 2 is counted twice).
+   */
   double getLoad();
 
 private:
   simgrid::xbt::string name_{"noname"};
-  std::unordered_map<std::string, Storage*>* mounts = nullptr; // caching
+  std::unordered_map<std::string, Storage*>* mounts_ = nullptr; // caching
 
 public:
   // TODO, this could be a unique_ptr
@@ -139,14 +143,14 @@ public:
   kernel::routing::NetPoint* pimpl_netpoint = nullptr;
 
   /*** Called on each newly created host */
-  static simgrid::xbt::signal<void(Host&)> onCreation;
+  static simgrid::xbt::signal<void(Host&)> on_creation;
   /*** Called just before destructing an host */
-  static simgrid::xbt::signal<void(Host&)> onDestruction;
+  static simgrid::xbt::signal<void(Host&)> on_destruction;
   /*** Called when the machine is turned on or off (called AFTER the change) */
-  static simgrid::xbt::signal<void(Host&)> onStateChange;
+  static simgrid::xbt::signal<void(Host&)> on_state_change;
   /*** Called when the speed of the machine is changed (called AFTER the change)
    * (either because of a pstate switch or because of an external load event coming from the profile) */
-  static simgrid::xbt::signal<void(Host&)> onSpeedChange;
+  static simgrid::xbt::signal<void(Host&)> on_speed_change;
 };
 }
 } // namespace simgrid::s4u
@@ -154,18 +158,3 @@ public:
 extern int USER_HOST_LEVEL;
 
 #endif /* SIMGRID_S4U_HOST_HPP */
-
-#if 0
-
-public class Host {
-
-  /**
-   * This method returns the number of tasks currently running on a host.
-   * The external load (coming from an availability trace) is not taken in account.
-   *
-   * @return      The number of tasks currently running on a host.
-   */
-  public native int getLoad();
-
-}
-#endif
index cb72c4e..6eff605 100644 (file)
@@ -382,8 +382,8 @@ void instr_define_callbacks()
   // properly
   if (TRACE_needs_platform()) {
     simgrid::s4u::on_platform_created.connect(instr_on_platform_created);
-    simgrid::s4u::Host::onCreation.connect(instr_host_on_creation);
-    simgrid::s4u::Host::onSpeedChange.connect(instr_host_on_speed_change);
+    simgrid::s4u::Host::on_creation.connect(instr_host_on_creation);
+    simgrid::s4u::Host::on_speed_change.connect(instr_host_on_speed_change);
     simgrid::s4u::Link::on_creation.connect(instr_link_on_creation);
     simgrid::s4u::Link::on_bandwidth_change.connect(instr_link_on_bandwidth_change);
   }
@@ -403,12 +403,12 @@ void instr_define_callbacks()
   }
 
   if (TRACE_vm_is_enabled()) {
-    simgrid::s4u::Host::onCreation.connect(instr_vm_on_creation);
+    simgrid::s4u::Host::on_creation.connect(instr_vm_on_creation);
     simgrid::s4u::VirtualMachine::on_start.connect(instr_vm_on_start);
     simgrid::s4u::VirtualMachine::on_started.connect(instr_vm_on_started);
     simgrid::s4u::VirtualMachine::on_suspend.connect(instr_vm_on_suspend);
     simgrid::s4u::VirtualMachine::on_resume.connect(instr_vm_on_resume);
-    simgrid::s4u::Host::onDestruction.connect(instr_vm_on_destruction);
+    simgrid::s4u::Host::on_destruction.connect(instr_vm_on_destruction);
   }
 }
 /*
index 0c3a7dc..bbcec30 100644 (file)
@@ -59,7 +59,7 @@ simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vector<doubl
     for (auto const& kv : *props)
       res->setProperty(kv.first, kv.second);
 
-  simgrid::s4u::Host::onCreation(*res); // notify the signal
+  simgrid::s4u::Host::on_creation(*res); // notify the signal
 
   return res;
 }
index 056ffa9..d89ecd0 100644 (file)
@@ -360,7 +360,7 @@ void sg_storage_file_system_init()
 
   if (not FileDescriptorHostExt::EXTENSION_ID.valid()) {
     FileDescriptorHostExt::EXTENSION_ID = simgrid::s4u::Host::extension_create<FileDescriptorHostExt>();
-    simgrid::s4u::Host::onCreation.connect(&on_host_creation);
+    simgrid::s4u::Host::on_creation.connect(&on_host_creation);
   }
 }
 
index 025fc56..6f9fe0b 100644 (file)
@@ -58,7 +58,7 @@ static void hostStateChange(s4u::Host& host)
 }
 VMModel::VMModel()
 {
-  s4u::Host::onStateChange.connect(hostStateChange);
+  s4u::Host::on_state_change.connect(hostStateChange);
 }
 
 double VMModel::next_occuring_event(double now)
index 2985b7c..8d83e9b 100644 (file)
@@ -46,7 +46,7 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount,
 
 VirtualMachine::~VirtualMachine()
 {
-  onDestruction(*this);
+  on_destruction(*this);
 
   XBT_DEBUG("destroy %s", get_cname());
 
index 0e94456..a9a58c0 100644 (file)
@@ -23,10 +23,10 @@ template class Extendable<simgrid::s4u::Host>;
 
 namespace s4u {
 
-simgrid::xbt::signal<void(Host&)> Host::onCreation;
-simgrid::xbt::signal<void(Host&)> Host::onDestruction;
-simgrid::xbt::signal<void(Host&)> Host::onStateChange;
-simgrid::xbt::signal<void(Host&)> Host::onSpeedChange;
+simgrid::xbt::signal<void(Host&)> Host::on_creation;
+simgrid::xbt::signal<void(Host&)> Host::on_destruction;
+simgrid::xbt::signal<void(Host&)> Host::on_state_change;
+simgrid::xbt::signal<void(Host&)> Host::on_speed_change;
 
 Host::Host(const char* name) : name_(name)
 {
@@ -43,7 +43,7 @@ Host::~Host()
   if (pimpl_netpoint != nullptr) // not removed yet by a children class
     simgrid::s4u::Engine::get_instance()->netpoint_unregister(pimpl_netpoint);
   delete pimpl_cpu;
-  delete mounts;
+  delete mounts_;
 }
 
 /** @brief Fire the required callbacks and destroy the object
@@ -58,7 +58,7 @@ void Host::destroy()
 {
   if (not currentlyDestroying_) {
     currentlyDestroying_ = true;
-    onDestruction(*this);
+    on_destruction(*this);
     Engine::get_instance()->host_unregister(std::string(name_));
     delete this;
   }
@@ -95,7 +95,7 @@ void Host::turnOn()
     simgrid::simix::simcall([this] {
       this->extension<simgrid::simix::Host>()->turnOn();
       this->pimpl_cpu->turn_on();
-      onStateChange(*this);
+      on_state_change(*this);
     });
   }
 }
@@ -106,7 +106,7 @@ void Host::turnOff()
     smx_actor_t self = SIMIX_process_self();
     simgrid::simix::simcall([this, self] {
       SIMIX_host_off(this, self);
-      onStateChange(*this);
+      on_state_change(*this);
     });
   }
 }
@@ -249,13 +249,13 @@ void Host::getAttachedStorages(std::vector<const char*>* storages)
 
 std::unordered_map<std::string, Storage*> const& Host::getMountedStorages()
 {
-  if (mounts == nullptr) {
-    mounts = new std::unordered_map<std::string, Storage*>();
+  if (mounts_ == nullptr) {
+    mounts_ = new std::unordered_map<std::string, Storage*>();
     for (auto const& m : this->pimpl_->storage_) {
-      mounts->insert({m.first, &m.second->piface_});
+      mounts_->insert({m.first, &m.second->piface_});
     }
   }
-  return *mounts;
+  return *mounts_;
 }
 
 void Host::execute(double flops)
index a4a9b7a..f01bd8f 100644 (file)
@@ -209,7 +209,7 @@ void SIMIX_global_init(int *argc, char **argv)
     /* register a function to be called by SURF after the environment creation */
     sg_platf_init();
     simgrid::s4u::on_platform_created.connect(SIMIX_post_create_environment);
-    simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
+    simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) {
       if (host.extension<simgrid::simix::Host>() == nullptr) // another callback to the same signal may have created it
         host.extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
     });
index a2cc767..3e9573a 100644 (file)
@@ -210,16 +210,14 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchr
 
 void simcall_HANDLER_execution_test(smx_simcall_t simcall, smx_activity_t synchro)
 {
-  simcall_execution_test__set__result(simcall, (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING));
-  if (simcall_execution_test__get__result(simcall)) {
+  int res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING);
+  if (res) {
     synchro->simcalls_.push_back(simcall);
     SIMIX_execution_finish(synchro);
   } else {
     SIMIX_simcall_answer(simcall);
   }
-  /* If the synchro is already finished then perform the error handling */
-  if (synchro->state_ != SIMIX_RUNNING)
-    SIMIX_execution_finish(synchro);
+  simcall_execution_test__set__result(simcall, res);
 }
 
 void SIMIX_execution_finish(smx_activity_t synchro)
index 72f03f7..649154b 100644 (file)
@@ -339,19 +339,17 @@ void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_activity_t synchro)
   simgrid::kernel::activity::CommImplPtr comm =
       boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
 
+  int res;
+
   if (MC_is_active() || MC_record_replay_is_active()){
-    simcall_comm_test__set__result(simcall, comm->src_proc && comm->dst_proc);
-    if (simcall_comm_test__get__result(simcall)){
+    res = comm->src_proc && comm->dst_proc;
+    if (res)
       synchro->state_ = SIMIX_DONE;
-      synchro->simcalls_.push_back(simcall);
-      SIMIX_comm_finish(synchro);
-    } else {
-      SIMIX_simcall_answer(simcall);
-    }
-    return;
+  } else {
+    res = synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING;
   }
 
-  simcall_comm_test__set__result(simcall, (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING));
+  simcall_comm_test__set__result(simcall, res);
   if (simcall_comm_test__get__result(simcall)) {
     synchro->simcalls_.push_back(simcall);
     SIMIX_comm_finish(synchro);
index 5c259e9..47ee856 100644 (file)
@@ -464,9 +464,8 @@ int smpi_main(const char* executable, int argc, char *argv[])
   // TODO This will not be executed in the case where smpi_main is not called,
   // e.g., not for smpi_msg_masterslave. This should be moved to another location
   // that is always called -- maybe close to Actor::onCreation?
-  simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
-    host.extension_set(new simgrid::smpi::Host(&host));
-  });
+  simgrid::s4u::Host::on_creation.connect(
+      [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
 
   // parse the platform file: get the host list
   SIMIX_create_environment(argv[1]);
index e18c775..05fbd12 100644 (file)
@@ -133,7 +133,7 @@ double Cpu::get_available_speed()
 }
 
 void Cpu::onSpeedChange() {
-  s4u::Host::onSpeedChange(*host_);
+  s4u::Host::on_speed_change(*host_);
 }
 
 int Cpu::coreCount()
index 4a68c7b..bc08ced 100644 (file)
@@ -92,7 +92,7 @@ void surf_network_model_init_IB()
   all_existing_models->push_back(surf_network_model);
   simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback);
   simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback);
-  simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
+  simgrid::s4u::Host::on_creation.connect(IB_create_host_callback);
   simgrid::config::set_default<double>("network/weight-S", 8775);
 }
 
index 215336f..e5ea579 100644 (file)
@@ -303,7 +303,7 @@ void sg_host_dvfs_plugin_init()
 
   sg_host_load_plugin_init();
 
-  simgrid::s4u::Host::onCreation.connect(&on_host_added);
+  simgrid::s4u::Host::on_creation.connect(&on_host_added);
   simgrid::config::declare_flag<double>(
       property_sampling_rate, "How often should the dvfs plugin check whether the frequency needs to be changed?", 0.1);
   simgrid::config::declare_flag<std::string>(
index a90c80e..3f76a5b 100644 (file)
@@ -457,10 +457,10 @@ void sg_host_energy_plugin_init()
 
   HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostEnergy>();
 
-  simgrid::s4u::Host::onCreation.connect(&onCreation);
-  simgrid::s4u::Host::onStateChange.connect(&onHostChange);
-  simgrid::s4u::Host::onSpeedChange.connect(&onHostChange);
-  simgrid::s4u::Host::onDestruction.connect(&onHostDestruction);
+  simgrid::s4u::Host::on_creation.connect(&onCreation);
+  simgrid::s4u::Host::on_state_change.connect(&onHostChange);
+  simgrid::s4u::Host::on_speed_change.connect(&onHostChange);
+  simgrid::s4u::Host::on_destruction.connect(&onHostDestruction);
   simgrid::s4u::on_simulation_end.connect(&onSimulationEnd);
   simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange);
 }
index 039f23c..94e8966 100644 (file)
@@ -177,15 +177,15 @@ void sg_host_load_plugin_init()
 
   /* When attaching a callback into a signal, you can use a lambda as follows, or a regular function as done below */
 
-  simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
+  simgrid::s4u::Host::on_creation.connect([](simgrid::s4u::Host& host) {
     if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
       return;
     host.extension_set(new HostLoad(&host));
   });
 
   simgrid::surf::CpuAction::onStateChange.connect(&onActionStateChange);
-  simgrid::s4u::Host::onStateChange.connect(&onHostChange);
-  simgrid::s4u::Host::onSpeedChange.connect(&onHostChange);
+  simgrid::s4u::Host::on_state_change.connect(&onHostChange);
+  simgrid::s4u::Host::on_speed_change.connect(&onHostChange);
 }
 
 /** @brief Returns the current load of the host passed as argument
index 94b9558..8e9ffc4 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2016-2018. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2016-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. */