X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/121e1dc6ee0462b6f6f1f1570b0f48c61ee4ff9a..eeff3b8f8915c9ed3d3eb588e3ab59ccb1df3221:/src/instr/jedule/jedule_sd_binding.cpp diff --git a/src/instr/jedule/jedule_sd_binding.cpp b/src/instr/jedule/jedule_sd_binding.cpp index 782bb6e0e8..dfa670104e 100644 --- a/src/instr/jedule/jedule_sd_binding.cpp +++ b/src/instr/jedule/jedule_sd_binding.cpp @@ -1,46 +1,38 @@ -/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-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. */ -#include "simgrid/jedule/jedule_sd_binding.h" - #include "simgrid/jedule/jedule.hpp" -#include "src/simdag/simdag_private.hpp" - #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/NetZone.hpp" +#include "src/simdag/simdag_private.hpp" -#if HAVE_JEDULE +#if SIMGRID_HAVE_JEDULE -XBT_LOG_NEW_CATEGORY(jedule, "Logging specific to Jedule"); -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule, "Logging specific to Jedule SD binding"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, sd, "Jedule SimDag binding"); jedule_t my_jedule; -void jedule_log_sd_event(SD_task_t task) +void jedule_log_sd_event(const_SD_task_t task) { xbt_assert(task != nullptr); - jed_event_t event = new simgrid::jedule::Event(std::string(SD_task_get_name(task)), - SD_task_get_start_time(task), SD_task_get_finish_time(task), "SD"); - event->addResources(task->allocation); - my_jedule->event_set.push_back(event); + simgrid::jedule::Event event(std::string(SD_task_get_name(task)), SD_task_get_start_time(task), + SD_task_get_finish_time(task), "SD"); + event.add_resources(*task->allocation); + my_jedule->add_event(event); } void jedule_sd_init() { - sg_netzone_t root_comp = simgrid::s4u::Engine::instance()->netRoot(); - XBT_DEBUG("root name %s\n", root_comp->name()); - - my_jedule = new simgrid::jedule::Jedule(); + const_sg_netzone_t root_comp = simgrid::s4u::Engine::get_instance()->get_netzone_root(); + XBT_DEBUG("root name %s\n", root_comp->get_cname()); - jed_container_t root_container = new simgrid::jedule::Container(std::string(root_comp->name())); - root_container->createHierarchy(root_comp); - my_jedule->root_container = root_container; + my_jedule = new simgrid::jedule::Jedule(root_comp->get_name()); } -void jedule_sd_exit(void) +void jedule_sd_exit() { delete my_jedule; } @@ -48,19 +40,19 @@ void jedule_sd_exit(void) void jedule_sd_dump(const char * filename) { if (my_jedule) { - char *fname; - if (!filename) { - fname = bprintf("%s.jed", xbt_binary_name); + std::string fname; + if (not filename) { + fname = simgrid::xbt::binary_name + ".jed"; } else { - fname = xbt_strdup(filename); + fname = filename; } - FILE *fh = fopen(fname, "w"); + FILE* fh = fopen(fname.c_str(), "w"); + xbt_assert(fh != nullptr, "Failed to open file: %s", fname.c_str()); - my_jedule->writeOutput(fh); + my_jedule->write_output(fh); fclose(fh); - xbt_free(fname); } } #endif