I mean, we have a data cache, for example, about of 16 Kbytes on SH4 processor.
How the processor knows which data and when (and how much of them) to load into cache?
How the data loads in cache?
- RyoDC
- Mental DCEmu
- Posts: 366
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Wed Mar 30, 2011 12:13 pm
- Has thanked: 2 times
- Been thanked: 0
-
- DC Developer
- Posts: 968
- Joined: Tue Feb 11, 2003 4:12 pm
- Location: In a Dream
- Has thanked: 5 times
- Been thanked: 6 times
-
- DC Developer
- Posts: 109
- Joined: Sun Oct 04, 2009 11:13 am
- Has thanked: 2 times
- Been thanked: 96 times
Re: How the data loads in cache?
The SH4 loads data into the cache when the program tries to access cacheable memory and the data isn't already in the cache. Main RAM is usually accessed as cacheable, while hardware is usually accessed as uncacheable. When the SH4 load stuff into cache, it always loads a block of 32 bytes. The start of that block is the address of the memory access rounded down to a multiple of 32. So if the address accessed is between 0-31, the block loaded will contain the data from 0-31; if the address is between 32-63, the block loaded will contain the data from 32-63; etc.
- RyoDC
- Mental DCEmu
- Posts: 366
- Joined: Wed Mar 30, 2011 12:13 pm
- Has thanked: 2 times
- Been thanked: 0
Re: How the data loads in cache?
So there will be some delay, right? Is there's any way to pre-load that data?
What data are initially in the cache?
What data are initially in the cache?
How do I try to build a Dreamcast toolchain:
- BlueCrab
- The Crabby Overlord
- Posts: 5666
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: How the data loads in cache?
Or, of course, just use the pref instruction in assembly.Ayla wrote:You can use GCC's __builtin_prefetch for that purpose.
- GyroVorbis
- Elysian Shadows Developer
- Posts: 1874
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 81 times
- Been thanked: 64 times
- Contact:
Re: How the data loads in cache?
Yeah, there's considerable delay for a cache miss. That's why cache optimization is so important for time-critical algorithms.RyoDC wrote:So there will be some delay, right? Is there's any way to pre-load that data?
What data are initially in the cache?
BlueCrab wrote:Or, of course, just use the pref instruction in assembly.
Code: Select all
#define PREFETCH(addr) __asm__ __volatile__("pref @%0" : : "r" (addr));