3 ms·
There have been rumors that Zen could do memory renaming [1], this pretty much confirms it. [1] Basically the same as register renaming, but instead of using t
by gpderetta 6y ago
There have been rumors that Zen could do memory renaming [1], this pretty much confirms it.
[1] Basically the same as register renaming, but instead of using the register file to rename architectural registers, it can rename memory instead.
- tus88 6y agoWonder what side channel attacks this will result in.
- Razengan 6y agoA problem for every solution.
- saagarjha 6y agoIf the memory renaming cache isn't cleared, I can foresee Spectre-like attacks against that micro-architectural buffer. However, for a new feature like this hopefully they've figured out how to not leave that open…
- gpderetta 6y agoThe memory renaming cache is almost surely just the register file.
- saagarjha 6y agoFigured I might as well mention it in case AMD was doing something totally wild, but I would agree that using the register file sounds likely :) I wonder how they manage the pressure on it between renaming and memory mirroring…
- BeeOnRope 6y agoIn principle if you are using the GP PRF it is possible to implement it so that there is little additional pressure: the store instruction already has it's data input a register which has been renamed: now you just need to organize it so that the subsequent load that targets the same location is a no-go: simply alias the arch reg targeted by the load onto the existing register used by the store (much like mov-elimination) So except for a small window in the middle you have the same pressure on the PRF. I don't know if that is how it is actually implemented, of course!
- trasz 6y agoIt only (well, “only”) works for the stack, though?
- BeeOnRope 6y agoNo, I tried it with [rcx] as well and it works fine, i.e., no particular dependency on [rsp], at least in Zen2.
- BeeOnRope 6y agoAlthough I guess it depends what you mean by "stack". My test shows that it isn't tied specifically to [rsp], the register used to address the stack, but I suppose it could still be tied to the region of memory the CPU heuristically determines is part of "the stack", regardless of what memory is used to access it.
- BeeOnRope 6y agoWell they weren't just rumors, I measured this back in February and mentioned it in passing here [1]. Even at that point something similar was described in Wikichip (which I quote at the above link). Long before that, going back to Zen 1 I saw talk of the memfile, although I never saw a microbenchmark measuring the effect on on Zen 1: it seems much harder or impossible to trigger there (on Zen 2 it is very obvious: any basic store-then-forward loop using the same addressing expression will show a latency of 1). --- [1] https://gist.github.com/travisdowns/bc9af3a0aaca5399824cf182f85b9e9c#simple-store-forwarding https://gist.github.com/travisdowns/bc9af3a0aaca5399824cf182...
- gpderetta 6y agoThanks; I either missed the discussion or forgot about it. Interesting that the forwarding is claimed to be done under speculation. I wonder if it is really necessary. Also, is it value speculation or does it checks the state of the cacheline? Edit: thinking about it more, this is probably just the existing alias predictor that only cares about adresses.
- BeeOnRope 6y agoI think it has to be speculative? The optimization has to happen early, in the front-end (around allocation) at which point you'll not know if the load actually aliases the earlier store [1]. To get the zero latency, you take a guess and correct yourself if you are wrong. The non-speculative approach is basically the existing pre-memory-renaming approach: you probe the store buffer looking for earlier stores to the same address. This has also gotten much faster (3 cycles total on current Intel), but that's still a lot slower than 0 cycles (or 1 cycle total on Zen 2). > Also, is it value speculation or does it checks the state of the cacheline? I assume memory ordering is handled in the usual way, with an ordering nuke if a concurrency related misordering is detected. About how it's verified, I think it could either verify that the load actually came from the corresponding store (e.g., do the load and check that the SB entry used was the same as the predicted one), or it could verify that the value was the same: i.e., do the load and check that the value was the one used earlier based on the prediction. The latter would succeed in some additional cases. It should be easy to test the two cases (essentially, Agner's add test with different register, but add 0 not 1). --- [1] As a special case, you could prove that some loads alias some earlier stores when the addressing expression is the same (or can be proven equivalent), and there is no intermediate store, but evidently the AMD approach goes a ways beyond this since it allows for intermediate stores.