From: Frederic Suter Date: Sun, 3 Mar 2019 17:17:56 +0000 (+0100) Subject: more factoring when sending MSG tasks X-Git-Tag: v3_22~183 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8529dbc001d48079760ec4f67ae8258276ccedde more factoring when sending MSG tasks --- diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp deleted file mode 100644 index 36e5cf6d5b..0000000000 --- a/src/msg/instr_msg_task.cpp +++ /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 - -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); - } -} diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 36d0b0fd42..957b523f6b 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -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; diff --git a/src/msg/msg_private.hpp b/src/msg/msg_private.hpp index 31440dc6bc..a89064b396 100644 --- a/src/msg/msg_private.hpp +++ b/src/msg/msg_private.hpp @@ -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 diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index ff509898cf..3695cc0436 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -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. diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 718320030f..194cb9d435 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -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