Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the sg4 namespace in all examples
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 6 Mar 2022 20:24:11 +0000 (21:24 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 6 Mar 2022 21:43:11 +0000 (22:43 +0100)
71 files changed:
examples/cpp/app-bittorrent/s4u-bittorrent.cpp
examples/cpp/app-bittorrent/s4u-peer.cpp
examples/cpp/app-bittorrent/s4u-tracker.cpp
examples/cpp/app-chainsend/s4u-app-chainsend.cpp
examples/cpp/app-masterworkers/s4u-app-masterworkers-class.cpp
examples/cpp/app-masterworkers/s4u-app-masterworkers-fun.cpp
examples/cpp/app-token-ring/s4u-app-token-ring.cpp
examples/cpp/cloud-capping/s4u-cloud-capping.cpp
examples/cpp/cloud-migration/s4u-cloud-migration.cpp
examples/cpp/cloud-simple/s4u-cloud-simple.cpp
examples/cpp/comm-failure/s4u-comm-failure.cpp
examples/cpp/dag-comm/s4u-dag-comm.cpp
examples/cpp/dag-failure/s4u-dag-failure.cpp
examples/cpp/dag-from-dax/s4u-dag-from-dax.cpp
examples/cpp/dag-from-dot/s4u-dag-from-dot.cpp
examples/cpp/dag-io/s4u-dag-io.cpp
examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp
examples/cpp/dag-simple/s4u-dag-simple.cpp
examples/cpp/dht-chord/s4u-dht-chord-node.cpp
examples/cpp/dht-chord/s4u-dht-chord.hpp
examples/cpp/dht-kademlia/node.cpp
examples/cpp/dht-kademlia/s4u-dht-kademlia.cpp
examples/cpp/energy-boot/s4u-energy-boot.cpp
examples/cpp/energy-exec-ptask/s4u-energy-exec-ptask.cpp
examples/cpp/energy-exec/s4u-energy-exec.cpp
examples/cpp/energy-link/s4u-energy-link.cpp
examples/cpp/energy-vm/s4u-energy-vm.cpp
examples/cpp/energy-wifi/s4u-energy-wifi.cpp
examples/cpp/engine-filtering/s4u-engine-filtering.cpp
examples/cpp/engine-run-partial/s4u-engine-run-partial.cpp
examples/cpp/exec-async/s4u-exec-async.cpp
examples/cpp/exec-basic/s4u-exec-basic.cpp
examples/cpp/exec-dependent/s4u-exec-dependent.cpp
examples/cpp/exec-dvfs/s4u-exec-dvfs.cpp
examples/cpp/exec-failure/s4u-exec-failure.cpp
examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore.cpp
examples/cpp/exec-ptask/s4u-exec-ptask.cpp
examples/cpp/exec-remote/s4u-exec-remote.cpp
examples/cpp/exec-unassigned/s4u-exec-unassigned.cpp
examples/cpp/exec-waitany/s4u-exec-waitany.cpp
examples/cpp/exec-waitfor/s4u-exec-waitfor.cpp
examples/cpp/io-async/s4u-io-async.cpp
examples/cpp/io-degradation/s4u-io-degradation.cpp
examples/cpp/io-dependent/s4u-io-dependent.cpp
examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp
examples/cpp/io-file-remote/s4u-io-file-remote.cpp
examples/cpp/io-file-system/s4u-io-file-system.cpp
examples/cpp/io-priority/s4u-io-priority.cpp
examples/cpp/maestro-set/s4u-maestro-set.cpp
examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp
examples/cpp/mc-bugged1/s4u-mc-bugged1.cpp
examples/cpp/mc-bugged2-liveness/s4u-mc-bugged2-liveness.cpp
examples/cpp/mc-centralized-mutex/s4u-mc-centralized-mutex.cpp
examples/cpp/mc-failing-assert/s4u-mc-failing-assert.cpp
examples/cpp/network-ns3-wifi/s4u-network-ns3-wifi.cpp
examples/cpp/network-ns3/s4u-network-ns3.cpp
examples/cpp/network-wifi/s4u-network-wifi.cpp
examples/cpp/platform-profile/s4u-platform-profile.cpp
examples/cpp/plugin-host-load/s4u-plugin-host-load.cpp
examples/cpp/plugin-link-load/s4u-plugin-link-load.cpp
examples/cpp/replay-comm/s4u-replay-comm.cpp
examples/cpp/replay-io/s4u-replay-io.cpp
examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp
examples/cpp/synchro-barrier/s4u-synchro-barrier.cpp
examples/cpp/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp
examples/cpp/synchro-condition-variable/s4u-synchro-condition-variable.cpp
examples/cpp/trace-categories/s4u-trace-categories.cpp
examples/cpp/trace-host-user-variables/s4u-trace-host-user-variables.cpp
examples/cpp/trace-link-user-variables/s4u-trace-link-user-variables.cpp
examples/cpp/trace-masterworkers/s4u-trace-masterworkers.cpp
examples/cpp/trace-route-user-variables/s4u-trace-route-user-variables.cpp

index b647e8e..216ebea 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2022. 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. */
index 7de17e9..a2169a1 100644 (file)
@@ -11,6 +11,7 @@
 #include "s4u-tracker.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_peer, "Messages specific for the peers");
+namespace sg4 = simgrid::s4u;
 
 /*
  * User parameters for transferred file data. For the test, the default values are :
@@ -58,7 +59,7 @@ Peer::Peer(std::vector<std::string> args)
   xbt_assert(args.size() == 3 || args.size() == 4, "Wrong number of arguments");
   try {
     id       = std::stoi(args[1]);
-    mailbox_ = simgrid::s4u::Mailbox::by_name(std::to_string(id));
+    mailbox_ = sg4::Mailbox::by_name(std::to_string(id));
   } catch (const std::invalid_argument&) {
     throw std::invalid_argument("Invalid ID:" + args[1]);
   }
@@ -86,8 +87,8 @@ void Peer::operator()()
   // Getting peer data from the tracker.
   if (getPeersFromTracker()) {
     XBT_DEBUG("Got %zu peers from the tracker. Current status is: %s", connected_peers.size(), getStatus().c_str());
-    begin_receive_time = simgrid::s4u::Engine::get_clock();
-    mailbox_->set_receiver(simgrid::s4u::Actor::self());
+    begin_receive_time = sg4::Engine::get_clock();
+    mailbox_->set_receiver(sg4::Actor::self());
     if (hasFinished()) {
       sendHandshakeToAllPeers();
     } else {
@@ -103,7 +104,7 @@ void Peer::operator()()
 
 bool Peer::getPeersFromTracker()
 {
-  simgrid::s4u::Mailbox* tracker_mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX);
+  sg4::Mailbox* tracker_mailbox = sg4::Mailbox::by_name(TRACKER_MAILBOX);
   // Build the task to send to the tracker
   auto* peer_request = new TrackerQuery(id, mailbox_);
   try {
@@ -138,13 +139,13 @@ void Peer::sendHandshakeToAllPeers()
   }
 }
 
-void Peer::sendMessage(simgrid::s4u::Mailbox* mailbox, MessageType type, uint64_t size)
+void Peer::sendMessage(sg4::Mailbox* mailbox, MessageType type, uint64_t size)
 {
   XBT_DEBUG("Sending %s to %s", message_name(type), mailbox->get_cname());
   mailbox->put_init(new Message(type, id, bitfield_, mailbox_), size)->detach();
 }
 
-void Peer::sendBitfield(simgrid::s4u::Mailbox* mailbox)
+void Peer::sendBitfield(sg4::Mailbox* mailbox)
 {
   XBT_DEBUG("Sending a BITFIELD to %s", mailbox->get_cname());
   mailbox
@@ -153,7 +154,7 @@ void Peer::sendBitfield(simgrid::s4u::Mailbox* mailbox)
       ->detach();
 }
 
-void Peer::sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int block_index, int block_length)
+void Peer::sendPiece(sg4::Mailbox* mailbox, unsigned int piece, int block_index, int block_length)
 {
   xbt_assert(not hasNotPiece(piece), "Tried to send a unavailable piece.");
   XBT_DEBUG("Sending the PIECE %u (%d,%d) to %s", piece, block_index, block_length, mailbox->get_cname());
@@ -240,14 +241,14 @@ int Peer::nbInterestedPeers() const
 
 void Peer::leech()
 {
-  double next_choked_update = simgrid::s4u::Engine::get_clock() + UPDATE_CHOKED_INTERVAL;
+  double next_choked_update = sg4::Engine::get_clock() + UPDATE_CHOKED_INTERVAL;
   XBT_DEBUG("Start downloading.");
 
   /* Send a "handshake" message to all the peers it got (since it couldn't have gotten more than 50 peers) */
   sendHandshakeToAllPeers();
   XBT_DEBUG("Starting main leech loop listening on mailbox: %s", mailbox_->get_cname());
 
-  while (simgrid::s4u::Engine::get_clock() < deadline && countPieces(bitfield_) < FILE_PIECES) {
+  while (sg4::Engine::get_clock() < deadline && countPieces(bitfield_) < FILE_PIECES) {
     if (comm_received == nullptr) {
       comm_received = mailbox_->get_async<Message>(&message);
     }
@@ -257,11 +258,11 @@ void Peer::leech()
       comm_received = nullptr;
     } else {
       // We don't execute the choke algorithm if we don't already have a piece
-      if (simgrid::s4u::Engine::get_clock() >= next_choked_update && countPieces(bitfield_) > 0) {
+      if (sg4::Engine::get_clock() >= next_choked_update && countPieces(bitfield_) > 0) {
         updateChokedPeers();
         next_choked_update += UPDATE_CHOKED_INTERVAL;
       } else {
-        simgrid::s4u::this_actor::sleep_for(SLEEP_DURATION);
+        sg4::this_actor::sleep_for(SLEEP_DURATION);
       }
     }
   }
@@ -271,10 +272,10 @@ void Peer::leech()
 
 void Peer::seed()
 {
-  double next_choked_update = simgrid::s4u::Engine::get_clock() + UPDATE_CHOKED_INTERVAL;
+  double next_choked_update = sg4::Engine::get_clock() + UPDATE_CHOKED_INTERVAL;
   XBT_DEBUG("Start seeding.");
   // start the main seed loop
-  while (simgrid::s4u::Engine::get_clock() < deadline) {
+  while (sg4::Engine::get_clock() < deadline) {
     if (comm_received == nullptr) {
       comm_received = mailbox_->get_async<Message>(&message);
     }
@@ -283,12 +284,12 @@ void Peer::seed()
       delete message;
       comm_received = nullptr;
     } else {
-      if (simgrid::s4u::Engine::get_clock() >= next_choked_update) {
+      if (sg4::Engine::get_clock() >= next_choked_update) {
         updateChokedPeers();
         // TODO: Change the choked peer algorithm when seeding.
         next_choked_update += UPDATE_CHOKED_INTERVAL;
       } else {
-        simgrid::s4u::this_actor::sleep_for(SLEEP_DURATION);
+        sg4::this_actor::sleep_for(SLEEP_DURATION);
       }
     }
   }
@@ -418,9 +419,9 @@ void Peer::handleMessage()
   }
   // Update the peer speed.
   if (remote_peer) {
-    remote_peer->addSpeedValue(1.0 / (simgrid::s4u::Engine::get_clock() - begin_receive_time));
+    remote_peer->addSpeedValue(1.0 / (sg4::Engine::get_clock() - begin_receive_time));
   }
-  begin_receive_time = simgrid::s4u::Engine::get_clock();
+  begin_receive_time = sg4::Engine::get_clock();
 }
 
 /** Selects the appropriate piece to download and requests it to the remote_peer */
@@ -556,7 +557,7 @@ void Peer::updateChokedPeers()
 
   /**If we are currently seeding, we unchoke the peer which has been unchoked the last time.*/
   if (hasFinished()) {
-    double unchoke_time = simgrid::s4u::Engine::get_clock() + 1;
+    double unchoke_time = sg4::Engine::get_clock() + 1;
     for (auto& kv : connected_peers) {
       Connection& remote_peer = kv.second;
       if (remote_peer.last_unchoke < unchoke_time && remote_peer.interested && remote_peer.choked_upload) {
@@ -608,7 +609,7 @@ void Peer::updateChokedPeers()
       xbt_assert((chosen_peer->choked_upload), "Tries to unchoked an unchoked peer");
       chosen_peer->choked_upload = false;
       active_peers.insert(chosen_peer);
-      chosen_peer->last_unchoke = simgrid::s4u::Engine::get_clock();
+      chosen_peer->last_unchoke = sg4::Engine::get_clock();
       XBT_DEBUG("(%d) Sending a UNCHOKE to %d", id, chosen_peer->id);
       updateActivePeersSet(chosen_peer);
       sendMessage(chosen_peer->mailbox_, MessageType::UNCHOKE, message_size(MessageType::UNCHOKE));
index c3adb04..c94b0fa 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2022. 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. */
@@ -8,6 +7,7 @@
 #include <algorithm>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_tracker, "Messages specific for the tracker");
+namespace sg4 = simgrid::s4u;
 
 Tracker::Tracker(std::vector<std::string> args)
 {
@@ -21,16 +21,16 @@ Tracker::Tracker(std::vector<std::string> args)
   }
   xbt_assert(deadline > 0, "Wrong deadline supplied");
 
-  mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX);
+  mailbox = sg4::Mailbox::by_name(TRACKER_MAILBOX);
 
   XBT_INFO("Tracker launched.");
 }
 
 void Tracker::operator()()
 {
-  simgrid::s4u::CommPtr comm = nullptr;
+  sg4::CommPtr comm          = nullptr;
   TrackerQuery* query        = nullptr;
-  while (simgrid::s4u::Engine::get_clock() < deadline) {
+  while (sg4::Engine::get_clock() < deadline) {
     if (comm == nullptr)
       comm = mailbox->get_async<TrackerQuery>(&query);
     if (comm->test()) {
@@ -59,7 +59,7 @@ void Tracker::operator()()
       delete query;
       comm = nullptr;
     } else {
-      simgrid::s4u::this_actor::sleep_for(1);
+      sg4::this_actor::sleep_for(1);
     }
   }
   XBT_INFO("Tracker is leaving");
index 5bb14ae..bddfeb4 100644 (file)
@@ -11,13 +11,14 @@ constexpr unsigned MESSAGE_BUILD_CHAIN_SIZE      = 40;
 constexpr unsigned MESSAGE_SEND_DATA_HEADER_SIZE = 1;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_chainsend, "Messages specific for chainsend");
+namespace sg4 = simgrid::s4u;
 
 class ChainMessage {
 public:
-  simgrid::s4u::Mailbox* prev_   = nullptr;
-  simgrid::s4u::Mailbox* next_   = nullptr;
+  sg4::Mailbox* prev_            = nullptr;
+  sg4::Mailbox* next_            = nullptr;
   unsigned int num_pieces        = 0;
-  explicit ChainMessage(simgrid::s4u::Mailbox* prev, simgrid::s4u::Mailbox* next, const unsigned int num_pieces)
+  explicit ChainMessage(sg4::Mailbox* prev, sg4::Mailbox* next, const unsigned int num_pieces)
       : prev_(prev), next_(next), num_pieces(num_pieces)
   {
   }
@@ -30,17 +31,17 @@ public:
 
 class Peer {
 public:
-  simgrid::s4u::Mailbox* prev = nullptr;
-  simgrid::s4u::Mailbox* next = nullptr;
-  simgrid::s4u::Mailbox* me   = nullptr;
-  std::vector<simgrid::s4u::CommPtr> pending_recvs;
-  std::vector<simgrid::s4u::CommPtr> pending_sends;
+  sg4::Mailbox* prev = nullptr;
+  sg4::Mailbox* next = nullptr;
+  sg4::Mailbox* me   = nullptr;
+  std::vector<sg4::CommPtr> pending_recvs;
+  std::vector<sg4::CommPtr> pending_sends;
 
   unsigned long long received_bytes = 0;
   unsigned int received_pieces      = 0;
   unsigned int total_pieces         = 0;
 
-  Peer() { me = simgrid::s4u::Mailbox::by_name(simgrid::s4u::Host::current()->get_cname()); }
+  Peer() { me = sg4::Mailbox::by_name(sg4::Host::current()->get_cname()); }
 
   void joinChain()
   {
@@ -58,17 +59,17 @@ public:
     bool done = false;
 
     while (not done) {
-      simgrid::s4u::CommPtr comm = me->get_async<FilePiece>(&received);
+      sg4::CommPtr comm = me->get_async<FilePiece>(&received);
       pending_recvs.push_back(comm);
 
-      ssize_t idx = simgrid::s4u::Comm::wait_any(pending_recvs);
+      ssize_t idx = sg4::Comm::wait_any(pending_recvs);
       if (idx != -1) {
         comm = pending_recvs.at(idx);
         XBT_DEBUG("Peer %s got a 'SEND_DATA' message", me->get_cname());
         pending_recvs.erase(pending_recvs.begin() + idx);
         if (next != nullptr) {
           XBT_DEBUG("Sending (asynchronously) from %s to %s", me->get_cname(), next->get_cname());
-          simgrid::s4u::CommPtr send = next->put_async(received, MESSAGE_SEND_DATA_HEADER_SIZE + PIECE_SIZE);
+          sg4::CommPtr send = next->put_async(received, MESSAGE_SEND_DATA_HEADER_SIZE + PIECE_SIZE);
           pending_sends.push_back(send);
         } else
           delete received;
@@ -86,8 +87,8 @@ public:
 
 class Broadcaster {
 public:
-  simgrid::s4u::Mailbox* first = nullptr;
-  std::vector<simgrid::s4u::Mailbox*> mailboxes;
+  sg4::Mailbox* first = nullptr;
+  std::vector<sg4::Mailbox*> mailboxes;
   unsigned int piece_count;
 
   void buildChain()
@@ -97,11 +98,11 @@ public:
       first = mailboxes.front();
 
     for (unsigned i = 0; i < mailboxes.size(); i++) {
-      simgrid::s4u::Mailbox* prev = i > 0 ? mailboxes[i - 1] : nullptr;
-      simgrid::s4u::Mailbox* next = i < mailboxes.size() - 1 ? mailboxes[i + 1] : nullptr;
+      sg4::Mailbox* prev = i > 0 ? mailboxes[i - 1] : nullptr;
+      sg4::Mailbox* next = i < mailboxes.size() - 1 ? mailboxes[i + 1] : nullptr;
       XBT_DEBUG("Building chain--broadcaster:\"%s\" dest:\"%s\" prev:\"%s\" next:\"%s\"",
-                simgrid::s4u::Host::current()->get_cname(), mailboxes[i]->get_cname(),
-                prev ? prev->get_cname() : nullptr, next ? next->get_cname() : nullptr);
+                sg4::Host::current()->get_cname(), mailboxes[i]->get_cname(), prev ? prev->get_cname() : nullptr,
+                next ? next->get_cname() : nullptr);
       /* Send message to current peer */
       mailboxes[i]->put(new ChainMessage(prev, next, piece_count), MESSAGE_BUILD_CHAIN_SIZE);
     }
@@ -109,14 +110,14 @@ public:
 
   void sendFile()
   {
-    std::vector<simgrid::s4u::CommPtr> pending_sends;
+    std::vector<sg4::CommPtr> pending_sends;
     for (unsigned int current_piece = 0; current_piece < piece_count; current_piece++) {
-      XBT_DEBUG("Sending (send) piece %u from %s into mailbox %s", current_piece,
-                simgrid::s4u::Host::current()->get_cname(), first->get_cname());
-      simgrid::s4u::CommPtr comm = first->put_async(new FilePiece(), MESSAGE_SEND_DATA_HEADER_SIZE + PIECE_SIZE);
+      XBT_DEBUG("Sending (send) piece %u from %s into mailbox %s", current_piece, sg4::Host::current()->get_cname(),
+                first->get_cname());
+      sg4::CommPtr comm = first->put_async(new FilePiece(), MESSAGE_SEND_DATA_HEADER_SIZE + PIECE_SIZE);
       pending_sends.push_back(comm);
     }
-    simgrid::s4u::Comm::wait_all(pending_sends);
+    sg4::Comm::wait_all(pending_sends);
   }
 
   Broadcaster(int hostcount, unsigned int piece_count) : piece_count(piece_count)
@@ -124,7 +125,7 @@ public:
     for (int i = 1; i <= hostcount; i++) {
       std::string name = std::string("node-") + std::to_string(i) + ".simgrid.org";
       XBT_DEBUG("%s", name.c_str());
-      mailboxes.push_back(simgrid::s4u::Mailbox::by_name(name));
+      mailboxes.push_back(sg4::Mailbox::by_name(name));
     }
   }
 };
@@ -135,12 +136,12 @@ static void peer()
 
   Peer p;
 
-  double start_time = simgrid::s4u::Engine::get_clock();
+  double start_time = sg4::Engine::get_clock();
   p.joinChain();
   p.forwardFile();
 
-  simgrid::s4u::Comm::wait_all(p.pending_sends);
-  double end_time = simgrid::s4u::Engine::get_clock();
+  sg4::Comm::wait_all(p.pending_sends);
+  double end_time = sg4::Engine::get_clock();
 
   XBT_INFO("### %f %llu bytes (Avg %f MB/s); copy finished (simulated).", end_time - start_time, p.received_bytes,
            p.received_bytes / 1024.0 / 1024.0 / (end_time - start_time));
@@ -157,23 +158,23 @@ static void broadcaster(int hostcount, unsigned int piece_count)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("broadcaster", e.host_by_name("node-0.simgrid.org"), broadcaster, 8, 256);
+  sg4::Actor::create("broadcaster", e.host_by_name("node-0.simgrid.org"), broadcaster, 8, 256);
 
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-1.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-2.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-3.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-4.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-5.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-6.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-7.simgrid.org"), peer);
-  simgrid::s4u::Actor::create("peer", e.host_by_name("node-8.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-1.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-2.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-3.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-4.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-5.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-6.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-7.simgrid.org"), peer);
+  sg4::Actor::create("peer", e.host_by_name("node-8.simgrid.org"), peer);
 
   e.run();
-  XBT_INFO("Total simulation time: %e", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Total simulation time: %e", sg4::Engine::get_clock());
 
   return 0;
 }
index 88612b4..4324bad 100644 (file)
 #include <simgrid/s4u.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 class Master {
   long tasks_count      = 0;
   double compute_cost   = 0;
   long communicate_cost = 0;
-  std::vector<simgrid::s4u::Mailbox*> workers;
+  std::vector<sg4::Mailbox*> workers;
 
 public:
   explicit Master(std::vector<std::string> args)
@@ -26,7 +27,7 @@ public:
     compute_cost     = std::stod(args[2]);
     communicate_cost = std::stol(args[3]);
     for (unsigned int i = 4; i < args.size(); i++)
-      workers.push_back(simgrid::s4u::Mailbox::by_name(args[i]));
+      workers.push_back(sg4::Mailbox::by_name(args[i]));
 
     XBT_INFO("Got %zu workers and %ld tasks to process", workers.size(), tasks_count);
   }
@@ -35,7 +36,7 @@ public:
   {
     for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
       /* - Select a worker in a round-robin way */
-      simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()];
+      sg4::Mailbox* mailbox = workers[i % workers.size()];
 
       /* - Send the computation amount to the worker */
       if (tasks_count < 10000 || (tasks_count < 100000 && i % 10000 == 0) || i % 100000 == 0)
@@ -46,21 +47,21 @@ public:
     XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
     for (unsigned int i = 0; i < workers.size(); i++) {
       /* The workers stop when receiving a negative compute_cost */
-      simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()];
+      sg4::Mailbox* mailbox = workers[i % workers.size()];
       mailbox->put(new double(-1.0), 0);
     }
   }
 };
 
 class Worker {
-  simgrid::s4u::Mailbox* mailbox = nullptr;
+  sg4::Mailbox* mailbox = nullptr;
 
 public:
   explicit Worker(std::vector<std::string> args)
   {
     xbt_assert(args.size() == 1, "The worker expects to not get any argument");
 
-    mailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_name());
+    mailbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
   }
 
   void operator()()
@@ -71,7 +72,7 @@ public:
       compute_cost = *msg;
 
       if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
-        simgrid::s4u::this_actor::execute(compute_cost);
+        sg4::this_actor::execute(compute_cost);
     } while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
 
     XBT_INFO("Exiting now.");
@@ -80,7 +81,7 @@ public:
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
 
   /* Register the classes representing the actors */
index 3710195..fe07ce7 100644 (file)
@@ -8,6 +8,7 @@
 /* ************************************************************************* */
 
 #include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this example");
 
@@ -19,15 +20,15 @@ static void master(std::vector<std::string> args)
   long tasks_count        = std::stol(args[1]);
   double compute_cost     = std::stod(args[2]);
   long communication_cost = std::stol(args[3]);
-  std::vector<simgrid::s4u::Mailbox*> workers;
+  std::vector<sg4::Mailbox*> workers;
   for (unsigned int i = 4; i < args.size(); i++)
-    workers.push_back(simgrid::s4u::Mailbox::by_name(args[i]));
+    workers.push_back(sg4::Mailbox::by_name(args[i]));
 
   XBT_INFO("Got %zu workers and %ld tasks to process", workers.size(), tasks_count);
 
   for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
     /* - Select a worker in a round-robin way */
-    simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()];
+    sg4::Mailbox* mailbox = workers[i % workers.size()];
 
     /* - Send the computation cost to that worker */
     XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname());
@@ -37,7 +38,7 @@ static void master(std::vector<std::string> args)
   XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
   for (unsigned int i = 0; i < workers.size(); i++) {
     /* The workers stop when receiving a negative compute_cost */
-    simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()];
+    sg4::Mailbox* mailbox = workers[i % workers.size()];
 
     mailbox->put(new double(-1.0), 0);
   }
