RECIP(3clc)
π half_recip, native_recip β OpenCL Manual (3clc) π
okay bestie, welcome to the OpenCL manual page for two lil math girlies: half_recip and native_recip. yes they're sisters. yes one of them is the β¨accurateβ¨ one and one is the β‘fastβ¨ one. let's get into it π«Ά
πΈ NAME πΈ
half_recip, native_recip β floating point reciprocal. that's it. that's the vibe. you give it a number, it gives you 1/x energy back π
β¨ SYNOPSIS β¨
gentype half_recip(gentype x);
gentype native_recip(gentype x);
look at them. twin signatures. iconic. π
π¦ DESCRIPTION π¦
half_recip computes reciprocal. periodt. π
native_recip computes reciprocal over an implementation-defined range. and the maximum error is... also implementation-defined. so like, your mileage varies by device, no cap. π€·βοΈ
π NOTES π
okay so this built-in math function takes scalar or vector arguments. the generic type name gentype is used to indicate that the function can take float, float2, float4, float8, or float16 as the type for the arguments. and for any specific use of these functions, the actual type has to be the same for all arguments and the return type. consistency is the moment, fr fr. π§
functions with the half_ prefix are implemented with a minimum of 10-bits of accuracy, i.e. an ULP value less than or equal to 8192 ulp. yes bestie, 8192 ulp. that's the number. don't come for me, I didn't write the spec π
functions with the native__ prefix may map to one or more native device instructions and will typically have better performance compared to the corresponding functions (without the native__ prefix). but β and this is the tradeoff, the whole plot twist β the accuracy (and in some cases the input range(s)) of these functions is implementation-defined. so like, faster but the vibes are less guaranteed. πβοΈπ¨
the vector versions of the math functions operate component-wise. the description is per-component. so every lane does its own lil thing, independently. slay. β¨
the built-in math functions are not affected by the prevailing rounding mode in the calling environment, and always return the same value as they would if called with the round to nearest even rounding mode. so don't bother changing your rounding mode, she's not listening. main character energy only. π
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
π AUTHORS π
The Khronos Group β the collective. the council. the ones who wrote all of this down. π
π 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.
yes they made me include the whole legal paragraph verbatim. bestie I am not about to mess with lawyers. π«Ά
π₯ NOTES π₯
- OpenCL Specification β page
244, section6.12.2 - Math Functions
and that's the whole page bestie!! this little love letter to half_recip and native_recip came from The Khronos Group, dated 01/14/2021, and it lives in the OpenCL manual as HALF_RECIP, NATIVE_R(3clc). now go compute some reciprocals, you absolute icon πβ¨π¦πΈπ
π«Ά
π¦ 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