Re: [hatari-devel] Lower emulation ressources in 68000 cycle exact mode

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


Le 09/08/2021 à 12:21, Eero Tamminen a écrit :
Hi,

On 9.8.2021 0.04, Nicolas Pomarède wrote:
I just pushed some changes to do_cycles_ce() to require a little less cpu ressource. This function is called after every cpu instruction is emulated, so even small optimisations can have positive effects.

In the case of the Amiga and WinUAE, emulation needs to update other components (blitter, video, audio, ...) every 2 cycles during the emulation of each cpu instruction.

In the case of Hatari when emulating STF/STE machines, this is not required. So we can replace this loop :

while ( <n times> )
  do_cycles ( 1 * CYCLE_UNIT );

with :
   do_cycles ( n * CYCLE_UNIT);

 From a quick benchmark when running some demos, I go from ~134 emulated VBL/s to 143.3 VBL/s, which gives 7% increase in emulation speed.

It's only when running in STE mode and blitter is enabled that we use the slower "sub cycle" version to emulate that part of the last cpu instruction can run in parallel with the blitter.

Nice! That's a good improvement, especially
considering that it does not have any impact
parts that need to run with sub cycle code.


Hi

just for the record, doing a similar change to 'do_cycles_ce020()' doesn't give any benefit when using cpu >=68020 in CE mode. This is certainly because : - cpu >= 68020 take less cycles per instruction compared to 68000, so the while loop is smaller - there's more overhead in CE mode for these cpu to emulate instr/data cache, prefetch and so on, thus the relative time spent in the while loop is less.

So, I rather keep common code with WinUAE for do_cycles_ce020() instead of doing an Hatari specific case for >=68020.

Nicolas




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