FP_CONTRACT(3clc)
π FP_CONTRACT, FP_FAST π
okay bestie, welcome to the OpenCL Manual corner of the universe π«Ά this is FP_CONTRACT, _FP_FAST_FMAF, and _FP_FAST_FMA_HALF(3clc) β the page about controlling expression contraction and vibing with fast fma(). yes the manual name is literally in the title, we're being efficient today π
β¨ NAME β¨
FP_CONTRACT, _FP_FAST_FMAF, _FP_FAST_FMA_HALF β Control expression contraction; fast fma() πΈ
π FP_CONTRACT π
The FP_CONTRACT pragma takes the form:
#pragma OPENCL FP_CONTRACT
on-off-switch
so what is this actually doing? FP_CONTRACT lets you allow (when the state is on) or disallow (when the state is off) the implementation to contract expressions. that's the whole vibe check π₯
Each pragma can show up either outside external declarations, or preceding all explicit declarations and statements inside a compound statement. those are the only two places it's allowed to be, no cap.
The parameter on-off-switch is one of ON, OFF, or DEFAULT. and the DEFAULT value is ON. yes, it defaults to on, it's giving main character energy π
Now the scoping, because this is the part everyone gets wrong π:
- When it's outside external declarations, the pragma takes effect from its occurrence until another
FP_CONTRACTpragma is encountered, or until the end of the translation unit. π¦ - When it's inside a compound statement, the pragma takes effect from its occurrence until another
FP_CONTRACTpragma is encountered (including within a nested compound statement), or until the end of the compound statement. at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement. it literally snaps back to how it was before, iconic behavior β¨
π¨ If this pragma is used in any other context, the behavior is undefined. like, genuinely undefined, not cute undefined. do not do this bestie, please π
π FP_FAST_FMAF AND FP_FAST_FMA π
The FP_FAST_FMAF macro indicates whether the fma(3clc) function is fast compared with direct code for single precision floating-point. If defined, the FP_FAST_FMAF macro shall indicate that the fma(3clc)() function generally executes about as fast as, or faster than, a multiply and an add of float operands. β‘
The FP_FAST_FMA macro indicates whether the fma(3clc) family of functions are fast compared with direct code for double precision floating-point. If defined, the FP_FAST_FMA macro shall indicate that the fma(3clc)() function generally executes about as fast as, or faster than, a multiply and an add of double operands. π
The FP_FAST_FMA_HALF macro indicates whether the fma(3clc)() family of functions are fast compared with direct code for half precision floating-point. If defined, the FP_FAST_FMA_HALF macro shall indicate that the fma(3clc)() function generally executes about as fast as, or faster than, a multiply and an add of half operands. π§
π SPECIFICATION π
OpenCL Specification[1] π
π SEE ALSO π
go read those too, they're all in the same friend group π«Ά
π AUTHORS π
The Khronos Group π
βοΈ COPYRIGHT βοΈ
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES π
- OpenCL Specification page 252, section 6.12.2.1 - Floating-point macros and pragmas
okay that's the whole page, you ate that bestie ππ
this was The Khronos Group's work, dated 01/14/2021, and you just read the FP_CONTRACT, FP_FAST(3clc) page from the OpenCL Manual. periodt. β¨π¦π
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms