1 /* Copyright (c) 2010-2013. 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"
23 XBT_LOG_NEW_CATEGORY(jedule, "Logging specific to Jedule");
24 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule,
25 "Logging specific to Jedule SD binding");
29 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 = sg_host_name(task->workstation_list[i]);
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(AS_t current_comp,
57 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)
127 jed_free_jedule(jedule);
132 void jedule_sd_dump()
139 strcat(fname, xbt_binary_name);
140 strcat(fname, ".jed\0");
142 fh = fopen(fname, "w");
144 write_jedule_output(fh, jedule, jedule_event_list, NULL);