Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove a bunch of dumb deployment files + simplify some examples
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Wed, 5 Jan 2022 12:16:15 +0000 (13:16 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Wed, 5 Jan 2022 12:16:15 +0000 (13:16 +0100)
18 files changed:
MANIFEST.in
examples/cpp/CMakeLists.txt
examples/cpp/actor-yield/s4u-actor-yield.cpp
examples/cpp/actor-yield/s4u-actor-yield_d.xml [deleted file]
examples/cpp/comm-ready/s4u-comm-ready.cpp
examples/cpp/comm-ready/s4u-comm-ready.tesh
examples/cpp/comm-ready/s4u-comm-ready_d.xml [deleted file]
examples/cpp/comm-suspend/s4u-comm-suspend.cpp
examples/cpp/comm-suspend/s4u-comm-suspend.tesh
examples/cpp/comm-suspend/s4u-comm-suspend_d.xml [deleted file]
examples/cpp/comm-wait/s4u-comm-wait.cpp
examples/cpp/comm-wait/s4u-comm-wait.tesh
examples/cpp/comm-wait/s4u-comm-wait_d.xml [deleted file]
examples/cpp/comm-waituntil/s4u-comm-waituntil.cpp
examples/cpp/comm-waituntil/s4u-comm-waituntil.tesh
examples/cpp/comm-waituntil/s4u-comm-waituntil_d.xml [deleted file]
examples/python/actor-yield/actor-yield.py
examples/python/actor-yield/actor-yield.tesh

index 461e9e8..4ad8115 100644 (file)
@@ -146,7 +146,6 @@ include examples/cpp/actor-suspend/s4u-actor-suspend.cpp
 include examples/cpp/actor-suspend/s4u-actor-suspend.tesh
 include examples/cpp/actor-yield/s4u-actor-yield.cpp
 include examples/cpp/actor-yield/s4u-actor-yield.tesh
-include examples/cpp/actor-yield/s4u-actor-yield_d.xml
 include examples/cpp/app-bittorrent/s4u-app-bittorrent.tesh
 include examples/cpp/app-bittorrent/s4u-app-bittorrent_d.xml
 include examples/cpp/app-bittorrent/s4u-bittorrent.cpp
@@ -182,17 +181,14 @@ include examples/cpp/comm-pingpong/s4u-comm-pingpong.tesh
 include examples/cpp/comm-pingpong/simix-breakpoint.tesh
 include examples/cpp/comm-ready/s4u-comm-ready.cpp
 include examples/cpp/comm-ready/s4u-comm-ready.tesh
-include examples/cpp/comm-ready/s4u-comm-ready_d.xml
 include examples/cpp/comm-serialize/s4u-comm-serialize.cpp
 include examples/cpp/comm-serialize/s4u-comm-serialize.tesh
 include examples/cpp/comm-suspend/s4u-comm-suspend.cpp
 include examples/cpp/comm-suspend/s4u-comm-suspend.tesh
-include examples/cpp/comm-suspend/s4u-comm-suspend_d.xml
 include examples/cpp/comm-throttling/s4u-comm-throttling.cpp
 include examples/cpp/comm-throttling/s4u-comm-throttling.tesh
 include examples/cpp/comm-wait/s4u-comm-wait.cpp
 include examples/cpp/comm-wait/s4u-comm-wait.tesh
-include examples/cpp/comm-wait/s4u-comm-wait_d.xml
 include examples/cpp/comm-waitall/s4u-comm-waitall.cpp
 include examples/cpp/comm-waitall/s4u-comm-waitall.tesh
 include examples/cpp/comm-waitall/s4u-comm-waitall_d.xml
@@ -201,7 +197,6 @@ include examples/cpp/comm-waitany/s4u-comm-waitany.tesh
 include examples/cpp/comm-waitany/s4u-comm-waitany_d.xml
 include examples/cpp/comm-waituntil/s4u-comm-waituntil.cpp
 include examples/cpp/comm-waituntil/s4u-comm-waituntil.tesh
-include examples/cpp/comm-waituntil/s4u-comm-waituntil_d.xml
 include examples/cpp/dag-comm/s4u-dag-comm.cpp
 include examples/cpp/dag-comm/s4u-dag-comm.tesh
 include examples/cpp/dag-failure/s4u-dag-failure.cpp
index 1211106..36fb059 100644 (file)
@@ -226,15 +226,10 @@ set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simi
                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh  PARENT_SCOPE)
 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/comm-suspend/s4u-comm-suspend_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/s4u-comm-wait_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitany/s4u-comm-waitany_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitall/s4u-comm-waitall_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/comm-ready/s4u-comm-ready_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/comm-waituntil/s4u-comm-waituntil_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-scheduling/Montage_25.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
