Re: [hatari-devel] Re: Profiler - long history

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


Le 18/05/2015 20:46, Nicolas Pomarède a écrit :

It depends on the cpu. 68020 only has one cache for instructions. 68030
and 68040 have 2 caches, one for instructions and one for data.


Hi

Code updated. As indicated, 68030/40/60 also have a data cache, so I added more variables to track this :

typedef struct {
        int     I_Cache_miss;
        int     I_Cache_hit;
        int     D_Cache_miss;
        int     D_Cache_hit;
} cpu_instruction_t;

Eero, for now, I only updated debug/profilecpu.c to use I_Cache_miss, as it was before with the older version of WinUAE cpu.

To get correct cache stat, you will now need to check the cpu model and update profilecpu.c accordingly :

- If it's a 68020, you should use only I_Cache_miss and I_Cache_hit.

- If it's a 68030/40/60, you should use I_Cache_miss, I_Cache_hit, D_Cache_miss, D_Cache_hit.

Regarding data cache, it's not fully implemented yet for 68040/60, so results are not be trusted I guess. But 68030 cache should give correct values.

One thing to note about 68030 data cache is that if a long word (32 bits) must be read, it might be stored in 2 cache's entries, depending if the address was aligned on 2 or 4 bytes, requiring 2 read in the cache.

So, a read for 32 bits could yield :
 - 1 hit
 - or 1 misses
 - or 1 hit and 1 miss
 - or 2 hits
 - or 2 misses

Of course, if cache is disabled, you get 0 hit and 0 miss.

Also, in order to not slow down the main cpu loop in newcpu.c, it's the external profiler *that must clear the hit/miss cache counter*. This way, counters will be cleared only when needed, no need to clear them every time in newcpu.c if the profiler is not used anyway.

Nicolas




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