3 ms·
A note on mask registers (AVX-512)
- BeeOnRope 7y agoAuthor here, happy to answer any questions or for any feedback!
- ylk1 7y agoGreat article as usual! Nice analysis. btw, just wondering, were you a processor architect in your previous roles?
- BeeOnRope 7y agoNo, my training and background is on the software side and so the hardware stuff is only a hobby.
- fluffything 7y agoIs zeroing a mask register a common operation? I'd suspect that setting all mask bits would be much more common. I mean, if you are going to zero the register, the real optimization would be to completely skip emitting any instructions for the operation you are going to perform, since it probably isn't going to do anything if the mask is cleared.
- tarlinian 7y agoI have no particular reason at the moment to care about any of this, but your posts are always very interesting reading. I was actually surprised to see the zeroing idioms not being recognized. I sort of assumed those were cheap to implement. I suppose they may not actually have much value since you would never actually want to use a zero mask register as an actual mask?
- BeeOnRope 7y agoYeah, I would think most mask registers values just "pop into existence" as already nonzero based on a full write to the register, e.g., from a comparison, a load from memory, move from GP reg, etc. I can't see all that many scenarios where you want a zeroed register to begin with. Many of the cases that happens in the GP world (e.g., zeroing out some accumulator or pointer or whatever) just don't come up in mask registers. I am not sure about the cost to implement it. I don't think it's all that complicated to describe how it would work, but it does occur in the renamer, which is a critical path on modern chips, so probably the less complication there, the better. We already know that not all zeroing idioms are recognized (like sub same, same) on some chips, so that is some indication that it's not super cheap (or else you'd think they'd have just implemented all the idioms the first time around).