index b7e377a..710c6c4 100644 (file)
@@ -15,32 +15,22 @@ namespace sg4 = simgrid::s4u;
  * It can also be used to benchmark our context-switching mechanism.
  */
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_yield, "Messages specific for this s4u example");
-/* Main function of the Yielder actor */
-class yielder {
-  long number_of_yields;
-
-public:
-  explicit yielder(std::vector<std::string> args) { number_of_yields = std::stol(args[1]); }
-  void operator()() const
-  {
-    for (int i = 0; i < number_of_yields; i++)
-      sg4::this_actor::yield();
-    XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields);
-  }
-};
+
+static void yielder(long number_of_yields)
+{
+  for (int i = 0; i < number_of_yields; i++)
+    sg4::this_actor::yield();
+  XBT_INFO("I yielded %ld times. Goodbye now!", number_of_yields);
+}
 
 int main(int argc, char* argv[])
 {
   sg4::Engine e(&argc, argv);
 
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
-                       "\tExample: %s platform.xml deployment.xml\n",
-             argv[0], argv[0]);
-
   e.load_platform(argv[1]);             /* Load the platform description */
-  e.register_actor<yielder>("yielder"); /* Register the class representing the actors */
 
-  e.load_deployment(argv[2]);
+  sg4::Actor::create("yielder", e.host_by_name("Tremblay"), yielder, 10);
+  sg4::Actor::create("yielder", e.host_by_name("Ruby"), yielder, 15);
 
   e.run(); /* - Run the simulation */
 
diff --git a/examples/cpp/actor-yield/s4u-actor-yield_d.xml b/examples/cpp/actor-yield/s4u-actor-yield_d.xml
deleted file mode 100644 (file)
index 968055f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-  <actor host="Tremblay" function="yielder">
-    <argument value="10"/>       <!-- Number of yields to do  -->
-  </actor>
-  <actor host="Ruby" function="yielder">
-    <argument value="15"/>       <!-- Number of yields to do  -->
-  </actor>
-</platform>
index 6cbe694..834c730 100644 (file)
@@ -26,14 +26,8 @@ namespace sg4 = simgrid::s4u;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_ready, "Messages specific for this s4u example");
 
-static void peer(int argc, char** argv)
+static void peer(int my_id, int messages_count, size_t payload_size, int peers_count)
 {
-  xbt_assert(argc == 5, "Expecting 4 parameters from the XML deployment file but got %d", argc);
-  int my_id           = std::stoi(argv[1]); /* - my id */
-  long messages_count = std::stol(argv[2]); /* - number of message */
-  long msg_size       = std::stol(argv[3]); /* - message size in bytes */
-  long peers_count    = std::stol(argv[4]); /* - number of peers */
-
   /* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put
    * into it */
   sg4::Mailbox* my_mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(my_id));
