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 */
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;
}
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!");