SQRT(3clc)
π SQRT, RSQRT, HALF_SQ π
welcome to the OpenCL Manual, bestie β this is the page for SQRT, RSQRT, HALF_SQ (that's the 3clc section, iykyk). it's giving square roots, inverse square roots, and a whole lotta gentype π
πΈ NAME πΈ
sqrt, _rsqrt, _half_sqrt, _native_sqrt, _half_sqrt, _native_sqrt β Square root functions.
okay so, yes, that list literally says_half_sqrtand_native_sqrttwice and never mentionshalf_rsqrtornative_rsqrt. that's what the page says, and we do not touch it. we report, we do not editorialize. π«‘
and here's the actual synopsis vibe, verbatim:
gentype sqrt(gentype );
gentype half_sqrt(gentype x);
gentype native_sqrt(gentype x);
gentype rsqrt(gentype );
gentype half_rsqrt(gentype x);
gentype native_rsqrt(gentype x);
β¨ DESCRIPTION β¨
okay so, what do these even do:
sqrtβ computes square root. that's it, that's the whole job. πhalf_sqrtβ computes square root.native_sqrtβ computes square root over an implementation-defined range. the maximum error is implementation-defined. so like, it's fast and vibes-based, and the vibes are decided by your implementation, not by you. πrsqrtβ computes inverse square root.half_rsqrtβ computes inverse square root.native_rsqrtβ computes inverse square root over an implementation-defined range. the maximum error is implementation-defined. same energy as above, just the upside-down version. π
π§ NOTES π§
- the vector versions of the math functions operate component-wise. the description is per-component. so like, one lil instruction, everybody in the vector gets it, no favorites. π«
- 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. no cap. rounding mode does not get a vote here. π³οΈβ
- the built-in math functions take scalar or vector arguments. for any specific use of these functions, the actual type has to be the same for all arguments and the return type, unless otherwise specified. no mixing, no matching, no chaos. π
- the generic type name
gentypeis used to indicate that the function can takefloat,float2,float3,float4,float8,float16,double,double2,double3,double4,double8, ordouble16as the type for the arguments. - if extended with
cl_khr_fp16(3clc), generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. π¦ - the generic type name
gentypefis used to indicate that the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. - the generic type name
gentypedis used to indicate that the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. - 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. it's the "good enough, fast enough" aisle, and honestly? respect. π - 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 thenative_prefix). the accuracy (and in some cases the input range(s)) of these functions is implementation-defined.
β οΈ fr fr though β every time you see "implementation-defined," that means your mileage is literally decided by your implementation. read your vendor's docs before you trust a native_ result with your whole chest. π
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
π 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 following condition: the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES (yes, again β the footnote lives down here) π
OpenCL Specificationβ page 244, section 6.12.2 - Math Functions
and that's the whole page, bestie π signing off β this one's brought to you by The Khronos Group, dated 01/14/2021, and it's the SQRT, RSQRT, HALF_SQ(3clc) page, periodt. go compute some roots, hydrate, and remember: native_ is fast but it does not owe you accuracy. πβ¨π¦
π¦ 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