FMA(3G)

πŸ“¦
version 1.0~svn33624 Β· 4 versions
, in ubuntu jammy, ubuntu noble

✨ FMA β€” the fused multiply-add bestie ✨

Okay so this is fma, and it lives in section 3G of the manual (that's the OpenGL shading language corner of the docs, iykyk). It does one thing and it does it beautifully: it multiplies two numbers and adds a third, all in one go. πŸ¦‹


πŸ’– NAME πŸ’–

fma β€” perform a fused multiply-add operation. That's it, that's the whole vibe. πŸ’…


🌸 DECLARATION 🌸

Here's the signature, and bestie, you're gonna want to copy this exactly:

genType fma(genType a, genType b, genType c);

genDType fma(genDType a, genDType b, genDType c);

Two flavors, one for the regular floats (genType) and one for the double-precision girlies (genDType). Both are icons. πŸ‘‘


πŸŽ€ PARAMETERS πŸŽ€

  • a β€” the first multiplicand, aka the first number getting multiplied. She's part of the main character energy of the multiplication. ✨
  • b β€” the second multiplicand. Her partner in crime in the multiplication. 🫢
  • c β€” the value that gets added onto the result. The little sprinkle on top. πŸ“

🌈 DESCRIPTION 🌈

So fma performs, where possible, a fused multiply-add operation, and it returns:

a * b + c

But here's the part that actually matters, the part where it gets interesting. There are use cases where the return value eventually gets consumed by a variable declared as precise. And when that happens:

  • fma() is considered a single operation, whereas the expression a * b + c consumed by a variable declared as precise is considered two operations. Two!! Different count entirely. πŸ’€
  • The precision of fma() can differ from the precision of the expression a * b + c. Like, not even the same number of bits of accuracy, potentially.
  • fma() will be computed with the same precision as any other fma() consumed by a precise variable, which gives you invariant results for the same input values of a, b and c. Consistent. Reliable. Slay. ✨
Otherwise β€” meaning in the absense of precise consumption (yes, that's how it's spelled in the original, and I'm keeping it fr fr) β€” there are no special constraints on the number of operations, or on any difference in precision between fma() and the expression a * b + c. So outside of that precise situation, don't assume anything extra. No cap. πŸ™ˆ

πŸ‘‘ VERSION SUPPORT πŸ‘‘

Here's the vibe check on which OpenGL Shading Language versions support this function. βœ” means she's there, - means she has not arrived yet. The columns are, in order: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50.

  • fma (genType) β€” 1.10: -, 1.20: -, 1.30: -, 1.40: -, 1.50: -, 3.30: -, 4.00: βœ”, 4.10: βœ”, 4.20: βœ”, 4.30: βœ”, 4.40: βœ”, 4.50: βœ”
  • fma (genDType) β€” 1.10: -, 1.20: -, 1.30: -, 1.40: -, 1.50: -, 3.30: -, 4.00: βœ”, 4.10: βœ”, 4.20: βœ”, 4.30: βœ”, 4.40: βœ”, 4.50: βœ”

So basically both versions showed up in 4.00 and have been serving looks ever since. Anything before that? Ghost town. πŸ«₯ Before 4.00, it's giving nothing. But from 4.00 onward? Every single one. Ate. πŸ’…


Copyright Β© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.


Copyright Β© 2011-2014 Khronos Group


And that's the whole page, bestie β€” mwah. πŸŽ€ This one came out of the [FIXME: source] build, dated 01/03/2018, filed under FMA(3G). Go forth and fused-multiply-add responsibly. πŸ¦‹βœ¨

πŸ“¦ where this page comes from