From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
Subject: Re: Measuring VERY short durations
Date: 13 Dec 2002 12:59:08 +0100 [thread overview]
Message-ID: <874r9i3zar.fsf@student.uni-tuebingen.de> (raw)
In-Reply-To: 3df9b8da$0$22996$626a54ce@news.free.fr
"JF Larvoire" <jean-francois.larvoire@remove_this.free.fr> writes:
> we'd like to measure the duration of very short code pieces. Is
> there a way to get access to processor clock counters on the Alpha?
Yes. Try this code:
#ifdef __GNUC__
static inline unsigned realcc(void) {
unsigned long cc;
asm volatile("rpcc %0" : "=r"(cc));
return cc;
}
#else /* DEC C */
#include <c_asm.h>
static inline unsigned realcc(void) {
return asm("rpcc %v0");
}
#endif
This will get the lower 32 bits of the cycle counter (the upper 32
bits contain a process-specific counter that you can use to calculate
user time for a specific process). Note that it wraps around every few
seconds, and context switches might disturb the result, so you should
do some sanity checks.
If you need *extremely* short measurements (like 20 cycles), and have
an EV6, you should pass a second argument to rpcc, which will avoid it
being executed too early by the out-of-order mechanism. See the Alpha
Architecture Reference Manual (4th edition) for details.
--
Falk
next prev parent reply other threads:[~2002-12-13 11:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-13 10:36 Measuring VERY short durations JF Larvoire
2002-12-13 11:59 ` Falk Hueffner [this message]
2002-12-13 13:44 ` JF Larvoire
2002-12-13 13:56 ` Andrew Duane USG
2002-12-18 10:03 ` JF Larvoire
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox