task->successors = new std::set<SD_task_t>();
task->data = data;
- task->name = xbt_strdup(name);
+ task->name = std::string(name);
task->amount = amount;
task->allocation = new std::vector<sg_host_t>();
task->rate = -1;
if (task->state == SD_SCHEDULED || task->state == SD_RUNNABLE)
__SD_task_destroy_scheduling_data(task);
- xbt_free(task->name);
-
if (task->surf_action != nullptr)
task->surf_action->unref();
void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
{
std::set<SD_task_t>::iterator idx;
- XBT_DEBUG("Set state of '%s' to %d", task->name, new_state);
+ XBT_DEBUG("Set state of '%s' to %d", task->name.c_str(), new_state);
if ((new_state == SD_NOT_SCHEDULED || new_state == SD_SCHEDULABLE) && task->state == SD_FAILED){
sd_global->completed_tasks->erase(task);
sd_global->initial_tasks->insert(task);
task->state = new_state;
if (task->watch_points & new_state) {
- XBT_VERB("Watch point reached with task '%s'!", task->name);
+ XBT_VERB("Watch point reached with task '%s'!", task->name.c_str());
sd_global->watch_point_reached = true;
SD_task_unwatch(task, new_state); /* remove the watch point */
}
*/
const char *SD_task_get_name(SD_task_t task)
{
- return task->name;
+ return task->name.c_str();
}
/** @brief Allows to change the name of a task */
void SD_task_set_name(SD_task_t task, const char *name)
{
- xbt_free(task->name);
- task->name = xbt_strdup(name);
+ task->name = std::string(name);
}
/** @brief Returns the dynar of the parents of a task
if ((task->inputs->size()+ task->predecessors->size()) > 0) {
XBT_INFO(" - pre-dependencies:");
for (auto it : *task->predecessors)
- XBT_INFO(" %s", it->name);
+ XBT_INFO(" %s", it->name.c_str());
for (auto it: *task->inputs)
- XBT_INFO(" %s", it->name);
+ XBT_INFO(" %s", it->name.c_str());
}
if ((task->outputs->size() + task->successors->size()) > 0) {
XBT_INFO(" - post-dependencies:");
for (auto it : *task->successors)
- XBT_INFO(" %s", it->name);
+ XBT_INFO(" %s", it->name.c_str());
for (auto it : *task->outputs)
- XBT_INFO(" %s", it->name);
+ XBT_INFO(" %s", it->name.c_str());
}
}
void SD_task_dotty(SD_task_t task, void *out)
{
FILE *fout = static_cast<FILE*>(out);
- fprintf(fout, " T%p [label=\"%.20s\"", task, task->name);
+ fprintf(fout, " T%p [label=\"%.20s\"", task, task->name.c_str());
switch (task->kind) {
case SD_TASK_COMM_E2E:
case SD_TASK_COMM_PAR_MXN_1D_BLOCK:
if (src->state == SD_DONE || src->state == SD_FAILED)
THROWF(arg_error, 0, "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED, SD_RUNNABLE, or SD_RUNNING",
- src->name);
+ src->name.c_str());
if (dst->state == SD_DONE || dst->state == SD_FAILED || dst->state == SD_RUNNING)
THROWF(arg_error, 0, "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED, or SD_RUNNABLE",
- dst->name);
+ dst->name.c_str());
if (dst->inputs->find(src) != dst->inputs->end() || src->outputs->find(dst) != src->outputs->end() ||
src->successors->find(dst) != src->successors->end() || dst->predecessors->find(src) != dst->predecessors->end())
- THROWF(arg_error, 0, "A dependency already exists between task '%s' and task '%s'", src->name, dst->name);
+ THROWF(arg_error, 0, "A dependency already exists between task '%s' and task '%s'", src->name.c_str(), dst->name.c_str());
- XBT_DEBUG("SD_task_dependency_add: src = %s, dst = %s", src->name, dst->name);
+ XBT_DEBUG("SD_task_dependency_add: src = %s, dst = %s", src->name.c_str(), dst->name.c_str());
if (src->kind == SD_TASK_COMM_E2E || src->kind == SD_TASK_COMM_PAR_MXN_1D_BLOCK){
if (dst->kind == SD_TASK_COMP_SEQ || dst->kind == SD_TASK_COMP_PAR_AMDAHL)
/* if the task was runnable, the task goes back to SD_SCHEDULED because of the new dependency*/
if (dst->state == SD_RUNNABLE) {
- XBT_DEBUG("SD_task_dependency_add: %s was runnable and becomes scheduled!", dst->name);
+ XBT_DEBUG("SD_task_dependency_add: %s was runnable and becomes scheduled!", dst->name.c_str());
SD_task_set_state(dst, SD_SCHEDULED);
}
}
if (src->successors->find(dst) == src->successors->end() && src->outputs->find(dst) == src->outputs->end())
THROWF(arg_error, 0, "No dependency found between task '%s' and '%s': task '%s' is not a successor of task '%s'",
- src->name, dst->name, dst->name, src->name);
+ src->name.c_str(), dst->name.c_str(), dst->name.c_str(), src->name.c_str());
if (src->kind == SD_TASK_COMM_E2E || src->kind == SD_TASK_COMM_PAR_MXN_1D_BLOCK){
if (dst->kind == SD_TASK_COMP_SEQ || dst->kind == SD_TASK_COMP_PAR_AMDAHL)
void SD_task_unschedule(SD_task_t task)
{
if (task->state == SD_NOT_SCHEDULED || task->state == SD_SCHEDULABLE)
- THROWF(arg_error, 0, "Task %s: the state must be SD_SCHEDULED, SD_RUNNABLE, SD_RUNNING or SD_FAILED", task->name);
+ THROWF(arg_error, 0, "Task %s: the state must be SD_SCHEDULED, SD_RUNNABLE, SD_RUNNING or SD_FAILED", task->name.c_str());
if ((task->state == SD_SCHEDULED || task->state == SD_RUNNABLE) /* if the task is scheduled or runnable */
&& ((task->kind == SD_TASK_COMP_PAR_AMDAHL) || (task->kind == SD_TASK_COMM_PAR_MXN_1D_BLOCK))) {
/* Runs a task. */
void SD_task_run(SD_task_t task)
{
- xbt_assert(task->state == SD_RUNNABLE, "Task '%s' is not runnable! Task state: %d", task->name, (int) task->state);
- xbt_assert(task->allocation != nullptr, "Task '%s': host_list is nullptr!", task->name);
+ xbt_assert(task->state == SD_RUNNABLE, "Task '%s' is not runnable! Task state: %d", task->name.c_str(), (int) task->state);
+ xbt_assert(task->allocation != nullptr, "Task '%s': host_list is nullptr!", task->name.c_str());
- XBT_VERB("Executing task '%s'", task->name);
+ XBT_VERB("Executing task '%s'", task->name.c_str());
/* Copy the elements of the task into the action */
int host_nb = task->allocation->size();
void SD_task_distribute_comp_amdahl(SD_task_t task, int count)
{
xbt_assert(task->kind == SD_TASK_COMP_PAR_AMDAHL, "Task %s is not a SD_TASK_COMP_PAR_AMDAHL typed task."
- "Cannot use this function.", task->name);
+ "Cannot use this function.", task->name.c_str());
task->flops_amount = xbt_new0(double, count);
task->bytes_amount = xbt_new0(double, count * count);
void SD_task_build_MxN_1D_block_matrix(SD_task_t task, int src_nb, int dst_nb){
xbt_assert(task->kind == SD_TASK_COMM_PAR_MXN_1D_BLOCK, "Task %s is not a SD_TASK_COMM_PAR_MXN_1D_BLOCK typed task."
- "Cannot use this function.", task->name);
+ "Cannot use this function.", task->name.c_str());
xbt_free(task->bytes_amount);
task->bytes_amount = xbt_new0(double,task->allocation->size() * task->allocation->size());
for(int i =0; i<count; i++)
task->allocation->push_back(list[i]);
- XBT_VERB("Schedule computation task %s on %zu host(s)", task->name, task->allocation->size());
+ XBT_VERB("Schedule computation task %s on %zu host(s)", task->name.c_str(), task->allocation->size());
if (task->kind == SD_TASK_COMP_SEQ) {
if (!task->flops_amount){ /*This task has failed and is rescheduled. Reset the flops_amount*/
int src_nb = input->allocation->size();
int dst_nb = count;
if (input->allocation->empty())
- XBT_VERB("Sender side of '%s' not scheduled. Set receiver side to '%s''s allocation", input->name, task->name);
+ XBT_VERB("Sender side of '%s' not scheduled. Set receiver side to '%s''s allocation", input->name.c_str(), task->name.c_str());
for (int i=0; i<count;i++)
input->allocation->push_back(task->allocation->at(i));
SD_task_do_schedule(input);
XBT_VERB ("Auto-Schedule Communication task '%s'. Send %.f bytes from %d hosts to %d hosts.",
- input->name,input->amount, src_nb, dst_nb);
+ input->name.c_str(),input->amount, src_nb, dst_nb);
}
}
int src_nb = count;
int dst_nb = output->allocation->size();
if (output->allocation->empty())
- XBT_VERB("Receiver side of '%s' not scheduled. Set sender side to '%s''s allocation", output->name, task->name);
+ XBT_VERB("Receiver side of '%s' not scheduled. Set sender side to '%s''s allocation", output->name.c_str(), task->name.c_str());
for (int i=0; i<count;i++)
output->allocation->insert(output->allocation->begin()+i, task->allocation->at(i));
SD_task_do_schedule(output);
XBT_VERB ("Auto-Schedule Communication task %s. Send %.f bytes from %d hosts to %d hosts.",
- output->name, output->amount, src_nb, dst_nb);
+ output->name.c_str(), output->amount, src_nb, dst_nb);
}
}
}