3 ms·
What task benefits from using such a complex instruction so easily dividable in simpler ones for it to be present in aarch64?
by voidbert 2y ago
What task benefits from using such a complex instruction so easily dividable in simpler ones for it to be present in aarch64?
- nanidin 2y agoNeon is SIMD so I would presume these instructions let you vectorize those calculations and do them in parallel on a lot of data more efficiently than if you broke it down into simpler operations and did them one by one.
- voidbert 2y agoYes, but the part that got me was the halving of the result followed by the clamping. SIMD generally makes sense, but for something like this to exist usually there's something very specific (like a certain video codec, for example) that greatly benefits from such a complex instruction.
- creato 2y agoIt's probably not about avoiding extra instructions/performance, but making the range of the result more useful and avoiding overflow. Or in other words, the entire instruction may be useless if you don't do these things.
- epcoa 2y agoThe halving and clamping is nothing particularly remarkable in the context of usefully using fixed point numbers (scaled integers) to avoid overflow. Reciprocal square root itself is a fundamental operation for DSP algorithms and of course computer graphics. This is a fairly generic instruction really, though FRSQRTE likely gets more real world use.
- ekelsen 2y agoThe halving could come from an intended use in a Newton Raphson iteration of a square root refinement. See for example https://math.mit.edu/~stevenj/18.335/newton-sqrt.pdf https://math.mit.edu/~stevenj/18.335/newton-sqrt.pdf The initial guess is the approximate square root, but it needs to be halved as part of the calculation.
- colechristensen 2y agoInverse square root is for normalizing vectors particularly in computer graphics calculations, it needs to be run a whole lot very fast. https://en.m.wikipedia.org/wiki/Fast_inverse_square_root#Motivation https://en.m.wikipedia.org/wiki/Fast_inverse_square_root#Mot...
- hinkley 2y agoFamously the magic constant in the Quake engine that nobody remembers inventing. That article does say there’s an SSE instruction rsqrtss that is better.