Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
jedule binding to SD started
authorsahu <sahu@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 9 Feb 2011 11:40:11 +0000 (11:40 +0000)
committersahu <sahu@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 9 Feb 2011 11:40:11 +0000 (11:40 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9594 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/instr/jedule/jedule_events.h [new file with mode: 0644]
include/instr/jedule/jedule_output.h [new file with mode: 0644]
include/instr/jedule/jedule_platform.h [new file with mode: 0644]
include/instr/jedule/jedule_sd_binding.h [new file with mode: 0644]
src/instr/jedule/jedule_events.c [new file with mode: 0644]
src/instr/jedule/jedule_output.c [new file with mode: 0644]
src/instr/jedule/jedule_platform.c [new file with mode: 0644]
src/instr/jedule/jedule_sd_binding.c [new file with mode: 0644]
src/simdag/sd_global.c
src/simdag/sd_task.c

diff --git a/include/instr/jedule/jedule_events.h b/include/instr/jedule/jedule_events.h
new file mode 100644 (file)
index 0000000..4d5b295
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * jedule_events.h
+ *
+ *  Created on: Nov 30, 2010
+ *      Author: sascha
+ */
+
+#ifndef JEDULE_EVENTS_H_
+#define JEDULE_EVENTS_H_
+
+#include "jedule_platform.h"
+
+#include "xbt/dynar.h"
+#include "xbt/dict.h"
+
+struct jed_event {
+       int event_id;
+       char *name;
+       double start_time;
+       double end_time;
+       char *type;
+       xbt_dynar_t resource_subsets;
+       xbt_dynar_t characteristics_list; /* just a list of names (strings) */
+       xbt_dict_t info_hash;     /* key/value pairs */
+};
+
+typedef struct jed_event s_jed_event_t, *jed_event_t;
+
+/************************************************************/
+
+void create_jed_event(jed_event_t *event, char *name, double start_time, double end_time, char *type);
+
+void jed_event_free(jed_event_t event);
+
+void jed_event_add_resources(jed_event_t event, xbt_dynar_t host_selection);
+
+void jed_event_add_characteristic(jed_event_t event, char *characteristic);
+
+void jed_event_add_info(jed_event_t event, char *key, char *value);
+
+#endif /* JEDULE_EVENTS_H_ */
diff --git a/include/instr/jedule/jedule_output.h b/include/instr/jedule/jedule_output.h
new file mode 100644 (file)
index 0000000..fea8a47
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * jedule_output.h
+ *
+ *  Created on: Nov 30, 2010
+ *      Author: sascha
+ */
+
+#ifndef JEDULE_OUTPUT_H_
+#define JEDULE_OUTPUT_H_
+
+#include "jedule_events.h"
+#include "jedule_platform.h"
+
+xbt_dynar_t jedule_event_list;
+
+void init_jedule_output();
+
+void cleanup_jedule();
+
+void jedule_store_event(jed_event_t event);
+
+void write_jedule_output(char *filename, jedule_t jedule,
+               xbt_dynar_t event_list, xbt_dict_t meta_info_dict);
+
+#endif /* JEDULE_OUTPUT_H_ */
diff --git a/include/instr/jedule/jedule_platform.h b/include/instr/jedule/jedule_platform.h
new file mode 100644 (file)
index 0000000..f700c63
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * jed_simgrid_platform.h
+ *
+ *  Created on: Nov 30, 2010
+ *      Author: sascha
+ */
+
+#ifndef JED_SIMGRID_PLATFORM_H_
+#define JED_SIMGRID_PLATFORM_H_
+
+#include "xbt/dynar.h"
+#include "xbt/hash.h"
+
+typedef struct jed_simgrid_container s_jed_simgrid_container_t,
+               *jed_simgrid_container_t;
+
+
+struct jed_simgrid_container {
+       char *name;
+       xbt_dynar_t container_children;
+       jed_simgrid_container_t parent;
+       xbt_dynar_t resource_list;
+       xbt_dict_t name2id;
+       int last_id;
+       int is_lowest;
+};
+
+
+/**
+ * selection of a subset of resources from the original set
+ *
+ */
+struct jed_res_subset {
+       jed_simgrid_container_t parent;
+       int start_idx; // start idx in resource_list of container
+       int nres;      // number of resources spanning starting at start_idx
+};
+
+typedef struct jed_res_subset s_jed_res_subset_t, *jed_res_subset_t;
+
+struct jedule_struct {
+       jed_simgrid_container_t root_container;
+       xbt_dict_t jedule_meta_info;
+};
+
+typedef struct jedule_struct s_jedule_t, *jedule_t;
+
+
+/*********************************************************/
+
+void jed_create_jedule(jedule_t *jedule);
+
+void jed_free_jedule(jedule_t jedule);
+
+void jedule_add_meta_info(jedule_t jedule, char *key, char *value);
+
+void jed_simgrid_create_container(jed_simgrid_container_t *container, char *name);
+
+void jed_simgrid_add_container(jed_simgrid_container_t parent,
+               jed_simgrid_container_t child);
+
+void jed_simgrid_add_resources(jed_simgrid_container_t parent,
+               xbt_dynar_t host_names);
+
+/**
+ *
+ * it is assumed that the host_names in the entire system are unique
+ * that means that we don't need parent references
+ *
+ * subset_list must be allocated
+ * host_names is the list of host_names associated with an event
+ */
+void jed_simgrid_get_resource_selection_by_hosts(xbt_dynar_t subset_list,
+               xbt_dynar_t host_names);
+
+/*
+  global:
+         hash host_id -> container
+
+  container:
+         hash host_id -> jed_host_id
+
+         list <- [ jed_host_ids ]
+         list <- sort( list )
+         list_chunks <- chunk( list )   -> [ 1, 3-5, 7-9 ]
+
+*/
+
+
+#endif /* JED_SIMGRID_PLATFORM_H_ */
diff --git a/include/instr/jedule/jedule_sd_binding.h b/include/instr/jedule/jedule_sd_binding.h
new file mode 100644 (file)
index 0000000..60f473a
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * jedule_sd_binding.h
+ *
+ *  Created on: Dec 2, 2010
+ *      Author: sascha
+ */
+
+#ifndef JEDULE_SD_BINDING_H_
+#define JEDULE_SD_BINDING_H_
+
+void jedule_log_sd_event(SD_task_t task);
+
+void jedule_setup_platform();
+
+#endif /* JEDULE_SD_BINDING_H_ */
diff --git a/src/instr/jedule/jedule_events.c b/src/instr/jedule/jedule_events.c
new file mode 100644 (file)
index 0000000..d781b38
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * jedule_events.c
+ *
+ *  Created on: Nov 30, 2010
+ *      Author: sascha
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jedule_events.h"
+#include "jedule_platform.h"
+
+#include "xbt/dict.h"
+#include "xbt/dynar.h"
+#include "xbt/asserts.h"
+
+void jed_event_add_resources(jed_event_t event, xbt_dynar_t host_selection) {
+       xbt_dynar_t resource_subset_list;
+       jed_res_subset_t res_set;
+       int i;
+
+       resource_subset_list = xbt_dynar_new(sizeof(jed_res_subset_t), NULL);
+
+       jed_simgrid_get_resource_selection_by_hosts(resource_subset_list, host_selection);
+       xbt_dynar_foreach(resource_subset_list, i, res_set)  {
+               xbt_dynar_push(event->resource_subsets, &res_set);
+       }
+
+       xbt_dynar_free(&resource_subset_list);
+}
+
+void jed_event_add_characteristic(jed_event_t event, char *characteristic) {
+       xbt_assert( characteristic != NULL );
+       xbt_dynar_push(event->characteristics_list, &characteristic);
+}
+
+
+void jed_event_add_info(jed_event_t event, char *key, char *value) {
+       char *val_cp;
+
+       xbt_assert(key != NULL);
+       xbt_assert(value != NULL);
+
+       val_cp = strdup(value);
+       xbt_dict_set(event->info_hash, key, val_cp, NULL);
+}
+
+
+void create_jed_event(jed_event_t *event, char *name, double start_time,
+               double end_time, char *type) {
+
+       *event = (jed_event_t) calloc(1, sizeof(s_jed_event_t));
+       (*event)->name = (char*) calloc(strlen(name) + 1, sizeof(char));
+       strcpy((*event)->name, name);
+
+       (*event)->start_time = start_time;
+       (*event)->end_time = end_time;
+
+       (*event)->type = (char*) calloc(strlen(type) + 1, sizeof(char));
+       strcpy((*event)->type, type);
+
+       (*event)->resource_subsets = xbt_dynar_new(sizeof(jed_res_subset_t), NULL);
+       (*event)->characteristics_list = xbt_dynar_new(sizeof(char*), NULL);
+       (*event)->info_hash = xbt_dict_new();
+
+}
+
+
+void jed_event_free(jed_event_t event) {
+
+       free(event->name);
+       free(event->type);
+
+       xbt_dynar_free(&event->resource_subsets);
+
+       xbt_dynar_free(&event->characteristics_list);
+       xbt_dict_free(&event->info_hash);
+
+       free(event);
+}
diff --git a/src/instr/jedule/jedule_output.c b/src/instr/jedule/jedule_output.c
new file mode 100644 (file)
index 0000000..cf24c82
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * jedule_output.c
+ *
+ *  Created on: Dec 1, 2010
+ *      Author: sascha
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jedule_output.h"
+
+#include "xbt/dynar.h"
+#include "xbt/asserts.h"
+
+/*********************************************************/
+
+static FILE *jed_file;
+
+static void print_platform(jed_simgrid_container_t root_container);
+static void print_container(jed_simgrid_container_t container);
+static void print_resources(jed_simgrid_container_t resource_parent);
+static void print_key_value_dict(xbt_dict_t meta_info_dict);
+static void print_events(xbt_dynar_t event_list);
+static void get_hierarchy_list(xbt_dynar_t hier_list, jed_simgrid_container_t container);
+
+/*********************************************************/
+
+
+static void get_hierarchy_list(xbt_dynar_t hier_list, jed_simgrid_container_t container) {
+
+       xbt_assert( container != NULL );
+
+       if( container->parent != NULL ) {
+
+               if( container->parent->container_children == NULL ) {
+                       // we are in the last level
+                       get_hierarchy_list(hier_list, container->parent);
+
+               } else {
+                       unsigned int i;
+                       int child_nb = -1;
+                       jed_simgrid_container_t child_container;
+
+                       xbt_dynar_foreach(container->parent->container_children, i, child_container) {
+                               if( child_container == container ) {
+                                       child_nb = i;
+                                       break;
+                               }
+                       }
+
+                       xbt_assert( child_nb > - 1);
+
+                       xbt_dynar_insert_at(hier_list, 0, &child_nb);
+
+                       get_hierarchy_list(hier_list, container->parent);
+               }
+       } else {
+               int top_level = 0;
+               xbt_dynar_insert_at(hier_list, 0, &top_level);
+       }
+
+}
+
+static void print_key_value_dict(xbt_dict_t key_value_dict) {
+       xbt_dict_cursor_t cursor=NULL;
+       char *key,*data;
+
+       xbt_dict_foreach(key_value_dict,cursor,key,data) {
+           fprintf(jed_file, "<prop key=\"%s\" values=\"%s\" />\n",key,data);
+       }
+}
+
+static void print_container(jed_simgrid_container_t container) {
+       unsigned int i;
+       jed_simgrid_container_t child_container;
+
+       xbt_assert( container != NULL );
+
+       fprintf(jed_file, "<res name=\"%s\">\n", container->name);
+       if( container->container_children != NULL ) {
+               xbt_dynar_foreach(container->container_children, i, child_container) {
+                       print_container(child_container);
+               }
+       } else {
+               print_resources(container);
+       }
+       fprintf(jed_file, "</res>\n");
+}
+
+static void print_resources(jed_simgrid_container_t resource_parent) {
+       int res_nb;
+       unsigned int i;
+       char *res_name;
+       xbt_assert( resource_parent->resource_list != NULL );
+
+       res_nb = xbt_dynar_length(resource_parent->resource_list);
+
+       fprintf(jed_file, "<rset nb=\"%d\" names=\"", res_nb);
+       xbt_dynar_foreach(resource_parent->resource_list, i, res_name) {
+               fprintf(jed_file, "%s", res_name);
+               if( i != res_nb-1 ) {
+                       fprintf(jed_file, "|");
+               }
+       }
+       fprintf(jed_file, "\" />\n");
+}
+
+
+static void print_platform(jed_simgrid_container_t root_container) {
+
+       fprintf(jed_file, "<platform>\n");
+       print_container(root_container);
+       fprintf(jed_file, "</platform>\n");
+}
+
+static void print_event(jed_event_t event) {
+       unsigned int i;
+       jed_res_subset_t subset;
+
+
+       xbt_assert( event != NULL );
+       xbt_assert( event->resource_subsets != NULL );
+
+       fprintf(jed_file, "<event>\n");
+
+
+       fprintf(jed_file, "<prop value=\"name\" value=\"%s\" />\n", event->name);
+       fprintf(jed_file, "<prop value=\"start\" value=\"%g\" />\n", event->start_time);
+       fprintf(jed_file, "<prop value=\"end\" value=\"%g\" />\n", event->end_time);
+       fprintf(jed_file, "<prop value=\"type\" value=\"%s\" />\n", event->type);
+
+       fprintf(jed_file, "<res_util>\n");
+
+       xbt_dynar_foreach(event->resource_subsets, i, subset) {
+
+               int start = subset->start_idx;
+               int end   = subset->start_idx + subset->nres - 1;
+               xbt_dynar_t hier_list;
+               unsigned int iter;
+               int number;
+
+               hier_list = xbt_dynar_new(sizeof(int), NULL);
+
+               //printf("subset start %d nres %d\n", subset->start_idx, subset->nres);
+
+               //printf("parent %s\n", event->resource_selection[i]->parent->name);
+               get_hierarchy_list(hier_list, subset->parent);
+
+               fprintf(jed_file, "<select resources=\"");
+
+               xbt_dynar_foreach(hier_list, iter, number) {
+                       fprintf(jed_file, "%d.", number);
+               }
+               fprintf(jed_file, "[%d-%d]", start, end);
+               fprintf(jed_file, "\" />\n");
+
+               xbt_dynar_free(&hier_list);
+       }
+
+       fprintf(jed_file, "</res_util>\n");
+
+       fprintf(jed_file, "<characteristics>\n");
+       {
+               char *ch;
+               unsigned int iter;
+               xbt_dynar_foreach(event->characteristics_list, iter, ch) {
+                       fprintf(jed_file, "<characteristic name=\"%s\" />\n", ch);
+               }
+       }
+       fprintf(jed_file, "</characteristics>\n");
+
+       fprintf(jed_file, "<info>\n");
+       print_key_value_dict(event->info_hash);
+       fprintf(jed_file, "</info>\n");
+
+       fprintf(jed_file, "</event>\n");
+}
+
+static void print_events(xbt_dynar_t event_list)  {
+       unsigned int i;
+       jed_event_t event;
+
+       fprintf(jed_file, "<events>\n");
+       xbt_dynar_foreach(event_list, i, event) {
+               print_event(event);
+       }
+       fprintf(jed_file, "</events>\n");
+}
+
+
+void write_jedule_output(char *filename, jedule_t jedule,
+               xbt_dynar_t event_list, xbt_dict_t meta_info_dict) {
+
+       xbt_assert( filename != NULL );
+
+       jed_file = fopen(filename, "w");
+       xbt_assert( jed_file != NULL );
+
+       fprintf(jed_file, "<jedule>\n");
+
+       fprintf(jed_file, "<jedule_meta>\n");
+       print_key_value_dict(jedule->jedule_meta_info);
+       fprintf(jed_file, "</jedule_meta>\n");
+
+       print_platform(jedule->root_container);
+
+       print_events(event_list);
+
+       fprintf(jed_file, "</jedule>\n");
+
+       fclose(jed_file);
+
+}
+
+void init_jedule_output() {
+       jedule_event_list = xbt_dynar_new(sizeof(jed_event_t), NULL);
+}
+
+void cleanup_jedule() {
+       xbt_dynar_free(&jedule_event_list);
+}
+
+void jedule_store_event(jed_event_t event) {
+       xbt_assert(event != NULL);
+       xbt_dynar_push(jedule_event_list, &event);
+}
+
+
diff --git a/src/instr/jedule/jedule_platform.c b/src/instr/jedule/jedule_platform.c
new file mode 100644 (file)
index 0000000..9b21d5c
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * jed_simgrid_platform.c
+ *
+ *  Created on: Nov 30, 2010
+ *      Author: sascha
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "xbt/asserts.h"
+#include "xbt/dynar.h"
+
+#include "jedule_platform.h"
+
+/********************************************************************/
+
+static xbt_dict_t host2_simgrid_parent_container;
+static xbt_dict_t container_name2container;
+
+/********************************************************************/
+
+static void add_subset_to(xbt_dynar_t subset_list, int start, int end,
+               jed_simgrid_container_t parent);
+
+static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup,
+               jed_simgrid_container_t parent);
+
+static void jed_free_container(jed_simgrid_container_t container);
+
+/********************************************************************/
+
+static int compare_hostnames(const void *host1, const void *host2) {
+       return strcmp ((char*)host1, (char*)host2);
+}
+
+static int compare_ids(const void *num1, const void *num2) {
+       int *i1 = (int*) num1;
+       int *i2 = (int*) num2;
+       return *i1 - *i2;
+}
+
+static void jed_free_container(jed_simgrid_container_t container) {
+
+       xbt_dict_free(&container->name2id);
+       if( container->resource_list != NULL ) {
+               xbt_dynar_free(&container->resource_list);
+       }
+
+       if( container->container_children != NULL ) {
+               unsigned int iter;
+               jed_simgrid_container_t child_container;
+               xbt_dynar_foreach(container->container_children, iter, child_container) {
+                       jed_free_container(child_container);
+               }
+       }
+
+       free(container->name);
+       free(container);
+}
+
+void jed_simgrid_create_container(jed_simgrid_container_t *container, char *name) {
+       xbt_assert( name != NULL );
+
+       *container = (jed_simgrid_container_t)calloc(1,sizeof(s_jed_simgrid_container_t));
+       (*container)->name = (char*)calloc((strlen(name)+1), sizeof(char));
+       strcpy((*container)->name, name);
+       (*container)->is_lowest = 0;
+       (*container)->container_children = xbt_dynar_new(sizeof(jed_simgrid_container_t), NULL);
+       (*container)->parent = NULL;
+
+       xbt_dict_set(container_name2container, (*container)->name, *container, NULL);
+}
+
+
+void jed_simgrid_add_container(jed_simgrid_container_t parent,
+               jed_simgrid_container_t child) {
+       xbt_assert(parent != NULL);
+       xbt_assert(child != NULL);
+       xbt_dynar_push(parent->container_children, &child);
+       child->parent = parent;
+}
+
+void jed_simgrid_add_resources(jed_simgrid_container_t parent,
+               xbt_dynar_t host_names) {
+
+       unsigned int iter;
+       char *host_name;
+       char buf[16];
+       char *buf_copy;
+
+       parent->is_lowest = 1;
+       xbt_dynar_free(&parent->container_children);
+       parent->container_children = NULL;
+       parent->name2id = xbt_dict_new();
+       parent->last_id = 0;
+       parent->resource_list = xbt_dynar_new(sizeof(char *), NULL);
+
+
+       xbt_dynar_sort (host_names,     &compare_hostnames);
+
+       xbt_dynar_foreach(host_names, iter, host_name) {
+               buf_copy = strdup(buf);
+               sprintf(buf_copy, "%d", parent->last_id);
+               (parent->last_id)++;
+               xbt_dict_set(parent->name2id, host_name, buf_copy, NULL);
+               xbt_dict_set(host2_simgrid_parent_container, host_name, parent, NULL);
+               xbt_dynar_push(parent->resource_list, &host_name);
+       }
+
+}
+
+static void add_subset_to(xbt_dynar_t subset_list, int start, int end,
+               jed_simgrid_container_t parent) {
+
+       jed_res_subset_t subset;
+
+       xbt_assert( subset_list != NULL );
+       xbt_assert( parent != NULL );
+
+       // printf(">>> start=%d end=%d\n", start, end);
+
+       subset = (jed_res_subset_t)calloc(1,sizeof(s_jed_res_subset_t));
+       subset->start_idx = start;
+       subset->nres      = end-start+1;
+       subset->parent    = parent;
+
+       xbt_dynar_push(subset_list, &subset);
+
+}
+
+static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup,
+               jed_simgrid_container_t parent) {
+
+       unsigned int iter;
+       char *host_name;
+       xbt_dynar_t id_list;
+       int *id_ar;
+       int nb_ids;
+       char *id_str;
+
+       // get ids for each host
+       // sort ids
+       // compact ids
+       // create subset for each id group
+
+       xbt_assert( host2_simgrid_parent_container != NULL );
+       xbt_assert( subset_list != NULL );
+       xbt_assert( hostgroup != NULL );
+       xbt_assert( parent != NULL );
+
+       id_list = xbt_dynar_new(sizeof(char *), NULL);
+
+       xbt_dynar_foreach(hostgroup, iter, host_name) {
+               jed_simgrid_container_t parent;
+               xbt_assert( host_name != NULL );
+               parent = xbt_dict_get(host2_simgrid_parent_container, host_name);
+               id_str = xbt_dict_get(parent->name2id, host_name);
+               xbt_dynar_push(id_list, &id_str);
+       }
+
+       nb_ids = xbt_dynar_length(id_list);
+       id_ar = (int*)calloc(nb_ids, sizeof(int));
+       xbt_dynar_foreach(id_list, iter, id_str) {
+               id_ar[iter] = atoi(id_str);
+       }
+
+       qsort (id_ar, nb_ids, sizeof(int), &compare_ids);
+
+       if( nb_ids > 0 ) {
+               int start = 0;
+               int pos;
+               int i;
+
+               pos = start;
+               for(i=0; i<nb_ids; i++) {
+
+                       if( id_ar[i] - id_ar[pos] > 1 ) {
+
+                               add_subset_to( subset_list, id_ar[start], id_ar[pos], parent );
+                               start = i;
+
+                               if( i == nb_ids-1 ) {
+                                       add_subset_to( subset_list, id_ar[i], id_ar[i], parent );
+                               }
+
+                       } else {
+                               if( i == nb_ids-1 ) {
+                                       add_subset_to( subset_list, id_ar[start], id_ar[i], parent );
+                               }
+                       }
+
+                       pos = i;
+               }
+       }
+
+       free(id_ar);
+       xbt_dynar_free(&id_list);
+
+
+}
+
+void jed_simgrid_get_resource_selection_by_hosts(xbt_dynar_t subset_list,
+               xbt_dynar_t host_names) {
+
+       char *host_name;
+       unsigned int iter;
+       xbt_dict_t parent2hostgroup;  // group hosts by parent
+
+       parent2hostgroup = xbt_dict_new();
+
+       xbt_assert( host_names != NULL );
+
+       // for each host name
+       //  find parent container
+       //  group by parent container
+
+       xbt_dynar_foreach(host_names, iter, host_name) {
+               jed_simgrid_container_t parent;
+               xbt_dynar_t hostgroup;
+
+               //printf("checking %s \n", host_name);
+
+               parent = xbt_dict_get(host2_simgrid_parent_container, host_name);
+               xbt_assert( parent != NULL );
+
+               hostgroup = xbt_dict_get_or_null (parent2hostgroup, parent->name);
+               if( hostgroup == NULL ) {
+                       hostgroup = xbt_dynar_new(sizeof(char*), NULL);
+                       xbt_dict_set(parent2hostgroup, parent->name, hostgroup, NULL);
+               }
+
+               xbt_dynar_push(hostgroup, &host_name);
+       }
+
+       {
+               xbt_dict_cursor_t cursor=NULL;
+               char *parent_name;
+               xbt_dynar_t hostgroup;
+               jed_simgrid_container_t parent;
+
+               xbt_dict_foreach(parent2hostgroup,cursor,parent_name,hostgroup) {
+                       parent = xbt_dict_get(container_name2container, parent_name);
+                       // printf("subset parent >>> %s\n", parent->name);
+                       add_subsets_to(subset_list, hostgroup, parent);
+               }
+
+       }
+
+       xbt_dict_free(&parent2hostgroup);
+
+}
+
+
+void jedule_add_meta_info(jedule_t jedule, char *key, char *value) {
+
+       char *val_cp;
+
+       xbt_assert(key != NULL);
+       xbt_assert(value != NULL);
+
+       val_cp = strdup(value);
+       xbt_dict_set(jedule->jedule_meta_info, key, val_cp, NULL);
+}
+
+void jed_create_jedule(jedule_t *jedule) {
+       *jedule = (jedule_t)calloc(1,sizeof(s_jedule_t));
+       host2_simgrid_parent_container = xbt_dict_new();
+       container_name2container       = xbt_dict_new();
+       (*jedule)->jedule_meta_info    = xbt_dict_new();
+}
+
+void jed_free_jedule(jedule_t jedule) {
+
+       jed_free_container(jedule->root_container);
+
+       xbt_dict_free(&jedule->jedule_meta_info);
+       free(jedule);
+
+       xbt_dict_free(&host2_simgrid_parent_container);
+       xbt_dict_free(&container_name2container);
+}
+
+
diff --git a/src/instr/jedule/jedule_sd_binding.c b/src/instr/jedule/jedule_sd_binding.c
new file mode 100644 (file)
index 0000000..a1b4e56
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * jedule_sd_binding.c
+ *
+ *  Created on: Dec 2, 2010
+ *      Author: sascha
+ */
+
+
+#include "xbt/asserts.h"
+#include "xbt/dynar.h"
+
+void jedule_log_sd_event(SD_task_t task) {
+       xbt_dynar_t host_list;
+       jed_event_t event;
+       int i;
+
+       xbt_assert(task != NULL);
+
+       host_list = xbt_dynar_new(sizeof(char*), NULL);
+
+       for(i=0; i<task->workstation_nb; i++) {
+               char *hostname = surf_resource_name(task->workstation_list[i]->surf_workstation);
+               xbt_dynar_push(host_list, &hostname);
+       }
+
+       create_jed_event(&event, SD_task_get_name(task), task->start_time,
+                       task->finish_time, "SD");
+
+       jed_event_add_resources(event, host_list);
+
+       jedule_store_event(event);
+
+       xbt_dynar_free(&host_list);
+}
+
+
+void jedule_setup_platform() {
+
+
+
+
+}
index 344ec2a..06849ea 100644 (file)
 #include <lualib.h>
 #endif
 
