Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
save some hidden calls to Engine::get_instance
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 20 Sep 2021 13:45:07 +0000 (15:45 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 20 Sep 2021 13:45:07 +0000 (15:45 +0200)
34 files changed:
examples/cpp/energy-wifi/s4u-energy-wifi.cpp
examples/cpp/network-wifi/s4u-network-wifi.cpp
src/surf/SplitDuplexLinkImpl_test.cpp
src/surf/sg_platf.cpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/mc/mutex-handling/mutex-handling.cpp
teshsuite/mc/random-bug/random-bug.cpp
teshsuite/models/cloud-sharing/cloud-sharing.cpp
teshsuite/models/cm02-set-lat-bw/cm02-set-lat-bw.cpp
teshsuite/models/ptask_L07_usage/ptask_L07_usage.cpp
teshsuite/models/wifi_usage/wifi_usage.cpp
teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp
teshsuite/s4u/actor-autorestart/actor-autorestart.cpp
teshsuite/s4u/actor-suspend/actor-suspend.cpp
teshsuite/s4u/actor/actor.cpp
teshsuite/s4u/basic-link-test/basic-link-test.cpp
teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp
teshsuite/s4u/cloud-interrupt-migration/cloud-interrupt-migration.cpp
teshsuite/s4u/cloud-two-execs/cloud-two-execs.cpp
teshsuite/s4u/comm-get-sender/comm-get-sender.cpp
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.cpp
teshsuite/s4u/host-on-off-actors/host-on-off-actors.cpp
teshsuite/s4u/host-on-off-recv/host-on-off-recv.cpp
teshsuite/s4u/host-on-off/host-on-off.cpp
teshsuite/s4u/listen_async/listen_async.cpp
teshsuite/s4u/pid/pid.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp
teshsuite/s4u/vm-live-migration/vm-live-migration.cpp
teshsuite/s4u/wait-all-for/wait-all-for.cpp
teshsuite/s4u/wait-any-for/wait-any-for.cpp
teshsuite/xbt/signals/signals.cpp

index a2d9a7e..b4f0983 100644 (file)
@@ -52,13 +52,13 @@ int main(int argc, char** argv)
   engine.load_platform(argv[1]);
 
   // setup WiFi bandwidths
-  const auto* l = simgrid::s4u::Link::by_name("AP1");
-  l->set_host_wifi_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
-  l->set_host_wifi_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
+  const auto* l = engine.link_by_name("AP1");
+  l->set_host_wifi_rate(engine.host_by_name("Station 1"), 0);
+  l->set_host_wifi_rate(engine.host_by_name("Station 2"), 0);
 
   // create the two actors for the test
-  simgrid::s4u::Actor::create("act0", simgrid::s4u::Host::by_name("Station 1"), sender);
-  simgrid::s4u::Actor::create("act1", simgrid::s4u::Host::by_name("Station 2"), receiver);
+  simgrid::s4u::Actor::create("act0", engine.host_by_name("Station 1"), sender);
+  simgrid::s4u::Actor::create("act1", engine.host_by_name("Station 2"), receiver);
 
   engine.run();
 
index 4ac5f12..8d30241 100644 (file)
@@ -41,7 +41,7 @@ int main(int argc, char* argv[])
   simgrid::s4u::Actor::create("receiver", station2, receiver, mailbox);
 
   /* Declare that the stations are not at the same distance from their AP */
-  auto ap = simgrid::s4u::Link::by_name("AP1");
+  auto ap = e.link_by_name("AP1");
   ap->set_host_wifi_rate(station1, 1); // The host "Station 1" uses the second level of bandwidths on that AP
   ap->set_host_wifi_rate(station2, 0); // This is perfectly useless as level 0 is used by default
 
index 8a2a928..b36ea8a 100644 (file)
@@ -20,9 +20,9 @@ TEST_CASE("SplitDuplexLink: create", "")
     simgrid::s4u::Link* link_down;
     simgrid::s4u::SplitDuplexLink* link;
     REQUIRE_NOTHROW(link = zone->create_split_duplex_link("link", "100GBps"));
-    REQUIRE(simgrid::s4u::SplitDuplexLink::by_name("link") == link);
-    REQUIRE_NOTHROW(link_up = simgrid::s4u::Link::by_name("link_UP"));
-    REQUIRE_NOTHROW(link_down = simgrid::s4u::Link::by_name("link_DOWN"));
+    REQUIRE(e.split_duplex_link_by_name("link") == link);
+    REQUIRE_NOTHROW(link_up = e.link_by_name("link_UP"));
+    REQUIRE_NOTHROW(link_down = e.link_by_name("link_DOWN"));
     REQUIRE(link_up->get_bandwidth() == 100e9);
     REQUIRE(link_down->get_bandwidth() == 100e9);
     REQUIRE(link_up == link->get_link_up());
index 0838631..712824e 100644 (file)
@@ -377,11 +377,12 @@ static void sg_platf_build_hostlink(simgrid::kernel::routing::StarZone* zone,
                                     const simgrid::kernel::routing::HostLinkCreationArgs* hostlink,
                                     const simgrid::s4u::Link* backbone)
 {
-  simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
+  const auto engine = simgrid::s4u::Engine::get_instance();
+  auto netpoint     = engine->host_by_name(hostlink->id)->get_netpoint();
   xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
 
-  const simgrid::s4u::Link* linkUp   = simgrid::s4u::Link::by_name_or_null(hostlink->link_up);
-  const simgrid::s4u::Link* linkDown = simgrid::s4u::Link::by_name_or_null(hostlink->link_down);
+  const auto linkUp   = engine->link_by_name_or_null(hostlink->link_up);
+  const auto linkDown = engine->link_by_name_or_null(hostlink->link_down);
 
   xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str());
   xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str());
