by scottlamb · 6y ago · 0 comments
* How many bytes of register files does the OS have to save on task switches? (With this question, subregisters shouldn't be counted.)
* How many registers does an emulator (such as Rosetta 2) have to implement and test? (Subregisters should be counted.)
Even these one might argue aren't directly useful; when considering context switching, one could dig down further into how much of the context switching time is attributable to saving the registers, validate that with experiments across architectures, etc.
This is something that has been bothering me for some time now - actually since the mid-80's: why not implement multiple contexts as an index into a large register file? This way, a context switch would take the time it takes to write to the `task-id` register. It will impact latencies, but would the impact of having, say, 8 contexts not be smaller than having to hit L1 or L2 for the same data?
I would assume that, instead, a modern CPU tags decoded instructions in the reorder buffer with the virtual core number (and register set) it should be applied to. This way, the parallelism would be much easier to exploit.
it still shouldn't because they can't be distinct in the emulator as writing on a subregister affects the larger register and viceversa.
There is precedent for all this too.
Take the 6809, having 8 bit A and B accumulators. These can be addressed as D, a 16 bit register.
D is not generally counted as it's own register because the D addressing does not point to anything new.
A and B are counted as two registers.
If somehow D brought new bits, say it was 24 bits long, then it would need to be counted.
However if I were doing emulation, I would have to count it because it is a register case that has to be addressed. Just like the D register has to be dealt with on a 6809.
My own personal way to resolve this has always been to determine whether or not a given register specification, that can be addressed somehow, brings new information not contain in any other register specification, to the table.
Fact is, CPU designers do all kinds of crazy things with registers. They overlap, they may be indirect, like not directly addressable, but still there as consideration for the programmer.
Think about something like the REP instruction found on some CPUs. There's a little circuit it keeps track of account, and some rules, and account may be a register that may or may not be directly addressable any other way.
My general take on this article is, "wow, that's a lot of registers!"
We can all quibble about what the quantity of a lot is, and it's all good fun, and I don't think it means anything really.
"Rosetta is a translation process"
https://developer.apple.com/documentation/apple_silicon/abou...
This is not the case for Rosetta 2, which does a translation pass before running the generated ARM binary. No x86 code is run.