Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more factoring when sending MSG tasks
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 3 Mar 2019 17:17:56 +0000 (18:17 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 3 Mar 2019 17:17:56 +0000 (18:17 +0100)
src/msg/instr_msg_task.cpp [deleted file]
src/msg/msg_gos.cpp
src/msg/msg_private.hpp
src/msg/msg_task.cpp
tools/cmake/DefinePackages.cmake

diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp
deleted file mode 100644 (file)
index 36e5cf6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (c) 2010-2019. 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 "mc/mc.h"
-#include "src/instr/instr_private.hpp"
-#include "src/msg/msg_private.hpp"
-
-#include <atomic>
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_msg, instr, "MSG instrumentation");
-
-/* MSG_task_put related functions */
-void TRACE_msg_task_put_start(msg_task_t task)
-{
-  XBT_DEBUG("PUT,in %p, %lld, %s", task, task->get_id(), task->get_tracing_category().c_str());
-
-  if (TRACE_actor_is_enabled()) {
-    container_t process_container = simgrid::instr::Container::by_name(instr_pid(MSG_process_self()));
-    std::string key               = std::string("p") + std::to_string(task->get_id());
-    simgrid::instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->start_event(process_container, "SR", key);
-  }
-}
index 36d0b0f..957b523 100644 (file)
@@ -573,23 +573,10 @@ msg_error_t MSG_task_send_bounded(msg_task_t task, const char *alias, double max
 msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout)
 {
   msg_error_t ret = MSG_OK;
-
-  TRACE_msg_task_put_start(task);
-
-  /* Prepare the task to send */
-  task->set_used();
-
-  msg_global->sent_msg++;
-
   /* Try to send it */
   try {
-    simgrid::s4u::CommPtr comm =
-        simgrid::s4u::Mailbox::by_name(alias)->put_init(task, task->bytes_amount)->set_rate(task->get_rate());
+    simgrid::s4u::CommPtr comm = task->send_async(alias, nullptr, false);
     task->comm = comm;
-    comm->start();
-    if (TRACE_is_enabled() && task->has_tracing_category())
-      simgrid::simix::simcall(
-          [comm, task] { comm->get_impl()->set_category(std::move(task->get_tracing_category())); });
     comm->wait_for(timeout);
   } catch (simgrid::TimeoutError& e) {
     ret = MSG_TIMEOUT;
index 31440dc..a89064b 100644 (file)
@@ -39,7 +39,7 @@ public:
   static Task* create_parallel(std::string name, int host_nb, const msg_host_t* host_list, double* flops_amount,
                                double* bytes_amount, void* data);
   msg_error_t execute();
-  Comm* send_async(std::string alias, void_f_pvoid_t cleanup, bool detached);
+  s4u::CommPtr send_async(std::string alias, void_f_pvoid_t cleanup, bool detached);
   void cancel();
 
   Task(const Task&) = delete;
@@ -112,9 +112,4 @@ XBT_PUBLIC_DATA MSG_Global_t msg_global;
 /*************************************************************/
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
 
-/********** Tracing **********/
-/* declaration of instrumentation functions from msg_task_instr.c */
-XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);
-
-
 #endif
index ff50989..3695cc0 100644 (file)
@@ -97,9 +97,13 @@ msg_error_t Task::execute()
   return status;
 }
 
-Comm* Task::send_async(std::string alias, void_f_pvoid_t cleanup, bool detached)
+s4u::CommPtr Task::send_async(std::string alias, void_f_pvoid_t cleanup, bool detached)
 {
-  TRACE_msg_task_put_start(this);
+  if (TRACE_actor_is_enabled()) {
+    container_t process_container = simgrid::instr::Container::by_name(instr_pid(MSG_process_self()));
+    std::string key               = std::string("p") + std::to_string(get_id());
+    simgrid::instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->start_event(process_container, "SR", key);
+  }
 
   /* Prepare the task to send */
   set_used();
@@ -117,10 +121,7 @@ Comm* Task::send_async(std::string alias, void_f_pvoid_t cleanup, bool detached)
   if (TRACE_is_enabled() && has_tracing_category())
     simgrid::simix::simcall([comm, this] { comm->get_impl()->set_category(std::move(tracing_category_)); });
 
-  if (not detached)
-    return new Comm(this, nullptr, comm);
-  else
-    return nullptr;
+  return comm;
 }
 
 void Task::cancel()
@@ -290,7 +291,7 @@ msg_error_t MSG_task_execute(msg_task_t task)
  */
 msg_comm_t MSG_task_isend(msg_task_t task, const char* alias)
 {
-  return task->send_async(alias, nullptr, false);
+  return new simgrid::msg::Comm(task, nullptr, task->send_async(alias, nullptr, false));
 }
 
 /**
@@ -307,7 +308,7 @@ msg_comm_t MSG_task_isend(msg_task_t task, const char* alias)
 msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char* alias, double maxrate)
 {
   task->set_rate(maxrate);
-  return task->send_async(alias, nullptr, false);
+  return new simgrid::msg::Comm(task, nullptr, task->send_async(alias, nullptr, false));
 }
 
 /**
@@ -327,8 +328,7 @@ msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char* alias, double max
  */
 void MSG_task_dsend(msg_task_t task, const char* alias, void_f_pvoid_t cleanup)
 {
-  msg_comm_t XBT_ATTRIB_UNUSED comm = task->send_async(alias, cleanup, true);
-  xbt_assert(comm == nullptr);
+  task->send_async(alias, cleanup, true);
 }
 
 /**
@@ -354,7 +354,7 @@ void MSG_task_dsend(msg_task_t task, const char* alias, void_f_pvoid_t cleanup)
 void MSG_task_dsend_bounded(msg_task_t task, const char* alias, void_f_pvoid_t cleanup, double maxrate)
 {
   task->set_rate(maxrate);
-  MSG_task_dsend(task, alias, cleanup);
+  task->send_async(alias, cleanup, true);
 }
 
 /** @brief Destroys the given task.
index 7183200..194cb9d 100644 (file)
@@ -449,7 +449,6 @@ set(SIMGRID_SRC
   )
 
 set(MSG_SRC
-  src/msg/instr_msg_task.cpp
   src/msg/msg_global.cpp
   src/msg/msg_gos.cpp
   src/msg/msg_legacy.cpp