@@ -49,8 +50,8 @@ static void worker(std::vector<std::string> args)
 {
   xbt_assert(args.size() == 1, "The worker expects no argument");
 
-  const simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host();
-  simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(my_host->get_name());
+  const sg4::Host* my_host = sg4::this_actor::get_host();
+  sg4::Mailbox* mailbox    = sg4::Mailbox::by_name(my_host->get_name());
 
   double compute_cost;
   do {
@@ -58,7 +59,7 @@ static void worker(std::vector<std::string> args)
     compute_cost = *msg;
 
     if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
-      simgrid::s4u::this_actor::execute(compute_cost);
+      sg4::this_actor::execute(compute_cost);
   } while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
 
   XBT_INFO("Exiting now.");
@@ -68,7 +69,7 @@ static void worker(std::vector<std::string> args)
 // main-begin
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
 
   /* Register the functions representing the actors */
index 51c03e6..6f8a4ce 100644 (file)
@@ -10,6 +10,7 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_token_ring, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 class RelayRunner {
 public:
@@ -18,22 +19,22 @@ public:
   void operator()() const
   {
     size_t token_size = 1000000; /* The token is 1MB long*/
-    simgrid::s4u::Mailbox* my_mailbox;
-    simgrid::s4u::Mailbox* neighbor_mailbox;
+    sg4::Mailbox* my_mailbox;
+    sg4::Mailbox* neighbor_mailbox;
     unsigned int rank = 0;
 
     try {
-      rank = std::stoi(simgrid::s4u::this_actor::get_name());
+      rank = std::stoi(sg4::this_actor::get_name());
     } catch (const std::invalid_argument& ia) {
       throw std::invalid_argument(std::string("Actors of this example must have a numerical name, not ") + ia.what());
     }
-    my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(rank));
-    if (rank + 1 == simgrid::s4u::Engine::get_instance()->get_host_count())
+    my_mailbox = sg4::Mailbox::by_name(std::to_string(rank));
+    if (rank + 1 == sg4::Engine::get_instance()->get_host_count())
       /* The last actor sends the token back to rank 0 */
-      neighbor_mailbox = simgrid::s4u::Mailbox::by_name("0");
+      neighbor_mailbox = sg4::Mailbox::by_name("0");
     else
       /* The others actors send to their right neighbor (rank+1) */
-      neighbor_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(rank + 1));
+      neighbor_mailbox = sg4::Mailbox::by_name(std::to_string(rank + 1));
 
     if (rank == 0) {
       /* The root actor (rank 0) first sends the token then waits to receive it back */
@@ -53,20 +54,20 @@ public:
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
   e.load_platform(argv[1]);
 
   XBT_INFO("Number of hosts '%zu'", e.get_host_count());
   int id = 0;
-  std::vector<simgrid::s4u::Host*> list = e.get_all_hosts();
+  std::vector<sg4::Host*> list = e.get_all_hosts();
   for (auto const& host : list) {
     /* - Give a unique rank to each host and create a @ref relay_runner actor on each */
-    simgrid::s4u::Actor::create((std::to_string(id)).c_str(), host, RelayRunner());
+    sg4::Actor::create((std::to_string(id)).c_str(), host, RelayRunner());
     id++;
   }
   e.run();
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 1f395fb..3586464 100644 (file)
@@ -8,12 +8,13 @@
 #include "simgrid/s4u/VirtualMachine.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void worker(double computation_amount, bool use_bound, double bound)
 {
-  double clock_start = simgrid::s4u::Engine::get_clock();
+  double clock_start = sg4::Engine::get_clock();
 
-  simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(computation_amount);
+  sg4::ExecPtr exec = sg4::this_actor::exec_init(computation_amount);
 
   if (use_bound) {
     if (bound < 1e-12) /* close enough to 0 without any floating precision surprise */
@@ -22,7 +23,7 @@ static void worker(double computation_amount, bool use_bound, double bound)
   }
   exec->start();
   exec->wait();
-  double clock_end     = simgrid::s4u::Engine::get_clock();
+  double clock_end     = sg4::Engine::get_clock();
   double duration      = clock_end - clock_start;
   double flops_per_sec = computation_amount / duration;
 
@@ -35,41 +36,41 @@ static void worker(double computation_amount, bool use_bound, double bound)
 static void worker_busy_loop(const char* name, double speed)
 {
   double exec_remain_prev    = 1e11;
-  simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_async(exec_remain_prev);
+  sg4::ExecPtr exec          = sg4::this_actor::exec_async(exec_remain_prev);
   for (int i = 0; i < 10; i++) {
     if (speed > 0) {
       double new_bound = (speed / 10) * i;
       XBT_INFO("set bound of VM1 to %f", new_bound);
-      static_cast<simgrid::s4u::VirtualMachine*>(simgrid::s4u::this_actor::get_host())->set_bound(new_bound);
+      static_cast<sg4::VirtualMachine*>(sg4::this_actor::get_host())->set_bound(new_bound);
     }
-    simgrid::s4u::this_actor::sleep_for(100);
+    sg4::this_actor::sleep_for(100);
     double exec_remain_now = exec->get_remaining();
     double flops_per_sec   = exec_remain_prev - exec_remain_now;
-    XBT_INFO("%s@%s: %.0f flops/s", name, simgrid::s4u::this_actor::get_host()->get_cname(), flops_per_sec / 100);
+    XBT_INFO("%s@%s: %.0f flops/s", name, sg4::this_actor::get_host()->get_cname(), flops_per_sec / 100);
     exec_remain_prev = exec_remain_now;
-    simgrid::s4u::this_actor::sleep_for(1);
+    sg4::this_actor::sleep_for(1);
   }
   exec->wait();
 }
 
 static void test_dynamic_change()
 {
-  simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
+  sg4::Host* pm0 = sg4::Host::by_name("Fafard");
 
   auto* vm0 = pm0->create_vm("VM0", 1);
   auto* vm1 = pm0->create_vm("VM1", 1);
   vm0->start();
   vm1->start();
 
-  simgrid::s4u::Actor::create("worker0", vm0, worker_busy_loop, "Task0", -1);
-  simgrid::s4u::Actor::create("worker1", vm1, worker_busy_loop, "Task1", pm0->get_speed());
+  sg4::Actor::create("worker0", vm0, worker_busy_loop, "Task0", -1);
+  sg4::Actor::create("worker1", vm1, worker_busy_loop, "Task1", pm0->get_speed());
 
-  simgrid::s4u::this_actor::sleep_for(3000); // let the activities end
+  sg4::this_actor::sleep_for(3000); // let the activities end
   vm0->destroy();
   vm1->destroy();
 }
 
-static void test_one_activity(simgrid::s4u::Host* host)
+static void test_one_activity(sg4::Host* host)
 {
   const double cpu_speed          = host->get_speed();
   const double computation_amount = cpu_speed * 10;
@@ -77,32 +78,32 @@ static void test_one_activity(simgrid::s4u::Host* host)
   XBT_INFO("### Test: with/without activity set_bound");
 
   XBT_INFO("### Test: no bound for Task1@%s", host->get_cname());
-  simgrid::s4u::Actor::create("worker0", host, worker, computation_amount, false, 0);
+  sg4::Actor::create("worker0", host, worker, computation_amount, false, 0);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 50%% for Task1@%s", host->get_cname());
-  simgrid::s4u::Actor::create("worker0", host, worker, computation_amount, true, cpu_speed / 2);
+  sg4::Actor::create("worker0", host, worker, computation_amount, true, cpu_speed / 2);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 33%% for Task1@%s", host->get_cname());
-  simgrid::s4u::Actor::create("worker0", host, worker, computation_amount, true, cpu_speed / 3);
+  sg4::Actor::create("worker0", host, worker, computation_amount, true, cpu_speed / 3);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: zero for Task1@%s (i.e., unlimited)", host->get_cname());
-  simgrid::s4u::Actor::create("worker0", host, worker, computation_amount, true, 0);
+  sg4::Actor::create("worker0", host, worker, computation_amount, true, 0);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 200%% for Task1@%s (i.e., meaningless)", host->get_cname());
-  simgrid::s4u::Actor::create("worker0", host, worker, computation_amount, true, cpu_speed * 2);
+  sg4::Actor::create("worker0", host, worker, computation_amount, true, cpu_speed * 2);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 }
 
-static void test_two_activities(simgrid::s4u::Host* hostA, simgrid::s4u::Host* hostB)
+static void test_two_activities(sg4::Host* hostA, sg4::Host* hostB)
 {
   const double cpu_speed = hostA->get_speed();
   xbt_assert(cpu_speed == hostB->get_speed());
@@ -111,51 +112,51 @@ static void test_two_activities(simgrid::s4u::Host* hostA, simgrid::s4u::Host* h
   const char* hostB_name          = hostB->get_cname();
 
   XBT_INFO("### Test: no bound for Task1@%s, no bound for Task2@%s", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, false, 0);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, false, 0);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, false, 0);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, false, 0);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 0 for Task1@%s, 0 for Task2@%s (i.e., unlimited)", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, true, 0);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, true, 0);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, true, 0);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, true, 0);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 50%% for Task1@%s, 50%% for Task2@%s", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed / 2);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 2);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed / 2);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 2);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 25%% for Task1@%s, 25%% for Task2@%s", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed / 4);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 4);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed / 4);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 4);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 75%% for Task1@%s, 100%% for Task2@%s", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed * 0.75);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed * 0.75);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: no bound for Task1@%s, 25%% for Task2@%s", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, false, 0);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 4);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, false, 0);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 4);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 
   XBT_INFO("### Test: 75%% for Task1@%s, 25%% for Task2@%s", hostA_name, hostB_name);
-  simgrid::s4u::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed * 0.75);
-  simgrid::s4u::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 4);
+  sg4::Actor::create("worker0", hostA, worker, computation_amount, true, cpu_speed * 0.75);
+  sg4::Actor::create("worker1", hostB, worker, computation_amount, true, cpu_speed / 4);
 
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::this_actor::sleep_for(1000);
 }
 
 static void master_main()
 {
-  simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
+  sg4::Host* pm0 = sg4::Host::by_name("Fafard");
 
   XBT_INFO("# 1. Put a single activity on a PM.");
   test_one_activity(pm0);
@@ -215,24 +216,24 @@ static void master_main()
   const double computation_amount = cpu_speed * 10;
 
   XBT_INFO("# 10. (a) Put an activity on a VM without any bound.");
-  simgrid::s4u::Actor::create("worker0", vm0, worker, computation_amount, false, 0);
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::Actor::create("worker0", vm0, worker, computation_amount, false, 0);
+  sg4::this_actor::sleep_for(1000);
   XBT_INFO(".");
 
   XBT_INFO("# 10. (b) set 10%% bound to the VM, and then put an activity on the VM.");
   vm0->set_bound(cpu_speed / 10);
-  simgrid::s4u::Actor::create("worker0", vm0, worker, computation_amount, false, 0);
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::Actor::create("worker0", vm0, worker, computation_amount, false, 0);
+  sg4::this_actor::sleep_for(1000);
   XBT_INFO(".");
 
   XBT_INFO("# 10. (c) migrate");
-  simgrid::s4u::Host* pm1 = simgrid::s4u::Host::by_name("Fafard");
+  sg4::Host* pm1 = sg4::Host::by_name("Fafard");
   sg_vm_migrate(vm0, pm1);
   XBT_INFO(".");
 
   XBT_INFO("# 10. (d) Put an activity again on the VM.");
-  simgrid::s4u::Actor::create("worker0", vm0, worker, computation_amount, false, 0);
-  simgrid::s4u::this_actor::sleep_for(1000);
+  sg4::Actor::create("worker0", vm0, worker, computation_amount, false, 0);
+  sg4::this_actor::sleep_for(1000);
   XBT_INFO(".");
 
   vm0->destroy();
@@ -243,17 +244,17 @@ static void master_main()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_vm_live_migration_plugin_init();
   /* load the platform file */
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/small_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master_", e.host_by_name("Fafard"), master_main);
+  sg4::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)", sg4::Engine::get_clock());
 
   return 0;
 }
index 2ce9a86..6e0db95 100644 (file)
@@ -8,27 +8,28 @@
 #include "simgrid/s4u/VirtualMachine.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_cloud_migration, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
-static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
+static void vm_migrate(sg4::VirtualMachine* vm, sg4::Host* dst_pm)
 {
-  const simgrid::s4u::Host* src_pm = vm->get_pm();
-  double mig_sta             = simgrid::s4u::Engine::get_clock();
+  const sg4::Host* src_pm = vm->get_pm();
+  double mig_sta          = sg4::Engine::get_clock();
   sg_vm_migrate(vm, dst_pm);
-  double mig_end = simgrid::s4u::Engine::get_clock();
+  double mig_end = sg4::Engine::get_clock();
 
   XBT_INFO("%s migrated: %s->%s in %g s", vm->get_cname(), src_pm->get_cname(), dst_pm->get_cname(), mig_end - mig_sta);
 }
 
-static void vm_migrate_async(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
+static void vm_migrate_async(sg4::VirtualMachine* vm, sg4::Host* dst_pm)
 {
-  simgrid::s4u::Actor::create("mig_wrk", simgrid::s4u::Host::current(), vm_migrate, vm, dst_pm);
+  sg4::Actor::create("mig_wrk", sg4::Host::current(), vm_migrate, vm, dst_pm);
 }
 
 static void master_main()
 {
-  simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
-  simgrid::s4u::Host* pm1 = simgrid::s4u::Host::by_name("Tremblay");
-  simgrid::s4u::Host* pm2 = simgrid::s4u::Host::by_name("Bourassa");
+  sg4::Host* pm0 = sg4::Host::by_name("Fafard");
+  sg4::Host* pm1 = sg4::Host::by_name("Tremblay");
+  sg4::Host* pm2 = sg4::Host::by_name("Bourassa");
 
   auto* vm0 = pm0->create_vm("VM0", 1);
   vm0->set_ramsize(1e9); // 1Gbytes
@@ -59,7 +60,7 @@ static void master_main()
   XBT_INFO("Test: Migrate two VMs at once from PM0 to PM1");
   vm_migrate_async(vm0, pm1);
   vm_migrate_async(vm1, pm1);
-  simgrid::s4u::this_actor::sleep_for(10000);
+  sg4::this_actor::sleep_for(10000);
 
   vm0->destroy();
   vm1->destroy();
@@ -75,7 +76,7 @@ static void master_main()
   XBT_INFO("Test: Migrate two VMs at once to different PMs");
   vm_migrate_async(vm0, pm1);
   vm_migrate_async(vm1, pm2);
-  simgrid::s4u::this_actor::sleep_for(10000);
+  sg4::this_actor::sleep_for(10000);
 
   vm0->destroy();
   vm1->destroy();
@@ -84,17 +85,17 @@ static void master_main()
 int main(int argc, char* argv[])
 {
   /* Get the arguments */
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_vm_live_migration_plugin_init();
 
   /* load the platform file */
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("master_", simgrid::s4u::Host::by_name("Fafard"), master_main);
+  sg4::Actor::create("master_", sg4::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)", sg4::Engine::get_clock());
 
   return 0;
 }
index e6c923c..9c5134c 100644 (file)
@@ -8,20 +8,21 @@
 #include "simgrid/s4u/VirtualMachine.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void computation_fun()
 {
-  double clock_sta = simgrid::s4u::Engine::get_clock();
-  simgrid::s4u::this_actor::execute(1000000);
-  double clock_end = simgrid::s4u::Engine::get_clock();
+  double clock_sta = sg4::Engine::get_clock();
+  sg4::this_actor::execute(1000000);
+  double clock_end = sg4::Engine::get_clock();
 
-  XBT_INFO("%s:%s executed %g", simgrid::s4u::this_actor::get_host()->get_cname(),
-           simgrid::s4u::this_actor::get_cname(), clock_end - clock_sta);
+  XBT_INFO("%s:%s executed %g", sg4::this_actor::get_host()->get_cname(), sg4::this_actor::get_cname(),
+           clock_end - clock_sta);
 }
 
 static void launch_computation_worker(s4u_Host* host)
 {
-  simgrid::s4u::Actor::create("compute", host, computation_fun);
+  sg4::Actor::create("compute", host, computation_fun);
 }
 
 struct s_payload {
@@ -32,23 +33,23 @@ struct s_payload {
 
 static void communication_tx_fun(std::vector<std::string> args)
 {
-  simgrid::s4u::Mailbox* mbox   = simgrid::s4u::Mailbox::by_name(args.at(0));
+  sg4::Mailbox* mbox            = sg4::Mailbox::by_name(args.at(0));
   auto* payload                 = new s_payload;
-  payload->tx_actor_name        = simgrid::s4u::Actor::self()->get_cname();
-  payload->tx_host              = simgrid::s4u::this_actor::get_host();
-  payload->clock_sta            = simgrid::s4u::Engine::get_clock();
+  payload->tx_actor_name        = sg4::Actor::self()->get_cname();
+  payload->tx_host              = sg4::this_actor::get_host();
+  payload->clock_sta            = sg4::Engine::get_clock();
 
   mbox->put(payload, 1000000);
 }
 
 static void communication_rx_fun(std::vector<std::string> args)
 {
-  const char* actor_name        = simgrid::s4u::Actor::self()->get_cname();
-  const char* host_name         = simgrid::s4u::this_actor::get_host()->get_cname();
-  simgrid::s4u::Mailbox* mbox   = simgrid::s4u::Mailbox::by_name(args.at(0));
+  const char* actor_name = sg4::Actor::self()->get_cname();
+  const char* host_name  = sg4::this_actor::get_host()->get_cname();
+  sg4::Mailbox* mbox     = sg4::Mailbox::by_name(args.at(0));
 
   auto payload     = mbox->get_unique<struct s_payload>();
-  double clock_end = simgrid::s4u::Engine::get_clock();
+  double clock_end = sg4::Engine::get_clock();
 
   XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name,
            clock_end - payload->clock_sta);
@@ -60,32 +61,32 @@ static void launch_communication_worker(s4u_Host* tx_host, s4u_Host* rx_host)
   std::vector<std::string> args;
   args.push_back(mbox_name);
 
-  simgrid::s4u::Actor::create("comm_tx", tx_host, communication_tx_fun, args);
+  sg4::Actor::create("comm_tx", tx_host, communication_tx_fun, args);
 
-  simgrid::s4u::Actor::create("comm_rx", rx_host, communication_rx_fun, args);
+  sg4::Actor::create("comm_rx", rx_host, communication_rx_fun, args);
 }
 
 static void master_main()
 {
-  s4u_Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
-  s4u_Host* pm1 = simgrid::s4u::Host::by_name("Tremblay");
-  s4u_Host* pm2 = simgrid::s4u::Host::by_name("Bourassa");
+  s4u_Host* pm0 = sg4::Host::by_name("Fafard");
+  s4u_Host* pm1 = sg4::Host::by_name("Tremblay");
+  s4u_Host* pm2 = sg4::Host::by_name("Bourassa");
 
   XBT_INFO("## Test 1 (started): check computation on normal PMs");
 
   XBT_INFO("### Put an activity on a PM");
   launch_computation_worker(pm0);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
 
   XBT_INFO("### Put two activities on a PM");
   launch_computation_worker(pm0);
   launch_computation_worker(pm0);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
 
   XBT_INFO("### Put an activity on each PM");
   launch_computation_worker(pm0);
   launch_computation_worker(pm1);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
 
   XBT_INFO("## Test 1 (ended)");
 
@@ -96,7 +97,7 @@ static void master_main()
   auto* vm0 = pm0->create_vm("VM0", 1);
   vm0->start();
   launch_computation_worker(vm0);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
   vm0->destroy();
 
   XBT_INFO("## Test 2 (ended)");
@@ -108,7 +109,7 @@ static void master_main()
   vm0 = pm0->create_vm("VM0", 1);
   vm0->start();
   launch_computation_worker(pm0);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
   vm0->destroy();
   XBT_INFO("## Test 3 (ended)");
 
@@ -122,7 +123,7 @@ static void master_main()
   auto* vm1 = pm0->create_vm("VM1", 1);
   launch_computation_worker(vm0);
   launch_computation_worker(vm1);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
   vm0->destroy();
   vm1->destroy();
 
@@ -133,7 +134,7 @@ static void master_main()
   vm1->start();
   launch_computation_worker(vm0);
   launch_computation_worker(vm1);
-  simgrid::s4u::this_actor::sleep_for(2);
+  sg4::this_actor::sleep_for(2);
   vm0->destroy();
   vm1->destroy();
   XBT_INFO("## Test 4 (ended)");
@@ -141,24 +142,24 @@ static void master_main()
   XBT_INFO("## Test 5  (started): Analyse network impact");
   XBT_INFO("### Make a connection between PM0 and PM1");
   launch_communication_worker(pm0, pm1);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
 
   XBT_INFO("### Make two connection between PM0 and PM1");
   launch_communication_worker(pm0, pm1);
   launch_communication_worker(pm0, pm1);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
 
   XBT_INFO("### Make a connection between PM0 and VM0@PM0");
   vm0 = pm0->create_vm("VM0", 1);
   vm0->start();
   launch_communication_worker(pm0, vm0);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   vm0->destroy();
 
   XBT_INFO("### Make a connection between PM0 and VM0@PM1");
   vm0 = pm1->create_vm("VM0", 1);
   launch_communication_worker(pm0, vm0);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   vm0->destroy();
 
   XBT_INFO("### Make two connections between PM0 and VM0@PM1");
@@ -166,7 +167,7 @@ static void master_main()
   vm0->start();
   launch_communication_worker(pm0, vm0);
   launch_communication_worker(pm0, vm0);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   vm0->destroy();
 
   XBT_INFO("### Make a connection between PM0 and VM0@PM1, and also make a connection between PM0 and PM1");
@@ -174,7 +175,7 @@ static void master_main()
   vm0->start();
   launch_communication_worker(pm0, vm0);
   launch_communication_worker(pm0, pm1);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   vm0->destroy();
 
   XBT_INFO("### Make a connection between VM0@PM0 and PM1@PM1, and also make a connection between VM0@PM0 and VM1@PM1");
@@ -184,7 +185,7 @@ static void master_main()
   vm1->start();
   launch_communication_worker(vm0, vm1);
   launch_communication_worker(vm0, vm1);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   vm0->destroy();
   vm1->destroy();
 
@@ -197,26 +198,26 @@ static void master_main()
 
   vm0->start();
   launch_communication_worker(vm0, pm2);
-  simgrid::s4u::this_actor::sleep_for(0.01);
+  sg4::this_actor::sleep_for(0.01);
   sg_vm_migrate(vm0, pm1);
-  simgrid::s4u::this_actor::sleep_for(0.01);
+  sg4::this_actor::sleep_for(0.01);
   sg_vm_migrate(vm0, pm0);
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   vm0->destroy();
   XBT_INFO("## Test 6 (ended)");
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_vm_live_migration_plugin_init();
   e.load_platform(argv[1]); /* - Load the platform description */
 
-  simgrid::s4u::Actor::create("master_", e.host_by_name("Fafard"), master_main);
+  sg4::Actor::create("master_", e.host_by_name("Fafard"), master_main);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 5e7f6bc..5c31aaa 100644 (file)
@@ -62,7 +62,7 @@ public:
     }
     XBT_INFO("Wait for remaining comm, just to be nice");
     pending_comms.erase(pending_comms.begin());
-    simgrid::s4u::Comm::wait_any(pending_comms);
+    sg4::Comm::wait_any(pending_comms);
   }
 };
 
index 4f4699e..a1cb5c9 100644 (file)
@@ -8,10 +8,11 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_storage_file_system_init();
   e.load_platform(argv[1]);
 
@@ -19,25 +20,25 @@ int main(int argc, char* argv[])
   auto jupiter  = e.host_by_name("Jupiter");
 
   // Display the details on vetoed activities
-  simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
+  sg4::Activity::on_veto_cb([](const sg4::Activity& a) {
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", a.get_cname(),
              (a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
   });
 
-  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
+  sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
+    const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
     if (exec != nullptr)
       XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
                exec->get_finish_time());
-    const auto* comm = dynamic_cast<simgrid::s4u::Comm const*>(&activity);
+    const auto* comm = dynamic_cast<sg4::Comm const*>(&activity);
     if (comm != nullptr)
       XBT_INFO("Activity '%s' is complete", comm->get_cname());
   });
 
   // Create a small DAG: parent->transfert->child
-  simgrid::s4u::ExecPtr parent    = simgrid::s4u::Exec::init();
-  simgrid::s4u::CommPtr transfert = simgrid::s4u::Comm::sendto_init();
-  simgrid::s4u::ExecPtr child     = simgrid::s4u::Exec::init();
+  sg4::ExecPtr parent    = sg4::Exec::init();
+  sg4::CommPtr transfert = sg4::Comm::sendto_init();
+  sg4::ExecPtr child     = sg4::Exec::init();
   parent->add_successor(transfert);
   transfert->add_successor(child);
 
@@ -55,7 +56,7 @@ int main(int argc, char* argv[])
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 7139b80..4d6fa4b 100644 (file)
@@ -19,7 +19,7 @@ int main(int argc, char** argv)
   auto* faulty = e.host_by_name("Faulty Host");
   auto* safe   = e.host_by_name("Safe Host");
   sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
+    const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
     if (exec->get_state() == sg4::Activity::State::FINISHED)
index 60c1a41..bcd18de 100644 (file)
@@ -1,7 +1,6 @@
 /* simple test trying to load a DAX file.                                   */
 
