Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make some correction to the converted examples
authorTakishipp <toufik.boubehziz@gmail.com>
Fri, 8 Sep 2017 12:30:53 +0000 (14:30 +0200)
committerTakishipp <toufik.boubehziz@gmail.com>
Fri, 8 Sep 2017 12:30:53 +0000 (14:30 +0200)
examples/s4u/async-waitall/s4u_async-waitall.cpp
examples/s4u/async-waitany/s4u_async-waitany.cpp

index c948ebb..492bc94 100644 (file)
@@ -26,7 +26,7 @@ public:
 }
 void operator()()
 {
-  simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
+  simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName("sender_mailbox");
   simgrid::s4u::CommPtr* comms = new simgrid::s4u::CommPtr[number_of_tasks + receivers_count] ;
 
   for (int i = 0; i < number_of_tasks; i++) {
index c41916a..26f711e 100644 (file)
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitany, "Messages specific for this msg example");
 
 class sender {
+  long number_of_tasks             = 0; /* - Number of tasks      */
+  long receivers_count             = 0; /* - Number of workers    */
+  int diff_com                     = 0;
+
 public:
   explicit sender(std::vector<std::string> args)
 {
   xbt_assert(args.size()== 5, "This function expects 5 parameters from the XML deployment file");
-  long number_of_tasks = xbt_str_parse_int(args[0].c_str(), "Invalid amount of tasks: %s");
-  double task_comp_size = xbt_str_parse_double(args[1].c_str(), "Invalid computational size: %s");
-  double task_comm_size = xbt_str_parse_double(args[2].c_str(), "Invalid communication size: %s");
-  long receivers_count = xbt_str_parse_int(args[3].c_str(), "Invalid amount of receivers: %s");
-  int diff_com = xbt_str_parse_int(args[4].c_str(), "Invalid value for diff_comm: %s");
+  number_of_tasks = std::stol(args[0]);
+  double task_comp_size = std::stod(args[1]);
+  double task_comm_size = std::stod(args[2]);
+  receivers_count = std::stol(args[3]);
+  diff_com = std::stoi(args[4]);
 
+}
+void operator()()
+{
   std::vector<simgrid::s4u::CommPtr> comms;
   simgrid::s4u::CommPtr comm;
   simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName("receiver_mailbox");
   /* First pack the communications in the dynar */
   for (int i = 0; i < number_of_tasks; i++) {
     double coef = (diff_com == 0) ? 1 : (i + 1);
-
     char mailbox[80];
     char taskname[80];
     snprintf(mailbox,79, "receiver-%ld", (i % receivers_count));
     snprintf(taskname,79, "Task_%d", i);
-
     comm = mbox->put_async((void*)taskname, 42.0);
     comms.push_back(comm);
-    XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, taskname, task_comm_size / coef);
   }
 
   /* Here we are waiting for the completion of all communications */
@@ -55,21 +59,22 @@ public:
     comm->wait();
     comm = nullptr;
   }
-
-}
-void operator()()
-{
   XBT_INFO("Goodbye now!");
 }
 };
 
 class receiver {
+  int id                     = 0;
+  int task_amount            = 0;
 public:
   explicit receiver(std::vector<std::string> args)
 {
   xbt_assert(args.size() == 2, "This function expects 2 parameters from the XML deployment file");
-  int id = xbt_str_parse_int(args[0].c_str(), "ID should be numerical, not %s");
-  int task_amount = xbt_str_parse_int(args[1].c_str(), "Invalid amount of tasks: %s");
+  id = std::stoi(args[0]);
+  task_amount = std::stoi(args[1]);
+}
+void operator()()
+{
   void *received; 
   std::vector<simgrid::s4u::CommPtr> comms;
   simgrid::s4u::CommPtr comm;
@@ -92,9 +97,6 @@ public:
   }
   comms.clear();
   comm = nullptr;
-}
-void operator()()
-{
   /* Here we tell to sender that all tasks are done */
   simgrid::s4u::Mailbox::byName("finalize")->put(nullptr, 1);
   XBT_INFO("I'm done. See you!");