Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove (void) in C++
[simgrid.git] / src / instr / jedule / jedule_sd_binding.cpp
1 /* Copyright (c) 2010-2017. 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 "src/simdag/simdag_private.hpp"
8
9 #include "simgrid/s4u/Engine.hpp"
10 #include "simgrid/s4u/NetZone.hpp"
11
12 #if SIMGRID_HAVE_JEDULE
13
14 XBT_LOG_NEW_CATEGORY(jedule, "Logging specific to Jedule");
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule, "Logging specific to Jedule SD binding");
16
17 jedule_t my_jedule;
18
19 void jedule_log_sd_event(SD_task_t task)
20 {
21   xbt_assert(task != nullptr);
22
23   jed_event_t event = new simgrid::jedule::Event(std::string(SD_task_get_name(task)),
24                                                  SD_task_get_start_time(task), SD_task_get_finish_time(task), "SD");
25   event->addResources(task->allocation);
26   my_jedule->event_set.push_back(event);
27 }
28
29 void jedule_sd_init()
30 {
31   sg_netzone_t root_comp = simgrid::s4u::Engine::instance()->netRoot();
32   XBT_DEBUG("root name %s\n", root_comp->name());
33
34   my_jedule = new simgrid::jedule::Jedule();
35
36   jed_container_t root_container = new simgrid::jedule::Container(std::string(root_comp->name()));
37   root_container->createHierarchy(root_comp);
38   my_jedule->root_container = root_container;
39 }
40
41 void jedule_sd_exit()
42 {
43   delete my_jedule;
44 }
45
46 void jedule_sd_dump(const char * filename)
47 {
48   if (my_jedule) {
49     char *fname;
50     if (not filename) {
51       fname = bprintf("%s.jed", xbt_binary_name);
52     } else {
53       fname = xbt_strdup(filename);
54     }
55
56     FILE *fh = fopen(fname, "w");
57
58     my_jedule->writeOutput(fh);
59
60     fclose(fh);
61     xbt_free(fname);
62   }
63 }
64 #endif