Paul Barton-Davis wrote:
> >> > > Do you know of any application using TSC?
>
> Most of my audio applications (Quasimodo, SoftWerk, Ardour, HDR and
> others) use the TSC for high resolution, low cost timing from user space.
Thank you for this info. I took a look at your code and I see that you
use gettimeofday() if tsc is not available, is this right?
I also see that in libpbd-1.0.0 in file precision_timer.cc you have the
following code to determine how many cycles rdtsc() takes:
rdtsc_start = rdtsc();
rdtsc_stop = rdtsc();
rdtsc_cycles = (int) (rdtsc_stop - rdtsc_start);
The result of this is really unpredictable, as the following program
shows:
#define N 4000000
typedef unsigned long long int tsc_t;
__inline__ tsc_t rdtsc(void)
{
tsc_t x;
__asm__ volatile ("rdtsc"
: "=A" (x));
return x;
}
int main()
{
int i;
static int cy[N];
tsc_t rdtsc_start, rdtsc_stop;
int rdtsc_cycles;
for (i=0; i < N; i++){
rdtsc_start = rdtsc();
rdtsc_stop = rdtsc();
rdtsc_cycles = (int) (rdtsc_stop - rdtsc_start);
if ( rdtsc_cycles < N )
cy[rdtsc_cycles]++;
else
cy[N-1]++;
}
for (i=0; i < N; i++) if (cy[i]) printf("%d %d\n", i, cy[i]);
}
The typical result that I get on P2/400 UP with another cpu intensive
task running in the background looks like this:
32 3999970
4325 1
4335 2
4460 2
4515 1
4518 1
4536 1
4548 1
4558 1
4565 1
4581 1
4592 1
4608 1
4639 1
4733 1
4738 1
4741 1
4767 1
4770 1
4791 1
4875 1
5031 1
5110 1
6181 1
10426 1
10593 1
33298 1
3999999 2
gettimeofday() takes on my computer about 400 cycles, so it is about
10-15 times slower then your rdtsc().
Probably I am missing something, but it seems to me that it is not worth
the possible trouble.
Boris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:26 EST