Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: [altivec] Time base on PPC



> > I'm looking for a PPC instruction which counts the processor clock 
> > ticks like the RDTSC (Read Time-Stamp Counter) instruction on the P4. 
> > So far I found the Move From Time Base (mftb) instruction, but it is 
> > mentioned that only the fourth of the bus clock is used to increment 
> > this counter rather than the real processor clock. I've also tried 
> > following code to check out the resulting values:
> >
> >   unsigned long a1,b1,a2,b2;
> >
> >   asm volatile ("mftb %0, 268 \n" "mftb %1, 269\n" : 
> > "=r"(a1),"=r"(b1));
> >   sleep(1);
> >   asm volatile ("mftb %0, 268 \n" "mftb %1, 269\n" : 
> > "=r"(a2),"=r"(b2));
> >
> > The difference between (b2<<32)|a2 and (b1<<32)|a1 is around 18,450,00 
> > but this number does not correspond to the fourth of the bus clock 
> > which in my case is settled around 166.67 MHz. Are there other 
> > instructions or special registers which can be used for this purpose? 
> > How should the values in the time base be interpreted?

[cross-posting this reply to perfoptimization-dev since I think this question
is general and important enough for the added traffic]

Are you sure your bus clock is 166.67? The bus frequency (and CPU frequency)
can vary to save power; this happens very often, particularly on laptops. To
get the maximum rated frequency all the time, you have to go into the Energy
Saver settings and change the CPU performance option to "Highest."

You can read Perf Monitor Counters with Shark or Monster to measure CPU
cycles, but we be aware that those counters can change frequency or may not
move if the CPU goes into sleep, nap, or doze states.

The best way to measure time on OSX is through mach_absolute_time() or
UpTime().

--Sanjay


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.