position ok with processing
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 23 Jul 2004 23:31:26 +0000 (23:31 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 23 Jul 2004 23:31:26 +0000 (23:31 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@632 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/event.c
ltt/branches/poly/ltt/ltt-private.h
ltt/branches/poly/ltt/time.h
ltt/branches/poly/ltt/trace.h
ltt/branches/poly/ltt/tracefile.c

index 7743cc9bbb0ae7f3d4e0d488c68c053ecb5461b9..d83c62c043a4d87bf8abfcfd3accd1db07d43bca 100644 (file)
@@ -31,7 +31,7 @@
  *    ltt_event_refresh_fields   : refresh fields of an event 
  *Input params
  *    offsetRoot      : offset from the root
- *    offsetParent    : offset from the parrent
+ *    offsetParent    : offset from the parent
  *    fld             : field
  *    evD             : event data
  *Return value
@@ -217,9 +217,17 @@ void ltt_event_position(LttEvent *e, LttEventPosition *ep)
   ep->event_time        = e->event_time;
   ep->event_cycle_count = e->event_cycle_count;
   ep->heart_beat_number = e->tracefile->cur_heart_beat_number;
-  ep->old_position      = FALSE;
+  ep->old_position      = TRUE;
   ep->event_offset      = e->data - e->tracefile->buffer - EVENT_HEADER_SIZE ;
   ep->tf                = e->tracefile;
+
+  /* This is a workaround for fast position seek */
+  ep->last_event_pos = e->last_event_pos;
+  ep->prev_block_end_time = e->prev_block_end_time;
+  ep->prev_event_time = e->prev_event_time;
+  ep->pre_cycle_count = e->pre_cycle_count;
+  ep->count = e->count;
+  /* end of workaround */
 }
 
 LttEventPosition * ltt_event_position_new()
index 96e9675ad82d385f48d1e745deca3b4d5f064585..f0c0d9572e72748a70bb70401f875c38ea8569d8 100644 (file)
@@ -123,6 +123,14 @@ struct _LttEvent{
   void * data;               //event data
   int which_block;           //the current block of the event
   int which_event;           //the position of the event
+  /* This is a workaround for fast position seek */
+  void * last_event_pos;
+
+  LttTime prev_block_end_time;       //the end time of previous block
+  LttTime prev_event_time;           //the time of the previous event
+  LttCycleCount pre_cycle_count;     //previous cycle count of the event
+  int      count;                    //the number of overflow of cycle count
+  /* end of workaround */
 };
 
 struct _LttFacility{
@@ -186,6 +194,15 @@ struct _LttEventPosition{
   LttTracefile *tf;                 //tracefile containing the event
   gboolean      old_position;       //flag to show if it is the position
                                     //being remembered
+  /* This is a workaround for fast position seek */
+  void * last_event_pos;
+
+  LttTime prev_block_end_time;       //the end time of previous block
+  LttTime prev_event_time;           //the time of the previous event
+  LttEvent an_event;
+  LttCycleCount pre_cycle_count;     //previous cycle count of the event
+  int      count;                    //the number of overflow of cycle count
+  /* end of workaround */
 };
 
 /* The characteristics of the system on which the trace was obtained
index dc1cb2201bdd4b809614954b49807e1cef81075b..61c3e596c3e0bb2ca76707fa12b738be27471ab2 100644 (file)
@@ -32,6 +32,8 @@ static const unsigned long NANOSECONDS_PER_SECOND = 1000000000;
 
 static const LttTime ltt_time_zero = { 0, 0};
 
+static const LttTime ltt_time_one = { 0, 1 };
+
 static const LttTime ltt_time_infinite = { G_MAXUINT, G_MAXUINT };
 
 static inline LttTime ltt_time_sub(LttTime t1, LttTime t2) 
index ba66c33aa6669f54c6801035db25c543e9d8d959..05ed31eb508bad3863b8cac1cddad9f348d906c4 100644 (file)
@@ -171,4 +171,10 @@ char * ltt_trace_system_description_description (LttSystemDescription * s);
 
 LttTime ltt_trace_system_description_trace_start_time(LttSystemDescription *s);
 
+/* copy tracefile info over another. Used for sync. */
+LttTracefile *ltt_tracefile_new();
+void ltt_tracefile_destroy(LttTracefile *tf);
+void ltt_tracefile_copy(LttTracefile *dest, const LttTracefile *src);
+
+
 #endif // TRACE_H
index efda5ce445f69caf6af5f65b82000ac1593ee237..cd44542031274802a76749b213fa1c2e399e2ce3 100644 (file)
@@ -978,6 +978,9 @@ void ltt_tracefile_seek_time(LttTracefile *t, LttTime time)
 
 /*****************************************************************************
  * Seek to the first event with position equal or larger to ep 
+ *
+ * Modified by Mathieu Desnoyers to used faster offset position instead of
+ * re-reading the whole buffer.
  ****************************************************************************/
 
 void ltt_tracefile_seek_position(LttTracefile *t, const LttEventPosition *ep)
@@ -988,15 +991,36 @@ void ltt_tracefile_seek_position(LttTracefile *t, const LttEventPosition *ep)
   
   if(t->which_block == ep->block_num) updateTracefile(t);
   else readBlock(t,ep->block_num);
-
-  //event offset is availiable
+  //event offset is available
   if(ep->old_position){
-    t->cur_heart_beat_number = ep->heart_beat_number;
+    int err;
+
+    t->which_event = ep->event_num;
     t->cur_event_pos = t->buffer + ep->event_offset;
+    t->prev_event_time = ep->event_time;
+    t->current_event_time = ep->event_time;
+    t->cur_heart_beat_number = ep->heart_beat_number;
+    t->cur_cycle_count = ep->event_cycle_count;
+
+    /* This is a workaround for fast position seek */
+    t->last_event_pos = ep->last_event_pos;
+    t->prev_block_end_time = ep->prev_block_end_time;
+    t->prev_event_time = ep->prev_event_time;
+    t->pre_cycle_count = ep->pre_cycle_count;
+    t->count = ep->count;
+    /* end of workaround */
+
+    //update the fields of the current event and go to the next event
+    err = skipEvent(t);
+    if(err == ERANGE) g_error("event id is out of range\n");
+      
     return;
   }
 
-  //only block number and event index are availiable
+  //only block number and event index are available
+  //MD: warning : this is slow!
+  g_warning("using slow O(n) tracefile seek position");
+
   while(t->which_event < ep->event_num) ltt_tracefile_read(t);
 
   return;
@@ -1040,6 +1064,16 @@ LttEvent *ltt_tracefile_read(LttTracefile *t)
   lttEvent->which_block = t->which_block;
   lttEvent->which_event = t->which_event;
 
+  /* This is a workaround for fast position seek */
+  lttEvent->last_event_pos = t->last_event_pos;
+  lttEvent->prev_block_end_time = t->prev_block_end_time;
+  lttEvent->prev_event_time = t->prev_event_time;
+  lttEvent->pre_cycle_count = t->pre_cycle_count;
+  lttEvent->count = t->count;
+  /* end of workaround */
+
+
+
   //update the fields of the current event and go to the next event
   err = skipEvent(t);
   if(err == ERANGE) g_error("event id is out of range\n");
@@ -1189,6 +1223,7 @@ int skipEvent(LttTracefile * t)
   return 0;
 }
 
+
 /*****************************************************************************
  *Function name
  *    getCyclePerNsec : calculate cycles per nsec for current block
@@ -1506,3 +1541,19 @@ LttTime ltt_trace_system_description_trace_start_time(LttSystemDescription *s)
   return s->trace_start;
 }
 
+
+LttTracefile *ltt_tracefile_new()
+{
+  return g_new(LttTracefile, 1);
+}
+
+void ltt_tracefile_destroy(LttTracefile *tf)
+{
+  g_free(tf);
+}
+
+void ltt_tracefile_copy(LttTracefile *dest, const LttTracefile *src)
+{
+  *dest = *src;
+}
+
This page took 0.027232 seconds and 4 git commands to generate.