Re: [hatari-devel] monotonic global cycle counter

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On 12/08/2013 20:54, Nicolas Pomarède wrote:
I will have a look at this ; the plan is to drop
Cycles_GetCounter(CYCLES_COUNTER_CPU) anyway.

Having different cycles for different purposes (_VIDEO, _CPU, _SOUND) is
not optimal in the end.
Each time cycles are changing, it required to update the 3 counters,
whether they will be used immediatly or not.

It's better to have one global monotonic counter and let each HW
component maintains its own copy (ie its local "clock") when it needs it.

Dropping CYCLES_COUNTER_VIDEO is more work, because it's used a lot, but
dropping CYCLES_COUNTER_CPU should be possible without too much breakage.



Hello

even if newcpu.c still uses the old method to count cycle, you can already use CyclesGlobalClockCounter in the debugger, as CyclesGlobalClockCounter is updated in both cores in parallel to the old method, to ease transition.

Set prev_cycles as Uint64 instead of Uint32

-        cpu_profile.prev_cycles = Cycles_GetCounter(CYCLES_COUNTER_CPU);
+        cpu_profile.prev_cycles = CyclesGlobalClockCounter;

And then only keep :

    Uint64 newcycles = CyclesGlobalClockCounter;
    cycles = newcycles - cpu_profile.prev_cycles;
    cpu_profile.prev_cycles = newcycles;

This should work in all cases.

Nicolas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/