Re: [hatari-devel] profiler cycles (was New WinUAE core issue with Bad Mood)

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


Le 04/12/2014 21:34, Nicolas Pomarède a écrit :

I see the problem ; in old winuae code, CYCLES_COUNTER_CPU was used to
measure instruction's cycle, but that's not optimal to maintain this
counter, as the new core as some variables to store instructions' cycles
and don't maintain CYCLES_COUNTER_CPU.

I will give a look to this to replace
Cycles_GetCounter(CYCLES_COUNTER_CPU); by other variables.


Hi

can you try this quick and dirty patch ? I think it should fix the cycles counting in the profiler code.

Basically, CyclesGlobalClockCounter is the 64 bit monotonic counter that get increased after each instruction and that can be considered as the "main" clock for the emulation (this counter is increased in m68000.h)

With this, it should be possible to remove the #if USE_CYCLES_COUNTER you added, as there's no more different behaviour depending on dsp yes/no or old/new cpu core.

If you wish, you can update profilecpu.c this way if it works.

Nicolas
diff -r ea193083ff75 src/debug/profilecpu.c
--- a/src/debug/profilecpu.c	Wed Dec 10 00:50:00 2014 +0100
+++ b/src/debug/profilecpu.c	Thu Dec 11 00:17:50 2014 +0100
@@ -76,7 +76,8 @@
 	int active;           /* number of active data items in all areas */
 	Uint32 *sort_arr;     /* data indexes used for sorting */
 	int prev_family;      /* previous instruction opcode family */
-	Uint32 prev_cycles;   /* previous instruction cycles counter */
+//	Uint32 prev_cycles;   /* previous instruction cycles counter */
+	Uint64 prev_cycles;   /* previous instruction cycles counter */
 	Uint32 prev_pc;       /* previous instruction address */
 	Uint32 loop_start;    /* address of last loop start */
 	Uint32 loop_end;      /* address of last loop end */
@@ -631,7 +632,8 @@
 		etos_switcher = PC_UNDEFINED;
 	}
 
-	cpu_profile.prev_cycles = Cycles_GetCounter(CYCLES_COUNTER_CPU);
+//	cpu_profile.prev_cycles = Cycles_GetCounter(CYCLES_COUNTER_CPU);
+	cpu_profile.prev_cycles = CyclesGlobalClockCounter;
 	cpu_profile.prev_family = OpcodeFamily;
 	cpu_profile.prev_pc = M68000_GetPC() & 0xffffff;
 
@@ -849,6 +851,7 @@
 		prev->count++;
 	}
 
+#if 0
 #if USE_CYCLES_COUNTER
 	/* Confusingly, with DSP enabled, cycle counter is for this instruction,
 	 * without DSP enabled, it's a monotonically increasing counter.
@@ -863,6 +866,11 @@
 #else
 	cycles = CurrentInstrCycles + nWaitStateCycles;
 #endif
+#else
+	cycles = CyclesGlobalClockCounter - cpu_profile.prev_cycles;
+	cpu_profile.prev_cycles = CyclesGlobalClockCounter;
+#endif
+
 	/* cycles are based on 8Mhz clock, change them to correct one */
 	cycles <<= nCpuFreqShift;
 


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