X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b8df87e176f27b25534f27d7e240defa32ca35bc..c2ee13e39edc041a79cce8d08fd58d0d45c3502b:/src/msg/msg_task.cpp diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 14b3ce6201..c4ad363213 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -6,10 +6,30 @@ #include "msg_private.hpp" #include "src/simix/smx_private.hpp" #include +#include +#include +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)"); -void s_simdata_task_t::reportMultipleUse() const +namespace simgrid { +namespace msg { +Task::~Task() +{ + /* parallel tasks only */ + delete[] host_list; + delete[] flops_parallel_amount; + delete[] bytes_parallel_amount; +} + +void Task::set_used() +{ + if (this->is_used) + this->report_multiple_use(); + this->is_used = true; +} + +void Task::report_multiple_use() const { if (msg_global->debug_multiple_use){ XBT_ERROR("This task is already used in there:"); @@ -22,6 +42,8 @@ void s_simdata_task_t::reportMultipleUse() const "(use --cfg=msg/debug-multiple-use:on to get the backtrace of the other process)"); } } +} // namespace msg +} // namespace simgrid /********************************* Task **************************************/ /** @brief Creates a new task @@ -39,19 +61,18 @@ void s_simdata_task_t::reportMultipleUse() const */ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data) { + static std::atomic_ullong counter{0}; + msg_task_t task = new s_msg_task_t; - simdata_task_t simdata = new s_simdata_task_t(); - task->simdata = simdata; + /* Simulator Data */ + task->simdata = new simgrid::msg::Task(name ? name : "", flop_amount, message_size); /* Task structure */ - task->name = xbt_strdup(name); task->data = data; + task->counter = counter++; - /* Simulator Data */ - simdata->bytes_amount = message_size; - simdata->flops_amount = flop_amount; - - TRACE_msg_task_create(task); + if (MC_is_active()) + MC_ignore_heap(&(task->counter), sizeof(task->counter)); return task; } @@ -134,19 +155,19 @@ msg_process_t MSG_task_get_sender(msg_task_t task) /** @brief Returns the source (the sender's host) of the given task */ msg_host_t MSG_task_get_source(msg_task_t task) { - return task->simdata->source; + return task->simdata->sender->get_host(); } /** @brief Returns the name of the given task. */ const char *MSG_task_get_name(msg_task_t task) { - return task->name; + return task->simdata->get_cname(); } /** @brief Sets the name of the given task. */ void MSG_task_set_name(msg_task_t task, const char *name) { - task->name = xbt_strdup(name); + task->simdata->set_name(name); } /** @brief Destroys the given task. @@ -161,13 +182,10 @@ void MSG_task_set_name(msg_task_t task, const char *name) */ msg_error_t MSG_task_destroy(msg_task_t task) { - if (task->simdata->isused) { + if (task->simdata->is_used) { /* the task is being sent or executed: cancel it first */ MSG_task_cancel(task); } - TRACE_msg_task_destroy(task); - - xbt_free(task->name); /* free main structures */ delete task->simdata; @@ -186,11 +204,11 @@ msg_error_t MSG_task_cancel(msg_task_t task) simdata_task_t simdata = task->simdata; if (simdata->compute) { - simcall_execution_cancel(simdata->compute); + simgrid::simix::simcall([simdata] { simdata->compute->cancel(); }); } else if (simdata->comm) { - simcall_comm_cancel(simdata->comm); + simdata->comm->cancel(); } - simdata->setNotUsed(); + simdata->set_not_used(); return MSG_OK; } @@ -257,7 +275,7 @@ void MSG_task_set_bytes_amount(msg_task_t task, double data_size) double MSG_task_get_remaining_communication(msg_task_t task) { XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->simdata->comm.get()); - return task->simdata->comm->remains(); + return task->simdata->comm->get_remaining(); } /** @brief Returns the size of the data attached to the given task. */ @@ -275,8 +293,7 @@ double MSG_task_get_bytes_amount(msg_task_t task) void MSG_task_set_priority(msg_task_t task, double priority) { task->simdata->priority = 1 / priority; - if (task->simdata->compute) - simcall_execution_set_priority(task->simdata->compute, task->simdata->priority); + xbt_assert(std::isfinite(task->simdata->priority), "priority is not finite!"); } /** @brief Changes the maximum CPU utilization of a computation task (in flops/s). @@ -287,8 +304,5 @@ void MSG_task_set_bound(msg_task_t task, double bound) { if (bound < 1e-12) /* close enough to 0 without any floating precision surprise */ XBT_INFO("bound == 0 means no capping (i.e., unlimited)."); - task->simdata->bound = bound; - if (task->simdata->compute) - simcall_execution_set_bound(task->simdata->compute, task->simdata->bound); }