Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] Re: Re: Measuring packet tracing


Chronological Thread 
  • From: "Biagio Cosenza" < >
  • To:
  • Subject: [Manta] Re: Re: Measuring packet tracing
  • Date: Tue, 30 Sep 2008 18:09:18 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :x-google-sender-auth; b=LsnCZmbEnsAzqzoE5DFHFtaWko+52XjnbuZ9/sNqJtHCfET+AmnxAgeiEWdJIF55OW /xQEuQZnlMB97cOf0c4zFiAT9g2aFL/tmGFdZLbZmrsmVKatv57oGCPTVVTAsjDqYlQ3 /IBT2Kxfyluj+I8Hc6uRmgoj4z/IPKJSWI3/o=

Thanks for your suggestions!

I have implemented a Timer class that uses an high resolution timer. In Pentium processor, it reads the current time-stamp counter variable with a specific instruction. It is based on Kazutomo's code http://www.mcs.anl.gov/~kazutomo/rdtsc.html .

As suggested by Abe, I also did a "scaling" of the given values.
Booth snapshots and code are enclosed. Maybe they can be useful to other people.

Thanks, Biagio

---
Biagio Cosenza
ISISLab, Dip. di Informatica ed Applicazioni "Renato M. Capocelli"
Universita' degli Studi di Salerno
http://www.dia.unisa.it/~cosenza

Attachment: timing_costmap_1.png
Description: PNG image

Attachment: timing_costmap_2.png
Description: PNG image

#ifndef __HRTIMER_H_DEFINED__
#define __HRTIMER_H_DEFINED__

#include <Core/Util/Timer.h>

/* 
    High resolution timer.
    Written by Biagio Cosenza. It is based on Parker's Timer class and Kazutomo's 
    time- stamp counter.

    Pentium class cpu has an instruction to read the current time-stamp counter
    variable ,which is a 64-bit variable, into registers (edx:eax). TSC (time stamp
    counter) is incremented every cpu tick (1/CPU_HZ). For example, at 1GHz cpu, TSC is
    incremented by 10^9 per second. It allows to measure time activety in an accurate
    fashion.

    PowerPC provides similar capability but PowerPC time counter is increments at
    either equal the processor core clock rate or as driven by a separate timer clock
    input. PowerPC time counter is also a 64-bit. 

*/



namespace Manta {



#if defined(__i386__)

static __inline__ unsigned long long rdtsc(void)
{
  unsigned long long int x;
     __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
     return x;
}

#elif defined(__x86_64__)

typedef unsigned long long int unsigned long long;

static __inline__ unsigned long long rdtsc(void)
{
  unsigned hi, lo;
  __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
  return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
}

#elif defined(__powerpc__)
typedef unsigned long long int unsigned long long;

static __inline__ unsigned long long rdtsc(void)
{
  unsigned long long int result=0;
  unsigned long int upper, lower,tmp;
  __asm__ volatile(
                "0:                  \n"
                "\tmftbu   %0           \n"
                "\tmftb    %1           \n"
                "\tmftbu   %2           \n"
                "\tcmpw    %2,%0        \n"
                "\tbne     0b         \n"
                : "=r"(upper),"=r"(lower),"=r"(tmp)
                );
  result = upper;
  result = result<<32;
  result = result|lower;
  return(result);
}

#else
    #error "No tick counter is available!"
#endif




class HRTimer : public Timer {
    double get_time(){ return double(rdtsc()); }
public:
    //virtual ~HRTimer();
};



}; // namespace Manta


#endif



  • [Manta] Re: Re: Measuring packet tracing, Biagio Cosenza, 09/30/2008

Archive powered by MHonArc 2.6.16.

Top of page