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>
Wed, 25 Apr 2018 08:13:59 +0000 (10:13 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 25 Apr 2018 08:21:39 +0000 (10:21 +0200)
19 files changed:
examples/s4u/actor-create/s4u-actor-create.cpp
examples/s4u/dht-chord/s4u-dht-chord-node.cpp
examples/s4u/dht-chord/s4u-dht-chord.cpp
examples/s4u/dht-chord/s4u-dht-chord.hpp
include/simgrid/s4u/Storage.hpp
include/simgrid/smpi/replay.hpp
src/bindings/java/org/simgrid/NativeLib.java
src/bindings/lua/lua_platf.cpp
src/include/surf/surf.hpp
src/instr/instr_config.cpp
src/instr/instr_private.hpp
src/s4u/s4u_Storage.cpp
src/surf/instr_routing.cpp
src/surf/network_cm02.cpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/surf_private.hpp
src/surf/xml/surfxml_parseplatf.cpp
tools/jenkins/build.sh

index 8a51c0e..6f18c3a 100644 (file)
@@ -65,7 +65,7 @@ public:
   std::string mbox  = "mb42";
   std::string msg = "GaBuZoMeu";
   explicit Sender() = default; /* Sending the default message */
-  explicit Sender(std::string arg) { /* Sending the specified message */ msg= arg; }
+  explicit Sender(std::string arg) : msg(arg) { /* Sending the specified message */}
   explicit Sender(std::vector<std::string> args)
   {
     /* This constructor is used when we start the actor from the deployment file */
index 0db3cef..d7ab98a 100644 (file)
@@ -184,7 +184,7 @@ void Node::setPredecessor(int predecessor_id)
 void Node::fixFingers()
 {
   XBT_DEBUG("Fixing fingers");
-  int id = findSuccessor(id_ + powers2[next_finger_to_fix]);
+  int id = findSuccessor(id_ + (1U << next_finger_to_fix));
   if (id != -1) {
     if (id != fingers_[next_finger_to_fix]) {
       setFinger(next_finger_to_fix, id);
@@ -201,7 +201,7 @@ void Node::printFingerTable()
     XBT_VERB("My finger table:");
     XBT_VERB("Start | Succ");
     for (int i = 0; i < nb_bits; i++) {
-      XBT_VERB(" %3d  | %3d", (id_ + powers2[i]) % nb_keys, fingers_[i]);
+      XBT_VERB(" %3u  | %3d", (id_ + (1U << i)) % nb_keys, fingers_[i]);
     }
 
     XBT_VERB("Predecessor: %d", pred_id_);
index 2fc2877..4a465bb 100644 (file)
@@ -11,32 +11,6 @@ simgrid::xbt::Extension<simgrid::s4u::Host, HostChord> HostChord::EXTENSION_ID;
 int nb_bits  = 24;
 int nb_keys  = 0;
 int timeout  = 50;
-int* powers2 = nullptr;
-
-/* Global initialization of the Chord simulation. */
-static void chord_init()
-{
-  // compute the powers of 2 once for all
-  powers2 = new int[nb_bits];
-  int pow = 1;
-  for (int i = 0; i < nb_bits; i++) {
-    powers2[i] = pow;
-    pow        = pow << 1;
-  }
-  nb_keys = pow;
-  XBT_DEBUG("Sets nb_keys to %d", nb_keys);
-
-  HostChord::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostChord>();
-
-  std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
-  for (auto const& host : list)
-    host->extension_set(new HostChord(host));
-}
-
-static void chord_exit()
-{
-  delete[] powers2;
-}
 
 int main(int argc, char* argv[])
 {
@@ -64,7 +38,13 @@ int main(int argc, char* argv[])
 
   e.load_platform(options[0]);
 
-  chord_init(); // FIXME: inline me
+  /* Global initialization of the Chord simulation. */
+  nb_keys = 1U << nb_bits;
+  XBT_DEBUG("Sets nb_keys to %d", nb_keys);
+
+  HostChord::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostChord>();
+  for (auto const& host : simgrid::s4u::Engine::get_instance()->get_all_hosts())
+    host->extension_set(new HostChord(host));
 
   e.register_actor<Node>("node");
   e.load_deployment(options[1]);
@@ -72,8 +52,5 @@ int main(int argc, char* argv[])
   e.run();
 
   XBT_INFO("Simulated time: %g", e.get_clock());
-
-  chord_exit();
-
   return 0;
 }
index 240a555..ea6e86b 100644 (file)
@@ -21,7 +21,6 @@
 extern int nb_bits;
 extern int nb_keys;
 extern int timeout;
-extern int* powers2;
 
 class HostChord {
   RngStream stream_;
index d8386ff..3204e04 100644 (file)
@@ -20,7 +20,9 @@ extern template class XBT_PUBLIC Extendable<simgrid::s4u::Storage>;
 }
 namespace s4u {
 
-XBT_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
+XBT_ATTRIB_DEPRECATED_v322(
+    "simgrid::s4u::getStorageList() is deprecated in favor of Engine::getAllStorages(). Please switch before v3.22")
+    XBT_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
 
 class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
   friend s4u::Engine;
index edbc4fc..0a4f4a6 100644 (file)
@@ -78,8 +78,6 @@ public:
   int root = 0;
   MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
   MPI_Datatype datatype2 = MPI_DEFAULT_TYPE;
-
-  virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) = 0;
 };
 
 class BcastArgParser : public CollCommParser {
index 1902618..3db622c 100644 (file)
@@ -103,6 +103,7 @@ public final class NativeLib {
                     "lib"+name+".dylib"             /* mac osx */}) {
                                                
                        File fileOut = new File(tempDir.toFile().getAbsolutePath() + File.separator + filename);
+                       boolean done = false;
                        try ( // Try-with-resources. These stream will be autoclosed when needed.
                                InputStream in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
                                OutputStream out = new FileOutputStream(fileOut);
@@ -116,14 +117,14 @@ public final class NativeLib {
                                while ((bytesRead = in.read(buffer)) != -1)     // Read until EOF
                                        out.write(buffer, 0, bytesRead);
                                
-                               out.close(); // Windows cannot open it twice, so close it first. Shame.
-                               
+                               done = true;
+                       }
+                       if (done) {
                                /* load that shit */
                                System.load(fileOut.getAbsolutePath());
                                
                                /* It loaded! we're good */
                                return true;
-                               
                        }
                }
                
index 26c9276..a52a707 100644 (file)
@@ -63,8 +63,6 @@ int console_open(lua_State *L) {
   sg_platf_init();
   sg_platf_begin();
 
-  storage_register_callbacks();
-
   return 0;
 }
 
index 03768f9..db629cc 100644 (file)
@@ -332,7 +332,6 @@ XBT_PUBLIC void parse_platform_file(const char* file);
 /********** Tracing **********/
 
 /* instr_routing.c */
-void instr_routing_define_callbacks();
 xbt_graph_t instr_routing_platform_graph();
 void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);
 
index f5e687a..1f76e6a 100644 (file)
@@ -81,6 +81,7 @@ int TRACE_start()
   //    - enabled (with --cfg=tracing:yes)
   //    - already configured (TRACE_global_init already called)
   if (TRACE_is_enabled()) {
+    instr_routing_define_callbacks();
 
     XBT_DEBUG("Tracing starts");
     /* init the tracing module to generate the right output */
@@ -201,42 +202,42 @@ bool TRACE_uncategorized ()
 
 bool TRACE_actor_is_enabled()
 {
-  return trace_actor_enabled && TRACE_is_enabled();
+  return trace_actor_enabled && trace_enabled;
 }
 
 bool TRACE_vm_is_enabled()
 {
-  return trace_vm_enabled && TRACE_is_enabled();
+  return trace_vm_enabled && trace_enabled;
 }
 
 bool TRACE_disable_link()
 {
-  return trace_disable_link && TRACE_is_enabled();
+  return trace_disable_link && trace_enabled;
 }
 
 bool TRACE_disable_speed()
 {
-  return trace_disable_power && TRACE_is_enabled();
+  return trace_disable_power && trace_enabled;
 }
 
 bool TRACE_buffer ()
 {
-  return trace_buffer && TRACE_is_enabled();
+  return trace_buffer && trace_enabled;
 }
 
 bool TRACE_disable_destroy ()
 {
-  return trace_disable_destroy && TRACE_is_enabled();
+  return trace_disable_destroy && trace_enabled;
 }
 
 bool TRACE_basic ()
 {
-  return trace_basic && TRACE_is_enabled();
+  return trace_basic && trace_enabled;
 }
 
 bool TRACE_display_sizes ()
 {
-   return trace_display_sizes && trace_smpi_enabled && TRACE_is_enabled();
+  return trace_display_sizes && trace_smpi_enabled && trace_enabled;
 }
 
 std::string TRACE_get_comment()
index 2e71e31..579758c 100644 (file)
@@ -249,6 +249,7 @@ XBT_PRIVATE void TRACE_surf_link_set_utilization(const char* resource, const cha
 extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
 extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
 XBT_PRIVATE long long int instr_new_paje_id();
+XBT_PRIVATE void instr_routing_define_callbacks();
 void instr_new_variable_type(std::string new_typename, std::string color);
 void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color);
 void instr_new_user_state_type(std::string father_type, std::string new_typename);
index 2e5d37d..6080b06 100644 (file)
@@ -19,9 +19,7 @@ template class Extendable<simgrid::s4u::Storage>;
 
 namespace s4u {
 
-void XBT_ATTRIB_DEPRECATED_v322(
-    "simgrid::s4u::getStorageList() is deprecated in favor of Engine::getAllStorages(). Please switch before v3.22")
-    getStorageList(std::map<std::string, Storage*>* whereTo)
+void getStorageList(std::map<std::string, Storage*>* whereTo)
 {
   for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages())
     whereTo->insert({s->get_name(), s});
index cfee574..e3faff6 100644 (file)
@@ -150,7 +150,7 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t
 /*
  * Callbacks
  */
-static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
+static void instr_netzone_on_creation(simgrid::s4u::NetZone& netzone)
 {
   std::string id = netzone.get_name();
 
@@ -180,14 +180,14 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
   }
 }
 
-static void sg_instr_AS_end(simgrid::s4u::NetZone& /*netzone*/)
+static void instr_netzone_on_seal(simgrid::s4u::NetZone& /*netzone*/)
 {
   if (TRACE_needs_platform()){
     currentContainer.pop_back();
   }
 }
 
-static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
+static void instr_link_on_creation(simgrid::s4u::Link& link)
 {
   if (currentContainer.empty()) // No ongoing parsing. Are you creating the loopback?
     return;
@@ -208,7 +208,7 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
   }
 }
 
-static void sg_instr_new_host(simgrid::s4u::Host& host)
+static void instr_host_on_creation(simgrid::s4u::Host& host)
 {
   container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
   container_t root      = simgrid::instr::Container::getRoot();
@@ -255,13 +255,13 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   }
 }
 
-static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint)
+static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint)
 {
   if (netpoint->is_router() && TRACE_is_enabled() && TRACE_needs_platform())
     new simgrid::instr::RouterContainer(netpoint->get_cname(), currentContainer.back());
 }
 
-static void instr_routing_parse_end_platform ()
+static void instr_on_platform_created()
 {
   currentContainer.clear();
   std::set<std::string>* filter = new std::set<std::string>;
@@ -273,19 +273,18 @@ static void instr_routing_parse_end_platform ()
   TRACE_paje_dump_buffer(true);
 }
 
-void instr_routing_define_callbacks ()
+void instr_routing_define_callbacks()
 {
-  // always need the callbacks to ASes (we need only the root AS), to create the rootContainer and the rootType properly
-  if (not TRACE_is_enabled())
-    return;
+  // always need the callbacks to zones (we need only the root zone), to create the rootContainer and the rootType
+  // properly
   if (TRACE_needs_platform()) {
-    simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
-    simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
-    simgrid::s4u::Host::onCreation.connect(sg_instr_new_host);
+    simgrid::s4u::Host::onCreation.connect(instr_host_on_creation);
+    simgrid::s4u::Link::onCreation.connect(instr_link_on_creation);
+    simgrid::s4u::onPlatformCreated.connect(instr_on_platform_created);
   }
-  simgrid::s4u::NetZone::onCreation.connect(sg_instr_AS_begin);
-  simgrid::s4u::NetZone::onSeal.connect(sg_instr_AS_end);
-  simgrid::kernel::routing::NetPoint::onCreation.connect(sg_instr_new_router);
+  simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation);
+  simgrid::s4u::NetZone::onSeal.connect(instr_netzone_on_seal);
+  simgrid::kernel::routing::NetPoint::onCreation.connect(instr_netpoint_on_creation);
 }
 /*
  * user categories support
index 45140ed..34d8881 100644 (file)
@@ -242,7 +242,6 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta)
 
 Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
 {
-  bool failed    = false;
   double latency = 0.0;
   std::vector<LinkImpl*> back_route;
   std::vector<LinkImpl*> route;
@@ -254,11 +253,12 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
              "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
              src->get_cname(), dst->get_cname());
 
-  failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
+  bool failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
 
   if (cfg_crosstraffic) {
     dst->routeTo(src, back_route, nullptr);
-    failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
+    if (not failed)
+      failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
   }
 
   NetworkCm02Action *action = new NetworkCm02Action(this, size, failed);
index 2af42b8..468f33e 100644 (file)
@@ -48,7 +48,8 @@ static simgrid::kernel::routing::NetZoneImpl* routing_get_current()
 
 /** Module management function: creates all internal data structures */
 void sg_platf_init()
-{ /* Do nothing: just for symmetry of user code */
+{
+  simgrid::s4u::onPlatformCreated.connect(check_disk_attachment);
 }
 
 /** Module management function: frees all internal data structures */
index 237c72d..e1a0cd2 100644 (file)
@@ -17,7 +17,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage);
  *************/
 extern std::map<std::string, simgrid::surf::StorageType*> storage_types;
 
-static void check_disk_attachment()
+void check_disk_attachment()
 {
   for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
     simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->getImpl()->getHost().c_str());
@@ -29,12 +29,6 @@ static void check_disk_attachment()
   }
 }
 
-void storage_register_callbacks()
-{
-  simgrid::s4u::onPlatformCreated.connect(check_disk_attachment);
-  instr_routing_define_callbacks();
-}
-
 /*********
  * Model *
  *********/
index 375960c..fc2e885 100644 (file)
@@ -20,8 +20,7 @@ XBT_PRIVATE std::ifstream* surf_ifsopen(std::string name);
  */
 XBT_PRIVATE int __surf_is_absolute_file_path(const char* file_path);
 
-XBT_PUBLIC void storage_register_callbacks();
-
+XBT_PRIVATE void check_disk_attachment();
 XBT_PRIVATE void parse_after_config();
 
 #endif
index 3edce86..14767ed 100644 (file)
@@ -65,9 +65,6 @@ void parse_after_config() {
   if (not after_config_done) {
     TRACE_start();
 
-    /* Register classical callbacks */
-    storage_register_callbacks();
-
     after_config_done = 1;
   }
 }
