From 18206708bafbba3198bfb82cca97f17d70a05666 Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 23 Jul 2004 23:31:26 +0000 Subject: [PATCH] position ok with processing git-svn-id: http://ltt.polymtl.ca/svn@632 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/event.c | 12 +++++- ltt/branches/poly/ltt/ltt-private.h | 17 +++++++++ ltt/branches/poly/ltt/time.h | 2 + ltt/branches/poly/ltt/trace.h | 6 +++ ltt/branches/poly/ltt/tracefile.c | 59 +++++++++++++++++++++++++++-- 5 files changed, 90 insertions(+), 6 deletions(-) diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 7743cc9b..d83c62c0 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -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() diff --git a/ltt/branches/poly/ltt/ltt-private.h b/ltt/branches/poly/ltt/ltt-private.h index 96e9675a..f0c0d957 100644 --- a/ltt/branches/poly/ltt/ltt-private.h +++ b/ltt/branches/poly/ltt/ltt-private.h @@ -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 diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index dc1cb220..61c3e596 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -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) diff --git a/ltt/branches/poly/ltt/trace.h b/ltt/branches/poly/ltt/trace.h index ba66c33a..05ed31eb 100644 --- a/ltt/branches/poly/ltt/trace.h +++ b/ltt/branches/poly/ltt/trace.h @@ -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 diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index efda5ce4..cd445420 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -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; +} + -- 2.34.1