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"
26 void jedule_log_sd_event(SD_task_t task) {
27 xbt_dynar_t host_list;
31 xbt_assert(task != NULL);
33 host_list = xbt_dynar_new(sizeof(char*), NULL);
35 for(i=0; i<task->workstation_nb; i++) {
36 char *hostname = surf_resource_name(task->workstation_list[i]->surf_workstation);
37 xbt_dynar_push(host_list, &hostname);
40 create_jed_event(&event,
41 SD_task_get_name(task),
46 jed_event_add_resources(event, host_list);
47 jedule_store_event(event);
49 xbt_dynar_free(&host_list);
52 static void create_hierarchy(routing_component_t current_comp,
53 jed_simgrid_container_t current_container) {
54 xbt_dict_cursor_t cursor = NULL;
56 routing_component_t elem;
57 network_element_t network_elem;
59 if( xbt_dict_length(current_comp->routing_sons) == 0 ) {
61 // add hosts to jedule platform
64 hosts = xbt_dynar_new(sizeof(char*), NULL);
66 xbt_dict_foreach(current_comp->to_index, cursor, key, network_elem) {
68 printf("key %s value %d\n", key, network_elem);
69 //xbt_dynar_push_as(hosts, char*, key);
70 hostname = strdup(key);
71 xbt_dynar_push(hosts, &hostname);
74 jed_simgrid_add_resources(current_container, hosts);
77 xbt_dict_foreach(current_comp->routing_sons, cursor, key, elem) {
78 jed_simgrid_container_t child_container;
79 jed_simgrid_create_container(&child_container, elem->name);
80 jed_simgrid_add_container(current_container, child_container);
81 printf("name : %s\n", elem->name);
82 create_hierarchy(elem, child_container);
87 void jedule_setup_platform() {
89 routing_component_t root_comp;
90 e_surf_network_element_type_t type;
92 jed_simgrid_container_t root_container;
95 jed_create_jedule(&jedule);
97 root_comp = global_routing->root;
98 printf("root name %s\n", root_comp->name);
101 type = root_comp->get_network_element_type(root_comp->name);
103 jed_simgrid_create_container(&root_container, root_comp->name);
104 jedule->root_container = root_container;
106 create_hierarchy(root_comp, root_container);
111 void jedule_sd_cleanup() {
113 jedule_cleanup_output();
116 void jedule_sd_init() {
118 jedule_init_output();
121 void jedule_sd_dump() {
123 write_jedule_output(stdout, jedule, jedule_event_list, NULL);