SQRT(3clc)

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

πŸ’– 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_sqrt and _native_sqrt twice and never mentions half_rsqrt or native_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 gentype is used to indicate that the function can take float, float2, float3, float4, float8, float16, double, double2, double3, double4, double8, or double16 as the type for the arguments.
  • if extended with cl_khr_fp16(3clc), generic type name gentype may indicate half and half{2|3|4|8|16} as arguments and return values. πŸ¦‹
  • the generic type name gentypef is used to indicate that the function can take float, float2, float3, float4, float8, or float16 as the type for the arguments.
  • the generic type name gentyped is used to indicate that the function can take double, double2, double3, double4, double8, or double16 as 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 the native_ 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 πŸ‘€

mathFunctions(3clc)


🌟 AUTHORS 🌟

The Khronos Group


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) πŸ“Ž

  1. 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