-/* Copyright (c) 2009-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2009-2022. 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 <string.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dag_from_dax, "Logging specific to this example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_DAX(argv[2]);
+  std::vector<sg4::ActivityPtr> dag = sg4::create_DAG_from_DAX(argv[2]);
 
   if (dag.empty()) {
     XBT_ERROR("A problem occurred during DAX parsing (cycle or syntax). Do not continue this test");
@@ -29,7 +29,7 @@ int main(int argc, char** argv)
   for (const auto& a : dag) {
     std::string type = "an Exec";
     std::string task = "flops to execute";
-    if (dynamic_cast<simgrid::s4u::Comm*>(a.get()) != nullptr) {
+    if (dynamic_cast<sg4::Comm*>(a.get()) != nullptr) {
       type = "a Comm";
       task = "bytes to transfer";
     }
@@ -43,18 +43,18 @@ int main(int argc, char** argv)
   auto count = e.get_host_count();
   int cursor = 0;
   // Schedule end first
-  static_cast<simgrid::s4u::Exec*>(dag.back().get())->set_host(hosts[0]);
+  static_cast<sg4::Exec*>(dag.back().get())->set_host(hosts[0]);
 
   for (const auto& a : dag) {
-    auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
+    auto* exec = dynamic_cast<sg4::Exec*>(a.get());
     if (exec != nullptr && exec->get_name() != "end") {
       exec->set_host(hosts[cursor % count]);
       cursor++;
     }
-    auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
+    auto* comm = dynamic_cast<sg4::Comm*>(a.get());
     if (comm != nullptr) {
-      auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-      auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+      auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
+      auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
       comm->set_source(pred->get_host())->set_destination(succ->get_host());
     }
   }
@@ -64,12 +64,12 @@ int main(int argc, char** argv)
 
   XBT_INFO("-------------- Summary of executed schedule ------------------");
   for (const auto& a : dag) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
+    const auto* exec = dynamic_cast<sg4::Exec*>(a.get());
     if (exec != nullptr) {
       XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(),
                exec->get_host()->get_cname());
     }
-    const auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
+    const auto* comm = dynamic_cast<sg4::Comm*>(a.get());
     if (comm != nullptr) {
       XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(),
                comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname());
index 627f065..10d32a5 100644 (file)
@@ -1,7 +1,6 @@
 /* simple test trying to load a DOT file.                                   */
 
-/* Copyright (c) 2010-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2022. 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>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dag_from_dot, "Logging specific to this example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_dot(argv[2]);
+  std::vector<sg4::ActivityPtr> dag = sg4::create_DAG_from_dot(argv[2]);
 
   if (dag.empty()) {
     XBT_CRITICAL("No dot loaded. Do you have a cycle in your graph?");
@@ -27,7 +27,7 @@ int main(int argc, char** argv)
   for (const auto& a : dag) {
     std::string type = "an Exec";
     std::string task = "flops to execute";
-    if (dynamic_cast<simgrid::s4u::Comm*>(a.get()) != nullptr) {
+    if (dynamic_cast<sg4::Comm*>(a.get()) != nullptr) {
       type = "a Comm";
       task = "bytes to transfer";
     }
@@ -41,18 +41,18 @@ int main(int argc, char** argv)
   auto count = e.get_host_count();
   int cursor = 0;
   // Schedule end first
-  static_cast<simgrid::s4u::Exec*>(dag.back().get())->set_host(hosts[0]);
+  static_cast<sg4::Exec*>(dag.back().get())->set_host(hosts[0]);
 
   for (const auto& a : dag) {
-    auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
+    auto* exec = dynamic_cast<sg4::Exec*>(a.get());
     if (exec != nullptr && exec->get_name() != "end") {
       exec->set_host(hosts[cursor % count]);
       cursor++;
     }
-    auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
+    auto* comm = dynamic_cast<sg4::Comm*>(a.get());
     if (comm != nullptr) {
-      auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-      auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+      auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
+      auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
       comm->set_source(pred->get_host())->set_destination(succ->get_host());
     }
   }
@@ -62,12 +62,12 @@ int main(int argc, char** argv)
 
   XBT_INFO("-------------- Summary of executed schedule ------------------");
   for (const auto& a : dag) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
+    const auto* exec = dynamic_cast<sg4::Exec*>(a.get());
     if (exec != nullptr) {
       XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(),
                exec->get_host()->get_cname());
     }
-    const auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
+    const auto* comm = dynamic_cast<sg4::Comm*>(a.get());
     if (comm != nullptr) {
       XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(),
                comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname());
index c2dccda..a75dbc0 100644 (file)
@@ -8,10 +8,11 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_storage_file_system_init();
   e.load_platform(argv[1]);
 
@@ -19,13 +20,13 @@ int main(int argc, char* argv[])
   auto carl = e.host_by_name("carl");
 
   // Display the details on vetoed activities
-  simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
+  sg4::Activity::on_veto_cb([](const sg4::Activity& a) {
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", a.get_cname(),
              (a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
   });
 
-  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
+  sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
+    const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
     XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
@@ -33,10 +34,10 @@ int main(int argc, char* argv[])
   });
 
   // Create a small DAG: parent->write_output->read_input->child
-  simgrid::s4u::ExecPtr parent     = simgrid::s4u::Exec::init();
-  simgrid::s4u::IoPtr write_output = simgrid::s4u::Io::init();
-  simgrid::s4u::IoPtr read_input   = simgrid::s4u::Io::init();
-  simgrid::s4u::ExecPtr child      = simgrid::s4u::Exec::init();
+  sg4::ExecPtr parent     = sg4::Exec::init();
+  sg4::IoPtr write_output = sg4::Io::init();
+  sg4::IoPtr read_input   = sg4::Io::init();
+  sg4::ExecPtr child      = sg4::Exec::init();
   parent->add_successor(write_output);
   write_output->add_successor(read_input);
   read_input->add_successor(child);
@@ -44,8 +45,8 @@ int main(int argc, char* argv[])
   // Set the parameters (the name is for logging purposes only)
   // + parent and chile end after 1 second
   parent->set_name("parent")->set_flops_amount(bob->get_speed());
-  write_output->set_name("write")->set_size(1e9)->set_op_type(simgrid::s4u::Io::OpType::WRITE);
-  read_input->set_name("read")->set_size(1e9)->set_op_type(simgrid::s4u::Io::OpType::READ);
+  write_output->set_name("write")->set_size(1e9)->set_op_type(sg4::Io::OpType::WRITE);
+  read_input->set_name("read")->set_size(1e9)->set_op_type(sg4::Io::OpType::READ);
   child->set_name("child")->set_flops_amount(carl->get_speed());
 
   // Schedule and try to start the different activities
@@ -56,7 +57,7 @@ int main(int argc, char* argv[])
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index f2d1549..897ebcc 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2009-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2009-2022. 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 <string.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dag_scheduling, "Logging specific to this example");
+namespace sg4 = simgrid::s4u;
 
 struct HostAttribute {
   /* Earliest time at which a host is ready to execute a task */
   double available_at                     = 0.0;
-  simgrid::s4u::Exec* last_scheduled_task = nullptr;
+  sg4::Exec* last_scheduled_task          = nullptr;
 };
 
-static double sg_host_get_available_at(const simgrid::s4u::Host* host)
+static double sg_host_get_available_at(const sg4::Host* host)
 {
   return host->get_data<HostAttribute>()->available_at;
 }
 
-static void sg_host_set_available_at(const simgrid::s4u::Host* host, double time)
+static void sg_host_set_available_at(const sg4::Host* host, double time)
 {
   host->get_data<HostAttribute>()->available_at = time;
 }
 
-static simgrid::s4u::Exec* sg_host_get_last_scheduled_task(const simgrid::s4u::Host* host)
+static sg4::Exec* sg_host_get_last_scheduled_task(const sg4::Host* host)
 {
   return host->get_data<HostAttribute>()->last_scheduled_task;
 }
 
-static void sg_host_set_last_scheduled_task(const simgrid::s4u::Host* host, simgrid::s4u::ExecPtr task)
+static void sg_host_set_last_scheduled_task(const sg4::Host* host, sg4::ExecPtr task)
 {
   host->get_data<HostAttribute>()->last_scheduled_task = task.get();
 }
 
-static bool dependency_exists(const simgrid::s4u::Exec* src, simgrid::s4u::Exec* dst)
+static bool dependency_exists(const sg4::Exec* src, sg4::Exec* dst)
 {
   const auto& dependencies = src->get_dependencies();
   const auto& successors   = src->get_successors();
@@ -46,23 +46,23 @@ static bool dependency_exists(const simgrid::s4u::Exec* src, simgrid::s4u::Exec*
           dependencies.find(dst) != dependencies.end());
 }
 
