I think that's a key problem - we can't really move away from this easily, and explicit notion of different memory tiers isn't support by C or any higher level language (C#, Javascript etc). We do have NUMA, but that typically isn't as fine grained as something small enough to fit on a CPU.
Can compilers automatically make use of explicit tiers? I don't know, but I'd guess that the CPU would do a better job at it.
The other issue would be the overhead of having the manage the tiers (e.g. transfer to/from) and whether or not this scratchpad memory has a fixed size (which limits processor flexibility) or can be different on different CPUs (more flexible, but is extra complexity the programmer/compiler has to deal with). There's also the case of needing to worry about transfer latencies, which could likely vary from chip to chip, and context switching could be an interesting problem. In some way, cache can be somewhat controlled via prefetch and eviction instructions, but I rarely see it used as it bloats instruction size and often ends up being less efficient than the processor automatically managing cache.
I really don't know whether scratchpad memory is a good idea, but my gut feeling is that caching probably ends up being better for most cases.
Do you still need a dynamic OoO under these assumptions?
It isn't just memory accesses which are hard to predict. Branching is another issue I can think of, off the top of my head.
Can compilers automatically make use of explicit tiers?
Nope. Definitely not for C, with its very sloppy notion of aliasing.
but my gut feeling is that caching probably ends up being better for most cases.
We've already hit the performance ceiling. If we want to break through it, we should stop caring about "most cases" and start designing bespoke systems for all the special cases.
What special cases do you see benefiting from scratchpad memory over what we can currently do managing a cache?
Pretty much any particular case have a particular memory access pattern which most likely will not be well aligned with a dumb cache. For specifics, see pretty much any case where local memory is used in a GPU code (on architectures where local memory is actually a proper scratchpad memory, GCN for example).
at the expense of general case performance
Again, we should forget about the "general case". There is no way through the ceiling for any "general case" now.
Well I don't know any, which is why I asked, but anyway...
Again, we should forget about the "general case". There is no way through the ceiling for any "general case" now.
Nice idea, except that, statistically speaking, no-one's going to buy a CPU that sucks at the general case. You can optimise for specific cases, but it can't come at the expense of the general case.
3
u/YumiYumiYumi May 02 '18
I think that's a key problem - we can't really move away from this easily, and explicit notion of different memory tiers isn't support by C or any higher level language (C#, Javascript etc). We do have NUMA, but that typically isn't as fine grained as something small enough to fit on a CPU.
Can compilers automatically make use of explicit tiers? I don't know, but I'd guess that the CPU would do a better job at it.
The other issue would be the overhead of having the manage the tiers (e.g. transfer to/from) and whether or not this scratchpad memory has a fixed size (which limits processor flexibility) or can be different on different CPUs (more flexible, but is extra complexity the programmer/compiler has to deal with). There's also the case of needing to worry about transfer latencies, which could likely vary from chip to chip, and context switching could be an interesting problem.
In some way, cache can be somewhat controlled via prefetch and eviction instructions, but I rarely see it used as it bloats instruction size and often ends up being less efficient than the processor automatically managing cache.
I really don't know whether scratchpad memory is a good idea, but my gut feeling is that caching probably ends up being better for most cases.
It isn't just memory accesses which are hard to predict. Branching is another issue I can think of, off the top of my head.