@@ -45,15 +39,13 @@ static void peer(int argc, char** argv)
   for (int i = 0; i < messages_count; i++) {
     for (int peer_id = 0; peer_id < peers_count; peer_id++) {
       if (peer_id != my_id) {
-        std::string mboxName        = std::string("peer-") + std::to_string(peer_id);
-        sg4::Mailbox* mbox          = sg4::Mailbox::by_name(mboxName);
-        std::string msgName =
-            std::string("Message ") + std::to_string(i) + std::string(" from peer ") + std::to_string(my_id);
-        auto* payload = new std::string(msgName); // copy the data we send:
+        sg4::Mailbox* mbox  = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
+        std::string message = std::string("Message ") + std::to_string(i) + " from peer " + std::to_string(my_id);
+        auto* payload       = new std::string(message); // copy the data we send:
         // 'msgName' is not a stable storage location
-        XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
+        XBT_INFO("Send '%s' to '%s'", message.c_str(), mbox->get_cname());
         /* Create a communication representing the ongoing communication */
-        pending_comms.push_back(mbox->put_async(payload, msg_size));
+        pending_comms.push_back(mbox->put_async(payload, payload_size));
       }
     }
   }
@@ -61,10 +53,9 @@ static void peer(int argc, char** argv)
   /* Start sending messages to let peers know that they should stop */
   for (int peer_id = 0; peer_id < peers_count; peer_id++) {
     if (peer_id != my_id) {
-      std::string mboxName        = std::string("peer-") + std::to_string(peer_id);
-      sg4::Mailbox* mbox          = sg4::Mailbox::by_name(mboxName);
-      auto* payload               = new std::string("finalize"); // Make a copy of the data we will send
-      pending_comms.push_back(mbox->put_async(payload, msg_size));
+      sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
+      auto* payload      = new std::string("finalize"); // Make a copy of the data we will send
+      pending_comms.push_back(mbox->put_async(payload, payload_size));
       XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);
     }
   }
@@ -100,13 +91,12 @@ static void peer(int argc, char** argv)
 
 int main(int argc, char* argv[])
 {
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
-
   sg4::Engine e(&argc, argv);
-  e.register_function("peer", &peer);
-
   e.load_platform(argv[1]);
-  e.load_deployment(argv[2]);
+
+  sg4::Actor::create("peer", e.host_by_name("Tremblay"), peer, 0, 2, 5e7, 3);
+  sg4::Actor::create("peer", e.host_by_name("Ruby"), peer, 1, 6, 2.5e5, 3);
+  sg4::Actor::create("peer", e.host_by_name("Perl"), peer, 2, 0, 5e7, 3);
 
   e.run();
 
index db7cb0f..8af42ea 100644 (file)
@@ -2,7 +2,7 @@
 
 p Test1 Peer sending and receiving
 
-$ ${bindir:=.}/s4u-comm-ready ${platfdir}/small_platform_fatpipe.xml s4u-comm-ready_d.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-ready ${platfdir}/small_platform_fatpipe.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
 > [  0.000000] (1:peer@Tremblay) Send 'Message 0 from peer 0' to 'peer-1'
 > [  0.000000] (2:peer@Ruby) Send 'Message 0 from peer 1' to 'peer-0'
 > [  0.000000] (3:peer@Perl) Send 'finalize' to 'peer-0'
diff --git a/examples/cpp/comm-ready/s4u-comm-ready_d.xml b/examples/cpp/comm-ready/s4u-comm-ready_d.xml
deleted file mode 100644 (file)
index d19aa20..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-  <!-- Register some peers in different hosts -->
-  <actor host="Tremblay" function="peer">
-    <argument value="0"/>         <!-- My id -->
-    <argument value="2"/>         <!-- Number of tasks -->
-    <argument value="50000000"/>  <!-- Computation size of tasks -->
-    <argument value="3"/>         <!-- Number of peers -->
-  </actor>
-  <actor host="Ruby" function="peer">
-    <argument value="1"/>         <!-- My id -->
-    <argument value="6"/>         <!-- Number of tasks -->
-    <argument value="250000"/>    <!-- Computation size of tasks -->
-    <argument value="3"/>         <!-- Number of peers -->
-  </actor>
-  <actor host="Perl" function="peer">
-    <argument value="2"/>         <!-- My id -->
-    <argument value="0"/>         <!-- Number of tasks -->
-    <argument value="50000000"/>  <!-- Computation size of tasks -->
-    <argument value="3"/>         <!-- Number of peers -->
-  </actor>
-</platform>
index 7af40f9..1170ca3 100644 (file)
@@ -13,10 +13,8 @@ namespace sg4 = simgrid::s4u;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_wait, "Messages specific for this s4u example");
 
