4 * Created on: Dec 2, 2010
9 #include "xbt/asserts.h"
10 #include "xbt/dynar.h"
12 #include "surf/surf_private.h"
13 #include "surf/surf_resource.h"
14 #include "surf/surf.h"
16 #include "instr/jedule/jedule_sd_binding.h"
17 #include "instr/jedule/jedule_events.h"
18 #include "instr/jedule/jedule_platform.h"
19 #include "instr/jedule/jedule_output.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) {
32 xbt_dynar_t host_list;
36 xbt_assert(task != NULL);
38 host_list = xbt_dynar_new(sizeof(char*), NULL);
40 for(i=0; i<task->workstation_nb; i++) {
41 char *hostname = sg_host_name(task->workstation_list[i]);
42 xbt_dynar_push(host_list, &hostname);
45 create_jed_event(&event,
46 (char*)SD_task_get_name(task),
51 jed_event_add_resources(event, host_list);
52 jedule_store_event(event);
54 xbt_dynar_free(&host_list);
57 static void create_hierarchy(AS_t current_comp,
58 jed_simgrid_container_t current_container) {
59 xbt_dict_cursor_t cursor = NULL;
60 unsigned int dynar_cursor;
63 sg_routing_edge_t network_elem;
65 if(xbt_dict_is_empty(current_comp->routing_sons)) {
67 // add hosts to jedule platform
70 hosts = xbt_dynar_new(sizeof(char*), NULL);
72 xbt_dynar_foreach(current_comp->index_network_elm,
73 dynar_cursor, network_elem) {
74 xbt_dynar_push_as(hosts, char*, network_elem->name);
77 jed_simgrid_add_resources(current_container, hosts);
78 xbt_dynar_free(&hosts);
80 xbt_dict_foreach(current_comp->routing_sons, cursor, key, elem) {
81 jed_simgrid_container_t child_container;
82 jed_simgrid_create_container(&child_container, elem->name);
83 jed_simgrid_add_container(current_container, child_container);
84 XBT_DEBUG("name : %s\n", elem->name);
85 create_hierarchy(elem, child_container);
90 void jedule_setup_platform() {
93 // e_surf_network_element_type_t type;
95 jed_simgrid_container_t root_container;
98 jed_create_jedule(&jedule);
100 root_comp = routing_platf->root;
101 XBT_DEBUG("root name %s\n", root_comp->name);
104 // type = root_comp->get_network_element_type(root_comp->name);
106 jed_simgrid_create_container(&root_container, root_comp->name);
107 jedule->root_container = root_container;
109 create_hierarchy(root_comp, root_container);
114 void jedule_sd_cleanup() {
116 jedule_cleanup_output();
119 void jedule_sd_init() {
121 jedule_init_output();
124 void jedule_sd_exit(void)
126 jed_free_jedule(jedule);
130 void jedule_sd_dump() {
135 strcat(fname, xbt_binary_name);
136 strcat(fname, ".jed\0");
138 fh = fopen(fname, "w");
140 write_jedule_output(fh, jedule, jedule_event_list, NULL);