X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8529dbc001d48079760ec4f67ae8258276ccedde..93e69b9ab0e7438d21068ff90309f83537d17f72:/src/msg/msg_gos.cpp diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 957b523f6b..1eba2f67f6 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -6,77 +6,15 @@ #include #include "simgrid/Exception.hpp" +#include "simgrid/s4u/Actor.hpp" #include "simgrid/s4u/Comm.hpp" +#include "simgrid/s4u/Exec.hpp" #include "simgrid/s4u/Mailbox.hpp" #include "src/instr/instr_private.hpp" -#include "src/kernel/activity/ExecImpl.hpp" #include "src/msg/msg_private.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg, "Logging specific to MSG (gos)"); -/** - * @brief Executes a parallel task and waits for its termination. - * - * @param task a #msg_task_t to execute on the location on which the process is running. - * - * @return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED or #MSG_HOST_FAILURE otherwise - */ -msg_error_t MSG_parallel_task_execute(msg_task_t task) -{ - return MSG_parallel_task_execute_with_timeout(task, -1); -} - -msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeout) -{ - e_smx_state_t comp_state; - msg_error_t status = MSG_OK; - - xbt_assert((not task->compute) && not task->is_used(), "This task is executed somewhere else. Go fix your code!"); - - XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self())); - - if (task->flops_amount <= 0.0 && not task->hosts_.empty()) { - return MSG_OK; - } - - if (TRACE_actor_is_enabled()) - simgrid::instr::Container::by_name(instr_pid(MSG_process_self()))->get_state("ACTOR_STATE")->push_event("execute"); - - try { - task->set_used(); - - task->compute = boost::static_pointer_cast(simcall_execution_parallel_start( - std::move(task->get_name()), task->hosts_.size(), task->hosts_.data(), - (task->flops_parallel_amount.empty() ? nullptr : task->flops_parallel_amount.data()), - (task->bytes_parallel_amount.empty() ? nullptr : task->bytes_parallel_amount.data()), -1.0, timeout)); - XBT_DEBUG("Parallel execution action created: %p", task->compute.get()); - if (task->has_tracing_category()) - simgrid::simix::simcall([task] { task->compute->set_category(std::move(task->get_tracing_category())); }); - - comp_state = simcall_execution_wait(task->compute); - - task->set_not_used(); - - XBT_DEBUG("Execution task '%s' finished in state %d", task->get_cname(), (int)comp_state); - } catch (simgrid::HostFailureException& e) { - status = MSG_HOST_FAILURE; - } catch (simgrid::TimeoutError& e) { - status = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { - status = MSG_TASK_CANCELED; - } - - /* action ended, set comm and compute = nullptr, the actions is already destroyed in the main function */ - task->flops_amount = 0.0; - task->comm = nullptr; - task->compute = nullptr; - - if (TRACE_actor_is_enabled()) - simgrid::instr::Container::by_name(instr_pid(MSG_process_self()))->get_state("ACTOR_STATE")->pop_event(); - - return status; -} - /** * @brief Receives a task from a mailbox. * @@ -282,10 +220,13 @@ msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rat XBT_CRITICAL("MSG_task_irecv() was asked to write in a non empty task struct."); /* Try to receive it by calling SIMIX network layer */ - msg_comm_t comm = new simgrid::msg::Comm( - nullptr, task, mbox->get_init()->set_dst_data((void**)task, sizeof(msg_task_t*))->set_rate(rate)->start()); + simgrid::s4u::CommPtr comm = simgrid::s4u::Mailbox::by_name(name) + ->get_init() + ->set_dst_data((void**)task, sizeof(msg_task_t*)) + ->set_rate(rate) + ->start(); - return comm; + return new simgrid::msg::Comm(nullptr, task, comm); } /** @@ -637,4 +578,3 @@ int MSG_task_listen_from(const char *alias) else return -1; } -