Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
re-organizing tracing masks and first support for "swarm-based" traces of tasks or...
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 21 Apr 2010 07:12:09 +0000 (07:12 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 21 Apr 2010 07:12:09 +0000 (07:12 +0000)
details:
- hosts are the hives
- tasks (TRACE_TASK mask) or processes (TRACE_PROCESS mask) are bees

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

src/instr/interface.c
src/instr/msg_task_instr.c
src/instr/private.h
src/instr/surf_instr.c

index 64a2445..f4927eb 100644 (file)
@@ -67,42 +67,33 @@ int TRACE_start_with_mask(const char *filename, int mask) {
   /* setting the mask */
   trace_mask = mask;
 
-  //check if options are correct
-  if (IS_TRACING_TASKS){
-       if (!IS_TRACING_PROCESSES){
-         TRACE_end();
-      THROW0 (tracing_error, TRACE_ERROR_MASK,
-              "TRACE_PROCESS must be enabled if TRACE_TASK is used");
-       }
+  /* define paje hierarchy for tracing */
+  pajeDefineContainerType("PLATFORM", "0", "platform");
+  pajeDefineContainerType("HOST", "PLATFORM", "HOST");
+  pajeDefineContainerType("LINK", "PLATFORM", "LINK");
+
+  if (IS_TRACING_PLATFORM){
+    pajeDefineVariableType ("power", "HOST", "power");
+    pajeDefineVariableType ("bandwidth", "LINK", "bandwidth");
+    pajeDefineVariableType ("latency", "LINK", "latency");
   }
 
-  if (IS_TRACING_PROCESSES|IS_TRACING_TASKS){
-       if (!IS_TRACING_PLATFORM){
-         TRACE_end();
-      THROW0 (tracing_error, TRACE_ERROR_MASK,
-                 "TRACE_PLATFORM must be enabled if TRACE_PROCESS or TRACE_TASK is used");
-       }
+  if (IS_TRACING_PROCESSES){
+    //processes grouped by host
+    pajeDefineContainerType("PROCESS", "HOST", "PROCESS");
+    pajeDefineStateType("presence", "PROCESS", "presence");
   }
 
-  //defining platform hierarchy
-  if (IS_TRACING_PLATFORM) pajeDefineContainerType("PLATFORM", "0", "platform");
-  if (IS_TRACING_PLATFORM) pajeDefineContainerType("HOST", "PLATFORM", "HOST");
-  if (IS_TRACING_PLATFORM) pajeDefineVariableType ("power", "HOST", "power");
-  if (IS_TRACING_PLATFORM) pajeDefineContainerType("LINK", "PLATFORM", "LINK");
-  if (IS_TRACING_PLATFORM) pajeDefineVariableType ("bandwidth", "LINK", "bandwidth");
-  if (IS_TRACING_PLATFORM) pajeDefineVariableType ("latency", "LINK", "latency");
-
-  if (IS_TRACING_PROCESSES) pajeDefineContainerType("PROCESS", "HOST", "PROCESS");
-  if (IS_TRACING_PROCESSES) pajeDefineStateType("presence", "PROCESS", "presence");
-
-  if (IS_TRACING_PROCESSES){
-       if (IS_TRACING_TASKS) pajeDefineContainerType("TASK", "PROCESS", "TASK");
-  }else{
-       if (IS_TRACING_TASKS) pajeDefineContainerType("TASK", "HOST", "TASK");
+  if (IS_TRACING_TASKS){
+    //tasks grouped by host
+    pajeDefineContainerType("TASK", "HOST", "TASK");
+    pajeDefineStateType("presence", "TASK", "presence");
   }
 
-  if (IS_TRACING_PLATFORM) pajeCreateContainer(MSG_get_clock(), "platform", "PLATFORM", "0", "simgrid-platform");
+  /* creating the platform */
+  pajeCreateContainer(MSG_get_clock(), "platform", "PLATFORM", "0", "simgrid-platform");
 
+  /* other trace initialization */
   defined_types = xbt_dict_new();
   created_categories = xbt_dict_new();
   __TRACE_msg_init();
index 75b8a91..febb1b6 100644 (file)
 
 #ifdef HAVE_TRACING
 
+static xbt_dict_t task_containers = NULL;
 static xbt_dict_t current_task_category = NULL;
 
 void __TRACE_msg_init (void)
 {
   current_task_category = xbt_dict_new();
+  task_containers = xbt_dict_new();
 }
 
 void __TRACE_current_category_set (m_task_t task)
@@ -44,22 +46,46 @@ char *__TRACE_current_category_get (smx_process_t proc)
 
 void __TRACE_task_location (m_task_t task)
 {
+  if (!IS_TRACING_TASKS) return;
   char container[200];
   m_process_t process = MSG_process_self();
   m_host_t host = MSG_process_get_host (process);
-  if (IS_TRACING_PROCESSES){
-       //container is a process
-       TRACE_process_alias_container (process, host, container, 200);
-       __TRACE_msg_process_location (process);
-  }else{
-       //container is a host
-       TRACE_host_container (host, container, 200);
-  }
+
+  //tasks are grouped by host
+  TRACE_host_container (host, container, 200);
 
   char name[200], alias[200];
   TRACE_task_container (task, name, 200);
   TRACE_task_alias_container (task, process, host, alias, 200);
-  if (IS_TRACING_TASKS) pajeCreateContainer (MSG_get_clock(), alias, "TASK", container, name);
+  //check if task container is already created
+  if (!xbt_dict_get_or_null (task_containers, alias)){
+    pajeCreateContainer (MSG_get_clock(), alias, "TASK", container, name);
+    xbt_dict_set (task_containers, xbt_strdup(alias), xbt_strdup("1"), xbt_free);
+  }
+}
+
+void __TRACE_task_location_present (m_task_t task)
+{
+  if (!IS_TRACING_TASKS) return;
+  //updating presence state of this task location
+  m_process_t process = MSG_process_self();
+  m_host_t host = MSG_process_get_host (process);
+
+  char alias[200];
+  TRACE_task_alias_container (task, process, host, alias, 200);
+  pajePushState (MSG_get_clock(), "presence", alias, "presence");
+}
+
+void __TRACE_task_location_not_present (m_task_t task)
+{
+  if (!IS_TRACING_TASKS) return;
+  //updating presence state of this task location
+  m_process_t process = MSG_process_self();
+  m_host_t host = MSG_process_get_host (process);
+
+  char alias[200];
+  TRACE_task_alias_container (task, process, host, alias, 200);
+  pajePopState (MSG_get_clock(), "presence", alias);
 }
 
 /*
@@ -73,14 +99,15 @@ void TRACE_msg_set_task_category(m_task_t task, const char *category)
   task->category = xbt_new (char, strlen (category)+1);
   strncpy(task->category, category, strlen(category)+1);
 
-  char name[200];//, alias[200], process_alias[200];
+  //tracing task location based on host
+  __TRACE_task_location (task);
+  __TRACE_task_location_present (task);
+
+  char name[200];
   TRACE_task_container (task, name, 200);
   //create container of type "task" to indicate behavior
   if (IS_TRACING_TASKS) pajeCreateContainer (MSG_get_clock(), name, "task", category, name);
   if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "created");
-
-  //tracing task location based on process/host
-  __TRACE_task_location (task);
 }
 
 /* MSG_task_create related function*/
@@ -123,6 +150,9 @@ void TRACE_msg_task_destroy (m_task_t task)
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajeDestroyContainer (MSG_get_clock(), "task", name);
 
+  //finish the location of this task
+  __TRACE_task_location_not_present (task);
+
   //free category
   xbt_free (task->category);
   return;
@@ -142,8 +172,8 @@ void TRACE_msg_task_get_end (double start_time, m_task_t task)
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
 
-  //tracing task location based on process/host
   __TRACE_task_location (task);
+  __TRACE_task_location_present (task);
 }
 
 /* MSG_task_put related functions */
@@ -156,6 +186,10 @@ int TRACE_msg_task_put_start (m_task_t task)
   if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
   if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "communicate");
 
+  //trace task location grouped by host
+  __TRACE_task_location_not_present (task);
+
+  //set current category
   __TRACE_current_category_set (task);
   return 1;
 }
index f37f03e..3bc538c 100644 (file)
@@ -75,6 +75,8 @@ void __TRACE_current_category_set (m_task_t task);
 void __TRACE_current_category_unset (void);
 char *__TRACE_current_category_get (smx_process_t proc);
 void __TRACE_task_location (m_task_t task);
+void __TRACE_task_location_present (m_task_t task);
+void __TRACE_task_location_not_present (m_task_t task);
 void TRACE_msg_task_create (m_task_t task);
 void TRACE_msg_task_execute_start (m_task_t task);
 void TRACE_msg_task_execute_end (m_task_t task);
index dab2f8c..a81f320 100644 (file)
@@ -287,11 +287,11 @@ void TRACE_surf_link_declaration (char *name, double bw, double lat)
 void TRACE_surf_host_declaration (char *name, double power)
 {
   if (!IS_TRACING) return;
+  pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
+  xbt_dict_set (host_containers, xbt_strdup(name), xbt_strdup("1"), xbt_free);
   if (IS_TRACING_PLATFORM){
-       pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
-       xbt_dict_set (host_containers, xbt_strdup(name), xbt_strdup("1"), xbt_free);
+    __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "power", name, power);
   }
-  __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "power", name, power);
 }
 
 void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst)