+#ifdef HAVE_JEDULE
+#include "instr/jedule/jedule_output.h"
+#endif
+
 XBT_LOG_NEW_CATEGORY(sd, "Logging specific to SimDag");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_kernel, sd,
                                 "Logging specific to SimDag (kernel)");
@@ -92,6 +96,10 @@ void SD_init(int *argc, char **argv)
 #ifdef HAVE_TRACING
   TRACE_start ();
 #endif
+
+#ifdef HAVE_JEDULE
+  init_jedule_output();
+#endif
 }
 
 /**
@@ -139,6 +147,12 @@ void SD_application_reinit(void)
     sd_global->failed_task_set =
         xbt_swag_new(xbt_swag_offset(task, state_hookup));
     sd_global->task_number = 0;
+
+#ifdef HAVE_JEDULE
+    cleanup_jedule();
+    init_jedule_output();
+#endif
+
   } else {
     WARN0("SD_application_reinit called before initialization of SimDag");
     /* we cannot use exceptions here because xbt is not running! */
@@ -194,6 +208,9 @@ void SD_create_environment(const char *platform_file)
 
   DEBUG2("Workstation number: %d, link number: %d",
          SD_workstation_get_number(), SD_link_get_number());
+#ifdef HAVE_JEDULE
+  jedule_setup_platform();
+#endif
 }
 
 /**
@@ -412,6 +429,9 @@ void SD_exit(void)
 #ifdef HAVE_TRACING
   TRACE_end();
 #endif
+#ifdef HAVE_JEDULE
+  cleanup_jedule();
+#endif
 
     DEBUG0("Exiting Surf...");
     surf_exit();
index 105ac01..255fe58 100644 (file)
@@ -961,6 +961,10 @@ void __SD_task_really_run(SD_task_t task)
     TRACE_surf_action(task->surf_action, task->category);
 #endif
 
+#ifdef HAVE_JEDULE
+  jedule_log_sd_event(task);
+#endif
+
   __SD_task_destroy_scheduling_data(task);      /* now the scheduling data are not useful anymore */
   __SD_task_set_state(task, SD_RUNNING);
   xbt_assert2(__SD_task_is_running(task), "Bad state of task '%s': %d",