Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
objectify simdata_task_t
[simgrid.git] / src / msg / msg_task.cpp
index 67a3c53..7eb541a 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
 
-void s_simdata_task_t::report_multiple_use() 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:");
@@ -25,6 +42,8 @@ void s_simdata_task_t::report_multiple_use() 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
@@ -45,17 +64,13 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_
   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(flop_amount, message_size);
 
   /* Task structure */
   task->name = xbt_strdup(name);
   task->data = data;
 
-  /* Simulator Data */
-  simdata->bytes_amount = message_size;
-  simdata->flops_amount = flop_amount;
-
   task->counter  = counter++;
   task->category = nullptr;
 
@@ -143,7 +158,7 @@ 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. */
@@ -285,8 +300,6 @@ void MSG_task_set_priority(msg_task_t task, double priority)
 {
   task->simdata->priority = 1 / priority;
   xbt_assert(std::isfinite(task->simdata->priority), "priority is not finite!");
-  if (task->simdata->compute)
-    simgrid::simix::simcall([task] { task->simdata->compute->set_priority(task->simdata->priority); });
 }
 
 /** @brief Changes the maximum CPU utilization of a computation task (in flops/s).
@@ -297,8 +310,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)
-    simgrid::simix::simcall([task, bound] { task->simdata->compute->set_bound(bound); });
 }