@@ -316,9 +316,9 @@ void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst)
     //if (IS_TRACING_PLATFORM) pajeEndLink (SIMIX_get_clock()+0.1, "edge", "platform", "route", dstname, key);
     double *bw = xbt_dict_get (link_bandwidth, link_name);
     double *lat = xbt_dict_get (link_latency, link_name);
-    if (IS_TRACING_PLATFORM) pajeCreateContainerWithBandwidthLatencySrcDst (SIMIX_get_clock(), link_name, "LINK", "platform", link_name, *bw, *lat, srcname, dstname);
-    __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "bandwidth", link_name, *bw);
-    __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "latency", link_name, *lat);
+    pajeCreateContainerWithBandwidthLatencySrcDst (SIMIX_get_clock(), link_name, "LINK", "platform", link_name, *bw, *lat, srcname, dstname);
+    if (IS_TRACING_PLATFORM) __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "bandwidth", link_name, *bw);
+    if (IS_TRACING_PLATFORM) __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "latency", link_name, *lat);
     xbt_dict_set (created_links, xbt_strdup(link_name), xbt_strdup ("1"), xbt_free);
   }
 }
@@ -414,7 +414,7 @@ void TRACE_msg_clean (void)
 
   /* get all host from host_containers */
   xbt_dict_foreach(host_containers, cursor, key, value) {
-    if (IS_TRACING_PLATFORM) pajeDestroyContainer (MSG_get_clock(), "HOST", key);
+    pajeDestroyContainer (MSG_get_clock(), "HOST", key);
   }
 }