X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fe304706848f0a64477d4687b3ea97d5b9a0c35c..0df2443c629a762737ece131404098bba63ef460:/src/simdag/sd_global.cpp diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index e466ff038d..5a9e8224e6 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2021. 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. */ @@ -10,6 +10,8 @@ #include "simgrid/sg_config.hpp" #include "src/surf/surf_interface.hpp" +#include + XBT_LOG_NEW_CATEGORY(sd, "Logging specific to SimDag"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_kernel, sd, "Logging specific to SimDag (kernel)"); @@ -33,7 +35,6 @@ std::set* simulate(double how_long){ /* main loop */ while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long - total_time)) && not sd_global->watch_point_reached) { - XBT_DEBUG("Total time: %f", total_time); elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time: -1.0); @@ -43,15 +44,14 @@ std::set* simulate(double how_long){ /* let's see which tasks are done */ for (auto const& model : all_existing_models) { - simgrid::kernel::resource::Action* action = model->extract_done_action(); + const simgrid::kernel::resource::Action* action = model->extract_done_action(); while (action != nullptr && action->get_data() != nullptr) { - SD_task_t task = static_cast(action->get_data()); + auto* task = static_cast(action->get_data()); XBT_VERB("Task '%s' done", SD_task_get_name(task)); SD_task_set_state(task, SD_DONE); /* the state has changed. Add it only if it's the first change */ - if (sd_global->return_set.find(task) == sd_global->return_set.end()) - sd_global->return_set.insert(task); + sd_global->return_set.emplace(task); /* remove the dependencies after this task */ for (auto const& succ : *task->successors) { @@ -95,7 +95,7 @@ std::set* simulate(double how_long){ /* let's see which tasks have just failed */ action = model->extract_failed_action(); while (action != nullptr) { - SD_task_t task = static_cast(action->get_data()); + auto* task = static_cast(action->get_data()); XBT_VERB("Task '%s' failed", SD_task_get_name(task)); SD_task_set_state(task, SD_FAILED); sd_global->return_set.insert(task); @@ -125,9 +125,9 @@ std::set* simulate(double how_long){ * @return the equivalent as a readable string */ const char *__get_state_name(e_SD_task_state_t state){ - static std::string state_names[7] = - { "not scheduled", "schedulable", "scheduled", "runnable","running", "done", "failed" }; - return state_names[static_cast(log2(static_cast(state)))].data(); + static constexpr std::array state_names{ + {"not scheduled", "schedulable", "scheduled", "runnable", "running", "done", "failed"}}; + return state_names.at(static_cast(log2(static_cast(state)))); } /** @@ -148,7 +148,7 @@ void SD_init_nocheck(int *argc, char **argv) sd_global = new simgrid::sd::Global(); simgrid::config::set_default("host/model", "ptask_L07"); - if (simgrid::config::get_value("clean-atexit")) + if (simgrid::config::get_value("debug/clean-atexit")) atexit(SD_exit); } @@ -214,7 +214,7 @@ void SD_simulate(double how_long) void SD_simulate_with_update(double how_long, xbt_dynar_t changed_tasks_dynar) { - std::set *changed_tasks = simgrid::sd::simulate(how_long); + const std::set* changed_tasks = simgrid::sd::simulate(how_long); for (auto const& task : *changed_tasks) xbt_dynar_push(changed_tasks_dynar, &task); }