POW(3clc)
β¨ POW, POWN, POWR, HAL(3clc) β¨
okay bestie, welcome to the OpenCL Manual β today we're doing exponent math and honestly? it's giving β¨ power β¨ (literally). pull up a chair, we're gonna go through every single one of these functions, no skips, no skimming, periodt. π
πΈ NAME πΈ
pow, _pown, _powr, _half_powr, _native_powr β Compute x to the power of y.
and here's the whole squad in their exact fits, no cap:
gentype pow(gentype x, gentype y);
floatn pown(floatn x, intn y);
float pown(float x, int y);
doublen pown(doublen x, intn y);
double pown(double x, int y);
gentype powr(gentype x, gentype y);
gentype half_powr(gentype x, gentype y);
gentype native_powr(gentype x, gentype y);
halfn pown(halfn x, intn y);
half pown(half x, int y);
like. look at them. iconic lineup fr fr π«Ά
π DESCRIPTION π
powβ Computes x to the power of y. the classic. the moment. πpownβ Computes x to the power of y, where y is an integer. y said "I'm built different" and locked in as an int. π’powrβ Computes x to the power of y, where x is β₯ 0. so like, keep x non-negative bestie, it's the vibe check of this function. β¨half_powrβ Computes x to the power of y, where x is β₯ 0. same energy, half precision edition πnative_powrβ Computes x to the power of y, where x is β₯ 0. heads up though: the range of x and y are implementation-defined, and the maximum error is implementation-defined too. so like, it's fast but it's mysterious. π
π NOTES π
okay this is the part where I tell you the important lore, don't skip it:
- The vector versions of the math functions operate component-wise. The description is per-component. so each lil component does its own thing, independently, living its own life π¦
- 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. they do not care what the environment is doing. unbothered. thriving. π
- The built-in math functions take scalar or vector arguments. For any specific use of these function, the actual type has to be the same for all arguments and the return type unless otherwise specified. so no mixing, bestie, the fit has to match head to toe π
- 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. that's the whole roster. π - If extended with
cl_khr_fp16(3clc), generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. half girlies rise π§ - The generic type name
gentypefis used to indicate that the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. float-only club β - The generic type name
gentypedis used to indicate that the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. double-only club, precision girlies only π - Functions with the
half_prefix are implemented with a minimum of 10-bits of accuracy i.e. an ULP value less than or equal to8192 ulp. yes that is a lot of ulp. it is what it is π - 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. so: faster, yes, but it's on the implementation to decide how accurate, and sometimes even how much input it'll accept. no promises, only vibes π«Ά
not me writing "implementation-defined" three separate times because it keeps coming up π it's coming up A LOT okay
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
π«Ά AUTHORS π«Ά
The Khronos Group
βοΈ COPYRIGHT βοΈ
Copyright Β© 2007-2010 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 244, section 6.12.2 - Math Functions
and that's the whole page bestie!! this edition of the OpenCL Manual was brought to you by The Khronos Group, dated 01/14/2021, and it's titled POW, POWN, POWR, HAL(3clc) β go forth and exponentiate responsibly πβ¨π
π¦ 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