Date: Fri, 22 Sep 2000 16:28:31 -0400 (EDT) From: Darrell Anderson <anderson@cs.duke.edu> To: freebsd-alpha@freebsd.org Cc: gallatin@cs.duke.edu (Andrew Gallatin) Subject: FreeBSD alpha cycle counter wackiness Message-ID: <200009222028.QAA16630@cold.cs.duke.edu>
next in thread | raw e-mail | index | archive | help
Can someone explain this cycle counter behavior to me? The attached program reads the cycle counter from userspace, spitting out cycle counter values and deltas. On x86, I see consistent deltas (~8000 cycles). On alpha, I usually see a reasonable delta (~6000 cycles), with occassional jumps (~2^64). The jumps appear at consistent intervals. Sometimes there are long sequences where every delta is a jump. Before you tell me it's just wrapping, the delta is ~2^56. Deltas before and after the jumps seem quite reasonable. Here is some sample output from a 500MHz XP1000. I get similar results for 4.0-RELEASE and 5.0-CURRENT. 0xc5657103cc1d06a3 delta 0x1602 0xc5657103cc1d1ae5 delta 0x1442 0xc5657103cc1d2f41 delta 0x145c 0xc5652696cc1d9bc3 delta 0xffffb59300006c82 0xc5652696cc1db76e delta 0x1bab 0xc5652696cc1dcf85 delta 0x1817 0xc5652696cc1de53c delta 0x15b7 ... 0xc5652696cc1fda5e delta 0x13bc 0xc5652696cc1fedba delta 0x135c 0xc5652696cc200266 delta 0x14ac 0xc564dfc7cc206c65 delta 0xffffb931000069ff 0xc564dfc7cc208930 delta 0x1ccb 0xc564dfc7cc20a033 delta 0x1703 0xc564dfc7cc20b646 delta 0x1613 ... 0xc564dfc7cc22b111 delta 0x1374 0xc564dfc7cc22c690 delta 0x157f 0xc564dfc7cc22d9ed delta 0x135d 0xc564900ecc234d57 delta 0xffffb0470000736a 0xc564900ecc236b22 delta 0x1dcb 0xc564900ecc2382fb delta 0x17d9 0xc564900ecc239aae delta 0x17b3 here's the code: --begin-- #include <stdio.h> #include <unistd.h> static __inline u_int64_t read_cc(void) { u_int64_t rv = 0; #ifdef __i386__ __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (rv)); #endif #ifdef __alpha__ __asm__ __volatile__ ("rpcc %0" : "=r" (rv)); #endif return rv; } int main(int argc, char *argv[]) { unsigned long then = read_cc(), now; while (1) { now = read_cc(); printf("0x%lx delta 0x%lx\n", now, now - then); then = now; } return 0; } --end-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009222028.QAA16630>