index 594bedb..264f755 100755 (executable)
@@ -53,12 +53,15 @@ build_mode="$1"
 echo "Build mode $build_mode on $(uname -np)" >&2
 case "$build_mode" in
   "Debug")
+      INSTALL="/builds/simgrid_install"
   ;;
 
   "ModelChecker")
+      INSTALL="/builds/mc_simgrid_install"
   ;;
 
   "DynamicAnalysis")
+      INSTALL=""
   ;;
 
   *)
@@ -114,11 +117,6 @@ echo "XX Configure and build SimGrid"
 echo "XX   pwd: "$(pwd)
 echo "XX"
 set -x
-if [ "$build_mode" = "ModelChecker" ] ; then
-   INSTALL="-DCMAKE_INSTALL_PREFIX=/builds/mc_simgrid_install"
-elif [ "$build_mode" = "Debug" ] ; then
-   INSTALL="-DCMAKE_INSTALL_PREFIX=/builds/simgrid_install"
-fi
 
 if cmake --version | grep -q 3\.11 ; then
   # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
@@ -128,7 +126,7 @@ else
   MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
 fi
 
-cmake -G"$GENERATOR" $INSTALL \
+cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
   -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
@@ -156,13 +154,12 @@ if [ -f Testing/TAG ] ; then
    mv CTestResults.xml $WORKSPACE
 fi
 
-if test "$(uname)" != "Msys" && test "${build_mode}" = "Debug" -o "${build_mode}" = "ModelChecker" ; then
+if test -n "$INSTALL"; then
   echo "XX"
   echo "XX Test done. Install everything since it's a regular build, not on a Windows."
   echo "XX"
 
-  test "${build_mode}" = "Debug"        && rm -rf /builds/simgrid_install
-  test "${build_mode}" = "ModelChecker" && rm -rf /builds/mc_simgrid_install
+  rm -rf "$INSTALL"
 
   make install
 fi