Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] new data structure to hold values of states, events and links
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 7 Feb 2011 13:36:37 +0000 (13:36 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 7 Feb 2011 13:36:37 +0000 (13:36 +0000)
details:
- we save some trace space with this, by using aliases to state values
- links is yet to be done

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9582 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/instr/instr_interface.c
src/instr/instr_msg_process.c
src/instr/instr_msg_task.c
src/instr/instr_paje.c
src/instr/instr_paje_trace.c
src/instr/instr_private.h
src/instr/instr_routing.c
src/instr/instr_smpi.c

index 34d03af..2a7bb19 100644 (file)
@@ -84,7 +84,8 @@ void TRACE_mark(const char *mark_type, const char *mark_value)
 
   DEBUG2("MARK %s %s", mark_type, mark_value);
   type_t type = getEventType (mark_type, NULL, getRootContainer()->type);
-  new_pajeNewEvent (MSG_get_clock(), getRootContainer(), type, mark_value);
+  val_t value = getValue (mark_value, NULL, type);
+  new_pajeNewEvent (MSG_get_clock(), getRootContainer(), type, value);
 }
 
 
index 9c4866c..99a8e63 100644 (file)
@@ -50,7 +50,8 @@ void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_hos
 
     //set the state of this new container
     type = getType ("MSG_PROCESS_STATE", msg->type);
-    new_pajeSetState (MSG_get_clock(), msg, type, "executing");
+    val_t value = getValueByName ("executing", type);
+    new_pajeSetState (MSG_get_clock(), msg, type, value);
 
     //end link
     msg = getContainer(instr_process_id(process, str, len));
@@ -70,7 +71,8 @@ void TRACE_msg_process_create (m_process_t process)
     container_t msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, host_container);
 
     type_t type = getType ("MSG_PROCESS_STATE", msg->type);
-    new_pajeSetState (MSG_get_clock(), msg, type, "executing");
+    val_t value = getValueByName ("executing", type);
+    new_pajeSetState (MSG_get_clock(), msg, type, value);
   }
 }
 
@@ -93,7 +95,8 @@ void TRACE_msg_process_suspend(m_process_t process)
 
     container_t process_container = getContainer (instr_process_id(process, str, len));
     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePushState (MSG_get_clock(), process_container, type, "suspend");
+    val_t value = getValueByName ("suspend", type);
+    new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -117,7 +120,8 @@ void TRACE_msg_process_sleep_in(m_process_t process)
 
     container_t process_container = getContainer (instr_process_id(process, str, len));
     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePushState (MSG_get_clock(), process_container, type, "sleep");
+    val_t value = getValueByName ("sleep", type);
+    new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
 
index 46d28b0..0677d05 100644 (file)
@@ -55,7 +55,8 @@ void TRACE_msg_set_task_category(m_task_t task, const char *category)
     new_pajeSetVariable (SIMIX_get_clock(), msg, type, 1);
 
     type = getType ("MSG_TASK_STATE", msg->type);
-    new_pajePushState (MSG_get_clock(), msg, type, "created");
+    val_t value = getValueByName ("created", type);
+    new_pajePushState (MSG_get_clock(), msg, type, value);
   }
 }
 