-static std::vector<simgrid::s4u::Exec*> get_ready_tasks(const std::vector<simgrid::s4u::ActivityPtr>& dax)
+static std::vector<sg4::Exec*> get_ready_tasks(const std::vector<sg4::ActivityPtr>& dax)
 {
-  std::vector<simgrid::s4u::Exec*> ready_tasks;
-  std::map<simgrid::s4u::Exec*, unsigned int> candidate_execs;
+  std::vector<sg4::Exec*> ready_tasks;
+  std::map<sg4::Exec*, unsigned int> candidate_execs;
 
   for (auto& a : dax) {
     // Only loot at activity that have their dependencies solved but are not assigned
     if (a->dependencies_solved() && not a->is_assigned()) {
       // if it is an exec, it's ready
-      auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
+      auto* exec = dynamic_cast<sg4::Exec*>(a.get());
       if (exec != nullptr)
         ready_tasks.push_back(exec);
       // if it a comm, we consider its successor as a candidate. If a candidate solves all its dependencies,
       // i.e., get all its input data, it's ready
-      const auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
+      const auto* comm = dynamic_cast<sg4::Comm*>(a.get());
       if (comm != nullptr) {
-        auto* next_exec = static_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+        auto* next_exec = static_cast<sg4::Exec*>(comm->get_successors().front().get());
         candidate_execs[next_exec]++;
         if (next_exec->get_dependencies().size() == candidate_execs[next_exec])
           ready_tasks.push_back(next_exec);
@@ -73,7 +73,7 @@ static std::vector<simgrid::s4u::Exec*> get_ready_tasks(const std::vector<simgri
   return ready_tasks;
 }
 
-static double finish_on_at(const simgrid::s4u::ExecPtr task, const simgrid::s4u::Host* host)
+static double finish_on_at(const sg4::ExecPtr task, const sg4::Host* host)
 {
   double result;
 
@@ -86,7 +86,7 @@ static double finish_on_at(const simgrid::s4u::ExecPtr task, const simgrid::s4u:
     last_data_available = -1.0;
     for (const auto& parent : parents) {
       /* normal case */
-      const auto* comm = dynamic_cast<simgrid::s4u::Comm*>(parent.get());
+      const auto* comm = dynamic_cast<sg4::Comm*>(parent.get());
       if (comm != nullptr) {
         auto source = comm->get_source();
         XBT_DEBUG("transfer from %s to %s", source->get_cname(), host->get_cname());
@@ -103,7 +103,7 @@ static double finish_on_at(const simgrid::s4u::ExecPtr task, const simgrid::s4u:
         data_available = *comm->get_data<double>() + redist_time;
       }
 
-      const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(parent.get());
+      const auto* exec = dynamic_cast<sg4::Exec*>(parent.get());
       /* no transfer, control dependency */
       if (exec != nullptr) {
         data_available = exec->get_finish_time();
@@ -120,9 +120,9 @@ static double finish_on_at(const simgrid::s4u::ExecPtr task, const simgrid::s4u:
   return result;
 }
 
-static simgrid::s4u::Host* get_best_host(const simgrid::s4u::ExecPtr exec)
+static sg4::Host* get_best_host(const sg4::ExecPtr exec)
 {
-  std::vector<simgrid::s4u::Host*> hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts();
+  std::vector<sg4::Host*> hosts          = sg4::Engine::get_instance()->get_all_hosts();
   auto best_host                         = hosts.front();
   double min_EFT                         = finish_on_at(exec, best_host);
 
@@ -138,12 +138,12 @@ static simgrid::s4u::Host* get_best_host(const simgrid::s4u::ExecPtr exec)
   return best_host;
 }
 
-static void schedule_on(simgrid::s4u::ExecPtr exec, simgrid::s4u::Host* host)
+static void schedule_on(sg4::ExecPtr exec, sg4::Host* host)
 {
   exec->set_host(host);
   // we can also set the destination of all the input comms of this exec
   for (const auto& pred : exec->get_dependencies()) {
-    auto* comm = dynamic_cast<simgrid::s4u::Comm*>(pred.get());
+    auto* comm = dynamic_cast<sg4::Comm*>(pred.get());
     if (comm != nullptr) {
       comm->set_destination(host);
       delete comm->get_data<double>();
@@ -151,7 +151,7 @@ static void schedule_on(simgrid::s4u::ExecPtr exec, simgrid::s4u::Host* host)
   }
   // we can also set the source of all the output comms of this exec
   for (const auto& succ : exec->get_successors()) {
-    auto* comm = dynamic_cast<simgrid::s4u::Comm*>(succ.get());
+    auto* comm = dynamic_cast<sg4::Comm*>(succ.get());
     if (comm != nullptr)
       comm->set_source(host);
   }
@@ -159,17 +159,17 @@ static void schedule_on(simgrid::s4u::ExecPtr exec, simgrid::s4u::Host* host)
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
-  std::set<simgrid::s4u::Activity*> vetoed;
+  sg4::Engine e(&argc, argv);
+  std::set<sg4::Activity*> vetoed;
   e.track_vetoed_activities(&vetoed);
 
-  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
+  sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
     // when an Exec completes, we need to set the potential start time of all its ouput comms
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
+    const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
     for (const auto& succ : exec->get_successors()) {
-      auto* comm = dynamic_cast<simgrid::s4u::Comm*>(succ.get());
+      auto* comm = dynamic_cast<sg4::Comm*>(succ.get());
       if (comm != nullptr) {
         auto* finish_time = new double(exec->get_finish_time());
         // We use the user data field to store the finish time of the predecessor of the comm, i.e., its potential start
@@ -189,10 +189,10 @@ int main(int argc, char** argv)
     hosts[i]->set_data(&host_attributes[i]);
 
   /* load the DAX file */
-  auto dax = simgrid::s4u::create_DAG_from_DAX(argv[2]);
+  auto dax = sg4::create_DAG_from_DAX(argv[2]);
 
   /* Schedule the root first */
-  auto* root = static_cast<simgrid::s4u::Exec*>(dax.front().get());
+  auto* root = static_cast<sg4::Exec*>(dax.front().get());
   auto host  = get_best_host(root);
   schedule_on(root, host);
 
@@ -214,8 +214,8 @@ int main(int argc, char** argv)
      * select the task that has the minimum completion time on its best host.
      */
     double min_finish_time            = -1.0;
-    simgrid::s4u::Exec* selected_task = nullptr;
-    simgrid::s4u::Host* selected_host = nullptr;
+    sg4::Exec* selected_task          = nullptr;
+    sg4::Host* selected_host          = nullptr;
 
     for (auto task : ready_tasks) {
       XBT_DEBUG("%s is ready", task->get_cname());
@@ -241,8 +241,8 @@ int main(int argc, char** argv)
      */
 
     auto last_scheduled_task = sg_host_get_last_scheduled_task(selected_host);
-    if (last_scheduled_task && (last_scheduled_task->get_state() != simgrid::s4u::Activity::State::FINISHED) &&
-        (last_scheduled_task->get_state() != simgrid::s4u::Activity::State::FAILED) &&
+    if (last_scheduled_task && (last_scheduled_task->get_state() != sg4::Activity::State::FINISHED) &&
+        (last_scheduled_task->get_state() != sg4::Activity::State::FAILED) &&
         not dependency_exists(sg_host_get_last_scheduled_task(selected_host), selected_task))
       last_scheduled_task->add_successor(selected_task);
 
index 4d13a82..f6411a6 100644 (file)
@@ -7,27 +7,28 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  std::set<simgrid::s4u::Activity*> vetoed;
+  std::set<sg4::Activity*> vetoed;
   e.track_vetoed_activities(&vetoed);
 
   auto fafard = e.host_by_name("Fafard");
 
   // Display the details on vetoed activities
-  simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
-    const auto& exec = static_cast<const simgrid::s4u::Exec&>(a); // all activities are execs in this example
+  sg4::Activity::on_veto_cb([](const sg4::Activity& a) {
+    const auto& exec = static_cast<const sg4::Exec&>(a); // all activities are execs in this example
 
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(),
              (exec.dependencies_solved() ? "solved" : "NOT solved"),
              (exec.is_assigned() ? "assigned" : "NOT assigned"));
   });
 
-  simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity const& activity) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec const*>(&activity);
+  sg4::Activity::on_completion_cb([](sg4::Activity const& activity) {
+    const auto* exec = dynamic_cast<sg4::Exec const*>(&activity);
     if (exec == nullptr) // Only Execs are concerned here
       return;
     XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
@@ -38,9 +39,9 @@ int main(int argc, char* argv[])
   double computation_amount = fafard->get_speed();
 
   // Create a small DAG: Two parents and a child
-  simgrid::s4u::ExecPtr first_parent  = simgrid::s4u::Exec::init();
-  simgrid::s4u::ExecPtr second_parent = simgrid::s4u::Exec::init();
-  simgrid::s4u::ExecPtr child         = simgrid::s4u::Exec::init();
+  sg4::ExecPtr first_parent  = sg4::Exec::init();
+  sg4::ExecPtr second_parent = sg4::Exec::init();
+  sg4::ExecPtr child         = sg4::Exec::init();
   first_parent->add_successor(child);
   second_parent->add_successor(child);
 
@@ -59,10 +60,10 @@ int main(int argc, char* argv[])
   second_parent->vetoable_start();
   child->vetoable_start();
 
-  while (child->get_state() != simgrid::s4u::Activity::State::FINISHED) {
+  while (child->get_state() != sg4::Activity::State::FINISHED) {
     e.run();
     for (auto* a : vetoed) {
-      auto* exec = static_cast<simgrid::s4u::Exec*>(a);
+      auto* exec = static_cast<sg4::Exec*>(a);
 
       // In this simple case, we just assign the child task to a resource when its dependencies are solved
       if (exec->dependencies_solved() && not exec->is_assigned()) {
@@ -75,7 +76,7 @@ int main(int argc, char* argv[])
     vetoed.clear(); // DON'T FORGET TO CLEAR this set between two calls to run
   }
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index e59562a..4e412f2 100644 (file)
@@ -6,6 +6,7 @@
 #include "s4u-dht-chord.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(s4u_chord);
+namespace sg4 = simgrid::s4u;
 
 /* Returns whether an id belongs to the interval [start, end].
  *
@@ -54,13 +55,13 @@ Node::Node(std::vector<std::string> args)
   id_                = std::stoi(args[1]);
   XBT_DEBUG("Initialize node with id: %d", id_);
   random.set_seed(id_);
-  mailbox_           = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
+  mailbox_           = sg4::Mailbox::by_name(std::to_string(id_));
   next_finger_to_fix = 0;
   fingers_.resize(nb_bits, id_);
 
   if (args.size() == 3) { // first ring
     deadline_   = std::stod(args[2]);
-    start_time_ = simgrid::s4u::Engine::get_clock();
+    start_time_ = sg4::Engine::get_clock();
     XBT_DEBUG("Create a new Chord ring...");
   } else {
     known_id_   = std::stoi(args[2]);
@@ -110,7 +111,7 @@ void Node::notifyAndQuit()
 
   XBT_DEBUG("Sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]);
   try {
-    simgrid::s4u::Mailbox::by_name(std::to_string(fingers_[0]))->put(pred_msg, 10, timeout);
+    sg4::Mailbox::by_name(std::to_string(fingers_[0]))->put(pred_msg, 10, timeout);
   } catch (const simgrid::TimeoutException&) {
     XBT_DEBUG("Timeout expired when sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]);
     delete pred_msg;
@@ -124,7 +125,7 @@ void Node::notifyAndQuit()
     XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
 
     try {
-      simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_))->put(succ_msg, 10, timeout);
+      sg4::Mailbox::by_name(std::to_string(pred_id_))->put(succ_msg, 10, timeout);
     } catch (const simgrid::TimeoutException&) {
       XBT_DEBUG("Timeout expired when sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
       delete succ_msg;
@@ -204,8 +205,8 @@ void Node::checkPredecessor()
   if (pred_id_ == -1)
     return;
 
-  simgrid::s4u::Mailbox* mailbox        = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_));
-  simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive");
+  sg4::Mailbox* mailbox        = sg4::Mailbox::by_name(std::to_string(pred_id_));
+  sg4::Mailbox* return_mailbox = sg4::Mailbox::by_name(std::to_string(id_) + "_is_alive");
 
   auto* message         = new ChordMessage(MessageType::PREDECESSOR_ALIVE);
   message->request_id   = pred_id_;
@@ -224,7 +225,7 @@ void Node::checkPredecessor()
   XBT_DEBUG("Sent 'Predecessor Alive' request to %d, waiting for the answer on my mailbox '%s'", pred_id_,
             message->answer_to->get_cname());
   ChordMessage* answer       = nullptr;
-  simgrid::s4u::CommPtr comm = return_mailbox->get_async<ChordMessage>(&answer);
+  sg4::CommPtr comm          = return_mailbox->get_async<ChordMessage>(&answer);
 
   try {
     comm->wait_for(timeout);
@@ -244,8 +245,8 @@ void Node::checkPredecessor()
 int Node::remoteGetPredecessor(int ask_to)
 {
   int predecessor_id                      = -1;
-  simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
-  simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred");
+  sg4::Mailbox* mailbox                   = sg4::Mailbox::by_name(std::to_string(ask_to));
+  sg4::Mailbox* return_mailbox            = sg4::Mailbox::by_name(std::to_string(id_) + "_pred");
 
   auto* message         = new ChordMessage(MessageType::GET_PREDECESSOR);
   message->request_id   = id_;
@@ -265,7 +266,7 @@ int Node::remoteGetPredecessor(int ask_to)
   XBT_DEBUG("Sent 'Get Predecessor' request to %d, waiting for the answer on my mailbox '%s'", ask_to,
             message->answer_to->get_cname());
   ChordMessage* answer       = nullptr;
-  simgrid::s4u::CommPtr comm = return_mailbox->get_async<ChordMessage>(&answer);
+  sg4::CommPtr comm          = return_mailbox->get_async<ChordMessage>(&answer);
 
   try {
     comm->wait_for(timeout);
@@ -315,8 +316,8 @@ int Node::findSuccessor(int id)
 int Node::remoteFindSuccessor(int ask_to, int id)
 {
   int successor                           = -1;
-  simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
-  simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
+  sg4::Mailbox* mailbox                   = sg4::Mailbox::by_name(std::to_string(ask_to));
+  sg4::Mailbox* return_mailbox            = sg4::Mailbox::by_name(std::to_string(id_) + "_succ");
 
   auto* message         = new ChordMessage(MessageType::FIND_SUCCESSOR);
   message->request_id   = id_;
@@ -334,7 +335,7 @@ int Node::remoteFindSuccessor(int ask_to, int id)
   // receive the answer
   XBT_DEBUG("Sent a 'Find Successor' request to %d for key %d, waiting for the answer", ask_to, id);
   ChordMessage* answer       = nullptr;
-  simgrid::s4u::CommPtr comm = return_mailbox->get_async<ChordMessage>(&answer);
+  sg4::CommPtr comm          = return_mailbox->get_async<ChordMessage>(&answer);
 
   try {
     comm->wait_for(timeout);
@@ -370,7 +371,7 @@ void Node::remoteNotify(int notify_id, int predecessor_candidate_id) const
 
   // send a "Notify" request to notify_id
   XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
-  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(notify_id));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::to_string(notify_id));
   mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
 }
 
@@ -417,7 +418,7 @@ void Node::handleMessage(ChordMessage* message)
         int closest = closestPrecedingFinger(message->request_id);
         XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
                   message->request_id, closest);
-        simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest));
+        sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::to_string(closest));
         mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
       }
       break;
@@ -478,7 +479,7 @@ void Node::handleMessage(ChordMessage* message)
 
 void Node::operator()()
 {
-  simgrid::s4u::this_actor::sleep_for(start_time_);
+  sg4::this_actor::sleep_for(start_time_);
   if (known_id_ == -1) {
     setPredecessor(-1); // -1 means that I have no predecessor
     printFingerTable();
@@ -490,12 +491,12 @@ void Node::operator()()
   if (not joined)
     return;
   ChordMessage* message              = nullptr;
-  double now                         = simgrid::s4u::Engine::get_clock();
+  double now                         = sg4::Engine::get_clock();
   double next_stabilize_date         = start_time_ + PERIODIC_STABILIZE_DELAY;
   double next_fix_fingers_date       = start_time_ + PERIODIC_FIX_FINGERS_DELAY;
   double next_check_predecessor_date = start_time_ + PERIODIC_CHECK_PREDECESSOR_DELAY;
   double next_lookup_date            = start_time_ + PERIODIC_LOOKUP_DELAY;
-  simgrid::s4u::CommPtr comm_receive = nullptr;
+  sg4::CommPtr comm_receive          = nullptr;
   while (now < std::min(start_time_ + deadline_, MAX_SIMULATION_TIME)) {
     if (comm_receive == nullptr)
       comm_receive = mailbox_->get_async<ChordMessage>(&message);
@@ -517,23 +518,23 @@ void Node::operator()()
       // no task was received: make some periodic calls
       if (now >= next_stabilize_date) {
         stabilize();
-        next_stabilize_date = simgrid::s4u::Engine::get_clock() + PERIODIC_STABILIZE_DELAY;
+        next_stabilize_date = sg4::Engine::get_clock() + PERIODIC_STABILIZE_DELAY;
       } else if (now >= next_fix_fingers_date) {
         fixFingers();
-        next_fix_fingers_date = simgrid::s4u::Engine::get_clock() + PERIODIC_FIX_FINGERS_DELAY;
+        next_fix_fingers_date = sg4::Engine::get_clock() + PERIODIC_FIX_FINGERS_DELAY;
       } else if (now >= next_check_predecessor_date) {
         checkPredecessor();
-        next_check_predecessor_date = simgrid::s4u::Engine::get_clock() + PERIODIC_CHECK_PREDECESSOR_DELAY;
+        next_check_predecessor_date = sg4::Engine::get_clock() + PERIODIC_CHECK_PREDECESSOR_DELAY;
       } else if (now >= next_lookup_date) {
         randomLookup();
-        next_lookup_date = simgrid::s4u::Engine::get_clock() + PERIODIC_LOOKUP_DELAY;
+        next_lookup_date = sg4::Engine::get_clock() + PERIODIC_LOOKUP_DELAY;
       } else {
         // nothing to do: sleep for a while
-        simgrid::s4u::this_actor::sleep_for(SLEEP_DELAY);
+        sg4::this_actor::sleep_for(SLEEP_DELAY);
       }
     }
 
-    now = simgrid::s4u::Engine::get_clock();
+    now = sg4::Engine::get_clock();
   }
   if (comm_receive != nullptr) {
     try {
index 50ef4fd..ea42824 100644 (file)
@@ -10,6 +10,8 @@
 #include <xbt/random.hpp>
 #include <xbt/str.h>
 
+namespace sg4 = simgrid::s4u;
+
 constexpr double MAX_SIMULATION_TIME              = 1000;
 constexpr double PERIODIC_STABILIZE_DELAY         = 20;
 constexpr double PERIODIC_FIX_FINGERS_DELAY       = 120;
@@ -37,11 +39,11 @@ enum class MessageType {
 class ChordMessage {
 public:
   MessageType type;                                                                    // type of message
-  std::string issuer_host_name     = simgrid::s4u::this_actor::get_host()->get_name(); // used for logging
+  std::string issuer_host_name = sg4::this_actor::get_host()->get_name();              // used for logging
   int request_id     = -1;            // id (used by some types of messages)
   int request_finger = 1;             // finger parameter (used by some types of messages)
   int answer_id      = -1;            // answer (used by some types of messages)
-  simgrid::s4u::Mailbox* answer_to = nullptr;       // mailbox to send an answer to (if any)
+  sg4::Mailbox* answer_to      = nullptr;       // mailbox to send an answer to (if any)
 
   explicit ChordMessage(MessageType type) : type(type) {}
 
@@ -56,7 +58,7 @@ class Node {
   int id_;                           // my id
   int pred_id_ = -1;                 // predecessor id
   simgrid::xbt::random::XbtRandom random; // random number generator for this node
-  simgrid::s4u::Mailbox* mailbox_;   // my mailbox
+  sg4::Mailbox* mailbox_;                 // my mailbox
   std::vector<int> fingers_;         // finger table,(fingers[0] is my successor)
   int next_finger_to_fix;            // index of the next finger to fix in fix_fingers()
 
index 65008e8..49374f8 100644 (file)
@@ -7,6 +7,7 @@
 #include "routing_table.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia_node, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
 namespace kademlia {
 static void destroy(void* message)
@@ -18,7 +19,7 @@ static void destroy(void* message)
 /**
   * Try to asynchronously get a new message from given mailbox. Return null if none available.
   */
-Message* Node::receive(simgrid::s4u::Mailbox* mailbox)
+Message* Node::receive(sg4::Mailbox* mailbox)
 {
   if (receive_comm == nullptr)
     receive_comm = mailbox->get_async<kademlia::Message>(&received_msg);
@@ -43,7 +44,7 @@ bool Node::join(unsigned int known_id)
   /* First step: Send a "FIND_NODE" request to the node we know */
   sendFindNode(known_id, id_);
 
-  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::to_string(id_));
   do {
     if (Message* msg = receive(mailbox)) {
       XBT_DEBUG("Received an answer from the node I know.");
@@ -58,7 +59,7 @@ bool Node::join(unsigned int known_id)
       }
       delete msg;
     } else
-      simgrid::s4u::this_actor::sleep_for(1);
+      sg4::this_actor::sleep_for(1);
   } while (not got_answer);
 
   /* Second step: Send a FIND_NODE to a random node in buckets */
@@ -84,11 +85,11 @@ bool Node::join(unsigned int known_id)
 void Node::sendFindNode(unsigned int id, unsigned int destination) const
 {
   /* Gets the mailbox to send to */
-  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::to_string(id));
   /* Build the task */
 
-  auto* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)),
-                          simgrid::s4u::Host::current()->get_cname());
+  auto* msg =
+      new Message(id_, destination, sg4::Mailbox::by_name(std::to_string(id_)), sg4::Host::current()->get_cname());
 
   /* Send the task */
   mailbox->put_init(msg, 1)->detach(kademlia::destroy);
@@ -188,7 +189,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
   unsigned int answers;
   bool destination_found   = false;
   unsigned int nodes_added = 0;
-  double global_timeout    = simgrid::s4u::Engine::get_clock() + FIND_NODE_GLOBAL_TIMEOUT;
+  double global_timeout    = sg4::Engine::get_clock() + FIND_NODE_GLOBAL_TIMEOUT;
   unsigned int steps       = 0;
 
   /* First we build a list of who we already know */
@@ -201,11 +202,11 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
     answers        = 0;
     queries        = sendFindNodeToBest(node_list.get());
     nodes_added    = 0;
-    double timeout = simgrid::s4u::Engine::get_clock() + FIND_NODE_TIMEOUT;
+    double timeout = sg4::Engine::get_clock() + FIND_NODE_TIMEOUT;
     steps++;
-    double time_beginreceive = simgrid::s4u::Engine::get_clock();
+    double time_beginreceive = sg4::Engine::get_clock();
 
-    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
+    sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::to_string(id_));
     do {
       if (Message* msg = receive(mailbox)) {
         // Check if what we have received is what we are looking for.
@@ -227,17 +228,17 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
             handleFindNode(msg);
           }
           // Update the timeout if we didn't have our answer
-          timeout += simgrid::s4u::Engine::get_clock() - time_beginreceive;
-          time_beginreceive = simgrid::s4u::Engine::get_clock();
+          timeout += sg4::Engine::get_clock() - time_beginreceive;
+          time_beginreceive = sg4::Engine::get_clock();
         }
         delete msg;
       } else {
-        simgrid::s4u::this_actor::sleep_for(1);
+        sg4::this_actor::sleep_for(1);
       }
-    } while (simgrid::s4u::Engine::get_clock() < timeout && answers < queries);
+    } while (sg4::Engine::get_clock() < timeout && answers < queries);
     destination_found = node_list->destinationFound();
-  } while (not destination_found && (nodes_added > 0 || answers == 0) &&
-           simgrid::s4u::Engine::get_clock() < global_timeout && steps < MAX_STEPS);
+  } while (not destination_found && (nodes_added > 0 || answers == 0) && sg4::Engine::get_clock() < global_timeout &&
+           steps < MAX_STEPS);
 
   if (destination_found) {
     if (count_in_stats)
@@ -272,9 +273,8 @@ void Node::handleFindNode(const Message* msg)
   XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),
            msg->issuer_host_name_.c_str(), msg->destination_id_);
   // Building the answer to the request
-  auto* answer =
-      new Message(id_, msg->destination_id_, findClosest(msg->destination_id_),
-                  simgrid::s4u::Mailbox::by_name(std::to_string(id_)), simgrid::s4u::Host::current()->get_cname());
+  auto* answer = new Message(id_, msg->destination_id_, findClosest(msg->destination_id_),
+                             sg4::Mailbox::by_name(std::to_string(id_)), sg4::Host::current()->get_cname());
   // Sending the answer
   msg->answer_to_->put_init(answer, 1)->detach(kademlia::destroy);
 }
index aa01483..58b4ead 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2022. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2022. 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. */
@@ -11,6 +10,7 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
 /** @brief Node function
   * @param my node ID
@@ -40,25 +40,25 @@ static void node(std::vector<std::string> args)
   if (join_success) {
     XBT_VERB("Ok, I'm joining the network with id %u", node.getId());
     // We start the main loop
-    double next_lookup_time = simgrid::s4u::Engine::get_clock() + RANDOM_LOOKUP_INTERVAL;
+    double next_lookup_time = sg4::Engine::get_clock() + RANDOM_LOOKUP_INTERVAL;
 
     XBT_VERB("Main loop start");
 
-    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node.getId()));
+    sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::to_string(node.getId()));
 
-    while (simgrid::s4u::Engine::get_clock() < deadline) {
+    while (sg4::Engine::get_clock() < deadline) {
       if (kademlia::Message* msg = node.receive(mailbox)) {
         // There has been a message, we need to handle it !
         node.handleFindNode(msg);
         delete msg;
       } else {
         /* We search for a pseudo random node */
-        if (simgrid::s4u::Engine::get_clock() >= next_lookup_time) {
+        if (sg4::Engine::get_clock() >= next_lookup_time) {
           node.randomLookup();
           next_lookup_time += RANDOM_LOOKUP_INTERVAL;
         } else {
           // Didn't get a message: sleep for a while...
-          simgrid::s4u::this_actor::sleep_for(1);
+          sg4::this_actor::sleep_for(1);
         }
       }
     }
@@ -72,7 +72,7 @@ static void node(std::vector<std::string> args)
 /** @brief Main function */
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   /* Check the arguments */
   xbt_assert(argc > 2,
@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
 
   e.run();
 
-  XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulated time: %g", sg4::Engine::get_clock());
 
   return 0;
 }
index ebdc075..607e3e2 100644 (file)
@@ -34,8 +34,9 @@
 #include "simgrid/plugins/energy.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
-static void simulate_bootup(simgrid::s4u::Host* host)
+static void simulate_bootup(sg4::Host* host)
 {
   unsigned long previous_pstate = host->get_pstate();
 
@@ -46,13 +47,13 @@ static void simulate_bootup(simgrid::s4u::Host* host)
   host->turn_on();
 
   XBT_INFO("Wait 150s to simulate the boot time.");
-  simgrid::s4u::this_actor::sleep_for(150);
+  sg4::this_actor::sleep_for(150);
 
   XBT_INFO("The host is now up and running. Switch back to previous pstate %lu", previous_pstate);
   host->set_pstate(previous_pstate);
 }
 
-static void simulate_shutdown(simgrid::s4u::Host* host)
+static void simulate_shutdown(sg4::Host* host)
 {
   unsigned long previous_pstate = host->get_pstate();
 
@@ -60,7 +61,7 @@ static void simulate_shutdown(simgrid::s4u::Host* host)
   host->set_pstate(4);
 
   XBT_INFO("Wait 7 seconds to simulate the shutdown time.");
-  simgrid::s4u::this_actor::sleep_for(7);
+  sg4::this_actor::sleep_for(7);
 
   XBT_INFO("Switch back to previous pstate %lu, that will be used on reboot.", previous_pstate);
   host->set_pstate(previous_pstate);
@@ -71,13 +72,13 @@ static void simulate_shutdown(simgrid::s4u::Host* host)
 
 static void monitor()
 {
-  simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1");
+  sg4::Host* host1 = sg4::Host::by_name("MyHost1");
 
   XBT_INFO("Initial pstate: %lu; Energy dissipated so far:%.0E J", host1->get_pstate(),
            sg_host_get_consumed_energy(host1));
 
   XBT_INFO("Sleep for 10 seconds");
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
   XBT_INFO("Done sleeping. Current pstate: %lu; Energy dissipated so far: %.2f J", host1->get_pstate(),
            sg_host_get_consumed_energy(host1));
 
@@ -86,7 +87,7 @@ static void monitor()
            sg_host_get_consumed_energy(host1));
 
   XBT_INFO("Sleep for 10 seconds");
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
   XBT_INFO("Done sleeping. Current pstate: %lu; Energy dissipated so far: %.2f J", host1->get_pstate(),
            sg_host_get_consumed_energy(host1));
 
@@ -98,12 +99,12 @@ static void monitor()
 int main(int argc, char* argv[])
 {
   sg_host_energy_plugin_init();
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("Boot Monitor", e.host_by_name("MyHost2"), monitor);
+  sg4::Actor::create("Boot Monitor", e.host_by_name("MyHost2"), monitor);
 
   e.run();
 
index e74d98e..39c52d5 100644 (file)
@@ -7,12 +7,13 @@
 #include "simgrid/plugins/energy.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void runner()
 {
-  simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1");
-  simgrid::s4u::Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
-  std::vector<simgrid::s4u::Host*> hosts{host1, host2};
+  sg4::Host* host1 = sg4::Host::by_name("MyHost1");
+  sg4::Host* host2 = sg4::Host::by_name("MyHost2");
+  std::vector<sg4::Host*> hosts{host1, host2};
 
   double old_energy_host1 = sg_host_get_consumed_energy(host1);
   double old_energy_host2 = sg_host_get_consumed_energy(host2);
@@ -24,39 +25,41 @@ static void runner()
   XBT_INFO("[%s] Initial peak speed=%.0E flop/s; Total energy dissipated =%.0E J", host2->get_cname(), host2->get_speed(),
            old_energy_host2);
 
-  double start = simgrid::s4u::Engine::get_clock();
+  double start = sg4::Engine::get_clock();
   XBT_INFO("Sleep for 10 seconds");
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
 
   double new_energy_host1 = sg_host_get_consumed_energy(host1);
   double new_energy_host2 = sg_host_get_consumed_energy(host2);
   XBT_INFO("Done sleeping (duration: %.2f s).\n"
            "[%s] Current peak speed=%.0E; Energy dissipated during this step=%.2f J; Total energy dissipated=%.2f J\n"
            "[%s] Current peak speed=%.0E; Energy dissipated during this step=%.2f J; Total energy dissipated=%.2f J\n",
-           simgrid::s4u::Engine::get_clock() - start,
-           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
-           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+           sg4::Engine::get_clock() - start, host1->get_cname(), host1->get_speed(),
+           (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1), host2->get_cname(),
+           host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
 
   old_energy_host1 = new_energy_host1;
   old_energy_host2 = new_energy_host2;
 
 
   // ========= Execute something =========
-  start             = simgrid::s4u::Engine::get_clock();
+  start             = sg4::Engine::get_clock();
   double flopAmount = 1E9;
   std::vector<double> cpu_amounts{flopAmount, flopAmount};
   std::vector<double> com_amounts{0, 0, 0, 0};
   XBT_INFO("Run a task of %.0E flops on two hosts", flopAmount);
-  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts, com_amounts);
+  sg4::this_actor::parallel_execute(hosts, cpu_amounts, com_amounts);
 
   new_energy_host1 = sg_host_get_consumed_energy(host1);
   new_energy_host2 = sg_host_get_consumed_energy(host2);
-  XBT_INFO("Task done (duration: %.2f s).\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
-           simgrid::s4u::Engine::get_clock() - start,
-           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
-           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+  XBT_INFO(
+      "Task done (duration: %.2f s).\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f "
+      "J\n",
+      sg4::Engine::get_clock() - start, host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1),
+      sg_host_get_consumed_energy(host1), host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2),
+      sg_host_get_consumed_energy(host2));
 
   old_energy_host1 = new_energy_host1;
   old_energy_host2 = new_energy_host2;
@@ -71,84 +74,92 @@ static void runner()
 
 
   // ========= Run another ptask =========
-  start             = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   std::vector<double> cpu_amounts2{flopAmount, flopAmount};
   std::vector<double> com_amounts2{0, 0, 0, 0};
   XBT_INFO("Run a task of %.0E flops on %s and %.0E flops on %s.", flopAmount, host1->get_cname(), flopAmount, host2->get_cname());
-  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts2, com_amounts2);
+  sg4::this_actor::parallel_execute(hosts, cpu_amounts2, com_amounts2);
 
   new_energy_host1 = sg_host_get_consumed_energy(host1);
   new_energy_host2 = sg_host_get_consumed_energy(host2);
-  XBT_INFO("Task done (duration: %.2f s).\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
-           simgrid::s4u::Engine::get_clock() - start,
-           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
-           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+  XBT_INFO(
+      "Task done (duration: %.2f s).\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f "
+      "J\n",
+      sg4::Engine::get_clock() - start, host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1),
+      sg_host_get_consumed_energy(host1), host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2),
+      sg_host_get_consumed_energy(host2));
 
   old_energy_host1 = new_energy_host1;
   old_energy_host2 = new_energy_host2;
 
 
   // ========= A new ptask with computation and communication =========
-  start             = simgrid::s4u::Engine::get_clock();
+  start            = sg4::Engine::get_clock();
   double comAmount = 1E7;
   std::vector<double> cpu_amounts3{flopAmount, flopAmount};
   std::vector<double> com_amounts3{0, comAmount, comAmount, 0};
   XBT_INFO("Run a task with computation and communication on two hosts.");
-  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts3, com_amounts3);
+  sg4::this_actor::parallel_execute(hosts, cpu_amounts3, com_amounts3);
 
   new_energy_host1 = sg_host_get_consumed_energy(host1);
   new_energy_host2 = sg_host_get_consumed_energy(host2);
-  XBT_INFO("Task done (duration: %.2f s).\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
-           simgrid::s4u::Engine::get_clock() - start,
-           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
-           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+  XBT_INFO(
+      "Task done (duration: %.2f s).\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f "
+      "J\n",
+      sg4::Engine::get_clock() - start, host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1),
+      sg_host_get_consumed_energy(host1), host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2),
+      sg_host_get_consumed_energy(host2));
 
   old_energy_host1 = new_energy_host1;
   old_energy_host2 = new_energy_host2;
 
 
   // ========= A new ptask with communication only =========
-  start             = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   std::vector<double> cpu_amounts4{0, 0};
   std::vector<double> com_amounts4{0, comAmount, comAmount, 0};
   XBT_INFO("Run a task with only communication on two hosts.");
-  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts4, com_amounts4);
+  sg4::this_actor::parallel_execute(hosts, cpu_amounts4, com_amounts4);
 
   new_energy_host1 = sg_host_get_consumed_energy(host1);
   new_energy_host2 = sg_host_get_consumed_energy(host2);
-  XBT_INFO("Task done (duration: %.2f s).\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
-           simgrid::s4u::Engine::get_clock() - start,
-           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
-           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+  XBT_INFO(
+      "Task done (duration: %.2f s).\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f "
+      "J\n",
+      sg4::Engine::get_clock() - start, host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1),
+      sg_host_get_consumed_energy(host1), host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2),
+      sg_host_get_consumed_energy(host2));
 
   old_energy_host1 = new_energy_host1;
   old_energy_host2 = new_energy_host2;
 
   // ========= A new ptask with computation and a timeout =========
-  start             = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   std::vector<double> cpu_amounts5{flopAmount, flopAmount};
   std::vector<double> com_amounts5{0, 0, 0, 0};
   XBT_INFO("Run a task with computation on two hosts and a timeout of 20s.");
   try {
-    simgrid::s4u::this_actor::exec_init(hosts, cpu_amounts5, com_amounts5)->wait_for(20);
+    sg4::this_actor::exec_init(hosts, cpu_amounts5, com_amounts5)->wait_for(20);
   } catch (const simgrid::TimeoutException &){
     XBT_INFO("Finished WITH timeout");
   }
 
   new_energy_host1 = sg_host_get_consumed_energy(host1);
   new_energy_host2 = sg_host_get_consumed_energy(host2);
-  XBT_INFO("Task ended (duration: %.2f s).\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
-           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
-           simgrid::s4u::Engine::get_clock() - start,
-           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
-           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+  XBT_INFO(
+      "Task ended (duration: %.2f s).\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+      "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f "
+      "J\n",
+      sg4::Engine::get_clock() - start, host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1),
+      sg_host_get_consumed_energy(host1), host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2),
+      sg_host_get_consumed_energy(host2));
 
   XBT_INFO("Now is time to quit!");
 }
@@ -156,13 +167,13 @@ static void runner()
 int main(int argc, char* argv[])
 {
   sg_host_energy_plugin_init();
-  simgrid::s4u::Engine e(&argc, argv);
-  simgrid::s4u::Engine::set_config("host/model:ptask_L07");
+  sg4::Engine e(&argc, argv);
+  sg4::Engine::set_config("host/model:ptask_L07");
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("energy_ptask_test", e.host_by_name("MyHost1"), runner);
+  sg4::Actor::create("energy_ptask_test", e.host_by_name("MyHost1"), runner);
 
   e.run();
   XBT_INFO("End of simulation.");
index 006fe45..1c573c3 100644 (file)
@@ -7,31 +7,32 @@
 #include "simgrid/plugins/energy.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void dvfs()
 {
-  simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1");
-  simgrid::s4u::Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
+  sg4::Host* host1 = sg4::Host::by_name("MyHost1");
+  sg4::Host* host2 = sg4::Host::by_name("MyHost2");
 
   XBT_INFO("Energetic profile: %s", host1->get_property("wattage_per_state"));
   XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", host1->get_speed(),
            sg_host_get_consumed_energy(host1));
 
-  double start = simgrid::s4u::Engine::get_clock();
+  double start = sg4::Engine::get_clock();
   XBT_INFO("Sleep for 10 seconds");
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
-           simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
+           sg4::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
 
   // Execute something
-  start             = simgrid::s4u::Engine::get_clock();
+  start             = sg4::Engine::get_clock();
   double flopAmount = 100E6;
   XBT_INFO("Run a computation of %.0E flops", flopAmount);
-  simgrid::s4u::this_actor::execute(flopAmount);
+  sg4::this_actor::execute(flopAmount);
   XBT_INFO(
       "Computation done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
       " depending on load; Energy dissipated=%.0f J",
-      simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_wattmin_at(host1, host1->get_pstate()),
+      sg4::Engine::get_clock() - start, host1->get_speed(), sg_host_get_wattmin_at(host1, host1->get_pstate()),
       sg_host_get_wattmax_at(host1, host1->get_pstate()), sg_host_get_consumed_energy(host1));
 
   // ========= Change power peak =========
@@ -41,37 +42,37 @@ static void dvfs()
            host1->get_pstate_speed(pstate), host1->get_speed());
 
   // Run another computation
-  start = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   XBT_INFO("Run a computation of %.0E flops", flopAmount);
-  simgrid::s4u::this_actor::execute(flopAmount);
+  sg4::this_actor::execute(flopAmount);
   XBT_INFO("Computation done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-           simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
+           sg4::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
 
-  start = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   XBT_INFO("Sleep for 4 seconds");
-  simgrid::s4u::this_actor::sleep_for(4);
+  sg4::this_actor::sleep_for(4);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-           simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
+           sg4::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
 
   // =========== Turn the other host off ==========
   XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
            sg_host_get_consumed_energy(host2));
   host2->turn_off();
-  start = simgrid::s4u::Engine::get_clock();
-  simgrid::s4u::this_actor::sleep_for(10);
+  start = sg4::Engine::get_clock();
+  sg4::this_actor::sleep_for(10);
   XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
-           simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
+           sg4::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1));
 }
 
 int main(int argc, char* argv[])
 {
   sg_host_energy_plugin_init();
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("dvfs_test", e.host_by_name("MyHost1"), dvfs);
+  sg4::Actor::create("dvfs_test", e.host_by_name("MyHost1"), dvfs);
 
   e.run();
 
index d347a3f..66e849c 100644 (file)
@@ -13,6 +13,7 @@ static const int min_size = 1e6;
 static const int max_size = 1e9;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_energyconsumption, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void sender(std::vector<std::string> args)
 {
@@ -21,10 +22,10 @@ static void sender(std::vector<std::string> args)
   long comm_size  = std::stol(args.at(1));
   XBT_INFO("Send %ld bytes, in %d flows", comm_size, flow_amount);
 
-  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("message"));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("message"));
 
   /* Sleep a while before starting the example */
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
 
   if (flow_amount == 1) {
     /* - Send the task to the @ref worker */
@@ -32,10 +33,10 @@ static void sender(std::vector<std::string> args)
     mailbox->put(payload, comm_size);
   } else {
     // Start all comms in parallel, and wait for all completions in one shot
-    std::vector<simgrid::s4u::CommPtr> comms;
+    std::vector<sg4::CommPtr> comms;
     for (int i = 0; i < flow_amount; i++)
       comms.push_back(mailbox->put_async(bprintf("%d", i), comm_size));
-    simgrid::s4u::Comm::wait_all(comms);
+    sg4::Comm::wait_all(comms);
   }
   XBT_INFO("sender done.");
 }
@@ -46,7 +47,7 @@ static void receiver(std::vector<std::string> args)
 
   XBT_INFO("Receiving %d flows ...", flow_amount);
 
-  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("message"));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("message"));
 
   if (flow_amount == 1) {
     char* res = mailbox->get<char>();
@@ -55,11 +56,11 @@ static void receiver(std::vector<std::string> args)
     std::vector<char*> data(flow_amount);
 
     // Start all comms in parallel, and wait for their completion in one shot
-    std::vector<simgrid::s4u::CommPtr> comms;
+    std::vector<sg4::CommPtr> comms;
     for (int i = 0; i < flow_amount; i++)
       comms.push_back(mailbox->get_async<char>(&data[i]));
 
-    simgrid::s4u::Comm::wait_all(comms);
+    sg4::Comm::wait_all(comms);
     for (int i = 0; i < flow_amount; i++)
       xbt_free(data[i]);
   }
@@ -68,7 +69,7 @@ static void receiver(std::vector<std::string> args)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   XBT_INFO("Activating the SimGrid link energy plugin");
   sg_link_energy_plugin_init();
@@ -99,8 +100,8 @@ int main(int argc, char* argv[])
   } else { // No parameter at all? Then use the default value
     argSender.emplace_back("25000");
   }
