diff options
author | Romaric Jodin <89833130+rjodinchr@users.noreply.github.com> | 2024-01-09 17:47:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 16:47:53 +0000 |
commit | 9160f49e08af4267efdc870a1c9a434bfd155ae3 (patch) | |
tree | 4eeda67fd8216a5dc4ab8ad49835a82387efc86e | |
parent | 51bf0dff53fdaca25f30d30a1c99462c7afdce74 (diff) |
libclc: generic: add half implementation for erf/erfc (#66901)
libclc does not have a half implementation for erf/erfc
Add one based on the float implementation by extending the input and
truncating the output.
-rw-r--r-- | libclc/generic/lib/math/erf.cl | 12 | ||||
-rw-r--r-- | libclc/generic/lib/math/erfc.cl | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/libclc/generic/lib/math/erf.cl b/libclc/generic/lib/math/erf.cl index 3dc82d926e86..2c395ce1a752 100644 --- a/libclc/generic/lib/math/erf.cl +++ b/libclc/generic/lib/math/erf.cl @@ -399,4 +399,16 @@ _CLC_OVERLOAD _CLC_DEF double erf(double y) { _CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, erf, double); +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half erf(half h) { + return (half)erf((float)h); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, erf, half); + +#endif + #endif diff --git a/libclc/generic/lib/math/erfc.cl b/libclc/generic/lib/math/erfc.cl index c322f8691b38..cd35ea8def7b 100644 --- a/libclc/generic/lib/math/erfc.cl +++ b/libclc/generic/lib/math/erfc.cl @@ -410,4 +410,16 @@ _CLC_OVERLOAD _CLC_DEF double erfc(double x) { _CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, erfc, double); +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half erfc(half h) { + return (half)erfc((float)h); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, erfc, half); + +#endif + #endif |