-static void sender(int argc, char**)
+static void sender()
 {
-  xbt_assert(argc == 1, "Expecting no parameter from the XML deployment file but got %d", argc - 1);
-
   sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver");
 
   // Copy the data we send: the 'msg_content' variable is not a stable storage location.
@@ -43,7 +41,7 @@ static void sender(int argc, char**)
   comm->suspend();
 }
 
-static void receiver(int, char**)
+static void receiver()
 {
   sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver");
   XBT_INFO("Wait for the message.");
@@ -54,14 +52,13 @@ static void receiver(int, char**)
 
 int main(int argc, char* argv[])
 {
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
-
   sg4::Engine e(&argc, argv);
-  e.register_function("sender", &sender);
-  e.register_function("receiver", &receiver);
 
   e.load_platform(argv[1]);
-  e.load_deployment(argv[2]);
+
+  sg4::Actor::create("sender", e.host_by_name("Tremblay"), sender);
+  sg4::Actor::create("receiver", e.host_by_name("Jupiter"), receiver);
+
   e.run();
 
   return 0;
index f572b6c..6fcc959 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env tesh
 
-$ ${bindir:=.}/s4u-comm-suspend ${platfdir}/small_platform.xml s4u-comm-suspend_d.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-suspend ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) Suspend the communication before it starts (remaining: 13194230 bytes) and wait a second.
 > [  0.000000] (2:receiver@Jupiter) Wait for the message.
 > [  1.000000] (1:sender@Tremblay) Now, start the communication (remaining: 13194230 bytes) and wait another second.
diff --git a/examples/cpp/comm-suspend/s4u-comm-suspend_d.xml b/examples/cpp/comm-suspend/s4u-comm-suspend_d.xml
deleted file mode 100644 (file)
index 3c24900..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-  <actor host="Tremblay" function="sender" />
-  <actor host="Jupiter" function="receiver" />
-</platform>
index 25cf806..99081f0 100644 (file)
@@ -19,11 +19,8 @@ namespace sg4 = simgrid::s4u;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_wait, "Messages specific for this s4u example");
 
-static void sender(int argc, char** argv)
+static void sender(int messages_count, size_t payload_size)
 {
-  xbt_assert(argc == 3, "Expecting 2 parameters from the XML deployment file but got %d", argc);
-  long messages_count     = std::stol(argv[1]); /* - number of messages */
-  long msg_size           = std::stol(argv[2]); /* - message size in bytes */
   double sleep_start_time = 5.0;
   double sleep_test_time  = 0;
 
@@ -39,7 +36,7 @@ static void sender(int argc, char** argv)
     auto* payload = new std::string(msg_content);
 
     /* Create a communication representing the ongoing communication and then */
-    sg4::CommPtr comm = mbox->put_async(payload, msg_size);
+    sg4::CommPtr comm = mbox->put_async(payload, payload_size);
     XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mbox->get_cname());
 
     if (sleep_test_time > 0) {   /* - "test_time" is set to 0, wait */
@@ -57,7 +54,7 @@ static void sender(int argc, char** argv)
 }
 
 /* Receiver actor expects 1 argument: its ID */