@@ -76,7 +77,8 @@ void TRACE_msg_task_execute_start(m_task_t task)
   if (TRACE_msg_task_is_enabled()){
     container_t task_container = getContainer (task->name);
     type_t type = getType ("MSG_TASK_STATE", task_container->type);
-    new_pajePushState (MSG_get_clock(), task_container, type, "MSG_task_execute");
+    val_t value = getValueByName ("MSG_task_execute", type);
+    new_pajePushState (MSG_get_clock(), task_container, type, value);
   }
 
   if (TRACE_msg_process_is_enabled()){
@@ -85,7 +87,8 @@ void TRACE_msg_task_execute_start(m_task_t task)
 
     container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePushState (MSG_get_clock(), process_container, type, "task_execute");
+    val_t value = getValueByName ("task_execute", type);
+    new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -140,7 +143,8 @@ void TRACE_msg_task_get_start(void)
 
     container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePushState (MSG_get_clock(), process_container, type, "receive");
+    val_t value = getValueByName ("receive", type);
+    new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
 
@@ -162,7 +166,8 @@ void TRACE_msg_task_get_end(double start_time, m_task_t task)
     new_pajeSetVariable (SIMIX_get_clock(), msg, type, 1);
 
     type = getType ("MSG_TASK_STATE", msg->type);
-    new_pajePushState (MSG_get_clock(), msg, type, "created");
+    val_t value = getValueByName ("created", type);
+    new_pajePushState (MSG_get_clock(), msg, type, value);
 
     type = getType ("MSG_TASK_LINK", getRootType());
     char key[INSTR_DEFAULT_STR_SIZE];
@@ -215,7 +220,8 @@ int TRACE_msg_task_put_start(m_task_t task)
 
     container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
     type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    new_pajePushState (MSG_get_clock(), process_container, type, "send");
+    val_t value = getValueByName ("send", type);
+    new_pajePushState (MSG_get_clock(), process_container, type, value);
 
     char key[INSTR_DEFAULT_STR_SIZE];
     snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
index 462955a..a54c304 100644 (file)
@@ -24,6 +24,41 @@ void instr_paje_init (container_t root)
   rootContainer = root;
 }
 
+static val_t newValue (const char *valuename, const char *color, type_t father)
+{
+  val_t ret = xbt_new0(s_val_t, 1);
+  ret->name = xbt_strdup (valuename);
+  ret->father = father;
+  ret->color = xbt_strdup (color);
+
+  static long long int type_id = 0;
+  char str_id[INSTR_DEFAULT_STR_SIZE];
+  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "v%lld", type_id++);
+  ret->id = xbt_strdup (str_id);
+
+  xbt_dict_set (father->values, valuename, ret, NULL);
+  DEBUG2("new value %s, child of %s", ret->name, ret->father->name);
+  return ret;
+}
+
+val_t getValue (const char *valuename, const char *color, type_t father)
+{
+  if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values
+
+  val_t ret = (val_t)xbt_dict_get_or_null (father->values, valuename);
+  if (ret == NULL){
+    ret = newValue (valuename, color, father);
+    DEBUG4("EntityValue %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+    new_pajeDefineEntityValue(ret);
+  }
+  return ret;
+}
+
+val_t getValueByName (const char *valuename, type_t father)
+{
+  return getValue (valuename, NULL, father);
+}
+
 static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father)
 {
   type_t ret = xbt_new0(s_type_t, 1);
@@ -31,6 +66,7 @@ static type_t newType (const char *typename, const char *key, const char *color,
   ret->father = father;
   ret->kind = kind;
   ret->children = xbt_dict_new ();
+  ret->values = xbt_dict_new ();
   ret->color = xbt_strdup (color);
 
   static long long int type_id = 0;
index 945d3f7..f7aeea9 100644 (file)
@@ -16,6 +16,7 @@ typedef enum {
   PAJE_DefineStateType,
   PAJE_DefineEventType,
   PAJE_DefineLinkType,
+  PAJE_DefineEntityValue,
   PAJE_CreateContainer,
   PAJE_DestroyContainer,
   PAJE_SetVariable,
@@ -65,6 +66,11 @@ typedef struct s_defineLinkType {
   type_t dest;
 }s_defineLinkType_t;
 
+typedef struct s_defineEntityValue *defineEntityValue_t;
+typedef struct s_defineEntityValue {
+  val_t value;
+}s_defineEntityValue_t;
+
 typedef struct s_createContainer *createContainer_t;
 typedef struct s_createContainer {
   container_t container;
@@ -100,14 +106,14 @@ typedef struct s_setState *setState_t;
 typedef struct s_setState {
   container_t container;
   type_t type;
-  char *value;
+  val_t value;
 }s_setState_t;
 
 typedef struct s_pushState *pushState_t;
 typedef struct s_pushState {
   container_t container;
   type_t type;
-  char *value;
+  val_t value;
 }s_pushState_t;
 
 typedef struct s_popState *popState_t;
@@ -138,7 +144,7 @@ typedef struct s_newEvent *newEvent_t;
 typedef struct s_newEvent {
   container_t container;
   type_t type;
-  char *value;
+  val_t value;
 }s_newEvent_t;
 
 static FILE *tracing_file = NULL;
@@ -228,6 +234,12 @@ void TRACE_paje_create_header(void)
 %%       DestContainerType string \n\
 %%       Name string \n\
 %%EndEventDef \n\
+%%EventDef PajeDefineEntityValue %d \n\
+%%       Alias string \n\
+%%       EntityType string \n\
+%%       Name string \n\
+%%       Color color \n\
+%%EndEventDef \n\
 %%EventDef PajeCreateContainer %d \n\
 %%       Time date \n\
 %%       Alias string \n\
@@ -302,6 +314,7 @@ void TRACE_paje_create_header(void)
   PAJE_DefineStateType,
   PAJE_DefineEventType,
   PAJE_DefineLinkType,
+  PAJE_DefineEntityValue,
   PAJE_CreateContainer,
   PAJE_DestroyContainer,
   PAJE_SetVariable,
@@ -405,6 +418,17 @@ static void print_pajeDefineLinkType(paje_event_t event)
       ((defineLinkType_t)event->data)->type->name);
 }
 
+static void print_pajeDefineEntityValue (paje_event_t event)
+{
+  DEBUG2("%s: event_type=%d", __FUNCTION__, event->event_type);
+  fprintf(tracing_file, "%d %s %s %s \"%s\"\n",
+      event->event_type,
+      ((defineEntityValue_t)event->data)->value->id,
+      ((defineEntityValue_t)event->data)->value->father->id,
+      ((defineEntityValue_t)event->data)->value->name,
+      ((defineEntityValue_t)event->data)->value->color);
+}
+
 static void print_pajeCreateContainer(paje_event_t event)
 {
   DEBUG3("%s: event_type=%d, timestamp=%f", __FUNCTION__, event->event_type, event->timestamp);
@@ -508,14 +532,14 @@ static void print_pajeSetState(paje_event_t event)
         event->event_type,
         ((setState_t)event->data)->type->id,
         ((setState_t)event->data)->container->id,
-        ((setState_t)event->data)->value);
+        ((setState_t)event->data)->value->id);
   }else{
     fprintf(tracing_file, "%d %lf %s %s %s\n",
         event->event_type,
         event->timestamp,
         ((setState_t)event->data)->type->id,
         ((setState_t)event->data)->container->id,
-        ((setState_t)event->data)->value);
+        ((setState_t)event->data)->value->id);
   }
 }
 
