1 /* Copyright (c) 2010-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "xbt/asserts.h"
10 #include "surf/surf_private.h"
11 #include "surf/surf_resource.h"
12 #include "surf/surf.h"
14 #include "instr/jedule/jedule_sd_binding.h"
15 #include "instr/jedule/jedule_events.h"
16 #include "instr/jedule/jedule_platform.h"
17 #include "instr/jedule/jedule_output.h"
19 #include "simdag/private.h"
25 XBT_LOG_NEW_CATEGORY(jedule, "Logging specific to Jedule");
26 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule,
27 "Logging specific to Jedule SD binding");
31 void jedule_log_sd_event(SD_task_t task)
33 xbt_dynar_t host_list;
37 xbt_assert(task != NULL);
39 host_list = xbt_dynar_new(sizeof(char*), NULL);
41 for(i=0; i<task->workstation_nb; i++) {
42 char *hostname = sg_host_name(task->workstation_list[i]);
43 xbt_dynar_push(host_list, &hostname);
46 create_jed_event(&event,
47 (char*)SD_task_get_name(task),
52 jed_event_add_resources(event, host_list);
53 jedule_store_event(event);
55 xbt_dynar_free(&host_list);
58 static void create_hierarchy(AS_t current_comp,
59 jed_simgrid_container_t current_container)
61 xbt_dict_cursor_t cursor = NULL;
64 xbt_dict_t routing_sons = surf_AS_get_routing_sons(current_comp);
66 if (xbt_dict_is_empty(routing_sons)) {
68 // add hosts to jedule platform
69 xbt_dynar_t table = surf_AS_get_hosts(current_comp);
71 unsigned int dynar_cursor;
74 hosts = xbt_dynar_new(sizeof(char*), NULL);
76 xbt_dynar_foreach(table, dynar_cursor, host_elem) {
77 xbt_dynar_push_as(hosts, char*, sg_host_name(host_elem));
80 jed_simgrid_add_resources(current_container, hosts);
81 xbt_dynar_free(&hosts);
82 xbt_dynar_free(&table);
84 xbt_dict_foreach(routing_sons, cursor, key, elem) {
85 jed_simgrid_container_t child_container;
86 jed_simgrid_create_container(&child_container, surf_AS_get_name(elem));
87 jed_simgrid_add_container(current_container, child_container);
88 XBT_DEBUG("name : %s\n", surf_AS_get_name(elem));
89 create_hierarchy(elem, child_container);
94 void jedule_setup_platform()
97 // e_surf_network_element_type_t type;
99 jed_simgrid_container_t root_container;
101 jed_create_jedule(&jedule);
103 root_comp = surf_AS_get_routing_root();
104 XBT_DEBUG("root name %s\n", surf_AS_get_name(root_comp));
106 jed_simgrid_create_container(&root_container, surf_AS_get_name(root_comp));
107 jedule->root_container = root_container;
109 create_hierarchy(root_comp, root_container);
113 void jedule_sd_cleanup()
115 jedule_cleanup_output();
118 void jedule_sd_init()
120 jedule_init_output();
123 void jedule_sd_exit(void)
126 jed_free_jedule(jedule);
131 void jedule_sd_dump()
138 strcat(fname, xbt_binary_name);
139 strcat(fname, ".jed\0");
141 fh = fopen(fname, "w");
143 write_jedule_output(fh, jedule, jedule_event_list, NULL);