https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/132054
These functions were already nominally in the CLC namespace; this commit just formally moves them over. Note that 'half' versions of these CLC functions are now provided. Previously the corresponding OpenCL builtins would forward directly to the 'float' versions of the CLC builtins. Now the OpenCL builtins call the 'half' CLC builtins, which themselves call the 'float' CLC versions. This keeps the interface between the OpenCL and CLC libraries neater and keeps the CLC library self-contained. No changes to the generated code for non-SPIR-V targets is observed. >From c749f456ab69d57134a8789d6e0233fbfdc8ca16 Mon Sep 17 00:00:00 2001 From: Fraser Cormack <fra...@codeplay.com> Date: Wed, 19 Mar 2025 14:52:09 +0000 Subject: [PATCH 1/3] [libclc] Move __clc_remainder to CLC library It was already nominally in the CLC namespace; this commit just formally moves it over. Note that a fp16 version of __clc_remainder is now provided. It is defined as forwarding on to the fp32 version. This makes a difference in the OpenCL layer, where the fp16 remainder builtin will forward to the fp16 __clc_remainder builtin, rather than directly forwarding onto the fp32 __clc_remainder builtin. No changes to the generated code for non-SPIR-V targets is observed. --- .../include/clc/math/binary_def_via_fp32.inc | 5 ++++ libclc/clc/include/clc/math/clc_remainder.h | 12 ++++++++++ libclc/clc/include/clc/math/gentype.inc | 7 ++++-- libclc/clc/lib/generic/SOURCES | 1 + .../lib/generic}/math/clc_remainder.cl | 23 +++++++++++++++---- libclc/clspv/lib/SOURCES | 1 - libclc/generic/include/math/clc_remainder.h | 4 ---- libclc/generic/lib/SOURCES | 1 - libclc/generic/lib/math/clc_fmod.cl | 1 - libclc/generic/lib/math/clc_remquo.cl | 1 - libclc/generic/lib/math/remainder.cl | 6 ++--- libclc/spirv/lib/SOURCES | 1 - 12 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 libclc/clc/include/clc/math/binary_def_via_fp32.inc create mode 100644 libclc/clc/include/clc/math/clc_remainder.h rename libclc/{generic/lib => clc/lib/generic}/math/clc_remainder.cl (93%) delete mode 100644 libclc/generic/include/math/clc_remainder.h diff --git a/libclc/clc/include/clc/math/binary_def_via_fp32.inc b/libclc/clc/include/clc/math/binary_def_via_fp32.inc new file mode 100644 index 0000000000000..704acb0d704b1 --- /dev/null +++ b/libclc/clc/include/clc/math/binary_def_via_fp32.inc @@ -0,0 +1,5 @@ +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x, + __CLC_GENTYPE y) { + return __CLC_CONVERT_GENTYPE( + __CLC_FUNCTION(__CLC_CONVERT_FLOATN(x), __CLC_CONVERT_FLOATN(y))); +} diff --git a/libclc/clc/include/clc/math/clc_remainder.h b/libclc/clc/include/clc/math/clc_remainder.h new file mode 100644 index 0000000000000..c35c431f72098 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_remainder.h @@ -0,0 +1,12 @@ +#ifndef __CLC_MATH_CLC_REMAINDER_H__ +#define __CLC_MATH_CLC_REMAINDER_H__ + +#define __CLC_FUNCTION __clc_remainder +#define __CLC_BODY <clc/shared/binary_decl.inc> + +#include <clc/math/gentype.inc> + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_REMAINDER_H__ diff --git a/libclc/clc/include/clc/math/gentype.inc b/libclc/clc/include/clc/math/gentype.inc index c624f4d19bbcf..b2299f13cfa23 100644 --- a/libclc/clc/include/clc/math/gentype.inc +++ b/libclc/clc/include/clc/math/gentype.inc @@ -56,6 +56,7 @@ #define __CLC_CONVERT_S_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_S_GENTYPE) #define __CLC_CONVERT_U_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_U_GENTYPE) +#if (!defined(__HALF_ONLY) && !defined(__DOUBLE_ONLY)) #define __CLC_SCALAR_GENTYPE float #define __CLC_FPSIZE 32 #define __CLC_FP_LIT(x) x##F @@ -119,7 +120,9 @@ #undef __CLC_FPSIZE #undef __CLC_SCALAR_GENTYPE -#ifndef __FLOAT_ONLY +#endif + +#if (!defined(__HALF_ONLY) && !defined(__FLOAT_ONLY)) #ifdef cl_khr_fp64 #pragma OPENCL EXTENSION cl_khr_fp64 : enable @@ -188,7 +191,7 @@ #endif #endif -#ifndef __FLOAT_ONLY +#if (!defined(__FLOAT_ONLY) && !defined(__DOUBLE_ONLY)) #ifdef cl_khr_fp16 #pragma OPENCL EXTENSION cl_khr_fp16 : enable diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index f7688d0442253..a4ce61fdcda43 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -32,6 +32,7 @@ math/clc_mad.cl math/clc_modf.cl math/clc_nan.cl math/clc_nextafter.cl +math/clc_remainder.cl math/clc_rint.cl math/clc_round.cl math/clc_rsqrt.cl diff --git a/libclc/generic/lib/math/clc_remainder.cl b/libclc/clc/lib/generic/math/clc_remainder.cl similarity index 93% rename from libclc/generic/lib/math/clc_remainder.cl rename to libclc/clc/lib/generic/math/clc_remainder.cl index d517e36b53277..ffdea257637c6 100644 --- a/libclc/generic/lib/math/clc_remainder.cl +++ b/libclc/clc/lib/generic/math/clc_remainder.cl @@ -20,17 +20,17 @@ * THE SOFTWARE. */ -#include <clc/clc.h> #include <clc/clc_convert.h> #include <clc/clcmacro.h> #include <clc/integer/clc_clz.h> +#include <clc/internal/clc.h> #include <clc/math/clc_floor.h> #include <clc/math/clc_fma.h> -#include <clc/math/clc_subnormal_config.h> +#include <clc/math/clc_ldexp.h> +#include <clc/math/clc_remainder.h> #include <clc/math/clc_trunc.h> #include <clc/math/math.h> #include <clc/shared/clc_max.h> -#include <math/clc_remainder.h> _CLC_DEF _CLC_OVERLOAD float __clc_remainder(float x, float y) { int ux = __clc_as_int(x); @@ -91,6 +91,9 @@ _CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_remainder, float, float); #ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + _CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y) { ulong ux = __clc_as_ulong(x); ulong ax = ux & ~SIGNBIT_DP64; @@ -118,7 +121,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y) { // but it doesn't matter - it just means that we'll go round // the loop below one extra time. int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); - double w = ldexp(dy, ntimes * 53); + double w = __clc_ldexp(dy, ntimes * 53); w = ntimes == 0 ? dy : w; double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; @@ -221,3 +224,15 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y) { _CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_remainder, double, double); #endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define __CLC_FUNCTION __clc_remainder +#define __CLC_BODY <clc/math/binary_def_via_fp32.inc> +#include <clc/math/gentype.inc> + +#endif diff --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES index fa9e68f6985ea..0a56588947aa3 100644 --- a/libclc/clspv/lib/SOURCES +++ b/libclc/clspv/lib/SOURCES @@ -21,7 +21,6 @@ subnormal_config.cl ../../generic/lib/math/clc_pow.cl ../../generic/lib/math/clc_pown.cl ../../generic/lib/math/clc_powr.cl -../../generic/lib/math/clc_remainder.cl ../../generic/lib/math/clc_remquo.cl ../../generic/lib/math/clc_rootn.cl ../../generic/lib/math/clc_tan.cl diff --git a/libclc/generic/include/math/clc_remainder.h b/libclc/generic/include/math/clc_remainder.h deleted file mode 100644 index db084cf1c26a0..0000000000000 --- a/libclc/generic/include/math/clc_remainder.h +++ /dev/null @@ -1,4 +0,0 @@ -#define __CLC_FUNCTION __clc_remainder -#define __CLC_BODY <clc/math/binary_decl_tt.inc> -#include <clc/math/gentype.inc> -#undef __CLC_FUNCTION diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index 15aafee79dfec..dab5424c984ed 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -164,7 +164,6 @@ math/clc_pown.cl math/pown.cl math/clc_powr.cl math/powr.cl -math/clc_remainder.cl math/remainder.cl math/clc_remquo.cl math/remquo.cl diff --git a/libclc/generic/lib/math/clc_fmod.cl b/libclc/generic/lib/math/clc_fmod.cl index b33dae23550c5..b3593130face8 100644 --- a/libclc/generic/lib/math/clc_fmod.cl +++ b/libclc/generic/lib/math/clc_fmod.cl @@ -30,7 +30,6 @@ #include <clc/math/clc_trunc.h> #include <clc/math/math.h> #include <clc/shared/clc_max.h> -#include <math/clc_remainder.h> _CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) { int ux = __clc_as_int(x); diff --git a/libclc/generic/lib/math/clc_remquo.cl b/libclc/generic/lib/math/clc_remquo.cl index d2a5845bc2684..02ae4f1171e1c 100644 --- a/libclc/generic/lib/math/clc_remquo.cl +++ b/libclc/generic/lib/math/clc_remquo.cl @@ -30,7 +30,6 @@ #include <clc/math/clc_trunc.h> #include <clc/math/math.h> #include <clc/shared/clc_max.h> -#include <math/clc_remainder.h> _CLC_DEF _CLC_OVERLOAD float __clc_remquo(float x, float y, __private int *quo) { diff --git a/libclc/generic/lib/math/remainder.cl b/libclc/generic/lib/math/remainder.cl index 0a22ee8be2dd8..7692c54fa4398 100644 --- a/libclc/generic/lib/math/remainder.cl +++ b/libclc/generic/lib/math/remainder.cl @@ -1,6 +1,6 @@ #include <clc/clc.h> -#include <math/clc_remainder.h> +#include <clc/math/clc_remainder.h> -#define __CLC_FUNC remainder -#define __CLC_BODY <clc_sw_binary.inc> +#define FUNCTION remainder +#define __CLC_BODY <clc/shared/binary_def.inc> #include <clc/math/gentype.inc> diff --git a/libclc/spirv/lib/SOURCES b/libclc/spirv/lib/SOURCES index 8378587d52bf3..ff68b410ec819 100644 --- a/libclc/spirv/lib/SOURCES +++ b/libclc/spirv/lib/SOURCES @@ -66,7 +66,6 @@ math/fma.cl ../../generic/lib/math/pown.cl ../../generic/lib/math/clc_powr.cl ../../generic/lib/math/powr.cl -../../generic/lib/math/clc_remainder.cl ../../generic/lib/math/remainder.cl ../../generic/lib/math/clc_remquo.cl ../../generic/lib/math/remquo.cl >From be8f846178542f66672193ce30fb6ca3c89ebbd9 Mon Sep 17 00:00:00 2001 From: Fraser Cormack <fra...@codeplay.com> Date: Wed, 19 Mar 2025 15:01:04 +0000 Subject: [PATCH 2/3] [libclc] Move __clc_fmod to the CLC library --- libclc/clc/include/clc/math/clc_fmod.h | 12 +++++++++++ libclc/clc/lib/generic/SOURCES | 1 + .../lib => clc/lib/generic}/math/clc_fmod.cl | 21 ++++++++++++++++--- libclc/clspv/lib/SOURCES | 1 - libclc/generic/include/math/clc_fmod.h | 4 ---- libclc/generic/lib/SOURCES | 1 - libclc/generic/lib/math/fmod.cl | 6 +++--- libclc/spirv/lib/SOURCES | 1 - 8 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 libclc/clc/include/clc/math/clc_fmod.h rename libclc/{generic/lib => clc/lib/generic}/math/clc_fmod.cl (92%) delete mode 100644 libclc/generic/include/math/clc_fmod.h diff --git a/libclc/clc/include/clc/math/clc_fmod.h b/libclc/clc/include/clc/math/clc_fmod.h new file mode 100644 index 0000000000000..e5b6c0a7da905 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_fmod.h @@ -0,0 +1,12 @@ +#ifndef __CLC_MATH_CLC_FMOD_H__ +#define __CLC_MATH_CLC_FMOD_H__ + +#define __CLC_FUNCTION __clc_fmod +#define __CLC_BODY <clc/shared/binary_decl.inc> + +#include <clc/math/gentype.inc> + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_FMOD_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index a4ce61fdcda43..f00f977c479fc 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -21,6 +21,7 @@ math/clc_ceil.cl math/clc_copysign.cl math/clc_fabs.cl math/clc_fma.cl +math/clc_fmod.cl math/clc_floor.cl math/clc_frexp.cl math/clc_hypot.cl diff --git a/libclc/generic/lib/math/clc_fmod.cl b/libclc/clc/lib/generic/math/clc_fmod.cl similarity index 92% rename from libclc/generic/lib/math/clc_fmod.cl rename to libclc/clc/lib/generic/math/clc_fmod.cl index b3593130face8..830d4a1dddfc7 100644 --- a/libclc/generic/lib/math/clc_fmod.cl +++ b/libclc/clc/lib/generic/math/clc_fmod.cl @@ -20,13 +20,13 @@ * THE SOFTWARE. */ -#include <clc/clc.h> #include <clc/clc_convert.h> #include <clc/clcmacro.h> #include <clc/integer/clc_clz.h> +#include <clc/internal/clc.h> #include <clc/math/clc_floor.h> #include <clc/math/clc_fma.h> -#include <clc/math/clc_subnormal_config.h> +#include <clc/math/clc_ldexp.h> #include <clc/math/clc_trunc.h> #include <clc/math/math.h> #include <clc/shared/clc_max.h> @@ -80,6 +80,9 @@ _CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) { _CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_fmod, float, float); #ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) { ulong ux = __clc_as_ulong(x); ulong ax = ux & ~SIGNBIT_DP64; @@ -105,7 +108,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) { // but it doesn't matter - it just means that we'll go round // the loop below one extra time. int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); - double w = ldexp(dy, ntimes * 53); + double w = __clc_ldexp(dy, ntimes * 53); w = ntimes == 0 ? dy : w; double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; @@ -184,3 +187,15 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) { _CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_fmod, double, double); #endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +// Forward the half version of this builtin onto the float one +#define __HALF_ONLY +#define __CLC_FUNCTION __clc_fmod +#define __CLC_BODY <clc/math/binary_def_via_fp32.inc> +#include <clc/math/gentype.inc> + +#endif diff --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES index 0a56588947aa3..b4b6964fad1fa 100644 --- a/libclc/clspv/lib/SOURCES +++ b/libclc/clspv/lib/SOURCES @@ -17,7 +17,6 @@ subnormal_config.cl ../../generic/lib/math/atanpi.cl ../../generic/lib/math/cbrt.cl ../../generic/lib/math/clc_exp10.cl -../../generic/lib/math/clc_fmod.cl ../../generic/lib/math/clc_pow.cl ../../generic/lib/math/clc_pown.cl ../../generic/lib/math/clc_powr.cl diff --git a/libclc/generic/include/math/clc_fmod.h b/libclc/generic/include/math/clc_fmod.h deleted file mode 100644 index 0409785ee500a..0000000000000 --- a/libclc/generic/include/math/clc_fmod.h +++ /dev/null @@ -1,4 +0,0 @@ -#define __CLC_FUNCTION __clc_fmod -#define __CLC_BODY <clc/math/binary_decl_tt.inc> -#include <clc/math/gentype.inc> -#undef __CLC_FUNCTION diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index dab5424c984ed..3ccb4a3702eef 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -109,7 +109,6 @@ math/floor.cl math/fma.cl math/fmax.cl math/fmin.cl -math/clc_fmod.cl math/fmod.cl math/fract.cl math/frexp.cl diff --git a/libclc/generic/lib/math/fmod.cl b/libclc/generic/lib/math/fmod.cl index fac3fc6eb995d..19d0d7a293357 100644 --- a/libclc/generic/lib/math/fmod.cl +++ b/libclc/generic/lib/math/fmod.cl @@ -1,6 +1,6 @@ #include <clc/clc.h> -#include <math/clc_fmod.h> +#include <clc/math/clc_fmod.h> -#define __CLC_FUNC fmod -#define __CLC_BODY <clc_sw_binary.inc> +#define FUNCTION fmod +#define __CLC_BODY <clc/shared/binary_def.inc> #include <clc/math/gentype.inc> diff --git a/libclc/spirv/lib/SOURCES b/libclc/spirv/lib/SOURCES index ff68b410ec819..deaa8b972da9e 100644 --- a/libclc/spirv/lib/SOURCES +++ b/libclc/spirv/lib/SOURCES @@ -42,7 +42,6 @@ subnormal_config.cl ../../generic/lib/math/clc_exp10.cl ../../generic/lib/math/exp10.cl math/fma.cl -../../generic/lib/math/clc_fmod.cl ../../generic/lib/math/fmod.cl ../../generic/lib/math/fract.cl ../../generic/lib/math/frexp.cl >From ae2c1b1ee7b69a99d13177a74e16212abd6b1320 Mon Sep 17 00:00:00 2001 From: Fraser Cormack <fra...@codeplay.com> Date: Wed, 19 Mar 2025 15:17:27 +0000 Subject: [PATCH 3/3] [libclc] Move clc_remquo --- libclc/clc/include/clc/math/clc_remquo.h | 14 ++++++++++++++ libclc/clc/include/clc/math/remquo_decl.inc | 2 ++ libclc/clc/lib/generic/SOURCES | 1 + .../lib => clc/lib/generic}/math/clc_remquo.cl | 8 ++++++-- libclc/clspv/lib/SOURCES | 1 - libclc/generic/include/clc/math/remquo.h | 6 +++--- libclc/generic/include/clc/math/remquo.inc | 1 - libclc/generic/include/math/clc_remquo.h | 8 -------- libclc/generic/lib/SOURCES | 1 - libclc/generic/lib/math/remquo.cl | 2 +- libclc/generic/lib/math/remquo.inc | 3 ++- libclc/spirv/lib/SOURCES | 1 - 12 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 libclc/clc/include/clc/math/clc_remquo.h create mode 100644 libclc/clc/include/clc/math/remquo_decl.inc rename libclc/{generic/lib => clc/lib/generic}/math/clc_remquo.cl (98%) delete mode 100644 libclc/generic/include/clc/math/remquo.inc delete mode 100644 libclc/generic/include/math/clc_remquo.h diff --git a/libclc/clc/include/clc/math/clc_remquo.h b/libclc/clc/include/clc/math/clc_remquo.h new file mode 100644 index 0000000000000..e980b3dc0e30a --- /dev/null +++ b/libclc/clc/include/clc/math/clc_remquo.h @@ -0,0 +1,14 @@ +#ifndef __CLC_MATH_CLC_REMQUO_H__ +#define __CLC_MATH_CLC_REMQUO_H__ + +#define __CLC_FUNCTION __clc_remquo + +#define __CLC_BODY <clc/math/remquo_decl.inc> +#define __CLC_ADDRESS_SPACE private +#include <clc/math/gentype.inc> + +#undef __CLC_ADDRESS_SPACE +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_REMQUO_H__ diff --git a/libclc/clc/include/clc/math/remquo_decl.inc b/libclc/clc/include/clc/math/remquo_decl.inc new file mode 100644 index 0000000000000..04d6bebc4f944 --- /dev/null +++ b/libclc/clc/include/clc/math/remquo_decl.inc @@ -0,0 +1,2 @@ +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION( + __CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_ADDRESS_SPACE __CLC_INTN *q); diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index f00f977c479fc..87869d8972f30 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -34,6 +34,7 @@ math/clc_modf.cl math/clc_nan.cl math/clc_nextafter.cl math/clc_remainder.cl +math/clc_remquo.cl math/clc_rint.cl math/clc_round.cl math/clc_rsqrt.cl diff --git a/libclc/generic/lib/math/clc_remquo.cl b/libclc/clc/lib/generic/math/clc_remquo.cl similarity index 98% rename from libclc/generic/lib/math/clc_remquo.cl rename to libclc/clc/lib/generic/math/clc_remquo.cl index 02ae4f1171e1c..a8aef29ca9cb4 100644 --- a/libclc/generic/lib/math/clc_remquo.cl +++ b/libclc/clc/lib/generic/math/clc_remquo.cl @@ -20,12 +20,13 @@ * THE SOFTWARE. */ -#include <clc/clc.h> #include <clc/clc_convert.h> #include <clc/clcmacro.h> #include <clc/integer/clc_clz.h> +#include <clc/internal/clc.h> #include <clc/math/clc_floor.h> #include <clc/math/clc_fma.h> +#include <clc/math/clc_ldexp.h> #include <clc/math/clc_subnormal_config.h> #include <clc/math/clc_trunc.h> #include <clc/math/math.h> @@ -129,6 +130,9 @@ __VEC_REMQUO(float, 8, 4) __VEC_REMQUO(float, 16, 8) #ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + _CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, __private int *pquo) { ulong ux = __clc_as_ulong(x); @@ -157,7 +161,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, // but it doesn't matter - it just means that we'll go round // the loop below one extra time. int ntimes = __clc_max(0, (xexp1 - yexp1) / 53); - double w = ldexp(dy, ntimes * 53); + double w = __clc_ldexp(dy, ntimes * 53); w = ntimes == 0 ? dy : w; double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; diff --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES index b4b6964fad1fa..4354cb6f4b32c 100644 --- a/libclc/clspv/lib/SOURCES +++ b/libclc/clspv/lib/SOURCES @@ -20,7 +20,6 @@ subnormal_config.cl ../../generic/lib/math/clc_pow.cl ../../generic/lib/math/clc_pown.cl ../../generic/lib/math/clc_powr.cl -../../generic/lib/math/clc_remquo.cl ../../generic/lib/math/clc_rootn.cl ../../generic/lib/math/clc_tan.cl ../../generic/lib/math/clc_tanpi.cl diff --git a/libclc/generic/include/clc/math/remquo.h b/libclc/generic/include/clc/math/remquo.h index 7daf82fc34b33..ceae6dfc407b4 100644 --- a/libclc/generic/include/clc/math/remquo.h +++ b/libclc/generic/include/clc/math/remquo.h @@ -1,16 +1,16 @@ #define __CLC_FUNCTION remquo -#define __CLC_BODY <clc/math/remquo.inc> +#define __CLC_BODY <clc/math/remquo_decl.inc> #define __CLC_ADDRESS_SPACE global #include <clc/math/gentype.inc> #undef __CLC_ADDRESS_SPACE -#define __CLC_BODY <clc/math/remquo.inc> +#define __CLC_BODY <clc/math/remquo_decl.inc> #define __CLC_ADDRESS_SPACE local #include <clc/math/gentype.inc> #undef __CLC_ADDRESS_SPACE -#define __CLC_BODY <clc/math/remquo.inc> +#define __CLC_BODY <clc/math/remquo_decl.inc> #define __CLC_ADDRESS_SPACE private #include <clc/math/gentype.inc> #undef __CLC_ADDRESS_SPACE diff --git a/libclc/generic/include/clc/math/remquo.inc b/libclc/generic/include/clc/math/remquo.inc deleted file mode 100644 index 42c7b6789f5fc..0000000000000 --- a/libclc/generic/include/clc/math/remquo.inc +++ /dev/null @@ -1 +0,0 @@ -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_ADDRESS_SPACE __CLC_INTN *q); diff --git a/libclc/generic/include/math/clc_remquo.h b/libclc/generic/include/math/clc_remquo.h deleted file mode 100644 index ed57ec98edf40..0000000000000 --- a/libclc/generic/include/math/clc_remquo.h +++ /dev/null @@ -1,8 +0,0 @@ -#define __CLC_FUNCTION __clc_remquo - -#define __CLC_BODY <clc/math/remquo.inc> -#define __CLC_ADDRESS_SPACE private -#include <clc/math/gentype.inc> -#undef __CLC_ADDRESS_SPACE - -#undef __CLC_FUNCTION diff --git a/libclc/generic/lib/SOURCES b/libclc/generic/lib/SOURCES index 3ccb4a3702eef..afa4bacb7825e 100644 --- a/libclc/generic/lib/SOURCES +++ b/libclc/generic/lib/SOURCES @@ -164,7 +164,6 @@ math/pown.cl math/clc_powr.cl math/powr.cl math/remainder.cl -math/clc_remquo.cl math/remquo.cl math/rint.cl math/clc_rootn.cl diff --git a/libclc/generic/lib/math/remquo.cl b/libclc/generic/lib/math/remquo.cl index fc29b366b36ed..2a580427f251f 100644 --- a/libclc/generic/lib/math/remquo.cl +++ b/libclc/generic/lib/math/remquo.cl @@ -1,5 +1,5 @@ #include <clc/clc.h> -#include <math/clc_remquo.h> +#include <clc/math/clc_remquo.h> #define __CLC_BODY <remquo.inc> #define __CLC_ADDRESS_SPACE global diff --git a/libclc/generic/lib/math/remquo.inc b/libclc/generic/lib/math/remquo.inc index c1de78a5e7f9c..88aed4b32c4ad 100644 --- a/libclc/generic/lib/math/remquo.inc +++ b/libclc/generic/lib/math/remquo.inc @@ -1,4 +1,5 @@ -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_ADDRESS_SPACE __CLC_INTN *q) { +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y, + __CLC_ADDRESS_SPACE __CLC_INTN *q) { __CLC_INTN local_q; __CLC_GENTYPE ret = __clc_remquo(x, y, &local_q); *q = local_q; diff --git a/libclc/spirv/lib/SOURCES b/libclc/spirv/lib/SOURCES index deaa8b972da9e..0ede4a23dfbb0 100644 --- a/libclc/spirv/lib/SOURCES +++ b/libclc/spirv/lib/SOURCES @@ -66,7 +66,6 @@ math/fma.cl ../../generic/lib/math/clc_powr.cl ../../generic/lib/math/powr.cl ../../generic/lib/math/remainder.cl -../../generic/lib/math/clc_remquo.cl ../../generic/lib/math/remquo.cl ../../generic/lib/math/clc_rootn.cl ../../generic/lib/math/rootn.cl _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits