X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/84402e8e2ee2a2d0bef25fdceb0a263ed8b471f6..5ed37babb2fa9097abe82df299c0aa259ed84d5a:/src/msg/msg_task.cpp diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 876a1fb77b..051de7413d 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2023. 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. */ @@ -16,6 +16,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)"); namespace simgrid { + +template class xbt::Extendable; + namespace msg { Task::Task(const std::string& name, double flops_amount, double bytes_amount, void* data) @@ -24,8 +27,7 @@ Task::Task(const std::string& name, double flops_amount, double bytes_amount, vo static std::atomic_ullong counter{0}; id_ = counter++; set_data(data); - if (MC_is_active()) - MC_ignore_heap(&(id_), sizeof(id_)); + MC_ignore_heap(&id_, sizeof id_); } Task::Task(const std::string& name, std::vector&& hosts, std::vector&& flops_amount, @@ -100,9 +102,9 @@ msg_error_t Task::execute() s4u::CommPtr Task::send_async(const std::string& alias, void_f_pvoid_t cleanup, bool detached) { if (TRACE_actor_is_enabled()) { - container_t process_container = instr::Container::by_name(instr_pid(*MSG_process_self())); - std::string key = std::string("p") + std::to_string(get_id()); - instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->start_event(process_container, "SR", key); + auto* process_container = instr::Container::by_name(instr_pid(*MSG_process_self())); + std::string key = "p" + std::to_string(get_id()); + instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(process_container, "SR", key); } /* Prepare the task to send */ @@ -205,22 +207,22 @@ void Task::report_multiple_use() const * @param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot * be transferred with MSG_task_send() and MSG_task_recv(). This value has to be >=0. * @param data a pointer to any data may want to attach to the new object. It is for user-level information and can - * be nullptr. It can be retrieved with the function @ref MSG_task_get_data. + * be nullptr. It can be retrieved with the function MSG_task_get_data(). * @return The new corresponding object. */ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data) { - return simgrid::msg::Task::create(name ? std::string(name) : "", flop_amount, message_size, data); + return simgrid::msg::Task::create(name ? name : "", flop_amount, message_size, data); } /** @brief Creates a new parallel task * * A constructor for #msg_task_t taking six arguments. * - * \rst - * See :cpp:func:`void simgrid::s4u::this_actor::parallel_execute(int, s4u::Host**, double*, double*)` for + * @beginrst + * See :ref:`simgrid::s4u::this_actor::parallel_execute() ` for * the exact semantic of the parameters. - * \endrst + * @endrst * * @param name a name for the object. It is for user-level information and can be nullptr. * @param host_nb the number of hosts implied in the parallel task. @@ -230,7 +232,7 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_ * @param bytes_amount an array of @p host_nb* @p host_nb doubles. * @param data a pointer to any data may want to attach to the new object. * It is for user-level information and can be nullptr. - * It can be retrieved with the function @ref MSG_task_get_data(). + * It can be retrieved with the function MSG_task_get_data(). */ msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_host_t * host_list, double *flops_amount, double *bytes_amount, void *data) @@ -243,7 +245,7 @@ msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_hos /** @brief Return the user data of the given task */ void* MSG_task_get_data(const_msg_task_t task) { - return task->get_data(); + return task->get_data(); } /** @brief Sets the user data of a given task */ @@ -570,10 +572,10 @@ msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* } if (TRACE_actor_is_enabled() && ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) { - container_t process_container = simgrid::instr::Container::by_name(instr_pid(*MSG_process_self())); + auto* 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")->end_event(process_container, "SR", key); + std::string key = "p" + std::to_string((*task)->get_id()); + simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->end_event(process_container, "SR", key); } return ret; } @@ -634,13 +636,7 @@ msg_comm_t MSG_task_irecv_bounded(msg_task_t* task, const char* name, double rat */ int MSG_task_listen_from(const char* alias) { - /* looks inside the rdv directly. Not clean. */ - simgrid::kernel::activity::CommImplPtr comm = simgrid::s4u::Mailbox::by_name(alias)->front(); - - if (comm && comm->src_actor_) - return comm->src_actor_->get_pid(); - else - return -1; + return simgrid::s4u::Mailbox::by_name(alias)->listen_from(); } /** @brief Destroys the given task. @@ -703,7 +699,7 @@ double MSG_task_get_remaining_work_ratio(const_msg_task_t task) */ double MSG_task_get_flops_amount(const_msg_task_t task) { - if (task->compute != nullptr) { + if (task->compute != nullptr && task->compute->get_state() == simgrid::s4u::Activity::State::STARTED) { return task->compute->get_remaining(); } else { // Not started or already done. @@ -740,7 +736,7 @@ void MSG_task_set_bytes_amount(msg_task_t task, double data_size) */ double MSG_task_get_remaining_communication(const_msg_task_t task) { - XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->comm.get()); + XBT_DEBUG("calling s4u::Comm::get_remaining (%p)", task->comm.get()); return task->comm->get_remaining(); } @@ -776,16 +772,16 @@ void MSG_task_set_bound(msg_task_t task, double bound) * @brief Sets the tracing category of a task. * * This function should be called after the creation of a MSG task, to define the category of that task. The - * first parameter task must contain a task that was =created with the function #MSG_task_create. The second + * first parameter task must contain a task that was =created with the function MSG_task_create(). The second * parameter category must contain a category that was previously declared with the function #TRACE_category * (or with #TRACE_category_with_color). * - * See @ref outcomes_vizu for details on how to trace the (categorized) resource utilization. + * @beginrst + * See :ref:`outcome_vizu` for details on how to trace the (categorized) resource utilization. + * @endrst * * @param task the task that is going to be categorized * @param category the name of the category to be associated to the task - * - * @see MSG_task_get_category, TRACE_category, TRACE_category_with_color */ void MSG_task_set_category(msg_task_t task, const char* category) {