[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [rtl] Problems with RDTSC examples posted here recently
- To: rtl@fsmlabs.com
- Subject: Re: [rtl] Problems with RDTSC examples posted here recently
- From: Chunky Kibbles <gjb105@cs.york.ac.uk>
- Date: Thu, 1 Nov 2001 08:57:39 +0000
- In-Reply-To: <20011031171240.X68528-100000@beryl.cs.utah.edu>; from regehr@cs.utah.edu on Wed, Oct 31, 2001 at 05:37:18PM -0700
- Organization: Kibbles'n'Bits
- References: <016301c160b7$2a724ca0$0600a8c0@compumagic> <20011031171240.X68528-100000@beryl.cs.utah.edu>
- Sender: Gary J Briggs (UG) <gjb105@student.cs.york.ac.uk>
- User-Agent: Mutt/1.2.5i
- User-Agent: mutt
On Wed, Oct 31, 2001 at 05:37:18PM -0700, John Regehr wrote:
> > method1 : 23573589435592 - 23573353927542 = 235508050
> > method2 : 23573353927556 - 23573353927556 = 0
> > method2A : 23573353927607 - 23573353927607 = 0
> > -- also m2_1 - m1_1 = 14
> > -- and m2A_1- m2_1 = 51
> > finally m2A_1- m1_1 = 65
>
> Take a look at the code that gcc generates when compiling your program
> with optimizations. The "rdtsc" instruction is executed three times,
> the program sleeps, and then rdtsc is executed only once more - hence
> the strange results. method2 and method2A are broken. I don't
> understand what the "mov edx, ecx" instruction in these functions is
> supposed to accomplish. Assuming that it is useful, you'll still need
> to inform gcc that you're clobbering ecx.
>
> method1 or something like it is what I've always used.
Don't forget to make sure it's __volatile__, elsewise this is the very
epitome of what would produce dodgy results...
Gary (-;