-  simgrid::s4u::Actor::create("sender", e.host_by_name("MyHost1"), sender, argSender);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("MyHost2"), receiver, argReceiver);
+  sg4::Actor::create("sender", e.host_by_name("MyHost1"), sender, argSender);
+  sg4::Actor::create("receiver", e.host_by_name("MyHost2"), receiver, argReceiver);
 
   /* And now, launch the simulation */
   e.run();
index 3615664..e81f2e0 100644 (file)
@@ -8,18 +8,19 @@
 #include "simgrid/s4u/VirtualMachine.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example");
+namespace sg4 = simgrid::s4u;
 
 static void executor()
 {
-  simgrid::s4u::this_actor::execute(300E6);
+  sg4::this_actor::execute(300E6);
   XBT_INFO("This worker is done.");
 }
 
 static void dvfs()
 {
-  simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1");
-  simgrid::s4u::Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
-  simgrid::s4u::Host* host3 = simgrid::s4u::Host::by_name("MyHost3");
+  sg4::Host* host1 = sg4::Host::by_name("MyHost1");
+  sg4::Host* host2 = sg4::Host::by_name("MyHost2");
+  sg4::Host* host3 = sg4::Host::by_name("MyHost3");
 
   /* Host 1 */
   XBT_INFO("Creating and starting two VMs");
@@ -29,22 +30,22 @@ static void dvfs()
   vm_host2->start();
 
   XBT_INFO("Create two activities on Host1: both inside a VM");
-  simgrid::s4u::Actor::create("p11", vm_host1, executor);
-  simgrid::s4u::Actor::create("p12", vm_host1, executor);
+  sg4::Actor::create("p11", vm_host1, executor);
+  sg4::Actor::create("p12", vm_host1, executor);
 
   XBT_INFO("Create two activities on Host2: one inside a VM, the other directly on the host");
-  simgrid::s4u::Actor::create("p21", vm_host2, executor);
-  simgrid::s4u::Actor::create("p22", host2, executor);
+  sg4::Actor::create("p21", vm_host2, executor);
+  sg4::Actor::create("p22", host2, executor);
 
   XBT_INFO("Create two activities on Host3: both directly on the host");
-  simgrid::s4u::Actor::create("p31", host3, executor);
-  simgrid::s4u::Actor::create("p32", host3, executor);
+  sg4::Actor::create("p31", host3, executor);
+  sg4::Actor::create("p32", host3, executor);
 
   XBT_INFO("Wait 5 seconds. The activities are still running (they run for 3 seconds, but 2 activities are co-located, "
            "so they run for 6 seconds)");
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
   XBT_INFO("Wait another 5 seconds. The activities stop at some point in between");
-  simgrid::s4u::this_actor::sleep_for(5);
+  sg4::this_actor::sleep_for(5);
 
   vm_host1->destroy();
   vm_host2->destroy();
@@ -53,19 +54,19 @@ static void dvfs()
 int main(int argc, char* argv[])
 {
   sg_host_energy_plugin_init();
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("dvfs", e.host_by_name("MyHost1"), dvfs);
+  sg4::Actor::create("dvfs", e.host_by_name("MyHost1"), dvfs);
 
   e.run();
 
   XBT_INFO("Total simulation time: %.2f; Host2 and Host3 must have the exact same energy consumption; Host1 is "
            "multi-core and will differ.",
-           simgrid::s4u::Engine::get_clock());
+           sg4::Engine::get_clock());
 
   return 0;
 }
index c65552a..84047a6 100644 (file)
 #include "simgrid/s4u/Mailbox.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test_wifi, "Wifi energy demo");
