https://github.com/rjodinchr created https://github.com/llvm/llvm-project/pull/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. >From 64826c23cfaef764c9a60600a2c0e96244c95cf6 Mon Sep 17 00:00:00 2001 From: Romaric Jodin <rjo...@chromium.org> Date: Mon, 21 Aug 2023 10:55:44 +0200 Subject: [PATCH] libclc: generic: add half implementation for erf/erfc 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. --- libclc/generic/lib/math/erf.cl | 12 ++++++++++++ libclc/generic/lib/math/erfc.cl | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libclc/generic/lib/math/erf.cl b/libclc/generic/lib/math/erf.cl index 3dc82d926e863a6..2c395ce1a75267b 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 c322f8691b3828a..cd35ea8def7b6a8 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits