Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] faster method to dump when unconditional dump to trace file is possible
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 Jan 2011 12:30:31 +0000 (12:30 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 Jan 2011 12:30:31 +0000 (12:30 +0000)
details:
- if force == 1, no checks: dump and free all events
- specially useful for big platform files (such as g5k)

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

src/instr/instr_config.c
src/instr/instr_paje.c
src/instr/instr_paje_trace.c
src/instr/instr_private.h
src/instr/instr_routing.c
src/surf/surf.c

index f9ffce0..67c7d50 100644 (file)
@@ -71,7 +71,7 @@ int TRACE_end()
 
   /* dump trace buffer */
   TRACE_last_timestamp_to_dump = surf_get_clock();
-  TRACE_paje_dump_buffer();
+  TRACE_paje_dump_buffer(1);
 
   /* destroy all data structures of tracing (and free) */
   destroyAllContainers();
index 678d1d0..33ea5c8 100644 (file)
@@ -272,7 +272,7 @@ void destroyContainer (container_t container)
   //obligation to dump previous events because they might
   //reference the container that is about to be destroyed
   TRACE_last_timestamp_to_dump = surf_get_clock();
-  TRACE_paje_dump_buffer();
+  TRACE_paje_dump_buffer(0);
 
   //free
   xbt_free (container->name);
index e4a6fa4..4841f79 100644 (file)
@@ -168,18 +168,29 @@ void TRACE_paje_end(void)
 
 double TRACE_last_timestamp_to_dump = 0;
 //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
-void TRACE_paje_dump_buffer (void)
+void TRACE_paje_dump_buffer (int force)
 {
   DEBUG2("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
-  paje_event_t event;
-  while (xbt_dynar_length (buffer) > 0){
-    double head_timestamp = (*(paje_event_t*)xbt_dynar_get_ptr(buffer, 0))->timestamp;
-    if (head_timestamp > TRACE_last_timestamp_to_dump){
-      break;
+  if (force){
+    paje_event_t event;
+    unsigned int i;
+    xbt_dynar_foreach(buffer, i, event){
+      event->print (event);
+      event->free (event);
+    }
+    xbt_dynar_free (&buffer);
+    buffer = xbt_dynar_new (sizeof(paje_event_t), NULL);
+  }else{
+    paje_event_t event;
+    while (xbt_dynar_length (buffer) > 0){
+      double head_timestamp = (*(paje_event_t*)xbt_dynar_get_ptr(buffer, 0))->timestamp;
+      if (head_timestamp > TRACE_last_timestamp_to_dump){
+        break;
+      }
+      xbt_dynar_remove_at (buffer, 0, &event);
+      event->print (event);
+      event->free (event);
     }
-    xbt_dynar_remove_at (buffer, 0, &event);
-    event->print (event);
-    event->free (event);
   }
   DEBUG1("%s: ends", __FUNCTION__);
 }
index cb8e1f0..ff33c7d 100644 (file)
@@ -64,7 +64,7 @@ extern double TRACE_last_timestamp_to_dump;
 void TRACE_paje_create_header(void);
 void TRACE_paje_start(void);
 void TRACE_paje_end(void);
-void TRACE_paje_dump_buffer (void);
+void TRACE_paje_dump_buffer (int force);
 void new_pajeDefineContainerType(type_t type);
 void new_pajeDefineVariableType(type_t type);
 void new_pajeDefineStateType(type_t type);
index 8113389..dcd5af5 100644 (file)
@@ -267,6 +267,7 @@ static void instr_routing_parse_end_platform ()
   currentContainer = NULL;
   recursiveGraphExtraction (getRootContainer());
   platform_created = 1;
+  TRACE_paje_dump_buffer(1);
 }
 
 void instr_routing_define_callbacks ()
index 283fa6f..26bfeea 100644 (file)
@@ -467,7 +467,7 @@ double surf_solve(double max_date)
       model->model_private->update_actions_state(NOW, min);
 
 #ifdef HAVE_TRACING
-  TRACE_paje_dump_buffer ();
+  TRACE_paje_dump_buffer (0);
 #endif
 
   return min;