@@ -527,14 +551,14 @@ static void print_pajePushState(paje_event_t event)
         event->event_type,
         ((pushState_t)event->data)->type->id,
         ((pushState_t)event->data)->container->id,
-        ((pushState_t)event->data)->value);
+        ((pushState_t)event->data)->value->id);
   }else{
     fprintf(tracing_file, "%d %lf %s %s %s\n",
         event->event_type,
         event->timestamp,
         ((pushState_t)event->data)->type->id,
         ((pushState_t)event->data)->container->id,
-        ((pushState_t)event->data)->value);
+        ((pushState_t)event->data)->value->id);
   }
 }
 
@@ -609,27 +633,21 @@ static void print_pajeNewEvent (paje_event_t event)
         event->event_type,
         ((newEvent_t)event->data)->type->id,
         ((newEvent_t)event->data)->container->id,
-        ((newEvent_t)event->data)->value);
+        ((newEvent_t)event->data)->value->id);
   }else{
     fprintf(tracing_file, "%d %lf %s %s %s\n",
         event->event_type,
         event->timestamp,
         ((newEvent_t)event->data)->type->id,
         ((newEvent_t)event->data)->container->id,
-        ((newEvent_t)event->data)->value);
+        ((newEvent_t)event->data)->value->id);
   }
 }
 
 static void free_paje_event (paje_event_t event)
 {
   DEBUG3("%s: event_type=%d, timestamp=%f", __FUNCTION__, event->event_type, event->timestamp);
-  if (event->event_type == PAJE_SetState) {
-    xbt_free (((setState_t)(event->data))->value);
-  }else if (event->event_type == PAJE_PushState) {
-    xbt_free (((pushState_t)(event->data))->value);
-  }else if (event->event_type == PAJE_NewEvent){
-    xbt_free (((newEvent_t)(event->data))->value);
-  }else if (event->event_type == PAJE_StartLink){
+  if (event->event_type == PAJE_StartLink){
     xbt_free (((startLink_t)(event->data))->value);
     xbt_free (((startLink_t)(event->data))->key);
   }else if (event->event_type == PAJE_EndLink){
@@ -727,6 +745,23 @@ void new_pajeDefineLinkType(type_t type, type_t source, type_t dest)
   event->free (event);
 }
 
+void new_pajeDefineEntityValue (val_t value)
+{
+  paje_event_t event = xbt_new0(s_paje_event_t, 1);
+  event->event_type = PAJE_DefineEntityValue;
+  event->timestamp = 0;
+  event->print = print_pajeDefineEntityValue;
+  event->free = free_paje_event;
+  event->data = xbt_new0(s_defineEntityValue_t, 1);
+  ((defineEntityValue_t)(event->data))->value = value;
+
+  DEBUG2("%s: event_type=%d", __FUNCTION__, event->event_type);
+
+  //print it
+  event->print (event);
+  event->free (event);
+}
+
 void new_pajeCreateContainer (container_t container)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
@@ -813,7 +848,7 @@ void new_pajeSubVariable (double timestamp, container_t container, type_t type,
   insert_into_buffer (event);
 }
 
-void new_pajeSetState (double timestamp, container_t container, type_t type, const char *value)
+void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
   event->event_type = PAJE_SetState;
@@ -823,7 +858,7 @@ void new_pajeSetState (double timestamp, container_t container, type_t type, con
   event->data = xbt_new0(s_setState_t, 1);
   ((setState_t)(event->data))->type = type;
   ((setState_t)(event->data))->container = container;
-  ((setState_t)(event->data))->value = xbt_strdup(value);
+  ((setState_t)(event->data))->value = value;
 
   DEBUG3("%s: event_type=%d, timestamp=%f", __FUNCTION__, event->event_type, event->timestamp);
 
@@ -831,7 +866,7 @@ void new_pajeSetState (double timestamp, container_t container, type_t type, con
 }
 
 
-void new_pajePushState (double timestamp, container_t container, type_t type, const char *value)
+void new_pajePushState (double timestamp, container_t container, type_t type, val_t value)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
   event->event_type = PAJE_PushState;
@@ -841,7 +876,7 @@ void new_pajePushState (double timestamp, container_t container, type_t type, co
   event->data = xbt_new0(s_pushState_t, 1);
   ((pushState_t)(event->data))->type = type;
   ((pushState_t)(event->data))->container = container;
-  ((pushState_t)(event->data))->value = xbt_strdup(value);
+  ((pushState_t)(event->data))->value = value;
 
   DEBUG3("%s: event_type=%d, timestamp=%f", __FUNCTION__, event->event_type, event->timestamp);
 
@@ -903,7 +938,7 @@ void new_pajeEndLink (double timestamp, container_t container, type_t type, cont
   insert_into_buffer (event);
 }
 
-void new_pajeNewEvent (double timestamp, container_t container, type_t type, const char *value)
+void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value)
 {
   paje_event_t event = xbt_new0(s_paje_event_t, 1);
   event->event_type = PAJE_NewEvent;
@@ -913,7 +948,7 @@ void new_pajeNewEvent (double timestamp, container_t container, type_t type, con
   event->data = xbt_new0(s_newEvent_t, 1);
   ((newEvent_t)(event->data))->type = type;
   ((newEvent_t)(event->data))->container = container;
-  ((newEvent_t)(event->data))->value = xbt_strdup(value);
+  ((newEvent_t)(event->data))->value = value;
 
   DEBUG3("%s: event_type=%d, timestamp=%f", __FUNCTION__, event->event_type, event->timestamp);
 
index 1981f54..e3fe27e 100644 (file)
@@ -34,8 +34,17 @@ typedef struct s_type {
   e_entity_types kind;
   struct s_type *father;
   xbt_dict_t children;
+  xbt_dict_t values; //valid for all types except variable and container
 }s_type_t;
 
+typedef struct s_val *val_t;
+typedef struct s_val {
+  char *id;
+  char *name;
+  char *color;
+  type_t father;
+}s_val_t;
+
 typedef enum {
   INSTR_HOST,
   INSTR_LINK,
@@ -70,17 +79,18 @@ void new_pajeDefineVariableType(type_t type);
 void new_pajeDefineStateType(type_t type);
 void new_pajeDefineEventType(type_t type);
 void new_pajeDefineLinkType(type_t type, type_t source, type_t dest);
+void new_pajeDefineEntityValue (val_t type);
 void new_pajeCreateContainer (container_t container);
 void new_pajeDestroyContainer (container_t container);
 void new_pajeSetVariable (double timestamp, container_t container, type_t type, double value);
 void new_pajeAddVariable (double timestamp, container_t container, type_t type, double value);
 void new_pajeSubVariable (double timestamp, container_t container, type_t type, double value);
-void new_pajeSetState (double timestamp, container_t container, type_t type, const char *value);
-void new_pajePushState (double timestamp, container_t container, type_t type, const char *value);
+void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value);
+void new_pajePushState (double timestamp, container_t container, type_t type, val_t value);
 void new_pajePopState (double timestamp, container_t container, type_t type);
 void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer, const char *value, const char *key);
 void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer, const char *value, const char *key);
-void new_pajeNewEvent (double timestamp, container_t container, type_t type, const char *value);
+void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value);
 
 /* declaration of instrumentation functions from msg_task_instr.c */
 char *TRACE_task_container(m_task_t task, char *output, int len);
@@ -208,6 +218,8 @@ type_t getVariableType (const char *name, const char *color, type_t father);
 type_t getLinkType (const char *name, type_t father, type_t source, type_t dest);
 type_t getStateType (const char *name, type_t father);
 type_t getType (const char *name, type_t father);
+val_t getValue (const char *valuename, const char *color, type_t father);
+val_t getValueByName (const char *valuename, type_t father);
 void destroyContainer (container_t container);
 void destroyAllContainers (void);
 
index ceeeb7d..1381e08 100644 (file)
@@ -236,14 +236,22 @@ static void instr_routing_parse_start_host ()
 
   if (TRACE_msg_process_is_enabled()) {
     type_t msg_process = getContainerType("MSG_PROCESS", new->type);
-    getStateType ("MSG_PROCESS_STATE", msg_process);
+    type_t state = getStateType ("MSG_PROCESS_STATE", msg_process);
+    getValue ("executing", "0 1 0", state);
+    getValue ("suspend", "1 0 1", state);
+    getValue ("sleep", "1 1 0", state);
+    getValue ("receive", "1 0 0", state);
+    getValue ("send", "0 0 1", state);
+    getValue ("task_execute", "0 1 1", state);
     getLinkType ("MSG_PROCESS_LINK", getRootType(), msg_process, msg_process);
     getLinkType ("MSG_PROCESS_TASK_LINK", getRootType(), msg_process, msg_process);
   }
 
   if (TRACE_msg_task_is_enabled()) {
     type_t msg_task = getContainerType ("MSG_TASK", new->type);
-    getStateType ("MSG_TASK_STATE", msg_task);
+    type_t state = getStateType ("MSG_TASK_STATE", msg_task);
+    getValue ("MSG_task_execute", "0 1 0", state);
+    getValue ("created", "1 1 0", state);
     getLinkType ("MSG_TASK_LINK", getRootType(), msg_task, msg_task);
   }
 }
index 49aeae9..659f444 100644 (file)
@@ -134,8 +134,9 @@ void TRACE_smpi_collective_in(int rank, int root, const char *operation)
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = getContainer (str);
   type_t type = getType ("MPI_STATE", container->type);
+  val_t value = getValue (operation, "1 1 1", type);
 
-  new_pajePushState (SIMIX_get_clock(), container, type, operation);
+  new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
 void TRACE_smpi_collective_out(int rank, int root, const char *operation)
@@ -158,8 +159,9 @@ void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation)
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = getContainer (str);
   type_t type = getType ("MPI_STATE", container->type);
+  val_t value = getValue (operation, "1 1 1", type);
 
-  new_pajePushState (SIMIX_get_clock(), container, type, operation);
+  new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
 void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)