Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Misc const qualifiers following yesterday's changes.
[simgrid.git] / src / instr / jedule / jedule_sd_binding.cpp
1 /* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/jedule/jedule.hpp"
7 #include "simgrid/s4u/Engine.hpp"
8 #include "simgrid/s4u/NetZone.hpp"
9 #include "src/simdag/simdag_private.hpp"
10
11 #if SIMGRID_HAVE_JEDULE
12
13 XBT_LOG_NEW_CATEGORY(jedule, "Logging specific to Jedule");
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule, "Logging specific to Jedule SD binding");
15
16 jedule_t my_jedule;
17
18 void jedule_log_sd_event(const_SD_task_t task)
19 {
20   xbt_assert(task != nullptr);
21
22   simgrid::jedule::Event event(std::string(SD_task_get_name(task)), SD_task_get_start_time(task),
23                                SD_task_get_finish_time(task), "SD");
24   event.add_resources(*task->allocation);
25   my_jedule->event_set_.emplace_back(std::move(event));
26 }
27
28 void jedule_sd_init()
29 {
30   const_sg_netzone_t root_comp = simgrid::s4u::Engine::get_instance()->get_netzone_root();
31   XBT_DEBUG("root name %s\n", root_comp->get_cname());
32
33   my_jedule = new simgrid::jedule::Jedule(root_comp->get_name());
34   my_jedule->root_container_.create_hierarchy(root_comp);
35 }
36
37 void jedule_sd_exit()
38 {
39   delete my_jedule;
40 }
41
42 void jedule_sd_dump(const char * filename)
43 {
44   if (my_jedule) {
45     std::string fname;
46     if (not filename) {
47       fname = simgrid::xbt::binary_name + ".jed";
48     } else {
49       fname = filename;
50     }
51
52     FILE* fh = fopen(fname.c_str(), "w");
53
54     my_jedule->write_output(fh);
55
56     fclose(fh);
57   }
58 }
59 #endif