-/* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-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 "msg_private.hpp"
#include "src/simix/smx_private.hpp"
#include <algorithm>
+#include <cmath>
+#include <simgrid/modelchecker.h>
+#include <simgrid/s4u/Comm.hpp>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
*/
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;
simdata->bytes_amount = message_size;
simdata->flops_amount = flop_amount;
- TRACE_msg_task_create(task);
+ task->counter = counter++;
+ task->category = nullptr;
+
+ if (MC_is_active())
+ MC_ignore_heap(&(task->counter), sizeof(task->counter));
return task;
}
/* the task is being sent or executed: cancel it first */
MSG_task_cancel(task);
}
- TRACE_msg_task_destroy(task);
+ xbt_free(task->category);
xbt_free(task->name);
/* free main structures */
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();
return MSG_OK;
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. */
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)
- simcall_execution_set_priority(task->simdata->compute, task->simdata->priority);
+ 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).
task->simdata->bound = bound;
if (task->simdata->compute)
- simcall_execution_set_bound(task->simdata->compute, task->simdata->bound);
+ simgrid::simix::simcall([task, bound] { task->simdata->compute->set_bound(bound); });
}