From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,d79af07892182421 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2002-12-13 04:01:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Falk Hueffner Newsgroups: comp.unix.tru64 Subject: Re: Measuring VERY short durations Date: 13 Dec 2002 12:59:08 +0100 Organization: T-Online Sender: falk@juist Message-ID: <874r9i3zar.fsf@student.uni-tuebingen.de> References: <3df9b8da$0$22996$626a54ce@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.t-online.com 1039780748 01 20649 ZTr6ERTVSBALMd 021213 11:59:08 X-Complaints-To: abuse@t-online.com X-Sender: 520046482682-0001@t-dialin.net X-Face: "iUeUu$b*W_"w?tV83Y3*r:`rh&dRv}$YnZ3,LVeCZSYVuf[Gpo*5%_=/\_!gc_,SS}[~xZ wY77I-M)xHIx:2f56g%/`SOw"Dx%4Xq0&f\Tj~>|QR|vGlU}TBYhiG(K:2 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 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