index 2576e49..674d7f5 100644 (file)
@@ -3,11 +3,12 @@
 /* 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 "surf/surf.hpp"
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/network_interface.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/xml/platf_private.hpp"
+#include "surf/surf.hpp"
+#include <simgrid/s4u/Engine.hpp>
 
 #include <vector>
 
@@ -100,12 +101,15 @@ void parse_platform_file(const std::string& file)
   /* Do the actual parsing */
   surf_parse();
 
+  /* Get the Engine singleton once and for all*/
+  const auto engine = simgrid::s4u::Engine::get_instance();
+
   /* connect all profiles relative to hosts */
   for (auto const& elm : trace_connect_list_host_avail) {
     surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"HOST_AVAIL\">: Trace ")+elm.first+" undefined.");
     auto profile = traces_set_list.at(elm.first);
 
-    auto host = simgrid::s4u::Host::by_name_or_null(elm.second);
+    auto host = engine->host_by_name_or_null(elm.second);
     surf_parse_assert(host, std::string("<trace_connect kind=\"HOST_AVAIL\">: Host ") + elm.second + " undefined.");
     host->set_state_profile(profile);
   }
@@ -114,7 +118,7 @@ void parse_platform_file(const std::string& file)
     surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"SPEED\">: Trace ")+elm.first+" undefined.");
     auto profile = traces_set_list.at(elm.first);
 
-    auto host = simgrid::s4u::Host::by_name_or_null(elm.second);
+    auto host = engine->host_by_name_or_null(elm.second);
     surf_parse_assert(host, std::string("<trace_connect kind=\"SPEED\">: Host ") + elm.second + " undefined.");
     host->set_speed_profile(profile);
   }
@@ -123,7 +127,7 @@ void parse_platform_file(const std::string& file)
     surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LINK_AVAIL\">: Trace ")+elm.first+" undefined.");
     auto profile = traces_set_list.at(elm.first);
 
-    auto link = simgrid::s4u::Link::by_name_or_null(elm.second);
+    auto link = engine->link_by_name_or_null(elm.second);
     surf_parse_assert(link, std::string("<trace_connect kind=\"LINK_AVAIL\">: Link ") + elm.second + " undefined.");
     link->set_state_profile(profile);
   }
@@ -132,7 +136,7 @@ void parse_platform_file(const std::string& file)
     surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"BANDWIDTH\">: Trace ")+elm.first+" undefined.");
     auto profile = traces_set_list.at(elm.first);
 
-    auto link = simgrid::s4u::Link::by_name_or_null(elm.second);
+    auto link = engine->link_by_name_or_null(elm.second);
     surf_parse_assert(link, std::string("<trace_connect kind=\"BANDWIDTH\">: Link ") + elm.second + " undefined.");
     link->set_bandwidth_profile(profile);
   }
@@ -141,7 +145,7 @@ void parse_platform_file(const std::string& file)
     surf_parse_assert(traces_set_list.find(elm.first) != traces_set_list.end(), std::string("<trace_connect kind=\"LATENCY\">: Trace ")+elm.first+" undefined.");
     auto profile = traces_set_list.at(elm.first);
 
-    auto link = simgrid::s4u::Link::by_name_or_null(elm.second);
+    auto link = engine->link_by_name_or_null(elm.second);
     surf_parse_assert(link, std::string("<trace_connect kind=\"LATENCY\">: Link ") + elm.second + " undefined.");
     link->set_latency_profile(profile);
   }
index 62947af..1ebfbd1 100644 (file)
@@ -481,19 +481,20 @@ void ETag_surfxml_link(){
 
 void STag_surfxml_link___ctn()
 {
+  const auto engine = simgrid::s4u::Engine::get_instance();
   const simgrid::s4u::Link* link;
   simgrid::s4u::LinkInRoute::Direction direction = simgrid::s4u::LinkInRoute::Direction::NONE;
   switch (A_surfxml_link___ctn_direction) {
   case AU_surfxml_link___ctn_direction:
   case A_surfxml_link___ctn_direction_NONE:
-    link = simgrid::s4u::Link::by_name(std::string(A_surfxml_link___ctn_id));
+    link = engine->link_by_name(std::string(A_surfxml_link___ctn_id));
     break;
   case A_surfxml_link___ctn_direction_UP:
-    link      = simgrid::s4u::SplitDuplexLink::by_name(std::string(A_surfxml_link___ctn_id));
+    link      = engine->split_duplex_link_by_name(std::string(A_surfxml_link___ctn_id));
     direction = simgrid::s4u::LinkInRoute::Direction::UP;
     break;
   case A_surfxml_link___ctn_direction_DOWN:
-    link      = simgrid::s4u::SplitDuplexLink::by_name(std::string(A_surfxml_link___ctn_id));
+    link      = engine->split_duplex_link_by_name(std::string(A_surfxml_link___ctn_id));
     direction = simgrid::s4u::LinkInRoute::Direction::DOWN;
     break;
   default:
index 243763b..236c5f3 100644 (file)
@@ -69,12 +69,12 @@ int main(int argc, char* argv[])
 #endif
 
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Jupiter"), receiver, "box");
-  simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Boivin"), sender, "box", mutex, 1);
-  simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Fafard"), sender, "box", mutex, 2);
+  simgrid::s4u::Actor::create("receiver", e.host_by_name("Jupiter"), receiver, "box");
+  simgrid::s4u::Actor::create("sender", e.host_by_name("Boivin"), sender, "box", mutex, 1);
+  simgrid::s4u::Actor::create("sender", e.host_by_name("Fafard"), sender, "box", mutex, 2);
 
   e.run();
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 2374cae..a4b2c06 100644 (file)
@@ -64,6 +64,6 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[2]);
 
-  simgrid::s4u::Actor::create("app", simgrid::s4u::Host::by_name("Fafard"), &app);
+  simgrid::s4u::Actor::create("app", e.host_by_name("Fafard"), &app);
   e.run();
 }
index 2b14c9d..49784b7 100644 (file)
@@ -588,7 +588,7 @@ int main(int argc, char* argv[])
     platform = argv[1];
   e.load_platform(platform);
 
-  simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
+  simgrid::s4u::Host* pm0 = e.host_by_name("node-0.1core.org");
   xbt_assert(pm0, "Host 'node-0.1core.org' not found");
   simgrid::s4u::Actor::create("master", pm0, master_main);
 
index 399fe99..cb19cdf 100644 (file)
@@ -96,9 +96,9 @@ int main(int argc, char** argv)
 {
   sg4::Engine e(&argc, argv);
   /* keep it simple, no network factors nor crosstrafic */
-  simgrid::s4u::Engine::set_config("network/model:CM02");
-  simgrid::s4u::Engine::set_config("network/weight-S:20537");
-  simgrid::s4u::Engine::set_config("network/crosstraffic:0");
+  e.set_config("network/model:CM02");
+  e.set_config("network/weight-S:20537");
+  e.set_config("network/crosstraffic:0");
 
   /* dog-bone platform */
   std::unordered_map<std::string, sg4::Host*> hosts;
index 25e4b78..6901c46 100644 (file)
@@ -23,9 +23,9 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to compute 1 flop on a 1 flop/s host.");
   XBT_INFO("Should be done in exactly one second.");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Exec::init()->set_flops_amount(1)->set_host(hosts[0])->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: computing 1 flop at 1 flop/s takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -35,12 +35,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to compute 2 x 1 flop on a 1 flop/s host.");
   XBT_INFO("Should be done in exactly 2 seconds because of sharing.");
-  start_time      = sg4::Engine::get_clock();
+  start_time      = e->get_clock();
   sg4::ExecPtr e1 = sg4::Exec::init()->set_flops_amount(1)->set_host(hosts[0])->start();
   sg4::ExecPtr e2 = sg4::Exec::init()->set_flops_amount(1)->set_host(hosts[0])->start();
   e1->wait();
   e2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: computing 2x1 flop at 1 flop/s takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -50,12 +50,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to compute 2 flops across two hosts running at 1 flop/s.");
   XBT_INFO("Should be done in exactly one second.");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Exec::init()
       ->set_flops_amounts(std::vector<double>({1.0, 1.0}))
       ->set_hosts(std::vector<sg4::Host*>({hosts[0], hosts[1]}))
       ->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: computing 2 flops on 2 hosts at 1 flop/s takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -65,12 +65,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to compute 2 flops across two hosts, one running at 1 flop/s and one at 2 flop/s.");
   XBT_INFO("Should be done in exactly one second.");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Exec::init()
       ->set_flops_amounts(std::vector<double>({1.0, 1.0}))
       ->set_hosts(std::vector<sg4::Host*>({hosts[0], hosts[5]}))
       ->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: computing 2 flops on 2 heterogeneous hosts takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -80,9 +80,9 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 1B from one host to another at 1Bps with a latency of 500ms.");
   XBT_INFO("Should be done in 1.5 seconds (500ms latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Comm::sendto_async(hosts[0], hosts[4], 1.0)->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte on a shared link at 1Bps + 500ms takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -92,9 +92,9 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 1B from one host to another at 1Bps with a latency of 500ms.");
   XBT_INFO("Should be done in 1.5 seconds (500ms latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Comm::sendto_async(hosts[0], hosts[5], 1.0)->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte on a fatpipe link at 1Bps + 500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -105,9 +105,9 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 1B from one host to another at 1Bps with a latency of 2 x 500ms + 1s.");
   XBT_INFO("Should be done in 3 seconds (2 x 500ms + 1s latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Comm::sendto_async(hosts[0], hosts[1], 1.0)->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte on a 3-link route at 1Bps + 2,500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -119,9 +119,9 @@ static void main_dispatcher()
   XBT_INFO("Have to send 1B from one host to another on a link at 2Bps with a latency of 2 x 1024^2s.");
   XBT_INFO("This latency is half the default TCP window size (4MiB). This limits the bandwidth to 1B");
   XBT_INFO("Should be done in 2 x 1024^2s + 1 seconds (large latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Comm::sendto_async(hosts[0], hosts[6], 1.0)->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte on a large latency link takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -131,12 +131,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 2 x 1B from one host to another at 1Bps with a latency of 500ms.");
   XBT_INFO("Should be done in 2.5 seconds (500ms latency + 2s transfert).");
-  start_time      = sg4::Engine::get_clock();
+  start_time      = e->get_clock();
   sg4::CommPtr c1 = sg4::Comm::sendto_async(hosts[0], hosts[4], 1.0);
   sg4::CommPtr c2 = sg4::Comm::sendto_async(hosts[0], hosts[4], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 2x1 bytes on a shared link at 1Bps + 500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -147,12 +147,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 2 x 1B from one host to another at 1Bps with a latency of 500ms.");
   XBT_INFO("Should be done in 1.5 seconds (500ms latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[5], 1.0);
   c2         = sg4::Comm::sendto_async(hosts[0], hosts[5], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 2x1 bytes on a fatpipe link at 1Bps + 500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -163,12 +163,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 2 x 1B from one host to another at 1Bps with a latency of 2 x 500ms + 1s.");
   XBT_INFO("Should be done in 4 seconds (2 x 500ms + 1s latency + 2s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[1], 1.0);
   c2         = sg4::Comm::sendto_async(hosts[0], hosts[1], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 2x1 bytes on a 3-link route at 1Bps + 2,500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -179,12 +179,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 1B between two hosts in each direction at 1Bps with a latency of 500ms.");
   XBT_INFO("Should be done in 2.5 seconds (500ms latency + 2s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[4], 1.0);
   c2         = sg4::Comm::sendto_async(hosts[4], hosts[0], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte in both directions on a shared link at 1Bps + 500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -195,12 +195,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 1B between two hosts in each direction at 1Bps with a latency of 500ms.");
   XBT_INFO("Should be done in 1.5 seconds (500ms latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[5], 1.0);
   c2         = sg4::Comm::sendto_async(hosts[5], hosts[0], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte in both directions on a fatpipe link at 1Bps + 500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -211,12 +211,12 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("Have to send 1B between two hosts in each direction at 1Bps with a latency of 2 x 500ms + 1s.");
   XBT_INFO("Should be done in 4 seconds (2 x 500ms + 1s latency + 2s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[1], 1.0);
   c2         = sg4::Comm::sendto_async(hosts[1], hosts[0], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 1 byte in both directions on a 3-link route at 1Bps + 2,500ms takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -227,7 +227,7 @@ static void main_dispatcher()
   XBT_INFO("------------------------------------------------------------");
   XBT_INFO("'cpu0' sends 1B to 'cpu1' and 'cpu2' sends 1B to 'cpu3'. The only shared link is the fatpipe switch.");
   XBT_INFO("Should be done in 3 seconds (2 x 500ms + 1s latency + 1s transfert).");
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Exec::init()
       ->set_bytes_amounts(std::vector<double>({0.0, 1.0, 0.0, 0.0,
                                                0.0, 0.0, 0.0, 0.0,
@@ -235,7 +235,7 @@ static void main_dispatcher()
                                                0.0, 0.0, 0.0, 0.0 }))
       ->set_hosts(std::vector<sg4::Host*>({hosts[0], hosts[1], hosts[2], hosts[3]}))
       ->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: sending 2 x 1 byte in a parallel communication without interference takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -250,7 +250,7 @@ static void main_dispatcher()
   XBT_INFO(" - For 2 seconds, two lows share a link to transfer 1 x 1B. 'cpu2' received is payload");
   XBT_INFO(" - For 1 second, one flow has the full bandwidth to transfer 1B. 'cpu3' received is payload");
 
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Exec::init()
       ->set_bytes_amounts(std::vector<double>({0.0, 1.0, 2.0, 3.0,
                                                0.0, 0.0, 0.0, 0.0,
@@ -258,7 +258,7 @@ static void main_dispatcher()
                                                0.0, 0.0, 0.0, 0.0 }))
       ->set_hosts(std::vector<sg4::Host*>({hosts[0], hosts[1], hosts[2], hosts[3]}))
       ->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: scattering an increasing number of bytes to 3 hosts takes %.2f seconds.",
            end_time - start_time);
   XBT_INFO("\n");
@@ -272,7 +272,7 @@ static void main_dispatcher()
   XBT_INFO("Each SHARED link is traversed by 6 flows (3 in and 3 out). ");
   XBT_INFO("Each 1B transfer thus takes 6 seconds on a 1Bps link");
 
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   sg4::Exec::init()
       ->set_bytes_amounts(std::vector<double>({0.0, 1.0, 1.0, 1.0,
                                                1.0, 0.0, 1.0, 1.0,
@@ -280,7 +280,7 @@ static void main_dispatcher()
                                                1.0, 1.0, 1.0, 0.0 }))
       ->set_hosts(std::vector<sg4::Host*>({hosts[0], hosts[1], hosts[2], hosts[3]}))
       ->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: 1-byte all-too-all in a parallel communication takes %.2f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -293,12 +293,12 @@ static void main_dispatcher()
   XBT_INFO("The small communication has a negligible impact on the large one.");
   XBT_INFO("This corresponds to paying latency once and having the full bandwidth for the large communication.");
 
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[7], 1e8);
   c2         = sg4::Comm::sendto_async(hosts[0], hosts[7], 1.0);
   c1->wait();
   c2->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: 1 small and 1 large concurrent communications take %.4f seconds.", end_time - start_time);
   XBT_INFO("\n");
 
@@ -311,12 +311,12 @@ static void main_dispatcher()
   XBT_INFO("The two activities should overlap smoothly as they use different resources.");
   XBT_INFO("The completion time is thus the maximum of the time to complete the two activities.");
 
-  start_time = sg4::Engine::get_clock();
+  start_time = e->get_clock();
   c1         = sg4::Comm::sendto_async(hosts[0], hosts[4], 1.0);
   e1         = sg4::Exec::init()->set_flops_amount(2.0)->set_host(hosts[4])->start();
   e1->wait();
   c1->wait();
-  end_time = sg4::Engine::get_clock();
+  end_time = e->get_clock();
   XBT_INFO("Actual result: Sending 1B while computing 2 flops takes %.4f seconds.", end_time - start_time);
   XBT_INFO("\n");
 }
@@ -325,7 +325,7 @@ int main(int argc, char** argv)
 {
   sg4::Engine engine(&argc, argv);
   engine.load_platform(argv[1]);
-  sg4::Actor::create("dispatcher", sg4::Host::by_name("cpu0"), main_dispatcher);
+  sg4::Actor::create("dispatcher", engine.host_by_name("cpu0"), main_dispatcher);
   engine.run();
 
   return 0;
index 619319f..04f093a 100644 (file)
@@ -49,11 +49,12 @@ static void main_dispatcher()
   }
   run_ping_test("Station 1", "Station 2", 1000);
 }
+
 int main(int argc, char** argv)
 {
   simgrid::s4u::Engine engine(&argc, argv);
   engine.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("dispatcher", simgrid::s4u::Host::by_name("node1"), main_dispatcher);
+  simgrid::s4u::Actor::create("dispatcher", engine.host_by_name("node1"), main_dispatcher);
   engine.run();
 
   return 0;
index 6525f73..8abfa03 100644 (file)
@@ -57,7 +57,7 @@ int main(int argc, char** argv)
 {
   simgrid::s4u::Engine engine(&argc, argv);
   engine.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("dispatcher", simgrid::s4u::Host::by_name("node1"), main_dispatcher);
+  simgrid::s4u::Actor::create("dispatcher", engine.host_by_name("node1"), main_dispatcher);
   engine.run();
 
   return 0;
index 6a86b41..65a5464 100644 (file)
@@ -56,10 +56,10 @@ int main(int argc, char* argv[])
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("Autostart", simgrid::s4u::Host::by_name("Tremblay"), autostart);
+  simgrid::s4u::Actor::create("Autostart", e.host_by_name("Tremblay"), autostart);
 
   e.run();
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 167313e..657b2fc 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
   simgrid::s4u::Engine engine(&argc, argv);
 
   engine.load_platform(argv[1]);
-  simgrid::s4u::Host* host = simgrid::s4u::Host::by_name("Tremblay");
+  simgrid::s4u::Host* host = engine.host_by_name("Tremblay");
 
   simgrid::s4u::Actor::create("Suspender", host, Suspender());
   receiver = simgrid::s4u::Actor::create("Receiver", host, Receiver());
index eafecfe..0bbc753 100644 (file)
@@ -56,11 +56,11 @@ int main(int argc, char* argv[])
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master);
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker);
 
   e.run();
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 9050174..e305da4 100644 (file)
@@ -19,7 +19,7 @@ int main(int argc, char** argv)
   /* creation of the environment */
   e.load_platform(argv[1]);
 
-  std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::get_instance()->get_all_links();
+  std::vector<simgrid::s4u::Link*> links = e.get_all_links();
   XBT_INFO("Link count: %zu", links.size());
 
   std::sort(links.begin(), links.end(), [](const simgrid::s4u::Link* a, const simgrid::s4u::Link* b) {
index e7c59e6..442faf3 100644 (file)
@@ -72,7 +72,7 @@ int main(int argc, char** argv)
     if (strcmp(argv[2], "FULL_LINK") == 0)
       test_full_link(hosts);
     if (strcmp(argv[2], "PROP") == 0)
-      XBT_INFO("SG_TEST_mem: %s", sg4::Host::by_name("host1")->get_property("SG_TEST_mem"));
+      XBT_INFO("SG_TEST_mem: %s", e.host_by_name("host1")->get_property("SG_TEST_mem"));
   }
 
   return 0;
index 6b52c4e..019b100 100644 (file)
@@ -61,11 +61,11 @@ int main(int argc, char* argv[])
   /* load the platform file */
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master_", simgrid::s4u::Host::by_name("Fafard"), master_main);
+  simgrid::s4u::Actor::create("master_", e.host_by_name("Fafard"), master_main);
 
   e.run();
 
-  XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Bye (simulation time %g)", e.get_clock());
 
   return 0;
 }
index 495453e..2114719 100644 (file)
@@ -55,10 +55,10 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master_", simgrid::s4u::Host::by_name("Fafard"), master_main);
+  simgrid::s4u::Actor::create("master_", e.host_by_name("Fafard"), master_main);
 
   e.run();
-  XBT_INFO("Bye (simulation time %g)", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Bye (simulation time %g)", e.get_clock());
 
   return 0;
 }
index 081b14a..a4b320c 100644 (file)
@@ -36,8 +36,8 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("send", simgrid::s4u::Host::by_name("Tremblay"), sender_fun);
-  simgrid::s4u::Actor::create("receive", simgrid::s4u::Host::by_name("Tremblay"), receiver_fun);
+  simgrid::s4u::Actor::create("send", e.host_by_name("Tremblay"), sender_fun);
+  simgrid::s4u::Actor::create("receive", e.host_by_name("Tremblay"), receiver_fun);
 
   e.run();
   return 0;
index 6fbc607..5ccfa0c 100644 (file)
@@ -186,7 +186,7 @@ int main(int argc, char* argv[])
   simgrid::s4u::Actor::create("recver", hosts[1], receiver, argRecv);
 
   e.run();
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 54aaf3a..d86661d 100644 (file)
@@ -35,10 +35,10 @@ int main(int argc, char** argv)
   e.load_platform(argv[1]);
 
   for (int i = 0; i < 5; i++)
-    sg4::Actor::create("host", sg4::Host::by_name("bob"), host);
+    sg4::Actor::create("host", e.host_by_name("bob"), host);
 
   e.run();
-  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 07ad10d..468c98f 100644 (file)
@@ -102,12 +102,12 @@ int main(int argc, char* argv[])
       ->seal();
   zone->seal();
 
-  sg4::Actor::create("carol", simgrid::s4u::Host::by_name("carol"), worker);
-  sg4::Actor::create("erin", simgrid::s4u::Host::by_name("erin"), failed_worker)->set_auto_restart(true);
+  sg4::Actor::create("carol", e.host_by_name("carol"), worker);
+  sg4::Actor::create("erin", e.host_by_name("erin"), failed_worker)->set_auto_restart(true);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index a94afdc..e5ad474 100644 (file)
@@ -159,12 +159,11 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("test_launcher", simgrid::s4u::Host::by_name("Tremblay"), test_launcher,
-                              std::stoi(argv[2]));
+  simgrid::s4u::Actor::create("test_launcher", e.host_by_name("Tremblay"), test_launcher, std::stoi(argv[2]));
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 08641ef..19de43d 100644 (file)
@@ -56,12 +56,12 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master);
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker);
+  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Jupiter"), worker);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index e4610d6..860df76 100644 (file)
@@ -94,12 +94,12 @@ int main(int argc, char* argv[])
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master);
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker);
+  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Jupiter"), worker);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", e.get_clock());
 
   return 0;
 }
index 3f83ca8..fd6effa 100644 (file)
@@ -49,7 +49,7 @@ int main(int argc, char* argv[])
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("Tremblay"), server);
+  simgrid::s4u::Actor::create("test", e.host_by_name("Tremblay"), server);
 
   e.run();
 
index 7c2c7c0..053209f 100644 (file)
@@ -38,10 +38,10 @@ int main(int argc, char* argv[])
 
   simgrid::s4u::Actor::kill_all();
 
-  simgrid::s4u::Actor::create("sendpid", simgrid::s4u::Host::by_name("Tremblay"), sendpid);
-  simgrid::s4u::Actor::create("sendpid", simgrid::s4u::Host::by_name("Tremblay"), sendpid);
-  simgrid::s4u::Actor::create("sendpid", simgrid::s4u::Host::by_name("Tremblay"), sendpid);
-  simgrid::s4u::Actor::create("killall", simgrid::s4u::Host::by_name("Tremblay"), killall);
+  simgrid::s4u::Actor::create("sendpid", e.host_by_name("Tremblay"), sendpid);
+  simgrid::s4u::Actor::create("sendpid", e.host_by_name("Tremblay"), sendpid);
+  simgrid::s4u::Actor::create("sendpid", e.host_by_name("Tremblay"), sendpid);
+  simgrid::s4u::Actor::create("killall", e.host_by_name("Tremblay"), killall);
 
   e.run();
 
index 30eec58..8c1f927 100644 (file)
@@ -149,11 +149,11 @@ int main(int argc, char* argv[])
   xbt_assert(argc == 2, "Usage: %s platform_file\n", argv[0]);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("server", simgrid::s4u::Host::by_name("alice"), server);
-  simgrid::s4u::Actor::create("client", simgrid::s4u::Host::by_name("bob"), client);
+  simgrid::s4u::Actor::create("server", e.host_by_name("alice"), server);
+  simgrid::s4u::Actor::create("client", e.host_by_name("bob"), client);
 
   e.run();
 
-  XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulated time: %g", e.get_clock());
   return 0;
 }
index 3352418..613852e 100644 (file)
@@ -28,7 +28,7 @@ static void task_executor()
 int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
-  simgrid::s4u::Engine::set_config("network/model:CM02"); // Much less realistic, but easier to compute manually
+  e.set_config("network/model:CM02"); // Much less realistic, but easier to compute manually
 
   sg_vm_live_migration_plugin_init();
   sg_host_energy_plugin_init();
@@ -36,7 +36,7 @@ int main(int argc, char* argv[])
   xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]);
 
   e.load_platform(argv[1]);
-  auto* pm = simgrid::s4u::Host::by_name("host1");
+  auto* pm = e.host_by_name("host1");
   auto* vm = new simgrid::s4u::VirtualMachine("VM0", pm, 1 /*nCores*/);
   vm->set_ramsize(1250000000)->start();
   simgrid::s4u::Actor::create("executor", vm, task_executor);
index f8ca85d..ee84b72 100644 (file)
@@ -47,7 +47,7 @@ int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker);
   e.run();
   return 0;
 }
index 9438f45..b10b4ff 100644 (file)
@@ -49,7 +49,7 @@ int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker);
   e.run();
   return 0;
 }
index 7effa0e..9191d8a 100644 (file)
@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker);
 
   e.run();