convert now only updates adaptation TSC on heartbeat, block start and block end events
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 17 Aug 2004 04:51:42 +0000 (04:51 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 17 Aug 2004 04:51:42 +0000 (04:51 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@799 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/convert/convert.c
ltt/branches/poly/ltt/tracefile.c

index 29622190009036521394bc96ed326d97cc3d096c..a13daaf2a8b05b33da7cfe445d1312759889e119 100644 (file)
@@ -144,7 +144,7 @@ int main(int argc, char ** argv){
   buffer_start start, start_proc, start_intr;
   buffer_end end, end_proc, end_intr;
   heartbeat beat;
-  uint64_t beat_count;
+  uint64_t adaptation_tsc;    // (Mathieu)
   uint32_t size_lost;
   int reserve_size = sizeof(buffer_start) + sizeof(uint16_t) + 2*sizeof(uint32_t);//lost_size and buffer_end event
   int nb_para;
@@ -357,8 +357,6 @@ int main(int argc, char ** argv){
       start.seconds = tBufStart->Time.tv_sec;
       /* usec -> nsec (Mathieu) */
       start.nanoseconds = tBufStart->Time.tv_usec * 1000;
-      start.cycle_count = tBufStart->TSC;
-      beat_count = start.cycle_count;
       start.block_id = tBufStart->ID;
       end.block_id = start.block_id;
       
@@ -374,14 +372,37 @@ int main(int argc, char ** argv){
       end.seconds = tBufEnd->Time.tv_sec;
       /* usec -> nsec (Mathieu) */
       end.nanoseconds = tBufEnd->Time.tv_usec * 1000;
-      end.cycle_count = tBufEnd->TSC;
+      // only 32 bits :( 
+      //end.cycle_count = tBufEnd->TSC;
     
       //skip buffer start and trace start events
-      if(i==0) //the first block
-       cur_pos = buffer + sizeof(trace_buffer_start) + sizeof(trace_start) + 2*(sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint32_t));
-      else //other blocks
-       cur_pos = buffer + sizeof(trace_buffer_start) + sizeof(uint8_t)+sizeof(uint16_t)+sizeof(uint32_t);
-      
+      if(i==0) {
+        //the first block
+        adaptation_tsc = (uint64_t)tBufStart->TSC;
+             cur_pos = buffer + sizeof(trace_buffer_start) 
+                         + sizeof(trace_start) 
+                         + 2*(sizeof(uint8_t)
+                         + sizeof(uint16_t)+sizeof(uint32_t));
+      } else {
+        //other blocks
+             cur_pos = buffer + sizeof(trace_buffer_start) 
+                         + sizeof(uint8_t)
+                         + sizeof(uint16_t)+sizeof(uint32_t);
+
+        /* Fix (Mathieu) */
+        if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
+          /* Overflow */
+          adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) 
+                                       + 0x100000000ULL 
+                                       + (uint64_t)time_delta;
+        } else {
+          /* No overflow */
+          adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
+        }
+
+      }
+      start.cycle_count = adaptation_tsc;
+
       //write start block event
       write_to_buffer(write_pos,(void*)&startId, sizeof(uint16_t));    
       write_to_buffer(write_pos,(void*)&startTimeDelta, sizeof(uint32_t));
@@ -454,16 +475,24 @@ int main(int argc, char ** argv){
        cur_pos += sizeof(uint8_t);
        time_delta = *(uint32_t*)cur_pos;
        cur_pos += sizeof(uint32_t); 
-       
+
+
        //write event_id and time_delta
        write_to_buffer(write_pos,(void*)&newId,sizeof(uint16_t));
        write_to_buffer(write_pos,(void*)&time_delta, sizeof(uint32_t));     
        
        if(evId == TRACE_BUFFER_END){
-#if 0 //(Mathieu : already set correctly to tBufEnd.TSC)
-    end.cycle_count = start.cycle_count 
-                         + beat_count * OVERFLOW_FIGURE;
-#endif //)
+    /* Fix (Mathieu) */
+    if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
+      /* Overflow */
+     adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL 
+                                   + (uint64_t)time_delta;
+    } else {
+      /* No overflow */
+      adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
+    }
+
+    end.cycle_count = adaptation_tsc;
          int size = (void*)buf_out + block_size - write_pos 
                    - sizeof(buffer_end) - sizeof(uint32_t);
 
@@ -581,24 +610,25 @@ int main(int argc, char ** argv){
            break;
          case TRACE_HEARTBEAT:
       /* Fix (Mathieu) */
-      if(timeDelta < (0xFFFFFFFF&beat_count)) {
+      if(time_delta < (0xFFFFFFFFULL&adaptation_tsc)) {
         /* Overflow */
-        beat_count += 0x100000000ULL - (uint64_t)(0xFFFFFFFF&beat_count)
-                                     + (uint64_t)timeDelta;
+       adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + 0x100000000ULL 
+                                     + (uint64_t)time_delta;
       } else {
         /* No overflow */
-        beat_count += timeDelta - (0xFFFFFFFF&beat_count);
+        adaptation_tsc = (adaptation_tsc&0xFFFFFFFF00000000ULL) + time_delta;
       }
+
            beat.seconds = 0;
            beat.nanoseconds = 0;
-           beat.cycle_count = beat_count;
+           beat.cycle_count = adaptation_tsc;
            event_size = 0;
            
            write_to_buffer(write_pos_intr,(void*)&newId, sizeof(uint16_t));
-           write_to_buffer(write_pos_intr,(void*)&timeDelta, sizeof(uint32_t));
+           write_to_buffer(write_pos_intr,(void*)&time_delta, sizeof(uint32_t));
            write_to_buffer(write_pos_intr,(void*)&beat, sizeof(heartbeat));              
            write_to_buffer(write_pos_proc,(void*)&newId, sizeof(uint16_t));
-           write_to_buffer(write_pos_proc,(void*)&timeDelta, sizeof(uint32_t));
+           write_to_buffer(write_pos_proc,(void*)&time_delta, sizeof(uint32_t));
            write_to_buffer(write_pos_proc,(void*)&beat, sizeof(heartbeat));              
            break;
           default:
index acd9954b872010b8cab1807afd9955f35737ab74..85d5161ac73b3c2db1b3dacb576ff5a740c18498 100644 (file)
@@ -1386,12 +1386,11 @@ int readBlock(LttTracefile * tf, int whichBlock)
   /* Make start time more precise */
   /* Start overflow_nsec to a negative value : takes account of the 
    * start of block cycle counter */
-  tf->overflow_nsec = (-((double)tf->a_block_start->cycle_count)
+  tf->overflow_nsec = (-((double)(tf->a_block_start->cycle_count&0xFFFFFFFF))
                                         * tf->nsec_per_cycle);
 
   tf->a_block_start->time = getEventTime(tf);
 
-
   {
     guint64 lEventNSec;
     LttTime lTimeOffset;
@@ -1421,10 +1420,9 @@ int readBlock(LttTracefile * tf, int whichBlock)
   /* recalculate the cycles per nsec, with now more precise start and end time
    */
   getCyclePerNsec(tf);
-  tf->overflow_nsec = (-((double)tf->a_block_start->cycle_count)
-                                        * tf->nsec_per_cycle);
-
 
+  tf->overflow_nsec = (-((double)(tf->a_block_start->cycle_count&0xFFFFFFFF))
+                                        * tf->nsec_per_cycle);
 
   tf->current_event_time = getEventTime(tf);  
 
@@ -1517,7 +1515,7 @@ void getCyclePerNsec(LttTracefile * t)
 {
   LttTime           lBufTotalTime; /* Total time for this buffer */
   double            lBufTotalNSec; /* Total time for this buffer in nsecs */
-  double            lBufTotalCycle;/* Total cycles for this buffer */
+  LttCycleCount     lBufTotalCycle;/* Total cycles for this buffer */
 
   /* Calculate the total time for this buffer */
   lBufTotalTime = ltt_time_sub(t->a_block_end->time, t->a_block_start->time);
@@ -1526,10 +1524,11 @@ void getCyclePerNsec(LttTracefile * t)
   lBufTotalCycle  = t->a_block_end->cycle_count;
   lBufTotalCycle -= t->a_block_start->cycle_count;
 
-  /* Convert the total time to nsecs */
+  /* Convert the total time to double */
   lBufTotalNSec  = ltt_time_to_double(lBufTotalTime);
   
   t->nsec_per_cycle = (double)lBufTotalNSec / (double)lBufTotalCycle;
+
   /* Pre-multiply one overflow (2^32 cycles) by nsec_per_cycle */
   t->one_overflow_nsec = t->nsec_per_cycle * (double)0x100000000ULL;
 
@@ -1660,15 +1659,14 @@ static inline LttTime getEventTime(LttTracefile * tf)
     lEventNSec = ((double)
                  (tf->a_block_end->cycle_count - tf->a_block_start->cycle_count)
                            * tf->nsec_per_cycle);
+#if 0
     g_printf("CYCLES COUNTED : %llu",
         (gint64)((double)cycle_count * tf->nsec_per_cycle)
                                 +tf->overflow_nsec 
                                 +tf->a_block_start->cycle_count);
-
+#endif //0
     
   }
-  /* heartbeat cycle counter is only numheartbeat<<32, not meaningful
-   */
 #if 0
   else if(unlikely(evId == TRACE_TIME_HEARTBEAT)) {
 
@@ -1679,7 +1677,6 @@ static inline LttTime getEventTime(LttTracefile * tf)
   }
 #endif //0
   else {
-  
     lEventNSec = (gint64)((double)cycle_count * tf->nsec_per_cycle)
                                 +tf->overflow_nsec;
   }
This page took 0.027101 seconds and 4 git commands to generate.