4 * Created on: Dec 2, 2010
11 #include "xbt/asserts.h"
12 #include "xbt/dynar.h"
14 #include "surf/surf_private.h"
15 #include "surf/surf.h"
17 #include "instr/jedule/jedule_sd_binding.h"
18 #include "instr/jedule/jedule_events.h"
19 #include "instr/jedule/jedule_platform.h"
20 #include "instr/jedule/jedule_output.h"
24 XBT_LOG_NEW_CATEGORY(jedule, "Logging specific to Jedule");
25 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule,
26 "Logging specific to Jedule SD binding");
30 void jedule_log_sd_event(SD_task_t task) {
31 xbt_dynar_t host_list;
35 xbt_assert(task != NULL);
37 host_list = xbt_dynar_new(sizeof(char*), NULL);
39 for(i=0; i<task->workstation_nb; i++) {
40 char *hostname = (char*)surf_resource_name(task->workstation_list[i]->surf_workstation);
41 xbt_dynar_push(host_list, &hostname);
44 create_jed_event(&event,
45 (char*)SD_task_get_name(task),
50 jed_event_add_resources(event, host_list);
51 jedule_store_event(event);
53 xbt_dynar_free(&host_list);
56 static void create_hierarchy(routing_component_t current_comp,
57 jed_simgrid_container_t current_container) {
58 xbt_dict_cursor_t cursor = NULL;
60 routing_component_t elem;
61 network_element_t network_elem;
63 if( xbt_dict_length(current_comp->routing_sons) == 0 ) {
65 // add hosts to jedule platform
68 hosts = xbt_dynar_new(sizeof(char*), NULL);
70 xbt_dict_foreach(current_comp->to_index, cursor, key, network_elem) {
72 XBT_DEBUG("key %s value %p\n", key, network_elem);
73 //xbt_dynar_push_as(hosts, char*, key);
74 hostname = strdup(key);
75 xbt_dynar_push(hosts, &hostname);
78 jed_simgrid_add_resources(current_container, hosts);
81 xbt_dict_foreach(current_comp->routing_sons, cursor, key, elem) {
82 jed_simgrid_container_t child_container;
83 jed_simgrid_create_container(&child_container, elem->name);
84 jed_simgrid_add_container(current_container, child_container);
85 XBT_DEBUG("name : %s\n", elem->name);
86 create_hierarchy(elem, child_container);
91 void jedule_setup_platform() {
93 routing_component_t root_comp;
94 // e_surf_network_element_type_t type;
96 jed_simgrid_container_t root_container;
99 jed_create_jedule(&jedule);
101 root_comp = global_routing->root;
102 XBT_DEBUG("root name %s\n", root_comp->name);
105 // type = root_comp->get_network_element_type(root_comp->name);
107 jed_simgrid_create_container(&root_container, root_comp->name);
108 jedule->root_container = root_container;
110 create_hierarchy(root_comp, root_container);
115 void jedule_sd_cleanup() {
117 jedule_cleanup_output();
120 void jedule_sd_init() {
122 XBT_LOG_CONNECT(jed_sd, jedule);
124 jedule_init_output();
127 void jedule_sd_dump() {
130 fh = fopen("simgrid.jed", "w");
132 write_jedule_output(fh, jedule, jedule_event_list, NULL);