Dio wrote:Do you have any examples of where they do the cache bits in a language as high or higher level compared to C++?
No, I don't but I don't think that's because it can't be done.
Dio wrote:Branch tagging is already done implicitly (the if branch should be the most likely branch) or by PGO; again, this seems like something problematic to specify in a language of C++ highness or more, because you're assuming an implementation.
I wasn't aware of the if(common)else(uncommon) convention (Is it in C99?). I don't understand how it assumes an implementation though - just adding the information is useful for the compiler but isn't dependent on the mechanism used to exploit it, surely?
Dio wrote:The implicit stack... there's no need to write C or C++ code that uses the stack for anything beyond call or return, and I struggle to see a paradigm where those two primitives aren't going to be used in the implementation (indeed, as you go more high level than C++, stacks seem to become more important rather than less, in my limited experience).
Anything lambda based is going to use a call/return stack but C, at least by convention, has a single stack for call/return and automatics. Here are a couple of ideas I've toyed with. (I'm not claiming to have invented anything here, btw, just been thinking about it).
- An implementation doesn't have to use a linear stack - one could use a cell based linked list to implement call/return, and everything else is allocated in standard sized chunks allocated off a different linked list. Then you don't need contiguous virtual space (and that in page sized increments) for threads and heap allocation doesn't cause fragmentation. Would work best with language level support. Also it allows call/return information to be separated from data so each can have a separate cache policy (i.e. you could exclude call/return from ever being cached thus increasing the proportion of your real data which fits in the first level cache, or the other way around.
- Lots of embedded designs are implemented as a number of threads running dispatch loops because this is encouraged by the C execution model which was in turn inherited from the UNIX process model. In fact many of these systems are either state machines or asynchronous event handlers - one could save memory and improve latency with a language which explicitly supports these models. In both cases the stacks' sizes can generally be statically calculated and are small and short lived. The ubiquitous Arm Cortex M processors have hardware features to support this but the ubiquitous language used with them can't explicitly express it.
Dio wrote:And, again, I'm interested to read about examples of HLLs that allow for more efficient targetting of incoherent-cache architectures or software OOE dependencies. Surely, as soon as you are sitting above such a system, all HLLs become subject to similar restrictions? (I may be displaying my inexperience of the wider landscape of programming here, of course).
Well, I've mostly been thinking about how one would design a low level or systems programming language which can use modern processor features rather than a higher level language. I'm not aware of any extant HLLs which address this but there that's not to say there aren't any.
Off the top of my head it seems to me that incoherent caches need some mechanism for marking use/commit blocks (so that data bars can be inserted) and specifying which functions are executed on which processor - something which can't easily be done in C because it no notion of separate threads of execution.
At the risk of repeating myself, I don't have solutions - I've just noticed that the systems I'm working on seem to be requiring more and more bending of the C model.