+namespace sg4 = simgrid::s4u;
 
 static void sender()
 {
   // start sending after 5 seconds
-  simgrid::s4u::this_actor::sleep_until(5);
+  sg4::this_actor::sleep_until(5);
 
   std::string mbName = "MailBoxRCV";
-  simgrid::s4u::Mailbox *dst = simgrid::s4u::Mailbox::by_name(mbName);
+  sg4::Mailbox* dst  = sg4::Mailbox::by_name(mbName);
 
   int size = 6750000;
 
@@ -39,7 +40,7 @@ static void receiver()
 {
   std::string mbName = "MailBoxRCV";
   XBT_INFO("RECEIVING on mb %s", mbName.c_str());
-  simgrid::s4u::Mailbox *myBox = simgrid::s4u::Mailbox::by_name(mbName);
+  sg4::Mailbox* myBox = sg4::Mailbox::by_name(mbName);
   myBox->get<std::string>();
 
   XBT_INFO("received all messages");
@@ -47,7 +48,7 @@ static void receiver()
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine engine(&argc, argv);
+  sg4::Engine engine(&argc, argv);
   sg_wifi_energy_plugin_init();
   engine.load_platform(argv[1]);
 
@@ -57,8 +58,8 @@ int main(int argc, char** argv)
   l->set_host_wifi_rate(engine.host_by_name("Station 2"), 0);
 
   // create the two actors for the test
-  simgrid::s4u::Actor::create("act0", engine.host_by_name("Station 1"), sender);
-  simgrid::s4u::Actor::create("act1", engine.host_by_name("Station 2"), receiver);
+  sg4::Actor::create("act0", engine.host_by_name("Station 1"), sender);
+  sg4::Actor::create("act1", engine.host_by_name("Station 2"), receiver);
 
   engine.run();
 
index 294b7ab..7136e33 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <simgrid/s4u.hpp>
 
-/* This example shows how to use simgrid::s4u::Engine::get_filtered_hosts() to retrieve
+/* This example shows how to use sg4::Engine::get_filtered_hosts() to retrieve
  * all hosts that match a given criteria. This criteria can be specified either with:
  *   - an inlined callback
  *   - a boolean function, such as filter_speed_more_than_50Mf() below
  */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_engine_filtering, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 namespace filter {
 /* First example of thing that we can use as a filtering criteria: a simple boolean function */
-static bool filter_speed_more_than_50Mf(const simgrid::s4u::Host* host)
+static bool filter_speed_more_than_50Mf(const sg4::Host* host)
 {
   return host->get_speed() > 50E6;
 }
@@ -29,38 +30,37 @@ static bool filter_speed_more_than_50Mf(const simgrid::s4u::Host* host)
  */
 class SingleCore {
 public:
-  bool operator()(const simgrid::s4u::Host* host) const { return host->get_core_count() == 1; }
+  bool operator()(const sg4::Host* host) const { return host->get_core_count() == 1; }
 };
 
 /* This functor is a bit more complex, as it saves the current state when created.
  * Then, it allows one to easily retrieve the hosts which frequency changed since the functor creation.
  */
 class FrequencyChanged {
-  std::map<simgrid::s4u::Host*, unsigned long> host_list;
+  std::map<sg4::Host*, unsigned long> host_list;
 
 public:
-  explicit FrequencyChanged(const simgrid::s4u::Engine& e)
+  explicit FrequencyChanged(const sg4::Engine& e)
   {
-    std::vector<simgrid::s4u::Host*> list = e.get_all_hosts();
+    std::vector<sg4::Host*> list = e.get_all_hosts();
     for (auto& host : list) {
       host_list.insert({host, host->get_pstate()});
     }
   }
 
-  bool operator()(simgrid::s4u::Host* host) { return host->get_pstate() != host_list.at(host); }
+  bool operator()(sg4::Host* host) { return host->get_pstate() != host_list.at(host); }
 
-  unsigned long get_old_speed_state(simgrid::s4u::Host* host) { return host_list.at(host); }
+  unsigned long get_old_speed_state(sg4::Host* host) { return host_list.at(host); }
 };
 }
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
   /* Use a lambda function to filter hosts: We only want multicore hosts */
   XBT_INFO("Hosts currently registered with this engine: %zu", e.get_host_count());
-  std::vector<simgrid::s4u::Host*> list =
-      e.get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
+  std::vector<sg4::Host*> list = e.get_filtered_hosts([](const sg4::Host* host) { return host->get_core_count() > 1; });
 
   for (auto& host : list)
     XBT_INFO("The following hosts have more than one core: %s", host->get_cname());
index 4075c7d..399efa7 100644 (file)
@@ -8,9 +8,10 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 /* This actor simply executes and waits the activity it got as a parameter. */
-static void runner(simgrid::s4u::ExecPtr activity)
+static void runner(sg4::ExecPtr activity)
 {
   activity->start();
   activity->wait();
@@ -20,21 +21,21 @@ static void runner(simgrid::s4u::ExecPtr activity)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Host* fafard = e.host_by_name("Fafard");
+  sg4::Host* fafard = e.host_by_name("Fafard");
 
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(fafard->get_speed() * 10.)->set_host(fafard);
-  simgrid::s4u::Actor::create("runner", fafard, runner, activity);
+  sg4::ExecPtr activity = sg4::this_actor::exec_init(fafard->get_speed() * 10.)->set_host(fafard);
+  sg4::Actor::create("runner", fafard, runner, activity);
 
   while (activity->get_remaining() > 0) {
     XBT_INFO("Remaining amount of flops: %g (%.0f%%)", activity->get_remaining(),
              100 * activity->get_remaining_ratio());
-    e.run_until(simgrid::s4u::Engine::get_clock() + 1);
+    e.run_until(sg4::Engine::get_clock() + 1);
   }
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index c17f334..6d2dcd9 100644 (file)
@@ -6,14 +6,15 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 /* This actor simply waits for its activity completion after starting it.
  * That's exactly equivalent to synchronous execution. */
 static void waiter()
 {
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+  double computation_amount = sg4::this_actor::get_host()->get_speed();
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
+  sg4::ExecPtr activity = sg4::this_actor::exec_init(computation_amount);
   activity->start();
   activity->wait();
 
@@ -23,15 +24,15 @@ static void waiter()
 /* This actor tests the ongoing execution until its completion, and don't wait before it's terminated. */
 static void monitor()
 {
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+  double computation_amount = sg4::this_actor::get_host()->get_speed();
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
+  sg4::ExecPtr activity = sg4::this_actor::exec_init(computation_amount);
   activity->start();
 
   while (not activity->test()) {
     XBT_INFO("Remaining amount of flops: %g (%.0f%%)", activity->get_remaining(),
              100 * activity->get_remaining_ratio());
-    simgrid::s4u::this_actor::sleep_for(0.3);
+    sg4::this_actor::sleep_for(0.3);
   }
 
   XBT_INFO("Goodbye now!");
@@ -40,11 +41,11 @@ static void monitor()
 /* This actor cancels the ongoing execution after a while. */
 static void canceller()
 {
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+  double computation_amount = sg4::this_actor::get_host()->get_speed();
 
   XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(computation_amount);
-  simgrid::s4u::this_actor::sleep_for(0.5);
+  sg4::ExecPtr activity = sg4::this_actor::exec_async(computation_amount);
+  sg4::this_actor::sleep_for(0.5);
   XBT_INFO("I changed my mind, cancel!");
   activity->cancel();
 
@@ -53,20 +54,20 @@ static void canceller()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Host* fafard  = e.host_by_name("Fafard");
-  simgrid::s4u::Host* ginette = e.host_by_name("Ginette");
-  simgrid::s4u::Host* boivin  = e.host_by_name("Boivin");
+  sg4::Host* fafard  = e.host_by_name("Fafard");
+  sg4::Host* ginette = e.host_by_name("Ginette");
+  sg4::Host* boivin  = e.host_by_name("Boivin");
 
-  simgrid::s4u::Actor::create("wait", fafard, waiter);
-  simgrid::s4u::Actor::create("monitor", ginette, monitor);
-  simgrid::s4u::Actor::create("cancel", boivin, canceller);
+  sg4::Actor::create("wait", fafard, waiter);
+  sg4::Actor::create("monitor", ginette, monitor);
+  sg4::Actor::create("cancel", boivin, canceller);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 66e95d2..c2b33b4 100644 (file)
@@ -6,12 +6,13 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void executor()
 {
   /* this_actor::execute() tells SimGrid to pause the calling actor
    * until its host has computed the amount of flops passed as a parameter */
-  simgrid::s4u::this_actor::execute(98095);
+  sg4::this_actor::execute(98095);
   XBT_INFO("Done.");
 
   /* This simple example does not do anything beyond that */
@@ -24,7 +25,7 @@ static void privileged()
    * Since the priority is 2, it computes twice as fast as a regular one.
    *
    * So instead of a half/half sharing between the two executions, we get a 1/3 vs 2/3 sharing. */
-  simgrid::s4u::this_actor::execute(98095, 2);
+  sg4::this_actor::execute(98095, 2);
   XBT_INFO("Done.");
 
   /* Note that the timings printed when running this example are a bit misleading, because the uneven sharing only  last
@@ -34,13 +35,13 @@ static void privileged()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("executor", e.host_by_name("Tremblay"), executor);
-  simgrid::s4u::Actor::create("privileged", e.host_by_name("Tremblay"), privileged);
+  sg4::Actor::create("executor", e.host_by_name("Tremblay"), executor);
+  sg4::Actor::create("privileged", e.host_by_name("Tremblay"), privileged);
 
   e.run();
 
index 5352e41..7f37d61 100644 (file)
@@ -7,21 +7,22 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void worker()
 {
   // Define an amount of work that should take 1 second to execute.
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+  double computation_amount = sg4::this_actor::get_host()->get_speed();
 
-  std::vector<simgrid::s4u::ExecPtr> pending_execs;
+  std::vector<sg4::ExecPtr> pending_execs;
   // Create a small DAG
   // + Two parents and a child
   // + First parent ends after 1 second and the Second parent after 2 seconds.
-  simgrid::s4u::ExecPtr first_parent  = simgrid::s4u::this_actor::exec_init(computation_amount);
+  sg4::ExecPtr first_parent = sg4::this_actor::exec_init(computation_amount);
   pending_execs.push_back(first_parent);
-  simgrid::s4u::ExecPtr second_parent = simgrid::s4u::this_actor::exec_init(2 * computation_amount);
+  sg4::ExecPtr second_parent = sg4::this_actor::exec_init(2 * computation_amount);
   pending_execs.push_back(second_parent);
-  simgrid::s4u::ExecPtr child = simgrid::s4u::Exec::init()->set_flops_amount(computation_amount);
+  sg4::ExecPtr child = sg4::Exec::init()->set_flops_amount(computation_amount);
   pending_execs.push_back(child);
 
   // Name the activities (for logging purposes only)
@@ -41,7 +42,7 @@ static void worker()
 
   // wait for the completion of all activities
   while (not pending_execs.empty()) {
-    ssize_t changed_pos = simgrid::s4u::Exec::wait_any_for(pending_execs, -1);
+    ssize_t changed_pos = sg4::Exec::wait_any_for(pending_execs, -1);
     XBT_INFO("Exec '%s' is complete", pending_execs[changed_pos]->get_cname());
     pending_execs.erase(pending_execs.begin() + changed_pos);
   }
@@ -49,13 +50,13 @@ static void worker()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Fafard"), worker);
+  sg4::Actor::create("worker", e.host_by_name("Fafard"), worker);
 
-  simgrid::s4u::Activity::on_veto_cb([&e](simgrid::s4u::Activity& a) {
-    auto& exec = static_cast<simgrid::s4u::Exec&>(a);
+  sg4::Activity::on_veto_cb([&e](sg4::Activity& a) {
+    auto& exec = static_cast<sg4::Exec&>(a);
 
     // First display the situation
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(),
@@ -71,7 +72,7 @@ int main(int argc, char* argv[])
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index f271e4a..dfcca1d 100644 (file)
@@ -6,11 +6,12 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
+namespace sg4 = simgrid::s4u;
 
 static int dvfs()
 {
   double workload = 100E6;
-  simgrid::s4u::Host* host = simgrid::s4u::this_actor::get_host();
+  sg4::Host* host = sg4::this_actor::get_host();
 
   unsigned long nb = host->get_pstate_count();
   XBT_INFO("Count of Processor states=%lu", nb);
@@ -18,9 +19,9 @@ static int dvfs()
   XBT_INFO("Current power peak=%f", host->get_speed());
 
   // Run a Computation
-  simgrid::s4u::this_actor::execute(workload);
+  sg4::this_actor::execute(workload);
 
-  double exec_time = simgrid::s4u::Engine::get_clock();
+  double exec_time = sg4::Engine::get_clock();
   XBT_INFO("Computation1 duration: %.2f", exec_time);
 
   // Change power peak
@@ -33,13 +34,13 @@ static int dvfs()
   XBT_INFO("Current power peak=%f", host->get_speed());
 
   // Run a second Computation
-  simgrid::s4u::this_actor::execute(workload);
+  sg4::this_actor::execute(workload);
 
-  exec_time = simgrid::s4u::Engine::get_clock() - exec_time;
+  exec_time = sg4::Engine::get_clock() - exec_time;
   XBT_INFO("Computation2 duration: %.2f", exec_time);
 
   // Verify that the default pstate is set to 0
-  host = simgrid::s4u::Host::by_name_or_null("MyHost2");
+  host = sg4::Host::by_name_or_null("MyHost2");
   XBT_INFO("Count of Processor states=%lu", host->get_pstate_count());
 
   XBT_INFO("Current power peak=%f", host->get_speed());
@@ -48,18 +49,18 @@ static int dvfs()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("dvfs_test", e.host_by_name("MyHost1"), dvfs);
-  simgrid::s4u::Actor::create("dvfs_test", e.host_by_name("MyHost2"), dvfs);
+  sg4::Actor::create("dvfs_test", e.host_by_name("MyHost1"), dvfs);
+  sg4::Actor::create("dvfs_test", e.host_by_name("MyHost2"), dvfs);
 
   e.run();
 
-  XBT_INFO("Total simulation time: %e", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Total simulation time: %e", sg4::Engine::get_clock());
 
   return 0;
 }
index e367b03..9ad7b47 100644 (file)
@@ -51,7 +51,7 @@ static void dispatcher(sg4::Host* host1, sg4::Host* host2)
   }
   pending_execs.pop_back();
   XBT_INFO("Wait for remaining exec, just to be nice");
-  simgrid::s4u::Exec::wait_any(pending_execs);
+  sg4::Exec::wait_any(pending_execs);
   XBT_INFO("Dispatcher ends");
 }
 
index 18256fc..ffc11d0 100644 (file)
@@ -6,7 +6,6 @@
 #include <simgrid/s4u.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_ptask_multicore, "Messages specific for this s4u example");
-
 namespace sg4 = simgrid::s4u;
 
 static void runner()
@@ -62,7 +61,7 @@ static void runner()
 
   // Add a background task and change ptask on the fly
   auto MyHost1                          = e->host_by_name("MyHost1");
-  simgrid::s4u::ExecPtr background_task = MyHost1->exec_async(5e9);
+  sg4::ExecPtr background_task          = MyHost1->exec_async(5e9);
   XBT_INFO("Start a 1-core background task on the 4-core host.");
 
   start_time = sg4::Engine::get_clock();
index 9420dcd..67f2f19 100644 (file)
 #include <simgrid/s4u.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_ptask, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void runner()
 {
   /* Retrieve the list of all hosts as an array of hosts */
-  auto hosts         = simgrid::s4u::Engine::get_instance()->get_all_hosts();
+  auto hosts         = sg4::Engine::get_instance()->get_all_hosts();
   size_t hosts_count = hosts.size();
 
   std::vector<double> computation_amounts;
@@ -41,7 +42,7 @@ static void runner()
     for (size_t j = i + 1; j < hosts_count; j++)
       communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
 
-  simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
+  sg4::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
 
   /* ------[ test 2 ]----------------- */
   XBT_INFO("We can do the same with a timeout of 10 seconds enabled.");
@@ -51,8 +52,7 @@ static void runner()
     for (size_t j = i + 1; j < hosts_count; j++)
       communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
 
-  simgrid::s4u::ExecPtr activity =
-      simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  sg4::ExecPtr activity = sg4::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
   try {
     activity->wait_for(10.0 /* timeout (in seconds)*/);
     xbt_die("Woops, this did not timeout as expected... Please report that bug.");
@@ -65,24 +65,24 @@ static void runner()
   XBT_INFO("Then, build a parallel activity involving only computations (of different amounts) and no communication");
   computation_amounts = {3e8, 6e8, 1e9}; // 300Mflop, 600Mflop, 1Gflop
   communication_amounts.clear();         // no comm
-  simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
+  sg4::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
 
   /* ------[ test 4 ]----------------- */
   XBT_INFO("Then, build a parallel activity with no computation nor communication (synchro only)");
   computation_amounts.clear();
   communication_amounts.clear();
-  simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
+  sg4::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
 
   /* ------[ test 5 ]----------------- */
   XBT_INFO("Then, Monitor the execution of a parallel activity");
   computation_amounts.assign(hosts_count, 1e6 /*1Mflop*/);
   communication_amounts = {0, 1e6, 0, 0, 0, 1e6, 1e6, 0, 0};
-  activity              = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  activity              = sg4::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
   activity->start();
 
   while (not activity->test()) {
     XBT_INFO("Remaining flop ratio: %.0f%%", 100 * activity->get_remaining_ratio());
-    simgrid::s4u::this_actor::sleep_for(5);
+    sg4::this_actor::sleep_for(5);
   }
   activity->wait();
 
@@ -91,10 +91,10 @@ static void runner()
   XBT_INFO("  - Start a regular parallel execution, with both comm and computation");
   computation_amounts.assign(hosts_count, 1e6 /*1Mflop*/);
   communication_amounts = {0, 1e6, 0, 0, 1e6, 0, 1e6, 0, 0};
-  activity              = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  activity              = sg4::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
   activity->start();
 
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
   double remaining_ratio = activity->get_remaining_ratio();
   XBT_INFO("  - After 10 seconds, %.2f%% remains to be done. Change it from 3 hosts to 2 hosts only.",
            remaining_ratio * 100);
@@ -104,7 +104,7 @@ static void runner()
   XBT_INFO("  - Now, simulate the reconfiguration (modeled as a comm from the removed host to the remaining ones).");
   std::vector<double> rescheduling_comp{0, 0, 0};
   std::vector<double> rescheduling_comm{0, 0, 0, 0, 0, 0, 25000, 25000, 0};
-  simgrid::s4u::this_actor::parallel_execute(hosts, rescheduling_comp, rescheduling_comm);
+  sg4::this_actor::parallel_execute(hosts, rescheduling_comp, rescheduling_comm);
 
   XBT_INFO("  - Now, let's cancel the old task and create a new task with modified comm and computation vectors:");
   XBT_INFO("    What was already done is removed, and the load of the removed host is shared between remaining ones.");
@@ -122,7 +122,7 @@ static void runner()
   communication_amounts = {0, remaining_comm, remaining_comm, 0}; // Resizing a linearized matrix is hairly
 
   activity->cancel();
-  activity = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  activity = sg4::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
 
   XBT_INFO("  - Done, let's wait for the task completion");
   activity->wait();
@@ -132,12 +132,12 @@ static void runner()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s <platform file>", argv[0]);
 
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("test", e.host_by_name("MyHost1"), runner);
+  sg4::Actor::create("test", e.host_by_name("MyHost1"), runner);
 
   e.run();
   XBT_INFO("Simulation done.");
index b91e646..54ee50b 100644 (file)
@@ -6,20 +6,21 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void wizard()
 {
-  const simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
-  simgrid::s4u::Host* ginette = simgrid::s4u::Host::by_name("Ginette");
-  simgrid::s4u::Host* boivin  = simgrid::s4u::Host::by_name("Boivin");
+  const sg4::Host* fafard = sg4::Host::by_name("Fafard");
+  sg4::Host* ginette      = sg4::Host::by_name("Ginette");
+  sg4::Host* boivin       = sg4::Host::by_name("Boivin");
 
   XBT_INFO("I'm a wizard! I can run an activity on the Ginette host from the Fafard one! Look!");
-  simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(48.492e6);
+  sg4::ExecPtr exec = sg4::this_actor::exec_init(48.492e6);
   exec->set_host(ginette);
   exec->start();
   XBT_INFO("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).");
 
-  simgrid::s4u::this_actor::sleep_for(0.1);
+  sg4::this_actor::sleep_for(0.1);
   XBT_INFO("Loads in flops/s: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", boivin->get_load(), fafard->get_load(),
            ginette->get_load());
 
@@ -27,16 +28,16 @@ static void wizard()
 
   XBT_INFO("Done!");
   XBT_INFO("And now, harder. Start a remote activity on Ginette and move it to Boivin after 0.5 sec");
-  exec = simgrid::s4u::this_actor::exec_init(73293500)->set_host(ginette);
+  exec = sg4::this_actor::exec_init(73293500)->set_host(ginette);
   exec->start();
 
-  simgrid::s4u::this_actor::sleep_for(0.5);
+  sg4::this_actor::sleep_for(0.5);
   XBT_INFO("Loads before the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", boivin->get_load(), fafard->get_load(),
            ginette->get_load());
 
   exec->set_host(boivin);
 
-  simgrid::s4u::this_actor::sleep_for(0.1);
+  sg4::this_actor::sleep_for(0.1);
   XBT_INFO("Loads after the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", boivin->get_load(), fafard->get_load(),
            ginette->get_load());
 
@@ -44,10 +45,10 @@ static void wizard()
   XBT_INFO("Done!");
 
   XBT_INFO("And now, even harder. Start a remote activity on Ginette and turn off the host after 0.5 sec");
-  exec = simgrid::s4u::this_actor::exec_init(48.492e6)->set_host(ginette);
+  exec = sg4::this_actor::exec_init(48.492e6)->set_host(ginette);
   exec->start();
 
-  simgrid::s4u::this_actor::sleep_for(0.5);
+  sg4::this_actor::sleep_for(0.5);
   ginette->turn_off();
   try {
     exec->wait();
@@ -59,9 +60,9 @@ static void wizard()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("test", e.host_by_name("Fafard"), wizard);
+  sg4::Actor::create("test", e.host_by_name("Fafard"), wizard);
 
   e.run();
 
index 17ef0a2..be32587 100644 (file)
@@ -7,34 +7,34 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void worker()
 {
   // Define an amount of work that should take 1 second to execute.
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+  double computation_amount = sg4::this_actor::get_host()->get_speed();
 
   // Create an unassigned activity and start it
-  simgrid::s4u::ExecPtr exec =
-      simgrid::s4u::Exec::init()->set_flops_amount(computation_amount)->set_name("exec")->vetoable_start();
+  sg4::ExecPtr exec = sg4::Exec::init()->set_flops_amount(computation_amount)->set_name("exec")->vetoable_start();
 
   // Wait for a while
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
 
   // Assign the activity to the current host. This triggers its start, then waits for it completion.
-  exec->set_host(simgrid::s4u::Host::current())->wait();
+  exec->set_host(sg4::Host::current())->wait();
   XBT_INFO("Exec '%s' is complete", exec->get_cname());
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Fafard"), worker);
+  sg4::Actor::create("worker", e.host_by_name("Fafard"), worker);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 41ad77d..1a2b87d 100644 (file)
@@ -9,22 +9,23 @@
 #include <string>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_exec_waitany, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void worker(bool with_timeout)
 {
   /* Vector in which we store all pending executions*/
-  std::vector<simgrid::s4u::ExecPtr> pending_executions;
+  std::vector<sg4::ExecPtr> pending_executions;
 
   for (int i = 0; i < 3; i++) {
     std::string name = std::string("Exec-") + std::to_string(i);
-    double amount    = (6 * (i % 2) + i + 1) * simgrid::s4u::this_actor::get_host()->get_speed();
+    double amount    = (6 * (i % 2) + i + 1) * sg4::this_actor::get_host()->get_speed();
 
-    simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(amount)->set_name(name);
+    sg4::ExecPtr exec = sg4::this_actor::exec_init(amount)->set_name(name);
     pending_executions.push_back(exec);
     exec->start();
 
     XBT_INFO("Activity %s has started for %.0f seconds", name.c_str(),
-             amount / simgrid::s4u::this_actor::get_host()->get_speed());
+             amount / sg4::this_actor::get_host()->get_speed());
   }
 
   /* Now that executions were initiated, wait for their completion, in order of termination.
@@ -35,9 +36,9 @@ static void worker(bool with_timeout)
   while (not pending_executions.empty()) {
     ssize_t pos;
     if (with_timeout)
-      pos = simgrid::s4u::Exec::wait_any_for(pending_executions, 4);
+      pos = sg4::Exec::wait_any_for(pending_executions, 4);
     else
-      pos = simgrid::s4u::Exec::wait_any(pending_executions);
+      pos = sg4::Exec::wait_any(pending_executions);
 
     if (pos < 0) {
       XBT_INFO("Do not wait any longer for an activity");
@@ -52,10 +53,10 @@ static void worker(bool with_timeout)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker, false);
-  simgrid::s4u::Actor::create("worker_timeout", e.host_by_name("Tremblay"), worker, true);
+  sg4::Actor::create("worker", e.host_by_name("Tremblay"), worker, false);
+  sg4::Actor::create("worker_timeout", e.host_by_name("Tremblay"), worker, true);
   e.run();
 
   return 0;
index a298102..f5baa0c 100644 (file)
@@ -6,14 +6,15 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_exec_waitfor, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void worker()
 {
-  simgrid::s4u::ExecPtr exec;
-  double amount = 5 * simgrid::s4u::this_actor::get_host()->get_speed();
+  sg4::ExecPtr exec;
+  double amount = 5 * sg4::this_actor::get_host()->get_speed();
   XBT_INFO("Create an activity that should run for 5 seconds");
 
-  exec = simgrid::s4u::this_actor::exec_async(amount);
+  exec = sg4::this_actor::exec_async(amount);
 
   /* Now that execution is started, wait for 3 seconds. */
   XBT_INFO("But let it end after 3 seconds");
@@ -26,7 +27,7 @@ static void worker()
 
   /* do it again, but this time with a timeout greater than the duration of the execution */
   XBT_INFO("Create another activity that should run for 5 seconds and wait for it for 6 seconds");
-  exec = simgrid::s4u::this_actor::exec_async(amount);
+  exec = sg4::this_actor::exec_async(amount);
   try {
     exec->wait_for(6);
     XBT_INFO("Execution complete");
@@ -35,7 +36,7 @@ static void worker()
   }
 
   XBT_INFO("Finally test with a parallel execution");
-  auto hosts         = simgrid::s4u::Engine::get_instance()->get_all_hosts();
+  auto hosts         = sg4::Engine::get_instance()->get_all_hosts();
   size_t hosts_count = hosts.size();
   std::vector<double> computation_amounts;
   std::vector<double> communication_amounts;
@@ -46,7 +47,7 @@ static void worker()
     for (size_t j = i + 1; j < hosts_count; j++)
       communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
 
-  exec = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  exec = sg4::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
   try {
     exec->wait_for(2);
     XBT_INFO("Parallel Execution complete");
@@ -57,9 +58,9 @@ static void worker()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), worker);
+  sg4::Actor::create("worker", e.host_by_name("Tremblay"), worker);
   e.run();
 
   return 0;
index fd510f7..3c828ff 100644 (file)
@@ -6,13 +6,14 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void test(sg_size_t size)
 {
-  const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+  const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
   XBT_INFO("Hello! read %llu bytes from %s", size, disk->get_cname());
 
-  simgrid::s4u::IoPtr activity = disk->io_init(size, simgrid::s4u::Io::OpType::READ);
+  sg4::IoPtr activity = disk->io_init(size, sg4::Io::OpType::READ);
   activity->start();
   activity->wait();
 
@@ -21,10 +22,10 @@ static void test(sg_size_t size)
 
 static void test_waitfor(sg_size_t size)
 {
-  const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+  const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
   XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
 
-  simgrid::s4u::IoPtr activity = disk->write_async(size);
+  sg4::IoPtr activity = disk->write_async(size);
   try {
     activity->wait_for(0.5);
   } catch (const simgrid::TimeoutException&) {
@@ -36,12 +37,12 @@ static void test_waitfor(sg_size_t size)
 
 static void test_cancel(sg_size_t size)
 {
-  const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
-  simgrid::s4u::this_actor::sleep_for(0.5);
+  const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
+  sg4::this_actor::sleep_for(0.5);
   XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
 
-  simgrid::s4u::IoPtr activity = disk->write_async(size);
-  simgrid::s4u::this_actor::sleep_for(0.5);
+  sg4::IoPtr activity = disk->write_async(size);
+  sg4::this_actor::sleep_for(0.5);
   XBT_INFO("I changed my mind, cancel!");
   activity->cancel();
 
@@ -50,13 +51,13 @@ static void test_cancel(sg_size_t size)
 
 static void test_monitor(sg_size_t size)
 {
-  const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
-  simgrid::s4u::this_actor::sleep_for(1);
-  simgrid::s4u::IoPtr activity = disk->write_async(size);
+  const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
+  sg4::this_actor::sleep_for(1);
+  sg4::IoPtr activity = disk->write_async(size);
 
   while (not activity->test()) {
     XBT_INFO("Remaining amount of bytes to write: %g", activity->get_remaining());
-    simgrid::s4u::this_actor::sleep_for(0.2);
+    sg4::this_actor::sleep_for(0.2);
   }
   activity->wait();
 
@@ -65,16 +66,16 @@ static void test_monitor(sg_size_t size)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("test", e.host_by_name("bob"), test, 2e7);
-  simgrid::s4u::Actor::create("test_waitfor", e.host_by_name("alice"), test_waitfor, 5e7);
-  simgrid::s4u::Actor::create("test_cancel", e.host_by_name("alice"), test_cancel, 5e7);
-  simgrid::s4u::Actor::create("test_monitor", e.host_by_name("alice"), test_monitor, 5e7);
+  sg4::Actor::create("test", e.host_by_name("bob"), test, 2e7);
+  sg4::Actor::create("test_waitfor", e.host_by_name("alice"), test_waitfor, 5e7);
+  sg4::Actor::create("test_cancel", e.host_by_name("alice"), test_cancel, 5e7);
+  sg4::Actor::create("test_monitor", e.host_by_name("alice"), test_monitor, 5e7);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 93a9bd9..f2c3e18 100644 (file)
@@ -16,9 +16,8 @@
 
 #include <simgrid/s4u.hpp>
 
-namespace sg4 = simgrid::s4u;
-
 XBT_LOG_NEW_DEFAULT_CATEGORY(disk_test, "Messages specific for this simulation");
+namespace sg4 = simgrid::s4u;
 
 /** @brief Calculates the bandwidth for disk doing async operations */
 static void estimate_bw(const sg4::Disk* disk, int n_flows, bool read)
@@ -143,10 +142,10 @@ int main(int argc, char** argv)
   create_sata_disk(bob, "Griffon (SATA II)");
   zone->seal();
 
-  simgrid::s4u::Actor::create("", bob, host);
+  sg4::Actor::create("", bob, host);
 
   e.run();
-  XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulated time: %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 3f83813..11785ff 100644 (file)
@@ -8,21 +8,20 @@
 #include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void test()
 {
-  std::vector<simgrid::s4u::ActivityPtr> pending_activities;
+  std::vector<sg4::ActivityPtr> pending_activities;
 
-  simgrid::s4u::ExecPtr bob_compute = simgrid::s4u::this_actor::exec_init(1e9);
-  pending_activities.push_back(boost::dynamic_pointer_cast<simgrid::s4u::Activity>(bob_compute));
-  simgrid::s4u::IoPtr bob_write =
-      simgrid::s4u::Host::current()->get_disks().front()->io_init(4000000, simgrid::s4u::Io::OpType::WRITE);
-  pending_activities.push_back(boost::dynamic_pointer_cast<simgrid::s4u::Activity>(bob_write));
-  simgrid::s4u::IoPtr carl_read =
-      simgrid::s4u::Host::by_name("carl")->get_disks().front()->io_init(4000000, simgrid::s4u::Io::OpType::READ);
-  pending_activities.push_back(boost::dynamic_pointer_cast<simgrid::s4u::Activity>(carl_read));
-  simgrid::s4u::ExecPtr carl_compute = simgrid::s4u::Host::by_name("carl")->exec_init(1e9);
-  pending_activities.push_back(boost::dynamic_pointer_cast<simgrid::s4u::Activity>(carl_compute));
+  sg4::ExecPtr bob_compute = sg4::this_actor::exec_init(1e9);
+  pending_activities.push_back(boost::dynamic_pointer_cast<sg4::Activity>(bob_compute));
+  sg4::IoPtr bob_write = sg4::Host::current()->get_disks().front()->io_init(4000000, sg4::Io::OpType::WRITE);
+  pending_activities.push_back(boost::dynamic_pointer_cast<sg4::Activity>(bob_write));
+  sg4::IoPtr carl_read = sg4::Host::by_name("carl")->get_disks().front()->io_init(4000000, sg4::Io::OpType::READ);
+  pending_activities.push_back(boost::dynamic_pointer_cast<sg4::Activity>(carl_read));
+  sg4::ExecPtr carl_compute = sg4::Host::by_name("carl")->exec_init(1e9);
+  pending_activities.push_back(boost::dynamic_pointer_cast<sg4::Activity>(carl_compute));
 
   // Name the activities (for logging purposes only)
   bob_compute->set_name("bob compute");
@@ -46,7 +45,7 @@ static void test()
 
   // wait for the completion of all activities
   while (not pending_activities.empty()) {
-    ssize_t changed_pos = simgrid::s4u::Activity::wait_any(pending_activities);
+    ssize_t changed_pos = sg4::Activity::wait_any(pending_activities);
     XBT_INFO("Activity '%s' is complete", pending_activities[changed_pos]->get_cname());
     pending_activities.erase(pending_activities.begin() + changed_pos);
   }
@@ -54,15 +53,15 @@ static void test()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_storage_file_system_init();
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("bob", e.host_by_name("bob"), test);
+  sg4::Actor::create("bob", e.host_by_name("bob"), test);
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index d86b014..f5ce9dd 100644 (file)
@@ -8,17 +8,18 @@
 #include <unordered_map>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(disk_test, "Messages specific for this simulation");
+namespace sg4 = simgrid::s4u;
 
 static void host()
 {
   /* -Add an extra disk in a programmatic way */
-  simgrid::s4u::Host::current()->create_disk("Disk3", /*read bandwidth*/ 9.6e7, /*write bandwidth*/6.4e7)->seal();
+  sg4::Host::current()->create_disk("Disk3", /*read bandwidth*/ 9.6e7, /*write bandwidth*/ 6.4e7)->seal();
 
   /* - Display information on the disks mounted by the current host */
-  XBT_INFO("*** Storage info on %s ***", simgrid::s4u::Host::current()->get_cname());
+  XBT_INFO("*** Storage info on %s ***", sg4::Host::current()->get_cname());
 
   /* - Retrieve all disks from current host */
-  std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
+  std::vector<sg4::Disk*> const& disk_list = sg4::Host::current()->get_disks();
 
   /* - For each disk mounted on host, display disk name and mount point */
   for (auto const& disk : disk_list)
@@ -26,7 +27,7 @@ static void host()
              disk->get_write_bandwidth());
 
   /* - Write 400,000 bytes on Disk1 */
-  simgrid::s4u::Disk* disk = disk_list.front();
+  sg4::Disk* disk          = disk_list.front();
   sg_size_t write          = disk->write(400000);
   XBT_INFO("Wrote %llu bytes on '%s'", write, disk->get_cname());
 
@@ -35,7 +36,7 @@ static void host()
   XBT_INFO("Read %llu bytes on '%s'", read, disk->get_cname());
 
   /* - Write 800,000 bytes on Disk3 */
-  const simgrid::s4u::Disk* disk3 = disk_list.back();
+  const sg4::Disk* disk3          = disk_list.back();
   sg_size_t write_on_disk3        = disk3->write(800000);
   XBT_INFO("Wrote %llu bytes on '%s'", write_on_disk3, disk3->get_cname());
 
@@ -54,7 +55,7 @@ static void host()
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
   /* - Display Host properties */
@@ -64,10 +65,10 @@ int main(int argc, char** argv)
       XBT_INFO("  %s -> %s", kv.first.c_str(), kv.second.c_str());
   }
 
-  simgrid::s4u::Actor::create("", e.host_by_name("bob"), host);
+  sg4::Actor::create("", e.host_by_name("bob"), host);
 
   e.run();
-  XBT_INFO("Simulated time: %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulated time: %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 05bc845..251f0c0 100644 (file)
 #define INMEGA (1024 * 1024)
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
+namespace sg4 = simgrid::s4u;
 
 static void host(std::vector<std::string> args)
 {
-  simgrid::s4u::File* file = simgrid::s4u::File::open(args[1], nullptr);
+  sg4::File* file          = sg4::File::open(args[1], nullptr);
   const char* filename     = file->get_path();
   XBT_INFO("Opened file '%s'", filename);
   file->dump();
@@ -23,13 +24,13 @@ static void host(std::vector<std::string> args)
 
   if (args.size() > 4) {
     if (std::stoi(args[4]) != 0) {
-      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file->size(),
-               simgrid::s4u::Host::current()->get_cname(), args[2].c_str());
-      file->remote_move(simgrid::s4u::Host::by_name(args[2]), args[3]);
+      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file->size(), sg4::Host::current()->get_cname(),
+               args[2].c_str());
+      file->remote_move(sg4::Host::by_name(args[2]), args[3]);
     } else {
-      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file->size(),
-               simgrid::s4u::Host::current()->get_cname(), args[2].c_str());
-      file->remote_copy(simgrid::s4u::Host::by_name(args[2]), args[3]);
+      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file->size(), sg4::Host::current()->get_cname(),
+               args[2].c_str());
+      file->remote_copy(sg4::Host::by_name(args[2]), args[3]);
     }
   }
   file->close();
@@ -37,12 +38,12 @@ static void host(std::vector<std::string> args)
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_storage_file_system_init();
   e.load_platform(argv[1]);
   e.register_function("host", host);
   e.load_deployment(argv[2]);
-  std::vector<simgrid::s4u::Host*> all_hosts = e.get_all_hosts();
+  std::vector<sg4::Host*> all_hosts = e.get_all_hosts();
 
   for (auto const& h : all_hosts) {
     for (auto const& d : h->get_disks())
@@ -58,6 +59,6 @@ int main(int argc, char** argv)
                sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
   }
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
   return 0;
 }
index 3dc82a0..24ba9bd 100644 (file)
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+namespace sg4 = simgrid::s4u;
 
 class MyHost {
 public:
-  void show_info(std::vector<simgrid::s4u::Disk*> const& disks) const
+  void show_info(std::vector<sg4::Disk*> const& disks) const
   {
-    XBT_INFO("Storage info on %s:", simgrid::s4u::Host::current()->get_cname());
+    XBT_INFO("Storage info on %s:", sg4::Host::current()->get_cname());
 
     for (auto const& d : disks) {
       // Retrieve disk's information
@@ -26,13 +27,13 @@ public:
 
   void operator()() const
   {
-    std::vector<simgrid::s4u::Disk*> const& disks = simgrid::s4u::Host::current()->get_disks();
+    std::vector<sg4::Disk*> const& disks = sg4::Host::current()->get_disks();
 
     show_info(disks);
 
     // Open a non-existing file to create it
     std::string filename     = "/scratch/tmp/data.txt";
-    auto* file               = simgrid::s4u::File::open(filename, nullptr);
+    auto* file               = sg4::File::open(filename, nullptr);
 
     sg_size_t write = file->write(200000); // Write 200,000 bytes
     XBT_INFO("Create a %llu bytes file named '%s' on /scratch", write, filename.c_str());
@@ -67,7 +68,7 @@ public:
     show_info(disks);
 
     // Reopen the file and then unlink it
-    file = simgrid::s4u::File::open("/scratch/tmp/simgrid.readme", nullptr);
+    file = sg4::File::open("/scratch/tmp/simgrid.readme", nullptr);
     XBT_INFO("Unlink file: '%s'", file->get_path());
     file->unlink();
     file->close(); // Unlinking the file on "disk" does not close the file and free the object
@@ -78,10 +79,10 @@ public:
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_storage_file_system_init();
   e.load_platform(argv[1]);
-  simgrid::s4u::Actor::create("host", e.host_by_name("bob"), MyHost());
+  sg4::Actor::create("host", e.host_by_name("bob"), MyHost());
   e.run();
 
   return 0;
index 33af0f4..46dbe93 100644 (file)
@@ -6,11 +6,12 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void writer()
 {
   /* - Retrieve all disks from current host */
-  std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
+  std::vector<sg4::Disk*> const& disk_list = sg4::Host::current()->get_disks();
   /* - Write 4,000,000 bytes on Disk1 */
   disk_list.front()->write(4000000);
   XBT_INFO("First write done.");
@@ -22,7 +23,7 @@ static void writer()
 static void privileged_writer()
 {
   /* - Retrieve all disks from current host */
-  std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
+  std::vector<sg4::Disk*> const& disk_list = sg4::Host::current()->get_disks();
 
   /* - Write 4,000,000 bytes on Disk1 but specifies that this I/O operation gets a larger share of the resource.
    *
@@ -37,7 +38,7 @@ static void privileged_writer()
    * quickly. */
 
   /* Resynchronize actors before second write */
-  simgrid::s4u::this_actor::sleep_for(0.05);
+  sg4::this_actor::sleep_for(0.05);
 
   /* - Write 4,000,000 bytes on Disk1 again and this time :
    *    - Start the I/O operation asynchronously to get an IoPtr
@@ -51,8 +52,8 @@ static void privileged_writer()
    *   0.025s to write the last MB.
    */
 
-  simgrid::s4u::IoPtr io = disk_list.front()->write_async(4000000);
-  simgrid::s4u::this_actor::sleep_for(0.1);
+  sg4::IoPtr io = disk_list.front()->write_async(4000000);
+  sg4::this_actor::sleep_for(0.1);
   XBT_INFO("Increase priority for the priviledged writer (%.0f bytes remaining to write)", io->get_remaining());
   io->update_priority(2);
   io->wait();
@@ -61,13 +62,13 @@ static void privileged_writer()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("writer", e.host_by_name("bob"), writer);
-  simgrid::s4u::Actor::create("privileged_writer", e.host_by_name("bob"), privileged_writer);
+  sg4::Actor::create("writer", e.host_by_name("bob"), writer);
+  sg4::Actor::create("privileged_writer", e.host_by_name("bob"), privileged_writer);
 
   e.run();
 
index bff52c5..afc56c5 100644 (file)
@@ -3,14 +3,13 @@
 /* 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. */
 
-/** @addtogroup S4U_examples
+/** Switch the system thread hosting our maestro.
  *
- *  - <b>maestro-set/maestro-set.cpp: Switch the system thread hosting our maestro</b>.
- *    That's a very advanced example in which we move the maestro context to another system thread.
- *    Not many users need it (maybe only one, actually), but this example is also a regression test.
+ *  That's a very advanced example in which we move the maestro context to another system thread.
+ *  Not many users need it (maybe only one, actually), but this example is also a regression test.
  *
- *    This example is in C++ because we use C++11 threads to ensure that the feature is working as
- *    expected. You can still use that feature from a C code.
+ *  This example is in C++ because we use C++11 threads to ensure that the feature is working as
+ *  expected. You can still use that feature from a C code.
  */
 
 #include "simgrid/Exception.hpp"
@@ -21,6 +20,7 @@
 #include <thread>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 const std::thread::id root_id = std::this_thread::get_id();
 
@@ -41,22 +41,22 @@ static void sender()
 {
   ensure_root_tid();
   auto* payload = new std::string("some message");
-  simgrid::s4u::Mailbox::by_name("some mailbox")->put(payload, 10e8);
+  sg4::Mailbox::by_name("some mailbox")->put(payload, 10e8);
 }
 
 static void receiver()
 {
   ensure_other_tid();
 
-  simgrid::s4u::Mailbox::by_name("some mailbox")->get_unique<std::string>();
+  sg4::Mailbox::by_name("some mailbox")->get_unique<std::string>();
   XBT_INFO("Task received");
 }
 
 static void maestro(void* /* data */)
 {
   ensure_other_tid();
-  simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Jupiter"), receiver);
-  simgrid::s4u::Engine::get_instance()->run();
+  sg4::Actor::create("receiver", sg4::Host::by_name("Jupiter"), receiver);
+  sg4::Engine::get_instance()->run();
 }
 
 /** Main function */
@@ -66,7 +66,7 @@ int main(int argc, char* argv[])
    * actor by the subsequent sg_actor_attach(). This must be done before the creation of the engine. */
   simgrid_set_maestro(maestro, nullptr);
 
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n"
                         "example: %s ../platforms/small_platform.xml\n",
index 6b49ae0..f5e9f2c 100644 (file)
 #include <xbt/dynar.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(bugged1_liveness, "my log messages");
+namespace sg4 = simgrid::s4u;
 
 class Message {
 public:
   enum class Kind { GRANT, REQUEST, RELEASE };
   Kind kind                             = Kind::GRANT;
-  simgrid::s4u::Mailbox* return_mailbox = nullptr;
-  explicit Message(Message::Kind kind, simgrid::s4u::Mailbox* mbox) : kind(kind), return_mailbox(mbox) {}
+  sg4::Mailbox* return_mailbox          = nullptr;
+  explicit Message(Message::Kind kind, sg4::Mailbox* mbox) : kind(kind), return_mailbox(mbox) {}
 };
 
 int r  = 0;
@@ -47,9 +48,9 @@ static void garbage_stack(void)
 static void coordinator()
 {
   bool CS_used = false;
-  std::queue<simgrid::s4u::Mailbox*> requests;
+  std::queue<sg4::Mailbox*> requests;
 
-  simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("coordinator");
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("coordinator");
 
   while (true) {
     auto m = mbox->get_unique<Message>();
@@ -67,7 +68,7 @@ static void coordinator()
     } else {
       if (not requests.empty()) {
         XBT_INFO("CS release. Grant to queued requests (queue size: %zu)", requests.size());
-        simgrid::s4u::Mailbox* req = requests.front();
+        sg4::Mailbox* req = requests.front();
         requests.pop();
         if (req->get_name() != "1") {
           req->put(new Message(Message::Kind::GRANT, mbox), 1000);
@@ -85,13 +86,13 @@ static void coordinator()
 
 static void client(int id)
 {
-  aid_t my_pid = simgrid::s4u::this_actor::get_pid();
+  aid_t my_pid = sg4::this_actor::get_pid();
 
-  simgrid::s4u::Mailbox* my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
+  sg4::Mailbox* my_mailbox = sg4::Mailbox::by_name(std::to_string(id));
 
   while (true) {
     XBT_INFO("Ask the request");
-    simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000);
+    sg4::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000);
 
     if (id == 1) {
       r  = 1;
@@ -109,11 +110,11 @@ static void client(int id)
 
     XBT_INFO("%d got the answer. Sleep a bit and release it", id);
 
-    simgrid::s4u::this_actor::sleep_for(1);
+    sg4::this_actor::sleep_for(1);
 
-    simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::RELEASE, my_mailbox), 1000);
+    sg4::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::RELEASE, my_mailbox), 1000);
 
-    simgrid::s4u::this_actor::sleep_for(static_cast<double>(my_pid));
+    sg4::this_actor::sleep_for(static_cast<double>(my_pid));
 
     if (id == 1) {
       cs = 0;
@@ -136,21 +137,21 @@ static void raw_client(int id)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   MC_automaton_new_propositional_symbol_pointer("r", &r);
   MC_automaton_new_propositional_symbol_pointer("cs", &cs);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("coordinator", e.host_by_name("Tremblay"), coordinator)
+  sg4::Actor::create("coordinator", e.host_by_name("Tremblay"), coordinator)
       ->set_kill_time(argc > 3 ? std::stod(argv[3]) : -1.0);
   if (std::stod(argv[2]) == 0) {
-    simgrid::s4u::Actor::create("client", e.host_by_name("Boivin"), raw_client, 1);
-    simgrid::s4u::Actor::create("client", e.host_by_name("Fafard"), raw_client, 2);
+    sg4::Actor::create("client", e.host_by_name("Boivin"), raw_client, 1);
+    sg4::Actor::create("client", e.host_by_name("Fafard"), raw_client, 2);
   } else { // "Visited" case
-    simgrid::s4u::Actor::create("client", e.host_by_name("Boivin"), raw_client, 2);
-    simgrid::s4u::Actor::create("client", e.host_by_name("Fafard"), raw_client, 1);
+    sg4::Actor::create("client", e.host_by_name("Boivin"), raw_client, 2);
+    sg4::Actor::create("client", e.host_by_name("Fafard"), raw_client, 1);
   }
   e.run();
 
index a2b47d9..fe40d93 100644 (file)
@@ -14,6 +14,7 @@
 constexpr int N = 3;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
+namespace sg4 = simgrid::s4u;
 
 static void server()
 {
@@ -21,7 +22,7 @@ static void server()
   int count     = 0;
   while (count < N) {
     received.reset();
-    received = simgrid::s4u::Mailbox::by_name("mymailbox")->get_unique<int>();
+    received = sg4::Mailbox::by_name("mymailbox")->get_unique<int>();
     count++;
   }
   int value_got = *received;
@@ -33,21 +34,21 @@ static void server()
 static void client(int id)
 {
   auto* payload = new int(id);
-  simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload, 10000);
+  sg4::Mailbox::by_name("mymailbox")->put(payload, 10000);
 
   XBT_INFO("Sent!");
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("server", e.host_by_name("HostA"), server);
-  simgrid::s4u::Actor::create("client", e.host_by_name("HostB"), client, 1);
-  simgrid::s4u::Actor::create("client", e.host_by_name("HostC"), client, 2);
-  simgrid::s4u::Actor::create("client", e.host_by_name("HostD"), client, 3);
+  sg4::Actor::create("server", e.host_by_name("HostA"), server);
+  sg4::Actor::create("client", e.host_by_name("HostB"), client, 1);
+  sg4::Actor::create("client", e.host_by_name("HostC"), client, 2);
+  sg4::Actor::create("client", e.host_by_name("HostD"), client, 3);
 
   e.run();
   return 0;
index f96587a..eb1c34e 100644 (file)
 #include <simgrid/s4u.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(bugged2_liveness, "my log messages");
+namespace sg4 = simgrid::s4u;
 
 class Message {
 public:
   enum class Kind { GRANT, NOT_GRANT, REQUEST };
   Kind kind                             = Kind::GRANT;
-  simgrid::s4u::Mailbox* return_mailbox = nullptr;
-  explicit Message(Message::Kind kind, simgrid::s4u::Mailbox* mbox) : kind(kind), return_mailbox(mbox) {}
+  sg4::Mailbox* return_mailbox          = nullptr;
+  explicit Message(Message::Kind kind, sg4::Mailbox* mbox) : kind(kind), return_mailbox(mbox) {}
 };
 
 int cs = 0;
@@ -27,9 +28,9 @@ int cs = 0;
 static void coordinator()
 {
   bool CS_used = false; // initially the CS is idle
-  std::queue<simgrid::s4u::Mailbox*> requests;
+  std::queue<sg4::Mailbox*> requests;
 
-  simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("coordinator");
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("coordinator");
 
   while (true) {
     auto m = mbox->get_unique<Message>();
@@ -51,13 +52,13 @@ static void coordinator()
 
 static void client(int id)
 {
-  aid_t my_pid = simgrid::s4u::this_actor::get_pid();
+  aid_t my_pid = sg4::this_actor::get_pid();
 
-  simgrid::s4u::Mailbox* my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
+  sg4::Mailbox* my_mailbox = sg4::Mailbox::by_name(std::to_string(id));
 
   while (true) {
     XBT_INFO("Client (%d) asks the request", id);
-    simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000);
+    sg4::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000);
 
     auto grant = my_mailbox->get_unique<Message>();
 
@@ -69,21 +70,21 @@ static void client(int id)
       XBT_INFO("Client (%d) got the answer (not grant). Try again", id);
     }
 
-    simgrid::s4u::this_actor::sleep_for(my_pid);
+    sg4::this_actor::sleep_for(my_pid);
   }
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   MC_automaton_new_propositional_symbol_pointer("cs", &cs);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("coordinator", e.host_by_name("Tremblay"), coordinator);
-  simgrid::s4u::Actor::create("client", e.host_by_name("Fafard"), client, 1);
-  simgrid::s4u::Actor::create("client", e.host_by_name("Boivin"), client, 2);
+  sg4::Actor::create("coordinator", e.host_by_name("Tremblay"), coordinator);
+  sg4::Actor::create("client", e.host_by_name("Fafard"), client, 1);
+  sg4::Actor::create("client", e.host_by_name("Boivin"), client, 2);
 
   e.run();
 
index 281efc1..b2e11ca 100644 (file)
@@ -15,19 +15,20 @@ constexpr int AMOUNT_OF_CLIENTS = 4;
 constexpr int CS_PER_PROCESS    = 2;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(centralized, "my log messages");
+namespace sg4 = simgrid::s4u;
 
 class Message {
 public:
   enum class Kind { GRANT, REQUEST, RELEASE };
   Kind kind                             = Kind::GRANT;
-  simgrid::s4u::Mailbox* return_mailbox = nullptr;
-  explicit Message(Message::Kind kind, simgrid::s4u::Mailbox* mbox) : kind(kind), return_mailbox(mbox) {}
+  sg4::Mailbox* return_mailbox          = nullptr;
+  explicit Message(Message::Kind kind, sg4::Mailbox* mbox) : kind(kind), return_mailbox(mbox) {}
 };
 
 static void coordinator()
 {
-  std::queue<simgrid::s4u::Mailbox*> requests;
-  simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("coordinator");
+  std::queue<sg4::Mailbox*> requests;
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("coordinator");
 
   bool CS_used = false;                              // initially the CS is idle
   int todo     = AMOUNT_OF_CLIENTS * CS_PER_PROCESS; // amount of releases we are expecting
@@ -46,7 +47,7 @@ static void coordinator()
     } else { // that's a release. Check if someone was waiting for the lock
       if (not requests.empty()) {
         XBT_INFO("CS release. Grant to queued requests (queue size: %zu)", requests.size());
-        simgrid::s4u::Mailbox* req = requests.front();
+        sg4::Mailbox* req = requests.front();
         requests.pop();
         req->put(new Message(Message::Kind::GRANT, mbox), 1000);
         todo--;
@@ -62,36 +63,36 @@ static void coordinator()
 
 static void client()
 {
-  aid_t my_pid = simgrid::s4u::this_actor::get_pid();
+  aid_t my_pid = sg4::this_actor::get_pid();
 
-  simgrid::s4u::Mailbox* my_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(my_pid));
+  sg4::Mailbox* my_mailbox = sg4::Mailbox::by_name(std::to_string(my_pid));
 
   // request the CS 3 times, sleeping a bit in between
   for (int i = 0; i < CS_PER_PROCESS; i++) {
     XBT_INFO("Ask the request");
-    simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000);
+    sg4::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::REQUEST, my_mailbox), 1000);
     // wait for the answer
     auto grant = my_mailbox->get_unique<Message>();
     XBT_INFO("got the answer. Sleep a bit and release it");
-    simgrid::s4u::this_actor::sleep_for(1);
+    sg4::this_actor::sleep_for(1);
 
-    simgrid::s4u::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::RELEASE, my_mailbox), 1000);
-    simgrid::s4u::this_actor::sleep_for(static_cast<double>(my_pid));
+    sg4::Mailbox::by_name("coordinator")->put(new Message(Message::Kind::RELEASE, my_mailbox), 1000);
+    sg4::this_actor::sleep_for(static_cast<double>(my_pid));
   }
   XBT_INFO("Got all the CS I wanted, quit now");
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("coordinator", e.host_by_name("Tremblay"), coordinator);
-  simgrid::s4u::Actor::create("client", e.host_by_name("Fafard"), client);
-  simgrid::s4u::Actor::create("client", e.host_by_name("Boivin"), client);
-  simgrid::s4u::Actor::create("client", e.host_by_name("Jacquelin"), client);
-  simgrid::s4u::Actor::create("client", e.host_by_name("Ginette"), client);
+  sg4::Actor::create("coordinator", e.host_by_name("Tremblay"), coordinator);
+  sg4::Actor::create("client", e.host_by_name("Fafard"), client);
+  sg4::Actor::create("client", e.host_by_name("Boivin"), client);
+  sg4::Actor::create("client", e.host_by_name("Jacquelin"), client);
+  sg4::Actor::create("client", e.host_by_name("Ginette"), client);
 
   e.run();
 
index 18d2ec5..eb91637 100644 (file)
 #include <simgrid/s4u.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(mc_assert_example, "Logging channel used in this example");
+namespace sg4 = simgrid::s4u;
 
 static int server(int worker_amount)
 {
   int value_got             = -1;
-  simgrid::s4u::Mailbox* mb = simgrid::s4u::Mailbox::by_name("server");
+  sg4::Mailbox* mb          = sg4::Mailbox::by_name("server");
   for (int count = 0; count < worker_amount; count++) {
     auto msg  = mb->get_unique<int>();
     value_got = *msg;
@@ -36,7 +37,7 @@ static int client(int rank)
   /* I just send my rank onto the mailbox. It must be passed as a stable memory block (thus the new) so that that
    * memory survives even after the end of the client */
 
-  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("server");
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name("server");
   mailbox->put(new int(rank), 1 /* communication cost is not really relevant in MC mode */);
 
   XBT_INFO("Sent!");
@@ -45,16 +46,16 @@ static int client(int rank)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n", argv[0]);
 
   e.load_platform(argv[1]);
   auto hosts = e.get_all_hosts();
   xbt_assert(hosts.size() >= 3, "This example requires at least 3 hosts");
 
-  simgrid::s4u::Actor::create("server", hosts[0], &server, 2);
-  simgrid::s4u::Actor::create("client1", hosts[1], &client, 1);
-  simgrid::s4u::Actor::create("client2", hosts[2], &client, 2);
+  sg4::Actor::create("server", hosts[0], &server, 2);
+  sg4::Actor::create("client1", hosts[1], &client, 1);
+  sg4::Actor::create("client2", hosts[2], &client, 2);
 
   e.run();
   return 0;
index eb8654d..d3ec019 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2022. The SimGrid Team. LEVEL_ALL rights reserved.          */
+/* Copyright (c) 2007-2022. 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. */
@@ -8,6 +8,7 @@
 #include <iomanip>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(ns3_wifi_example, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 class Message
 {
@@ -20,49 +21,46 @@ public:
 
 static void sender(const std::string& mailbox, int msg_size, unsigned sleep_time)
 {
-  simgrid::s4u::this_actor::sleep_for(sleep_time);
-  auto* mbox = simgrid::s4u::Mailbox::by_name(mailbox);
-  auto* msg  = new Message(simgrid::s4u::this_actor::get_host()->get_name(), msg_size);
+  sg4::this_actor::sleep_for(sleep_time);
+  auto* mbox = sg4::Mailbox::by_name(mailbox);
+  auto* msg  = new Message(sg4::this_actor::get_host()->get_name(), msg_size);
   mbox->put(msg, msg_size);
 }
 
 static void receiver(const std::string& mailbox)
 {
-  auto* mbox = simgrid::s4u::Mailbox::by_name(mailbox);
+  auto* mbox = sg4::Mailbox::by_name(mailbox);
   auto msg   = mbox->get_unique<Message>();
-  XBT_INFO("[%s] %s received %d bytes from %s",
-           mailbox.c_str(),
-           simgrid::s4u::this_actor::get_host()->get_name().c_str(),
-           msg->size,
-           msg->sender.c_str());
+  XBT_INFO("[%s] %s received %d bytes from %s", mailbox.c_str(), sg4::this_actor::get_host()->get_name().c_str(),
+           msg->size, msg->sender.c_str());
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   e.load_platform(argv[1]);
   int msg_size = 1e5;
 
   /* Communication between STA in the same wifi zone */
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA0-0"), sender, "1", msg_size, 10);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA0-1"), receiver, "1");
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA0-1"), sender, "2", msg_size, 20);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA0-0"), receiver, "2");
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA1-1"), sender, "3", msg_size, 30);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA1-2"), receiver, "3");
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA1-2"), sender, "4", msg_size, 40);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA1-1"), receiver, "4");
+  sg4::Actor::create("sender", e.host_by_name("STA0-0"), sender, "1", msg_size, 10);
+  sg4::Actor::create("receiver", e.host_by_name("STA0-1"), receiver, "1");
+  sg4::Actor::create("sender", e.host_by_name("STA0-1"), sender, "2", msg_size, 20);
+  sg4::Actor::create("receiver", e.host_by_name("STA0-0"), receiver, "2");
+  sg4::Actor::create("sender", e.host_by_name("STA1-1"), sender, "3", msg_size, 30);
+  sg4::Actor::create("receiver", e.host_by_name("STA1-2"), receiver, "3");
+  sg4::Actor::create("sender", e.host_by_name("STA1-2"), sender, "4", msg_size, 40);
+  sg4::Actor::create("receiver", e.host_by_name("STA1-1"), receiver, "4");
 
   /* Communication between STA of different wifi zones */
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA0-0"), sender, "5", msg_size, 50);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA1-0"), receiver, "5");
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA1-0"), sender, "6", msg_size, 60);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA0-0"), receiver, "6");
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA0-1"), sender, "7", msg_size, 70);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA1-2"), receiver, "7");
-  simgrid::s4u::Actor::create("sender", e.host_by_name("STA1-2"), sender, "8", msg_size, 80);
-  simgrid::s4u::Actor::create("receiver", e.host_by_name("STA0-1"), receiver, "8");
+  sg4::Actor::create("sender", e.host_by_name("STA0-0"), sender, "5", msg_size, 50);
+  sg4::Actor::create("receiver", e.host_by_name("STA1-0"), receiver, "5");
+  sg4::Actor::create("sender", e.host_by_name("STA1-0"), sender, "6", msg_size, 60);
+  sg4::Actor::create("receiver", e.host_by_name("STA0-0"), receiver, "6");
+  sg4::Actor::create("sender", e.host_by_name("STA0-1"), sender, "7", msg_size, 70);
+  sg4::Actor::create("receiver", e.host_by_name("STA1-2"), receiver, "7");
+  sg4::Actor::create("sender", e.host_by_name("STA1-2"), sender, "8", msg_size, 80);
+  sg4::Actor::create("receiver", e.host_by_name("STA0-1"), receiver, "8");
 
   e.run();
   return 0;
index 18e7c95..ae6b990 100644 (file)
@@ -8,6 +8,7 @@
 #include <unordered_map>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 double start_time;
 std::unordered_map<int, std::string> workernames;
@@ -26,14 +27,14 @@ static void master(std::vector<std::string> args)
   /* worker name */
   workernames[id] = args[2];
 
-  simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args[3]);
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name(args[3]);
 
-  masternames[id] = simgrid::s4u::Host::current()->get_name();
+  masternames[id] = sg4::Host::current()->get_name();
 
   auto* payload = new double(msg_size);
 
   /* time measurement */
-  start_time = simgrid::s4u::Engine::get_clock();
+  start_time = sg4::Engine::get_clock();
   mbox->put(payload, static_cast<uint64_t>(msg_size));
 
   XBT_DEBUG("Finished");
@@ -44,13 +45,13 @@ static void worker(std::vector<std::string> args)
   xbt_assert(args.size() == 2, "Strange number of arguments expected 1 got %zu", args.size() - 1);
 
   int id                      = std::stoi(args[1]);
-  simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args[1]);
+  sg4::Mailbox* mbox          = sg4::Mailbox::by_name(args[1]);
 
   XBT_DEBUG("Worker started");
 
   auto payload = mbox->get_unique<double>();
 
-  double elapsed_time = simgrid::s4u::Engine::get_clock() - start_time;
+  double elapsed_time = sg4::Engine::get_clock() - start_time;
 
   XBT_INFO("FLOW[%d] : Receive %.0f bytes from %s to %s", id, *payload, masternames.at(id).c_str(),
            workernames.at(id).c_str());
@@ -61,7 +62,7 @@ static void worker(std::vector<std::string> args)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 2,
              "Usage: %s platform_file deployment_file\n"
              "\tExample: %s platform.xml deployment.xml\n",
index 80ad05d..e021061 100644 (file)
  */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_network_wifi, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
-static void sender(simgrid::s4u::Mailbox* mailbox, int data_size)
+static void sender(sg4::Mailbox* mailbox, int data_size)
 {
   XBT_INFO("Send a message to the other station.");
   static std::string message = "message";
   mailbox->put(&message, data_size);
   XBT_INFO("Done.");
 }
-static void receiver(simgrid::s4u::Mailbox* mailbox)
+static void receiver(sg4::Mailbox* mailbox)
 {
   XBT_INFO("Wait for a message.");
   mailbox->get<std::string>();
@@ -27,18 +28,18 @@ static void receiver(simgrid::s4u::Mailbox* mailbox)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
 
   /* Exchange a message between the 2 stations */
-  auto mailbox  = simgrid::s4u::Mailbox::by_name("mailbox");
+  auto mailbox  = sg4::Mailbox::by_name("mailbox");
   auto station1 = e.host_by_name("Station 1");
   auto station2 = e.host_by_name("Station 2");
-  simgrid::s4u::Actor::create("sender", station1, sender, mailbox, 1e7);
-  simgrid::s4u::Actor::create("receiver", station2, receiver, mailbox);
+  sg4::Actor::create("sender", station1, sender, mailbox, 1e7);
+  sg4::Actor::create("receiver", station2, receiver, mailbox);
 
   /* Declare that the stations are not at the same distance from their AP */
   auto ap = e.link_by_name("AP1");
index 9cee496..e86a99a 100644 (file)
  * speed. The first way to do so is to use a file in the XML, while the second is to use the programmatic interface. */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_platform_profile, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void watcher()
 {
-  const auto* jupiter  = simgrid::s4u::Host::by_name("Jupiter");
-  const auto* fafard   = simgrid::s4u::Host::by_name("Fafard");
-  const auto* lilibeth = simgrid::s4u::Host::by_name("Lilibeth");
-  const auto* link1    = simgrid::s4u::Link::by_name("1");
-  const auto* link2    = simgrid::s4u::Link::by_name("2");
+  const auto* jupiter  = sg4::Host::by_name("Jupiter");
+  const auto* fafard   = sg4::Host::by_name("Fafard");
+  const auto* lilibeth = sg4::Host::by_name("Lilibeth");
+  const auto* link1    = sg4::Link::by_name("1");
+  const auto* link2    = sg4::Link::by_name("2");
 
-  std::vector<simgrid::s4u::Link*> links;
+  std::vector<sg4::Link*> links;
   double lat = 0;
   jupiter->route_to(fafard, links, &lat);
 
@@ -35,13 +36,13 @@ static void watcher()
              jupiter->get_speed() * jupiter->get_available_speed() / 1000000,
              lilibeth->get_speed() * lilibeth->get_available_speed() / 1000000, link1->get_bandwidth() / 1000,
              link1->get_latency() * 1000, link2->get_bandwidth() / 1000, link2->get_latency() * 1000);
-    simgrid::s4u::this_actor::sleep_for(1);
+    sg4::this_actor::sleep_for(1);
   }
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s platform.xml\n", argv[0], argv[0]);
 
@@ -59,7 +60,7 @@ int main(int argc, char* argv[])
       ->seal();
 
   // Add a watcher of the changes
-  simgrid::s4u::Actor::create("watcher", e.host_by_name("Fafard"), watcher);
+  sg4::Actor::create("watcher", e.host_by_name("Fafard"), watcher);
 
   e.run();
 
index c46c14b..09d69ee 100644 (file)
@@ -7,37 +7,38 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void execute_load_test()
 {
-  s4u_Host* host = simgrid::s4u::Host::by_name("MyHost1");
+  s4u_Host* host = sg4::Host::by_name("MyHost1");
 
   XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0) and current average "
            "load: %.5f (should be 0)",
            host->get_speed(), sg_host_get_computed_flops(host), sg_host_get_avg_load(host));
 
-  double start = simgrid::s4u::Engine::get_clock();
+  double start = sg4::Engine::get_clock();
   XBT_INFO("Sleep for 10 seconds");
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
 
   double speed = host->get_speed();
   XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
            "changed)",
-           simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
+           sg4::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
 
   // Run an activity
-  start = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   XBT_INFO("Run an activity of %.0E flops at current speed of %.0E flop/s", 200E6, host->get_speed());
-  simgrid::s4u::this_actor::execute(200E6);
+  sg4::this_actor::execute(200E6);
 
   XBT_INFO(
       "Done working on my activity; this took %.2fs; current peak speed: %.0E flop/s (when I started the computation, "
       "the speed was set to %.0E flop/s); number of flops computed so "
       "far: %.2E, average load as reported by the HostLoad plugin: %.5f (should be %.5f)",
-      simgrid::s4u::Engine::get_clock() - start, host->get_speed(), speed, sg_host_get_computed_flops(host),
+      sg4::Engine::get_clock() - start, host->get_speed(), speed, sg_host_get_computed_flops(host),
       sg_host_get_avg_load(host),
       200E6 / (10.5 * speed * host->get_core_count() +
-               (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->get_speed() * host->get_core_count()));
+               (sg4::Engine::get_clock() - start - 0.5) * host->get_speed() * host->get_core_count()));
 
   // ========= Change power peak =========
   int pstate = 1;
@@ -47,39 +48,39 @@ static void execute_load_test()
       pstate, host->get_pstate_speed(pstate), host->get_speed(), sg_host_get_avg_load(host));
 
   // Run a second activity
-  start = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   XBT_INFO("Run an activity of %.0E flops", 100E6);
-  simgrid::s4u::this_actor::execute(100E6);
+  sg4::this_actor::execute(100E6);
   XBT_INFO("Done working on my activity; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
            "far: %.2E",
-           simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
+           sg4::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
 
-  start = simgrid::s4u::Engine::get_clock();
+  start = sg4::Engine::get_clock();
   XBT_INFO("========= Requesting a reset of the computation and load counters");
   sg_host_load_reset(host);
   XBT_INFO("After reset: %.0E flops computed; load is %.5f", sg_host_get_computed_flops(host),
            sg_host_get_avg_load(host));
   XBT_INFO("Sleep for 4 seconds");
-  simgrid::s4u::this_actor::sleep_for(4);
+  sg4::this_actor::sleep_for(4);
   XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
-           simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
+           sg4::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
 
   // =========== Turn the other host off ==========
-  s4u_Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
+  s4u_Host* host2 = sg4::Host::by_name("MyHost2");
   XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far and has an "
            "average load of %.5f.",
            sg_host_get_computed_flops(host2), sg_host_get_avg_load(host2));
   host2->turn_off();
-  start = simgrid::s4u::Engine::get_clock();
-  simgrid::s4u::this_actor::sleep_for(10);
+  start = sg4::Engine::get_clock();
+  sg4::this_actor::sleep_for(10);
   XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
-           simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
+           sg4::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host));
 }
 
 static void change_speed()
 {
-  s4u_Host* host = simgrid::s4u::Host::by_name("MyHost1");
-  simgrid::s4u::this_actor::sleep_for(10.5);
+  s4u_Host* host = sg4::Host::by_name("MyHost1");
+  sg4::this_actor::sleep_for(10.5);
   XBT_INFO("I slept until now, but now I'll change the speed of this host "
            "while the other actor is still computing! This should slow the computation down.");
   host->set_pstate(2);
@@ -88,17 +89,17 @@ static void change_speed()
 int main(int argc, char* argv[])
 {
   sg_host_load_plugin_init();
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("load_test", e.host_by_name("MyHost1"), execute_load_test);
-  simgrid::s4u::Actor::create("change_speed", e.host_by_name("MyHost1"), change_speed);
+  sg4::Actor::create("load_test", e.host_by_name("MyHost1"), execute_load_test);
+  sg4::Actor::create("change_speed", e.host_by_name("MyHost1"), change_speed);
 
   e.run();
 
-  XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Total simulation time: %.2f", sg4::Engine::get_clock());
 
   return 0;
 }
index 8b5b6f1..37b0f82 100644 (file)
@@ -7,43 +7,43 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void sender(const std::string& mailbox, uint64_t msg_size)
 {
-  auto mbox = simgrid::s4u::Mailbox::by_name(mailbox);
+  auto mbox          = sg4::Mailbox::by_name(mailbox);
   static int payload = 42;
   mbox->put(&payload, msg_size);
 }
 
 static void receiver(const std::string& mailbox)
 {
-  auto mbox = simgrid::s4u::Mailbox::by_name(mailbox);
+  auto mbox = sg4::Mailbox::by_name(mailbox);
   mbox->get<int>();
 }
 
-static void run_transfer(simgrid::s4u::Host* src_host, simgrid::s4u::Host* dst_host, const std::string& mailbox,
-                         unsigned long msg_size)
+static void run_transfer(sg4::Host* src_host, sg4::Host* dst_host, const std::string& mailbox, unsigned long msg_size)
 {
   XBT_INFO("Launching the transfer of %lu bytes", msg_size);
-  simgrid::s4u::Actor::create("sender", src_host, sender, mailbox, msg_size);
-  simgrid::s4u::Actor::create("receiver", dst_host, receiver, mailbox);
+  sg4::Actor::create("sender", src_host, sender, mailbox, msg_size);
+  sg4::Actor::create("receiver", dst_host, receiver, mailbox);
 }
 
 static void execute_load_test()
 {
-  auto host0 = simgrid::s4u::Host::by_name("node-0.simgrid.org");
-  auto host1 = simgrid::s4u::Host::by_name("node-1.simgrid.org");
+  auto host0 = sg4::Host::by_name("node-0.simgrid.org");
+  auto host1 = sg4::Host::by_name("node-1.simgrid.org");
 
-  simgrid::s4u::this_actor::sleep_for(1);
+  sg4::this_actor::sleep_for(1);
   run_transfer(host0, host1, "1", 1000 * 1000 * 1000);
 
-  simgrid::s4u::this_actor::sleep_for(10);
+  sg4::this_actor::sleep_for(10);
   run_transfer(host0, host1, "2", 1000 * 1000 * 1000);
-  simgrid::s4u::this_actor::sleep_for(3);
+  sg4::this_actor::sleep_for(3);
   run_transfer(host0, host1, "3", 1000 * 1000 * 1000);
 }
 
-static void show_link_load(const std::string& link_name, const simgrid::s4u::Link* link)
+static void show_link_load(const std::string& link_name, const sg4::Link* link)
 {
   XBT_INFO("%s link load (cum, avg, min, max): (%g, %g, %g, %g)", link_name.c_str(), sg_link_get_cum_load(link),
            sg_link_get_avg_load(link), sg_link_get_min_instantaneous_load(link),
@@ -52,9 +52,9 @@ static void show_link_load(const std::string& link_name, const simgrid::s4u::Lin
 
 static void monitor()
 {
-  auto link_backbone = simgrid::s4u::Link::by_name("cluster0_backbone");
-  auto link_host0    = simgrid::s4u::Link::by_name("cluster0_link_0_UP");
-  auto link_host1    = simgrid::s4u::Link::by_name("cluster0_link_1_DOWN");
+  auto link_backbone = sg4::Link::by_name("cluster0_backbone");
+  auto link_host0    = sg4::Link::by_name("cluster0_link_0_UP");
+  auto link_host1    = sg4::Link::by_name("cluster0_link_1_DOWN");
 
   XBT_INFO("Tracking desired links");
   sg_link_load_track(link_backbone);
@@ -62,8 +62,8 @@ static void monitor()
   sg_link_load_track(link_host1);
 
   show_link_load("Backbone", link_backbone);
-  while (simgrid::s4u::Engine::get_clock() < 5) {
-    simgrid::s4u::this_actor::sleep_for(1);
+  while (sg4::Engine::get_clock() < 5) {
+    sg4::this_actor::sleep_for(1);
     show_link_load("Backbone", link_backbone);
   }
 
@@ -75,11 +75,11 @@ static void monitor()
 
   XBT_INFO("Now resetting and probing host links each second.");
 
-  while (simgrid::s4u::Engine::get_clock() < 29) {
+  while (sg4::Engine::get_clock() < 29) {
     sg_link_load_reset(link_host0);
     sg_link_load_reset(link_host1);
 
-    simgrid::s4u::this_actor::sleep_for(1);
+    sg4::this_actor::sleep_for(1);
 
     show_link_load("Host0_UP", link_host0);
     show_link_load("Host1_UP", link_host1);
@@ -88,18 +88,18 @@ static void monitor()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_link_load_plugin_init();
 
   xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
   e.load_platform(argv[1]);
 
-  simgrid::s4u::Actor::create("load_test", e.host_by_name("node-42.simgrid.org"), execute_load_test);
-  simgrid::s4u::Actor::create("monitor", e.host_by_name("node-51.simgrid.org"), monitor);
+  sg4::Actor::create("load_test", e.host_by_name("node-42.simgrid.org"), execute_load_test);
+  sg4::Actor::create("monitor", e.host_by_name("node-51.simgrid.org"), monitor);
 
   e.run();
 
-  XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Total simulation time: %.2f", sg4::Engine::get_clock());
 
   return 0;
 }
index c9a6172..e53af5b 100644 (file)
@@ -11,6 +11,7 @@
 #include <string>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(replay_comm, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
 #define ACT_DEBUG(...)                                                                                                 \
   if (XBT_LOG_ISENABLED(replay_comm, xbt_log_priority_verbose)) {                                                   \
@@ -49,40 +50,38 @@ public:
   static void compute(simgrid::xbt::ReplayAction& action)
   {
     double amount = std::stod(action[2]);
-    double clock  = simgrid::s4u::Engine::get_clock();
+    double clock  = sg4::Engine::get_clock();
     ACT_DEBUG("Entering %s", NAME.c_str());
-    simgrid::s4u::this_actor::execute(amount);
-    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
+    sg4::this_actor::execute(amount);
+    log_action(action, sg4::Engine::get_clock() - clock);
   }
 
   static void send(simgrid::xbt::ReplayAction& action)
   {
     auto size                 = static_cast<uint64_t>(std::stod(action[3]));
     auto* payload             = new std::string(action[3]);
-    double clock              = simgrid::s4u::Engine::get_clock();
-    simgrid::s4u::Mailbox* to = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]);
+    double clock              = sg4::Engine::get_clock();
+    sg4::Mailbox* to          = sg4::Mailbox::by_name(sg4::this_actor::get_name() + "_" + action[2]);
     ACT_DEBUG("Entering Send: %s (size: %" PRIu64 ") -- Actor %s on mailbox %s", NAME.c_str(), size,
-              simgrid::s4u::this_actor::get_cname(), to->get_cname());
+              sg4::this_actor::get_cname(), to->get_cname());
     to->put(payload, size);
-    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
+    log_action(action, sg4::Engine::get_clock() - clock);
   }
 
   static void recv(simgrid::xbt::ReplayAction& action)
   {
-    double clock = simgrid::s4u::Engine::get_clock();
-    simgrid::s4u::Mailbox* from =
-        simgrid::s4u::Mailbox::by_name(std::string(action[2]) + "_" + simgrid::s4u::this_actor::get_name());
+    double clock       = sg4::Engine::get_clock();
+    sg4::Mailbox* from = sg4::Mailbox::by_name(std::string(action[2]) + "_" + sg4::this_actor::get_name());
 
-    ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), simgrid::s4u::this_actor::get_cname(),
-              from->get_cname());
+    ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), sg4::this_actor::get_cname(), from->get_cname());
     from->get_unique<std::string>();
-    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
+    log_action(action, sg4::Engine::get_clock() - clock);
   }
 };
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   xbt_assert(argc > 2,
              "Usage: %s platform_file deployment_file [action_files]\n"
@@ -106,7 +105,7 @@ int main(int argc, char* argv[])
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 7d98484..1763d4b 100644 (file)
@@ -11,6 +11,7 @@
 #include <boost/algorithm/string/join.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(replay_io, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
 #define ACT_DEBUG(...)                                                                                                 \
   if (XBT_LOG_ISENABLED(replay_io, xbt_log_priority_verbose)) {                                                        \
@@ -20,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(replay_io, "Messages specific for this example");
     ((void)0)
 
 class Replayer {
-  static std::unordered_map<std::string, simgrid::s4u::File> opened_files;
+  static std::unordered_map<std::string, sg4::File> opened_files;
 
   static void log_action(const simgrid::xbt::ReplayAction& action, double date)
   {
@@ -30,9 +31,9 @@ class Replayer {
     }
   }
 
-  static simgrid::s4u::File* get_file_descriptor(const std::string& file_name)
+  static sg4::File* get_file_descriptor(const std::string& file_name)
   {
-    std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name;
+    std::string full_name = sg4::this_actor::get_name() + ":" + file_name;
     return &opened_files.at(full_name);
   }
 
@@ -57,48 +58,48 @@ public:
   static void open(simgrid::xbt::ReplayAction& action)
   {
     std::string file_name = action[2];
-    double clock          = simgrid::s4u::Engine::get_clock();
-    std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name;
+    double clock          = sg4::Engine::get_clock();
+    std::string full_name = sg4::this_actor::get_name() + ":" + file_name;
 
     ACT_DEBUG("Entering Open: %s (filename: %s)", NAME.c_str(), file_name.c_str());
     opened_files.emplace(std::piecewise_construct, std::forward_as_tuple(full_name),
                          std::forward_as_tuple(file_name, nullptr));
 
-    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
+    log_action(action, sg4::Engine::get_clock() - clock);
   }
 
   static void read(simgrid::xbt::ReplayAction& action)
   {
     std::string file_name = action[2];
     sg_size_t size        = std::stoul(action[3]);
-    double clock          = simgrid::s4u::Engine::get_clock();
+    double clock          = sg4::Engine::get_clock();
 
-    simgrid::s4u::File* file = get_file_descriptor(file_name);
+    sg4::File* file = get_file_descriptor(file_name);
 
     ACT_DEBUG("Entering Read: %s (size: %llu)", NAME.c_str(), size);
     file->read(size);
 
-    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
+    log_action(action, sg4::Engine::get_clock() - clock);
   }
 
   static void close(simgrid::xbt::ReplayAction& action)
   {
     std::string file_name = action[2];
-    std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name;
-    double clock          = simgrid::s4u::Engine::get_clock();
+    std::string full_name = sg4::this_actor::get_name() + ":" + file_name;
+    double clock          = sg4::Engine::get_clock();
 
     ACT_DEBUG("Entering Close: %s (filename: %s)", NAME.c_str(), file_name.c_str());
     xbt_assert(opened_files.erase(full_name) == 1, "File not found in opened files: %s", full_name.c_str());
 
-    log_action(action, simgrid::s4u::Engine::get_clock() - clock);
+    log_action(action, sg4::Engine::get_clock() - clock);
   }
 };
 
-std::unordered_map<std::string, simgrid::s4u::File> Replayer::opened_files;
+std::unordered_map<std::string, sg4::File> Replayer::opened_files;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   sg_storage_file_system_init();
 
   xbt_assert(argc > 3,
@@ -122,7 +123,7 @@ int main(int argc, char* argv[])
 
   e.run();
 
-  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+  XBT_INFO("Simulation time %g", sg4::Engine::get_clock());
 
   return 0;
 }
index 783b8e8..79d36f3 100644 (file)
@@ -8,10 +8,11 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
   std::vector<simgrid::kernel::routing::ClusterZone*> clusters =
@@ -19,7 +20,7 @@ int main(int argc, char* argv[])
 
   for (auto c : clusters) {
     XBT_INFO("%s", c->get_cname());
-    std::vector<simgrid::s4u::Host*> hosts = c->get_all_hosts();
+    std::vector<sg4::Host*> hosts = c->get_all_hosts();
     for (auto h : hosts)
       XBT_INFO("   %s", h->get_cname());
   }
index f7bbf0e..7c61144 100644 (file)
@@ -6,9 +6,10 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+namespace sg4 = simgrid::s4u;
 
 /// Wait on the barrier then leave
-static void worker(simgrid::s4u::BarrierPtr barrier)
+static void worker(sg4::BarrierPtr barrier)
 {
     XBT_INFO("Waiting on the barrier");
     barrier->wait();
@@ -19,11 +20,11 @@ static void worker(simgrid::s4u::BarrierPtr barrier)
 /// Spawn actor_count-1 workers and do a barrier with them
 static void master(int actor_count)
 {
-  simgrid::s4u::BarrierPtr barrier = simgrid::s4u::Barrier::create(actor_count);
+  sg4::BarrierPtr barrier = sg4::Barrier::create(actor_count);
 
   XBT_INFO("Spawning %d workers", actor_count - 1);
   for (int i = 0; i < actor_count - 1; i++) {
-    simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker, barrier);
+    sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), worker, barrier);
   }
 
     XBT_INFO("Waiting on the barrier");
@@ -34,7 +35,7 @@ static void master(int actor_count)
 
 int main(int argc, char **argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   // Parameter: Number of actores in the barrier
   xbt_assert(argc >= 2, "Usage: %s <actor-count>\n", argv[0]);
@@ -42,7 +43,7 @@ int main(int argc, char **argv)
   xbt_assert(actor_count > 0, "<actor-count> must be greater than 0");
 
   e.load_platform(argc > 2 ? argv[2] : "../../platforms/two_hosts.xml");
-  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master, actor_count);
+  sg4::Actor::create("master", e.host_by_name("Tremblay"), master, actor_count);
   e.run();
 
   return 0;
index 493c794..69ccef1 100644 (file)
@@ -7,17 +7,18 @@
 #include <simgrid/s4u.hpp> /* All of S4U */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+namespace sg4 = simgrid::s4u;
 
-simgrid::s4u::MutexPtr mtx = nullptr;
-simgrid::s4u::ConditionVariablePtr cv = nullptr;
+sg4::MutexPtr mtx            = nullptr;
+sg4::ConditionVariablePtr cv = nullptr;
 bool ready = false;
 
 static void competitor(int id)
 {
   XBT_INFO("Entering the race...");
-  std::unique_lock<simgrid::s4u::Mutex> lck(*mtx);
+  std::unique_lock<sg4::Mutex> lck(*mtx);
   while (not ready) {
-    auto now = simgrid::s4u::Engine::get_clock();
+    auto now = sg4::Engine::get_clock();
     if (cv->wait_until(lck, now + (id+1)*0.25) == std::cv_status::timeout) {
       XBT_INFO("Out of wait_until (timeout)");
     }
@@ -31,8 +32,8 @@ static void competitor(int id)
 static void go()
 {
   XBT_INFO("Are you ready? ...");
-  simgrid::s4u::this_actor::sleep_for(3);
-  std::unique_lock<simgrid::s4u::Mutex> lck(*mtx);
+  sg4::this_actor::sleep_for(3);
+  std::unique_lock<sg4::Mutex> lck(*mtx);
   XBT_INFO("Go go go!");
   ready = true;
   cv->notify_all();
@@ -40,21 +41,21 @@ static void go()
 
 static void main_actor()
 {
-  mtx = simgrid::s4u::Mutex::create();
-  cv = simgrid::s4u::ConditionVariable::create();
+  mtx = sg4::Mutex::create();
+  cv  = sg4::ConditionVariable::create();
 
-  auto host = simgrid::s4u::this_actor::get_host();
+  auto host = sg4::this_actor::get_host();
   for (int i = 0; i < 10; ++i)
-    simgrid::s4u::Actor::create("competitor", host, competitor, i);
-  simgrid::s4u::Actor::create("go", host, go);
+    sg4::Actor::create("competitor", host, competitor, i);
+  sg4::Actor::create("go", host, go);
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform("../../platforms/small_platform.xml");
 
-  simgrid::s4u::Actor::create("main", e.host_by_name("Tremblay"), main_actor);
+  sg4::Actor::create("main", e.host_by_name("Tremblay"), main_actor);
 
   e.run();
   return 0;
index 5e14507..2805c7c 100644 (file)
@@ -7,13 +7,14 @@
 #include <simgrid/s4u.hpp> /* All of S4U */
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+namespace sg4 = simgrid::s4u;
 
 std::string data;
 bool done = false;
 
-static void worker_fun(simgrid::s4u::ConditionVariablePtr cv, simgrid::s4u::MutexPtr mutex)
+static void worker_fun(sg4::ConditionVariablePtr cv, sg4::MutexPtr mutex)
 {
-  std::unique_lock<simgrid::s4u::Mutex> lock(*mutex);
+  std::unique_lock<sg4::Mutex> lock(*mutex);
 
   XBT_INFO("Start processing data which is '%s'.", data.c_str());
   data += std::string(" after processing");
@@ -27,13 +28,13 @@ static void worker_fun(simgrid::s4u::ConditionVariablePtr cv, simgrid::s4u::Mute
 
 static void master_fun()
 {
-  auto mutex  = simgrid::s4u::Mutex::create();
-  auto cv     = simgrid::s4u::ConditionVariable::create();
+  auto mutex  = sg4::Mutex::create();
+  auto cv     = sg4::ConditionVariable::create();
   data        = std::string("Example data");
-  auto worker = simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker_fun, cv, mutex);
+  auto worker = sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), worker_fun, cv, mutex);
 
   // wait for the worker
-  cv->wait(std::unique_lock<simgrid::s4u::Mutex>(*mutex), []() { return done; });
+  cv->wait(std::unique_lock<sg4::Mutex>(*mutex), []() { return done; });
   XBT_INFO("data is now '%s'.", data.c_str());
 
   worker->join();
@@ -41,9 +42,9 @@ static void master_fun()
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform("../../platforms/two_hosts.xml");
-  simgrid::s4u::Actor::create("main", e.host_by_name("Tremblay"), master_fun);
+  sg4::Actor::create("main", e.host_by_name("Tremblay"), master_fun);
   e.run();
 
   return 0;
index 23d329f..29eb21f 100644 (file)
@@ -11,6 +11,8 @@
 #include "simgrid/instr.h"
 #include "simgrid/s4u.hpp"
 
+namespace sg4 = simgrid::s4u;
+
 struct Task {
   std::string name;
   std::string category;
@@ -20,7 +22,7 @@ struct Task {
 
 static void master()
 {
-  auto mbox = simgrid::s4u::Mailbox::by_name("master_mailbox");
+  auto mbox = sg4::Mailbox::by_name("master_mailbox");
   for (int i = 0; i < 10; i++) {
     Task task;
     if (i % 2)
@@ -37,23 +39,20 @@ static void master()
 
 static void worker()
 {
-  auto mbox = simgrid::s4u::Mailbox::by_name("master_mailbox");
+  auto mbox = sg4::Mailbox::by_name("master_mailbox");
   while (true) {
     auto task = mbox->get_unique<Task>();
     if (task->name == "finalize") {
       break;
     }
     // creating task and setting its category
-    simgrid::s4u::this_actor::exec_init(task->flops)
-        ->set_name(task->name)
-        ->set_tracing_category(task->category)
-        ->wait();
+    sg4::this_actor::exec_init(task->flops)->set_name(task->name)->set_tracing_category(task->category)->wait();
   }
 }
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n \tExample: %s small_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
@@ -64,8 +63,8 @@ int main(int argc, char* argv[])
   simgrid::instr::declare_tracing_category("data", "0 0 1");     // blue
   simgrid::instr::declare_tracing_category("finalize", "0 0 0"); // black
 
-  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Fafard"), worker);
+  sg4::Actor::create("master", e.host_by_name("Tremblay"), master);
+  sg4::Actor::create("worker", e.host_by_name("Fafard"), worker);
 
   e.run();
   return 0;
index 75cab99..7e2ea6f 100644 (file)
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void trace_fun()
 {
-  const auto host = simgrid::s4u::this_actor::get_host()->get_name();
+  const auto host = sg4::this_actor::get_host()->get_name();
 
   // the hostname has an empty HDD with a capacity of 100000 (bytes)
   simgrid::instr::set_host_variable(host, "HDD_capacity", 100000);
@@ -23,7 +24,7 @@ static void trace_fun()
 
   for (int i = 0; i < 10; i++) {
     // create and execute a task just to make the simulated time advance
-    simgrid::s4u::this_actor::execute(1e4);
+    sg4::this_actor::execute(1e4);
 
     // ADD: after the execution of this task, the HDD utilization increases by 100 (bytes)
     simgrid::instr::add_host_variable(host, "HDD_utilization", 100);
@@ -31,7 +32,7 @@ static void trace_fun()
 
   for (int i = 0; i < 10; i++) {
     // create and execute a task just to make the simulated time advance
-    simgrid::s4u::this_actor::execute(1e4);
+    sg4::this_actor::execute(1e4);
 
     // SUB: after the execution of this task, the HDD utilization decreases by 100 (bytes)
     simgrid::instr::sub_host_variable(host, "HDD_utilization", 100);
@@ -40,7 +41,7 @@ static void trace_fun()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n \tExample: %s small_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
@@ -49,7 +50,7 @@ int main(int argc, char* argv[])
   simgrid::instr::declare_host_variable("HDD_capacity");
   simgrid::instr::declare_host_variable("HDD_utilization", "1 0 0"); // red color
 
-  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), trace_fun);
+  sg4::Actor::create("master", e.host_by_name("Tremblay"), trace_fun);
 
   e.run();
 
index 179afd5..edca62c 100644 (file)
@@ -11,6 +11,8 @@
 #include "simgrid/instr.h"
 #include "simgrid/s4u.hpp"
 
+namespace sg4 = simgrid::s4u;
+
 static void trace_fun()
 {
   // set initial values for the link user variables this example only shows for links identified by "6" and "3" in the
@@ -25,7 +27,7 @@ static void trace_fun()
 
   // run the simulation, update my variables accordingly
   for (int i = 0; i < 10; i++) {
-    simgrid::s4u::this_actor::execute(1e6);
+    sg4::this_actor::execute(1e6);
 
     // Add to link user variables
     simgrid::instr::add_link_variable("3", "Link_Utilization", 5.6);
@@ -33,7 +35,7 @@ static void trace_fun()
   }
 
   for (int i = 0; i < 10; i++) {
-    simgrid::s4u::this_actor::execute(1e6);
+    sg4::this_actor::execute(1e6);
 
     // Subtract from link user variables
     simgrid::instr::sub_link_variable("3", "Link_Utilization", 3.4);
@@ -43,7 +45,7 @@ static void trace_fun()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n \tExample: %s small_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
@@ -52,12 +54,12 @@ int main(int argc, char* argv[])
   simgrid::instr::declare_link_variable("Link_Capacity");
   simgrid::instr::declare_link_variable("Link_Utilization", "0.9 0.1 0.1");
 
-  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Jupiter"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Fafard"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Ginette"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Bourassa"), trace_fun);
+  sg4::Actor::create("master", e.host_by_name("Tremblay"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Tremblay"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Jupiter"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Fafard"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Ginette"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Bourassa"), trace_fun);
 
   e.run();
   return 0;
index e7c6f87..7700fee 100644 (file)
@@ -7,6 +7,7 @@
 #include <simgrid/s4u.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_trace_masterworker, "Messages specific for this example");
+namespace sg4 = simgrid::s4u;
 
 struct Task {
   std::string name;
@@ -22,8 +23,8 @@ static void master(std::vector<std::string> args)
   double compute_cost     = std::stod(args[2]);
   long communication_cost = std::stol(args[3]);
   size_t workers_count    = args.size() - 4;
-  const auto& my_host     = simgrid::s4u::this_actor::get_host()->get_name();
-  auto mailbox            = simgrid::s4u::Mailbox::by_name("master_mailbox");
+  const auto& my_host     = sg4::this_actor::get_host()->get_name();
+  auto mailbox            = sg4::Mailbox::by_name("master_mailbox");
 
   XBT_DEBUG("Got %zu workers and %ld tasks to process", workers_count, tasks_count);
 
@@ -52,8 +53,8 @@ static void worker(std::vector<std::string> args)
 {
   xbt_assert(args.size() == 1, "The worker expects no argument");
 
-  const auto& my_host = simgrid::s4u::this_actor::get_host()->get_name();
-  auto mailbox = simgrid::s4u::Mailbox::by_name("master_mailbox");
+  const auto& my_host = sg4::this_actor::get_host()->get_name();
+  auto mailbox        = sg4::Mailbox::by_name("master_mailbox");
 
   simgrid::instr::set_host_variable(my_host, "is_worker", 1);
   simgrid::instr::set_host_variable(my_host, "task_computation", 0);
@@ -65,10 +66,7 @@ static void worker(std::vector<std::string> args)
     }
     // adding the task's cost to the variable "task_computation"
     simgrid::instr::add_host_variable(my_host, "task_computation", task->flops);
-    simgrid::s4u::this_actor::exec_init(task->flops)
-        ->set_name(task->name)
-        ->set_tracing_category(task->category)
-        ->wait();
+    sg4::this_actor::exec_init(task->flops)->set_name(task->name)->set_tracing_category(task->category)->wait();
   }
 
   XBT_DEBUG("Exiting now.");
@@ -76,7 +74,7 @@ static void worker(std::vector<std::string> args)
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
 
   e.load_platform(argv[1]);
index 06c27b6..39a9eff 100644 (file)
@@ -12,6 +12,7 @@
 #include "simgrid/s4u.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+namespace sg4 = simgrid::s4u;
 
 static void trace_fun()
 {
@@ -29,7 +30,7 @@ static void trace_fun()
 
   // run the simulation, update my variables accordingly
   for (int i = 0; i < 10; i++) {
-    simgrid::s4u::this_actor::execute(1e6);
+    sg4::this_actor::execute(1e6);
 
     // Add to link user variables
     simgrid::instr::add_link_variable("Tremblay", "Bourassa", "Link_Utilization", 5.6);
@@ -37,7 +38,7 @@ static void trace_fun()
   }
 
   for (int i = 0; i < 10; i++) {
-    simgrid::s4u::this_actor::execute(1e6);
+    sg4::this_actor::execute(1e6);
 
     // Subtract from link user variables
     simgrid::instr::sub_link_variable("Tremblay", "Bourassa", "Link_Utilization", 3.4);
@@ -47,7 +48,7 @@ static void trace_fun()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n \tExample: %s small_platform.xml\n", argv[0], argv[0]);
 
   e.load_platform(argv[1]);
@@ -56,12 +57,12 @@ int main(int argc, char* argv[])
   simgrid::instr::declare_link_variable("Link_Capacity");
   simgrid::instr::declare_link_variable("Link_Utilization", "0.9 0.1 0.1");
 
-  simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Tremblay"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Jupiter"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Fafard"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Ginette"), trace_fun);
-  simgrid::s4u::Actor::create("worker", e.host_by_name("Bourassa"), trace_fun);
+  sg4::Actor::create("master", e.host_by_name("Tremblay"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Tremblay"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Jupiter"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Fafard"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Ginette"), trace_fun);
+  sg4::Actor::create("worker", e.host_by_name("Bourassa"), trace_fun);
 
   e.run();
   return 0;