-static void receiver(int, char**)
+static void receiver()
 {
   double sleep_start_time = 1.0;
   double sleep_test_time  = 0.1;
@@ -89,14 +86,13 @@ static void receiver(int, char**)
 
 int main(int argc, char* argv[])
 {
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
-
   sg4::Engine e(&argc, argv);
-  e.register_function("sender", &sender);
-  e.register_function("receiver", &receiver);
 
   e.load_platform(argv[1]);
-  e.load_deployment(argv[2]);
+
+  sg4::Actor::create("sender", e.host_by_name("Tremblay"), sender, 3, 482117300);
+  sg4::Actor::create("receiver", e.host_by_name("Ruby"), receiver);
+
   e.run();
 
   return 0;
index 547bfc4..c616d41 100644 (file)
@@ -2,7 +2,7 @@
 
 p Test1 Sleep_sender > Sleep_receiver
 
-$ ${bindir:=.}/s4u-comm-wait ${platfdir}/small_platform_fatpipe.xml s4u-comm-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-wait ${platfdir}/small_platform_fatpipe.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
 > [  0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
 > [  1.000000] (2:receiver@Ruby) Wait for my first message
diff --git a/examples/cpp/comm-wait/s4u-comm-wait_d.xml b/examples/cpp/comm-wait/s4u-comm-wait_d.xml
deleted file mode 100644 (file)
index eb1320e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-  <!-- The sender actor (with some arguments) -->
-  <actor host="Tremblay" function="sender">
-    <argument value="3"/>       <!-- Number of messages -->
-    <argument value="482117300"/>  <!-- Message size -->
-  </actor>
-  <!-- The receiver actor -->
-  <actor host="Ruby" function="receiver">
-  </actor>
-</platform>
index 5ac7b1b..70f4277 100644 (file)
@@ -18,40 +18,30 @@ namespace sg4 = simgrid::s4u;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_waituntil, "Messages specific for this s4u example");
 
-static void sender(int argc, char** argv)
+static void sender(int messages_count, size_t payload_size)
 {
-  xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
-  long messages_count  = std::stol(argv[1]); /* - number of messages */
-  long msg_size        = std::stol(argv[2]); /* - message size in bytes */
-  long receivers_count = std::stol(argv[3]); /* - number of receivers */
-
   std::vector<sg4::CommPtr> pending_comms;
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-0");
 
-  /* Start dispatching all messages to receivers, in a round robin fashion */
+  /* Start dispatching all messages to the receiver */
   for (int i = 0; i < messages_count; i++) {
-    std::string mboxName        = std::string("receiver-") + std::to_string(i % receivers_count);
-    sg4::Mailbox* mbox          = sg4::Mailbox::by_name(mboxName);
-    std::string msgName         = std::string("Message ") + std::to_string(i);
-    auto* payload               = new std::string(msgName); // copy the data we send:
+    std::string message = std::string("Message ") + std::to_string(i);
+    auto* payload       = new std::string(message); // copy the data we send:
 
     // 'msgName' is not a stable storage location
-    XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
+    XBT_INFO("Send '%s' to '%s'", message.c_str(), mbox->get_cname());
     /* Create a communication representing the ongoing communication */
-    sg4::CommPtr comm = mbox->put_async(payload, msg_size);
+    sg4::CommPtr comm = mbox->put_async(payload, payload_size);
     /* Add this comm to the vector of all known comms */
     pending_comms.push_back(comm);
   }
 
-  /* Start sending messages to let the workers know that they should stop */
-  for (int i = 0; i < receivers_count; i++) {
-    std::string mboxName        = std::string("receiver-") + std::to_string(i % receivers_count);
-    sg4::Mailbox* mbox          = sg4::Mailbox::by_name(mboxName);
-    auto* payload               = new std::string("finalize"); // Make a copy of the data we will send
+  /* Start the finalize signal to the receiver*/
+  auto* payload     = new std::string("finalize"); // Make a copy of the data we will send
+  sg4::CommPtr comm = mbox->put_async(payload, 0);
+  pending_comms.push_back(comm);
+  XBT_INFO("Send 'finalize' to 'receiver-0'");
 
-    sg4::CommPtr comm = mbox->put_async(payload, 0);
-    pending_comms.push_back(comm);
-    XBT_INFO("Send 'finalize' to 'receiver-%ld'", i % receivers_count);
-  }
   XBT_INFO("Done dispatching all messages");
 
   /* Now that all message exchanges were initiated, wait for their completion, in order of creation. */
@@ -64,11 +54,9 @@ static void sender(int argc, char** argv)
   XBT_INFO("Goodbye now!");
 }
 
-/* Receiver actor expects 1 argument: its ID */
-static void receiver(int argc, char** argv)
+static void receiver()
 {
-  xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
-  sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("receiver-") + argv[1]);
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-0");
 
   XBT_INFO("Wait for my first message");
   for (bool cont = true; cont;) {
@@ -81,14 +69,13 @@ static void receiver(int argc, char** argv)
 
 int main(int argc, char* argv[])
 {
-  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
-
   sg4::Engine e(&argc, argv);
-  e.register_function("sender", &sender);
-  e.register_function("receiver", &receiver);
 
   e.load_platform(argv[1]);
-  e.load_deployment(argv[2]);
+
+  sg4::Actor::create("sender", e.host_by_name("Tremblay"), sender, 3, 5e7);
+  sg4::Actor::create("receiver", e.host_by_name("Ruby"), receiver);
+
   e.run();
 
   return 0;
index 87d8794..3ca0564 100644 (file)
@@ -2,7 +2,7 @@
 
 p Test1 Sleep_sender > Sleep_receiver
 
-$ ${bindir:=.}/s4u-comm-waituntil ${platfdir}/small_platform_fatpipe.xml s4u-comm-waituntil_d.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-waituntil ${platfdir}/small_platform_fatpipe.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
 > [  0.000000] (2:receiver@Ruby) Wait for my first message
 > [  0.000000] (1:sender@Tremblay) Send 'Message 1' to 'receiver-0'
diff --git a/examples/cpp/comm-waituntil/s4u-comm-waituntil_d.xml b/examples/cpp/comm-waituntil/s4u-comm-waituntil_d.xml
deleted file mode 100644 (file)
index be1dba6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
-  <!-- The master actor (with some arguments) -->
-  <actor host="Tremblay" function="sender">
-    <argument value="3"/>       <!-- Number of tasks -->
-    <argument value="50000000"/>  <!-- Computation size of tasks -->
-    <argument value="1"/>         <!-- Number of receivers -->
-  </actor>
-  <!-- The receiver actors -->
-  <actor host="Ruby" function="receiver">
-    <argument value="0"/> <!-- id -->
-  </actor>
-</platform>
index cb0f3c1..337da86 100644 (file)
@@ -3,7 +3,7 @@
 # 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.
 
-from simgrid import Engine, this_actor
+from simgrid import Actor, Engine, Host, this_actor
 import sys
 
 # This example does not much: It just spans over-polite actor that yield a large amount
@@ -15,27 +15,17 @@ import sys
 # It can also be used to benchmark our context-switching mechanism.
 
 
-class Yielder:
-    """Main function of the Yielder actor"""
-    number_of_yields = 0
-
-    def __init__(self, *args):
-        self.number_of_yields = int(args[0])
-
-    def __call__(self):
-        for _ in range(self.number_of_yields):
-            this_actor.yield_()
-        this_actor.info("I yielded {:d} times. Goodbye now!".format(
-            self.number_of_yields))
-
+def yielder (number_of_yields):
+    for _ in range(number_of_yields):
+        this_actor.yield_()
+    this_actor.info("I yielded {:d} times. Goodbye now!".format(number_of_yields))
 
 if __name__ == '__main__':
     e = Engine(sys.argv)
 
     e.load_platform(sys.argv[1])             # Load the platform description
-    # Register the class representing the actors
-    e.register_actor("yielder", Yielder)
-
-    e.load_deployment(sys.argv[2])
+  
+    Actor.create("yielder", Host.by_name("Tremblay"), yielder, 10)
+    Actor.create("yielder", Host.by_name("Ruby"), yielder, 15)
 
     e.run()  # - Run the simulation
index 7348d31..8a6e0d3 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/env tesh
 
-$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-yield.py ${platfdir}/small_platform_fatpipe.xml ${srcdir:=.}/../../cpp/actor-yield/s4u-actor-yield_d.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-yield.py ${platfdir}/small_platform_fatpipe.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
 > [  0.000000] (1:yielder@Tremblay) I yielded 10 times. Goodbye now!
 > [  0.000000] (2:yielder@Ruby) I yielded 15 times. Goodbye now!