diff --git a/libclc/libspirv/lib/generic/SOURCES b/libclc/libspirv/lib/generic/SOURCES index 22d6a742004a9..76de074ec034a 100644 --- a/libclc/libspirv/lib/generic/SOURCES +++ b/libclc/libspirv/lib/generic/SOURCES @@ -65,13 +65,6 @@ math/atanh.cl math/atanpi.cl math/cbrt.cl math/ceil.cl -math/clc_exp10.cl -math/clc_fmod.cl -math/clc_remainder.cl -math/clc_remquo.cl -math/clc_rootn.cl -math/clc_tan.cl -math/clc_tanpi.cl math/copysign.cl math/cos.cl math/cosh.cl @@ -82,7 +75,6 @@ math/erfc.cl math/exp.cl math/exp10.cl math/exp2.cl -math/exp_helper.cl math/expm1.cl math/fabs.cl math/fdim.cl diff --git a/libclc/libspirv/lib/generic/math/clc_exp10.cl b/libclc/libspirv/lib/generic/math/clc_exp10.cl deleted file mode 100644 index c7cf488f28f0f..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_exp10.cl +++ /dev/null @@ -1,165 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Algorithm: -// -// e^x = 2^(x/ln(2)) = 2^(x*(64/ln(2))/64) -// -// x*(64/ln(2)) = n + f, |f| <= 0.5, n is integer -// n = 64*m + j, 0 <= j < 64 -// -// e^x = 2^((64*m + j + f)/64) -// = (2^m) * (2^(j/64)) * 2^(f/64) -// = (2^m) * (2^(j/64)) * e^(f*(ln(2)/64)) -// -// f = x*(64/ln(2)) - n -// r = f*(ln(2)/64) = x - n*(ln(2)/64) -// -// e^x = (2^m) * (2^(j/64)) * e^r -// -// (2^(j/64)) is precomputed -// -// e^r = 1 + r + (r^2)/2! + (r^3)/3! + (r^4)/4! + (r^5)/5! -// e^r = 1 + q -// -// q = r + (r^2)/2! + (r^3)/3! + (r^4)/4! + (r^5)/5! -// -// e^x = (2^m) * ( (2^(j/64)) + q*(2^(j/64)) ) - -_CLC_DEF _CLC_OVERLOAD float __clc_exp10(float x) { - // 128*log2/log10 : 38.53183944498959 - const float X_MAX = 0x1.344134p+5f; - // -149*log2/log10 : -44.8534693539332 - const float X_MIN = -0x1.66d3e8p+5f; - // 64*log10/log2 : 212.6033980727912 - const float R_64_BY_LOG10_2 = 0x1.a934f0p+7f; - // log2/(64 * log10) lead : 0.004699707 - const float R_LOG10_2_BY_64_LD = 0x1.340000p-8f; - // log2/(64 * log10) tail : 0.00000388665057 - const float R_LOG10_2_BY_64_TL = 0x1.04d426p-18f; - const float R_LN10 = 0x1.26bb1cp+1f; - - int return_nan = __clc_isnan(x); - int return_inf = x > X_MAX; - int return_zero = x < X_MIN; - - int n = __clc_convert_int(x * R_64_BY_LOG10_2); - - float fn = (float)n; - int j = n & 0x3f; - int m = n >> 6; - int m2 = m << EXPSHIFTBITS_SP32; - float r; - - r = R_LN10 * - __clc_mad(fn, -R_LOG10_2_BY_64_TL, __clc_mad(fn, -R_LOG10_2_BY_64_LD, x)); - - // Truncated Taylor series for e^r - float z2 = __clc_mad(__clc_mad(__clc_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), - r, 0x1.000000p-1f), - r * r, r); - - float two_to_jby64 = USE_TABLE(exp_tbl, j); - z2 = __clc_mad(two_to_jby64, z2, two_to_jby64); - - float z2s = z2 * __clc_as_float(0x1 << (m + 149)); - float z2n = __clc_as_float(__clc_as_int(z2) + m2); - z2 = m <= -126 ? z2s : z2n; - - z2 = return_inf ? __clc_as_float(PINFBITPATT_SP32) : z2; - z2 = return_zero ? 0.0f : z2; - z2 = return_nan ? x : z2; - return z2; -} -_CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_exp10, float) - -#ifdef cl_khr_fp64 -_CLC_DEF _CLC_OVERLOAD double __clc_exp10(double x) { - // 1024*ln(2)/ln(10) - const double X_MAX = 0x1.34413509f79ffp+8; - // -1074*ln(2)/ln(10) - const double X_MIN = -0x1.434e6420f4374p+8; - // 64*ln(10)/ln(2) - const double R_64_BY_LOG10_2 = 0x1.a934f0979a371p+7; - // head ln(2)/(64*ln(10)) - const double R_LOG10_2_BY_64_LD = 0x1.3441350000000p-8; - // tail ln(2)/(64*ln(10)) - const double R_LOG10_2_BY_64_TL = 0x1.3ef3fde623e25p-37; - // ln(10) - const double R_LN10 = 0x1.26bb1bbb55516p+1; - - int n = __clc_convert_int(x * R_64_BY_LOG10_2); - - double dn = (double)n; - - int j = n & 0x3f; - int m = n >> 6; - - double r = - R_LN10 * __spirv_ocl_fma(-R_LOG10_2_BY_64_TL, dn, - __spirv_ocl_fma(-R_LOG10_2_BY_64_LD, dn, x)); - - // 6 term tail of Taylor expansion of e^r - double z2 = - r * __spirv_ocl_fma( - r, - __spirv_ocl_fma( - r, - __spirv_ocl_fma( - r, - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, 0x1.6c16c16c16c17p-10, - 0x1.1111111111111p-7), - 0x1.5555555555555p-5), - 0x1.5555555555555p-3), - 0x1.0000000000000p-1), - 1.0); - - double2 tv; - tv.s0 = USE_TABLE(two_to_jby64_ep_tbl_head, j); - tv.s1 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); - z2 = __spirv_ocl_fma(tv.s0 + tv.s1, z2, tv.s1) + tv.s0; - - int small_value = (m < -1022) || ((m == -1022) && (z2 < 1.0)); - - int n1 = m >> 2; - int n2 = m - n1; - double z3 = z2 * __clc_as_double(((long)n1 + 1023) << 52); - z3 *= __clc_as_double(((long)n2 + 1023) << 52); - - z2 = __spirv_ocl_ldexp(z2, m); - z2 = small_value ? z3 : z2; - - z2 = __clc_isnan(x) ? x : z2; - - z2 = x > X_MAX ? __clc_as_double(PINFBITPATT_DP64) : z2; - z2 = x < X_MIN ? 0.0 : z2; - - return z2; -} -_CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_exp10, double) -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_UNARY_BUILTIN_SCALARIZE(half, __clc_exp10, __builtin_exp10f16, half) - -#endif diff --git a/libclc/libspirv/lib/generic/math/clc_fmod.cl b/libclc/libspirv/lib/generic/math/clc_fmod.cl deleted file mode 100644 index 7e1730c703835..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_fmod.cl +++ /dev/null @@ -1,176 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include - -_CLC_DEF _CLC_OVERLOAD float __clc_fmod(float x, float y) { - int ux = __clc_as_int(x); - int ax = ux & EXSIGNBIT_SP32; - float xa = __clc_as_float(ax); - int sx = ux ^ ax; - int ex = ax >> EXPSHIFTBITS_SP32; - - int uy = __clc_as_int(y); - int ay = uy & EXSIGNBIT_SP32; - float ya = __clc_as_float(ay); - int ey = ay >> EXPSHIFTBITS_SP32; - - float xr = __clc_as_float(0x3f800000 | (ax & 0x007fffff)); - float yr = __clc_as_float(0x3f800000 | (ay & 0x007fffff)); - int c; - int k = ex - ey; - - while (k > 0) { - c = xr >= yr; - xr -= c ? yr : 0.0f; - xr += xr; - --k; - } - - c = xr >= yr; - xr -= c ? yr : 0.0f; - - int lt = ex < ey; - - xr = lt ? xa : xr; - yr = lt ? ya : yr; - - float s = __clc_as_float(ey << EXPSHIFTBITS_SP32); - xr *= lt ? 1.0f : s; - - c = ax == ay; - xr = c ? 0.0f : xr; - - xr = __clc_as_float(sx ^ __clc_as_int(xr)); - - c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | - ay == 0; - xr = c ? __clc_as_float(QNANBITPATT_SP32) : xr; - - return xr; -} -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_fmod, float, float); - -#ifdef cl_khr_fp64 -_CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y) { - ulong ux = __clc_as_ulong(x); - ulong ax = ux & ~SIGNBIT_DP64; - ulong xsgn = ux ^ ax; - double dx = __clc_as_double(ax); - int xexp = __spirv_SatConvertUToS_Rint(ax >> EXPSHIFTBITS_DP64); - int xexp1 = 11 - (int)__spirv_ocl_clz(ax & MANTBITS_DP64); - xexp1 = xexp < 1 ? xexp1 : xexp; - - ulong uy = __clc_as_ulong(y); - ulong ay = uy & ~SIGNBIT_DP64; - double dy = __clc_as_double(ay); - int yexp = __spirv_SatConvertUToS_Rint(ay >> EXPSHIFTBITS_DP64); - int yexp1 = 11 - (int)__spirv_ocl_clz(ay & MANTBITS_DP64); - yexp1 = yexp < 1 ? yexp1 : yexp; - - // First assume |x| > |y| - - // Set ntimes to the number of times we need to do a - // partial remainder. If the exponent of x is an exact multiple - // of 53 larger than the exponent of y, and the mantissa of x is - // less than the mantissa of y, ntimes will be one too large - // but it doesn't matter - it just means that we'll go round - // the loop below one extra time. - int ntimes = __spirv_ocl_s_max(0, (xexp1 - yexp1) / 53); - double w = __spirv_ocl_ldexp(dy, ntimes * 53); - w = ntimes == 0 ? dy : w; - double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; - - // Each time round the loop we compute a partial remainder. - // This is done by subtracting a large multiple of w - // from x each time, where w is a scaled up version of y. - // The subtraction must be performed exactly in quad - // precision, though the result at each stage can - // fit exactly in a double precision number. - int i; - double t, v, p, pp; - - for (i = 0; i < ntimes; i++) { - // Compute integral multiplier - t = __spirv_ocl_trunc(dx / w); - - // Compute w * t in quad precision - p = w * t; - pp = __spirv_ocl_fma(w, t, -p); - - // Subtract w * t from dx - v = dx - p; - dx = v + (((dx - v) - p) - pp); - - // If t was one too large, dx will be negative. Add back one w. - dx += dx < 0.0 ? w : 0.0; - - // Scale w down by 2^(-53) for the next iteration - w *= scale; - } - - // One more time - // Variable todd says whether the integer t is odd or not - t = __spirv_ocl_floor(dx / w); - long lt = (long)t; - int todd = lt & 1; - - p = w * t; - pp = __spirv_ocl_fma(w, t, -p); - v = dx - p; - dx = v + (((dx - v) - p) - pp); - i = dx < 0.0; - todd ^= i; - dx += i ? w : 0.0; - - // At this point, dx lies in the range [0,dy) - double ret = __clc_as_double(xsgn ^ __clc_as_ulong(dx)); - dx = __clc_as_double(ax); - - // Now handle |x| == |y| - int c = dx == dy; - t = __clc_as_double(xsgn); - ret = c ? t : ret; - - // Next, handle |x| < |y| - c = dx < dy; - ret = c ? x : ret; - - // We don't need anything special for |x| == 0 - - // |y| is 0 - c = dy == 0.0; - ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; - - // y is +-Inf, NaN - c = yexp > BIASEDEMAX_DP64; - t = y == y ? x : y; - ret = c ? t : ret; - - // x is +=Inf, NaN - c = xexp > BIASEDEMAX_DP64; - ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; - - return ret; -} -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_fmod, double, - double); -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_BINARY_BUILTIN(half, __clc_fmod, __builtin_fmodf16, half, half) - -#endif diff --git a/libclc/libspirv/lib/generic/math/clc_remainder.cl b/libclc/libspirv/lib/generic/math/clc_remainder.cl deleted file mode 100644 index 7588061e7fc7c..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_remainder.cl +++ /dev/null @@ -1,213 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include - -_CLC_DEF _CLC_OVERLOAD float __clc_remainder(float x, float y) { - int ux = __clc_as_int(x); - int ax = ux & EXSIGNBIT_SP32; - float xa = __clc_as_float(ax); - int sx = ux ^ ax; - int ex = ax >> EXPSHIFTBITS_SP32; - - int uy = __clc_as_int(y); - int ay = uy & EXSIGNBIT_SP32; - float ya = __clc_as_float(ay); - int ey = ay >> EXPSHIFTBITS_SP32; - - float xr = __clc_as_float(0x3f800000 | (ax & 0x007fffff)); - float yr = __clc_as_float(0x3f800000 | (ay & 0x007fffff)); - int c; - int k = ex - ey; - - uint q = 0; - - while (k > 0) { - c = xr >= yr; - q = (q << 1) | c; - xr -= c ? yr : 0.0f; - xr += xr; - --k; - } - - c = xr > yr; - q = (q << 1) | c; - xr -= c ? yr : 0.0f; - - int lt = ex < ey; - - q = lt ? 0 : q; - xr = lt ? xa : xr; - yr = lt ? ya : yr; - - c = (yr < 2.0f * xr) | ((yr == 2.0f * xr) & ((q & 0x1) == 0x1)); - xr -= c ? yr : 0.0f; - q += c; - - float s = __clc_as_float(ey << EXPSHIFTBITS_SP32); - xr *= lt ? 1.0f : s; - - c = ax == ay; - xr = c ? 0.0f : xr; - - xr = __clc_as_float(sx ^ __clc_as_int(xr)); - - c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | - ay == 0; - xr = c ? __clc_as_float(QNANBITPATT_SP32) : xr; - - return xr; -} -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_remainder, float, - float); - -#ifdef cl_khr_fp64 -_CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y) { - ulong ux = __clc_as_ulong(x); - ulong ax = ux & ~SIGNBIT_DP64; - ulong xsgn = ux ^ ax; - double dx = __clc_as_double(ax); - int xexp = __spirv_SatConvertUToS_Rint(ax >> EXPSHIFTBITS_DP64); - int xexp1 = 11 - (int)__spirv_ocl_clz(ax & MANTBITS_DP64); - xexp1 = xexp < 1 ? xexp1 : xexp; - - ulong uy = __clc_as_ulong(y); - ulong ay = uy & ~SIGNBIT_DP64; - double dy = __clc_as_double(ay); - int yexp = __spirv_SatConvertUToS_Rint(ay >> EXPSHIFTBITS_DP64); - int yexp1 = 11 - (int)__spirv_ocl_clz(ay & MANTBITS_DP64); - yexp1 = yexp < 1 ? yexp1 : yexp; - - int qsgn = ((ux ^ uy) & SIGNBIT_DP64) == 0UL ? 1 : -1; - - // First assume |x| > |y| - - // Set ntimes to the number of times we need to do a - // partial remainder. If the exponent of x is an exact multiple - // of 53 larger than the exponent of y, and the mantissa of x is - // less than the mantissa of y, ntimes will be one too large - // but it doesn't matter - it just means that we'll go round - // the loop below one extra time. - int ntimes = __spirv_ocl_s_max(0, (xexp1 - yexp1) / 53); - double w = __spirv_ocl_ldexp(dy, ntimes * 53); - w = ntimes == 0 ? dy : w; - double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; - - // Each time round the loop we compute a partial remainder. - // This is done by subtracting a large multiple of w - // from x each time, where w is a scaled up version of y. - // The subtraction must be performed exactly in quad - // precision, though the result at each stage can - // fit exactly in a double precision number. - int i; - double t, v, p, pp; - - for (i = 0; i < ntimes; i++) { - // Compute integral multiplier - t = __spirv_ocl_trunc(dx / w); - - // Compute w * t in quad precision - p = w * t; - pp = __spirv_ocl_fma(w, t, -p); - - // Subtract w * t from dx - v = dx - p; - dx = v + (((dx - v) - p) - pp); - - // If t was one too large, dx will be negative. Add back one w. - dx += dx < 0.0 ? w : 0.0; - - // Scale w down by 2^(-53) for the next iteration - w *= scale; - } - - // One more time - // Variable todd says whether the integer t is odd or not - t = __spirv_ocl_floor(dx / w); - long lt = (long)t; - int todd = lt & 1; - - p = w * t; - pp = __spirv_ocl_fma(w, t, -p); - v = dx - p; - dx = v + (((dx - v) - p) - pp); - i = dx < 0.0; - todd ^= i; - dx += i ? w : 0.0; - - // At this point, dx lies in the range [0,dy) - - // For the fmod function, we're done apart from setting the correct sign. - // - // For the remainder function, we need to adjust dx - // so that it lies in the range (-y/2, y/2] by carefully - // subtracting w (== dy == y) if necessary. The rigmarole - // with todd is to get the correct sign of the result - // when x/y lies exactly half way between two integers, - // when we need to choose the even integer. - - int al = (2.0 * dx > w) | (todd & (2.0 * dx == w)); - double dxl = dx - (al ? w : 0.0); - - int ag = (dx > 0.5 * w) | (todd & (dx == 0.5 * w)); - double dxg = dx - (ag ? w : 0.0); - - dx = dy < 0x1.0p+1022 ? dxl : dxg; - - double ret = __clc_as_double(xsgn ^ __clc_as_ulong(dx)); - dx = __clc_as_double(ax); - - // Now handle |x| == |y| - int c = dx == dy; - t = __clc_as_double(xsgn); - ret = c ? t : ret; - - // Next, handle |x| < |y| - c = dx < dy; - ret = c ? x : ret; - - c &= (yexp<1023 & 2.0 * dx> dy) | (dx > 0.5 * dy); - // we could use a conversion here instead since qsgn = +-1 - p = qsgn == 1 ? -1.0 : 1.0; - t = __spirv_ocl_fma(y, p, x); - ret = c ? t : ret; - - // We don't need anything special for |x| == 0 - - // |y| is 0 - c = dy == 0.0; - ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; - - // y is +-Inf, NaN - c = yexp > BIASEDEMAX_DP64; - t = y == y ? x : y; - ret = c ? t : ret; - - // x is +=Inf, NaN - c = xexp > BIASEDEMAX_DP64; - ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; - - return ret; -} -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_remainder, double, - double); -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_BINARY_BUILTIN(half, __clc_remainder, __builtin_remainderf, half, - half) - -#endif diff --git a/libclc/libspirv/lib/generic/math/clc_remquo.cl b/libclc/libspirv/lib/generic/math/clc_remquo.cl deleted file mode 100644 index 98fce13ea5e1e..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_remquo.cl +++ /dev/null @@ -1,257 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include - -_CLC_DEF _CLC_OVERLOAD float __clc_remquo(float x, float y, - __private int *quo) { - x = __clc_flush_denormal_if_not_supported(x); - y = __clc_flush_denormal_if_not_supported(y); - int ux = __clc_as_int(x); - int ax = ux & EXSIGNBIT_SP32; - float xa = __clc_as_float(ax); - int sx = ux ^ ax; - int ex = ax >> EXPSHIFTBITS_SP32; - - int uy = __clc_as_int(y); - int ay = uy & EXSIGNBIT_SP32; - float ya = __clc_as_float(ay); - int sy = uy ^ ay; - int ey = ay >> EXPSHIFTBITS_SP32; - - float xr = __clc_as_float(0x3f800000 | (ax & 0x007fffff)); - float yr = __clc_as_float(0x3f800000 | (ay & 0x007fffff)); - int c; - int k = ex - ey; - - uint q = 0; - - while (k > 0) { - c = xr >= yr; - q = (q << 1) | c; - xr -= c ? yr : 0.0f; - xr += xr; - --k; - } - - c = xr > yr; - q = (q << 1) | c; - xr -= c ? yr : 0.0f; - - int lt = ex < ey; - - q = lt ? 0 : q; - xr = lt ? xa : xr; - yr = lt ? ya : yr; - - c = (yr < 2.0f * xr) | ((yr == 2.0f * xr) & ((q & 0x1) == 0x1)); - xr -= c ? yr : 0.0f; - q += c; - - float s = __clc_as_float(ey << EXPSHIFTBITS_SP32); - xr *= lt ? 1.0f : s; - - int qsgn = sx == sy ? 1 : -1; - int quot = (q & 0x7f) * qsgn; - - c = ax == ay; - quot = c ? qsgn : quot; - xr = c ? 0.0f : xr; - - xr = __clc_as_float(sx ^ __clc_as_int(xr)); - - c = ax > PINFBITPATT_SP32 | ay > PINFBITPATT_SP32 | ax == PINFBITPATT_SP32 | - ay == 0; - quot = c ? 0 : quot; - xr = c ? __clc_as_float(QNANBITPATT_SP32) : xr; - - *quo = quot; - - return xr; -} -// remquo singature is special, we don't have macro for this -#define __VEC_REMQUO(TYPE, VEC_SIZE, HALF_VEC_SIZE) \ - _CLC_DEF _CLC_OVERLOAD TYPE##VEC_SIZE __clc_remquo( \ - TYPE##VEC_SIZE x, TYPE##VEC_SIZE y, __private int##VEC_SIZE *quo) { \ - int##HALF_VEC_SIZE lo, hi; \ - TYPE##VEC_SIZE ret; \ - ret.lo = __clc_remquo(x.lo, y.lo, &lo); \ - ret.hi = __clc_remquo(x.hi, y.hi, &hi); \ - (*quo).lo = lo; \ - (*quo).hi = hi; \ - return ret; \ - } -__VEC_REMQUO(float, 2, ) -__VEC_REMQUO(float, 3, 2) -__VEC_REMQUO(float, 4, 2) -__VEC_REMQUO(float, 8, 4) -__VEC_REMQUO(float, 16, 8) - -#ifdef cl_khr_fp64 -_CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, - __private int *pquo) { - ulong ux = __clc_as_ulong(x); - ulong ax = ux & ~SIGNBIT_DP64; - ulong xsgn = ux ^ ax; - double dx = __clc_as_double(ax); - int xexp = __spirv_SatConvertUToS_Rint(ax >> EXPSHIFTBITS_DP64); - int xexp1 = 11 - (int)__spirv_ocl_clz(ax & MANTBITS_DP64); - xexp1 = xexp < 1 ? xexp1 : xexp; - - ulong uy = __clc_as_ulong(y); - ulong ay = uy & ~SIGNBIT_DP64; - double dy = __clc_as_double(ay); - int yexp = __spirv_SatConvertUToS_Rint(ay >> EXPSHIFTBITS_DP64); - int yexp1 = 11 - (int)__spirv_ocl_clz(ay & MANTBITS_DP64); - yexp1 = yexp < 1 ? yexp1 : yexp; - - int qsgn = ((ux ^ uy) & SIGNBIT_DP64) == 0UL ? 1 : -1; - - // First assume |x| > |y| - - // Set ntimes to the number of times we need to do a - // partial remainder. If the exponent of x is an exact multiple - // of 53 larger than the exponent of y, and the mantissa of x is - // less than the mantissa of y, ntimes will be one too large - // but it doesn't matter - it just means that we'll go round - // the loop below one extra time. - int ntimes = __spirv_ocl_s_max(0, (xexp1 - yexp1) / 53); - double w = __spirv_ocl_ldexp(dy, ntimes * 53); - w = ntimes == 0 ? dy : w; - double scale = ntimes == 0 ? 1.0 : 0x1.0p-53; - - // Each time round the loop we compute a partial remainder. - // This is done by subtracting a large multiple of w - // from x each time, where w is a scaled up version of y. - // The subtraction must be performed exactly in quad - // precision, though the result at each stage can - // fit exactly in a double precision number. - int i; - double t, v, p, pp; - - for (i = 0; i < ntimes; i++) { - // Compute integral multiplier - t = __spirv_ocl_trunc(dx / w); - - // Compute w * t in quad precision - p = w * t; - pp = __spirv_ocl_fma(w, t, -p); - - // Subtract w * t from dx - v = dx - p; - dx = v + (((dx - v) - p) - pp); - - // If t was one too large, dx will be negative. Add back one w. - dx += dx < 0.0 ? w : 0.0; - - // Scale w down by 2^(-53) for the next iteration - w *= scale; - } - - // One more time - // Variable todd says whether the integer t is odd or not - t = __spirv_ocl_floor(dx / w); - long lt = (long)t; - int todd = lt & 1; - - p = w * t; - pp = __spirv_ocl_fma(w, t, -p); - v = dx - p; - dx = v + (((dx - v) - p) - pp); - i = dx < 0.0; - todd ^= i; - dx += i ? w : 0.0; - - lt -= i; - - // At this point, dx lies in the range [0,dy) - - // For the remainder function, we need to adjust dx - // so that it lies in the range (-y/2, y/2] by carefully - // subtracting w (== dy == y) if necessary. The rigmarole - // with todd is to get the correct sign of the result - // when x/y lies exactly half way between two integers, - // when we need to choose the even integer. - - int al = (2.0 * dx > w) | (todd & (2.0 * dx == w)); - double dxl = dx - (al ? w : 0.0); - - int ag = (dx > 0.5 * w) | (todd & (dx == 0.5 * w)); - double dxg = dx - (ag ? w : 0.0); - - dx = dy < 0x1.0p+1022 ? dxl : dxg; - lt += dy < 0x1.0p+1022 ? al : ag; - int quo = ((int)lt & 0x7f) * qsgn; - - double ret = __clc_as_double(xsgn ^ __clc_as_ulong(dx)); - dx = __clc_as_double(ax); - - // Now handle |x| == |y| - int c = dx == dy; - t = __clc_as_double(xsgn); - quo = c ? qsgn : quo; - ret = c ? t : ret; - - // Next, handle |x| < |y| - c = dx < dy; - quo = c ? 0 : quo; - ret = c ? x : ret; - - c &= (yexp<1023 & 2.0 * dx> dy) | (dx > 0.5 * dy); - quo = c ? qsgn : quo; - // we could use a conversion here instead since qsgn = +-1 - p = qsgn == 1 ? -1.0 : 1.0; - t = __spirv_ocl_fma(y, p, x); - ret = c ? t : ret; - - // We don't need anything special for |x| == 0 - - // |y| is 0 - c = dy == 0.0; - quo = c ? 0 : quo; - ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; - - // y is +-Inf, NaN - c = yexp > BIASEDEMAX_DP64; - quo = c ? 0 : quo; - t = y == y ? x : y; - ret = c ? t : ret; - - // x is +=Inf, NaN - c = xexp > BIASEDEMAX_DP64; - quo = c ? 0 : quo; - ret = c ? __clc_as_double(QNANBITPATT_DP64) : ret; - - *pquo = quo; - return ret; -} -__VEC_REMQUO(double, 2, ) -__VEC_REMQUO(double, 3, 2) -__VEC_REMQUO(double, 4, 2) -__VEC_REMQUO(double, 8, 4) -__VEC_REMQUO(double, 16, 8) -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half __clc_remquo(half x, half y, __private int *pquo) { - return __clc_remquo((float)x, (float)y, pquo); -} - -__VEC_REMQUO(half, 2, ) -__VEC_REMQUO(half, 3, 2) -__VEC_REMQUO(half, 4, 2) -__VEC_REMQUO(half, 8, 4) -__VEC_REMQUO(half, 16, 8) -#endif diff --git a/libclc/libspirv/lib/generic/math/clc_rootn.cl b/libclc/libspirv/lib/generic/math/clc_rootn.cl deleted file mode 100644 index 3200cf73dcb16..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_rootn.cl +++ /dev/null @@ -1,408 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include - -// compute pow using log and exp -// x^y = exp(y * log(x)) -// -// we take care not to lose precision in the intermediate steps -// -// When computing log, calculate it in splits, -// -// r = f * (p_invead + p_inv_tail) -// r = rh + rt -// -// calculate log polynomial using r, in end addition, do -// poly = poly + ((rh-r) + rt) -// -// lth = -r -// ltt = ((xexp * log2_t) - poly) + logT -// lt = lth + ltt -// -// lh = (xexp * log2_h) + logH -// l = lh + lt -// -// Calculate final log answer as gh and gt, -// gh = l & higher-half bits -// gt = (((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh)) -// -// yh = y & higher-half bits -// yt = y - yh -// -// Before entering computation of exp, -// vs = ((yt*gt + yt*gh) + yh*gt) -// v = vs + yh*gh -// vt = ((yh*gh - v) + vs) -// -// In calculation of exp, add vt to r that is used for poly -// At the end of exp, do -// ((((expT * poly) + expT) + expH*poly) + expH) - -_CLC_DEF _CLC_OVERLOAD float __clc_rootn(float x, int ny) { - float y = MATH_RECIP((float)ny); - - int ix = __clc_as_int(x); - int ax = ix & EXSIGNBIT_SP32; - int xpos = ix == ax; - - int iy = __clc_as_int(y); - int ay = iy & EXSIGNBIT_SP32; - int ypos = iy == ay; - - // Extra precise log calculation - // First handle case that x is close to 1 - float r = 1.0f - __clc_as_float(ax); - int near1 = __spirv_ocl_fabs(r) < 0x1.0p-4f; - float r2 = r * r; - - // Coefficients are just 1/3, 1/4, 1/5 and 1/6 - float poly = __spirv_ocl_mad( - r, - __spirv_ocl_mad( - r, - __spirv_ocl_mad(r, __spirv_ocl_mad(r, 0x1.24924ap-3f, 0x1.555556p-3f), - 0x1.99999ap-3f), - 0x1.000000p-2f), - 0x1.555556p-2f); - - poly *= r2 * r; - - float lth_near1 = -r2 * 0.5f; - float ltt_near1 = -poly; - float lt_near1 = lth_near1 + ltt_near1; - float lh_near1 = -r; - float l_near1 = lh_near1 + lt_near1; - - // Computations for x not near 1 - int m = (int)(ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; - float mf = (float)m; - int ixs = __clc_as_int(__clc_as_float(ax | 0x3f800000) - 1.0f); - float mfs = (float)((ixs >> EXPSHIFTBITS_SP32) - 253); - int c = m == -127; - int ixn = c ? ixs : ax; - float mfn = c ? mfs : mf; - - int indx = (ixn & 0x007f0000) + ((ixn & 0x00008000) << 1); - - // F - Y - float f = __clc_as_float(0x3f000000 | indx) - - __clc_as_float(0x3f000000 | (ixn & MANTBITS_SP32)); - - indx = indx >> 16; - float2 tv; - tv.s0 = USE_TABLE(log_inv_tbl_ep_head, indx); - tv.s1 = USE_TABLE(log_inv_tbl_ep_tail, indx); - float rh = f * tv.s0; - float rt = f * tv.s1; - r = rh + rt; - - poly = __spirv_ocl_mad(r, __spirv_ocl_mad(r, 0x1.0p-2f, 0x1.555556p-2f), - 0x1.0p-1f) * - (r * r); - poly += (rh - r) + rt; - - const float LOG2_HEAD = 0x1.62e000p-1f; // 0.693115234 - const float LOG2_TAIL = 0x1.0bfbe8p-15f; // 0.0000319461833 - tv.s0 = USE_TABLE(loge_tbl_lo, indx); - tv.s1 = USE_TABLE(loge_tbl_hi, indx); - float lth = -r; - float ltt = __spirv_ocl_mad(mfn, LOG2_TAIL, -poly) + tv.s1; - float lt = lth + ltt; - float lh = __spirv_ocl_mad(mfn, LOG2_HEAD, tv.s0); - float l = lh + lt; - - // Select near 1 or not - lth = near1 ? lth_near1 : lth; - ltt = near1 ? ltt_near1 : ltt; - lt = near1 ? lt_near1 : lt; - lh = near1 ? lh_near1 : lh; - l = near1 ? l_near1 : l; - - float gh = __clc_as_float(__clc_as_int(l) & 0xfffff000); - float gt = ((ltt - (lt - lth)) + ((lh - l) + lt)) + (l - gh); - - float yh = __clc_as_float(iy & 0xfffff000); - - float fny = (float)ny; - float fnyh = __clc_as_float(__clc_as_int(fny) & 0xfffff000); - float fnyt = (float)(ny - (int)fnyh); - float yt = MATH_DIVIDE( - __spirv_ocl_mad(-fnyt, yh, __spirv_ocl_mad(-fnyh, yh, 1.0f)), fny); - - float ylogx_s = __spirv_ocl_mad(gt, yh, __spirv_ocl_mad(gh, yt, yt * gt)); - float ylogx = __spirv_ocl_mad(yh, gh, ylogx_s); - float ylogx_t = __spirv_ocl_mad(yh, gh, -ylogx) + ylogx_s; - - // Extra precise exp of ylogx - const float R_64_BY_LOG2 = 0x1.715476p+6f; // 64/log2 : 92.332482616893657 - int n = __spirv_ConvertFToS_Rint(ylogx * R_64_BY_LOG2); - float nf = (float)n; - - int j = n & 0x3f; - m = n >> 6; - int m2 = m << EXPSHIFTBITS_SP32; - - const float R_LOG2_BY_64_LD = 0x1.620000p-7f; // log2/64 lead: 0.0108032227 - const float R_LOG2_BY_64_TL = - 0x1.c85fdep-16f; // log2/64 tail: 0.0000272020388 - r = __spirv_ocl_mad(nf, -R_LOG2_BY_64_TL, - __spirv_ocl_mad(nf, -R_LOG2_BY_64_LD, ylogx)) + - ylogx_t; - - // Truncated Taylor series for e^r - poly = __spirv_ocl_mad( - __spirv_ocl_mad(__spirv_ocl_mad(r, 0x1.555556p-5f, 0x1.555556p-3f), r, - 0x1.000000p-1f), - r * r, r); - - tv.s0 = USE_TABLE(exp_tbl_ep_head, j); - tv.s1 = USE_TABLE(exp_tbl_ep_tail, j); - - float expylogx = - __spirv_ocl_mad(tv.s0, poly, __spirv_ocl_mad(tv.s1, poly, tv.s1)) + tv.s0; - float sexpylogx = __clc_fp32_subnormals_supported() - ? expylogx * __clc_as_float(0x1 << (m + 149)) - : 0.0f; - - float texpylogx = __clc_as_float(__clc_as_int(expylogx) + m2); - expylogx = m < -125 ? sexpylogx : texpylogx; - - // Result is +-Inf if (ylogx + ylogx_t) > 128*log2 - expylogx = ((ylogx > 0x1.62e430p+6f) | - (ylogx == 0x1.62e430p+6f & ylogx_t > -0x1.05c610p-22f)) - ? __clc_as_float(PINFBITPATT_SP32) - : expylogx; - - // Result is 0 if ylogx < -149*log2 - expylogx = ylogx < -0x1.9d1da0p+6f ? 0.0f : expylogx; - - // Classify y: - // inty = 0 means not an integer. - // inty = 1 means odd integer. - // inty = 2 means even integer. - - int inty = 2 - (ny & 1); - - float signval = __clc_as_float((__clc_as_uint(expylogx) ^ SIGNBIT_SP32)); - expylogx = ((inty == 1) & !xpos) ? signval : expylogx; - int ret = __clc_as_int(expylogx); - - // Corner case handling - ret = (!xpos & (inty == 2)) ? QNANBITPATT_SP32 : ret; - int xinf = xpos ? PINFBITPATT_SP32 : NINFBITPATT_SP32; - ret = ((ax == 0) & !ypos & (inty == 1)) ? xinf : ret; - ret = ((ax == 0) & !ypos & (inty == 2)) ? PINFBITPATT_SP32 : ret; - ret = ((ax == 0) & ypos & (inty == 2)) ? 0 : ret; - int xzero = xpos ? 0 : 0x80000000; - ret = ((ax == 0) & ypos & (inty == 1)) ? xzero : ret; - ret = - ((ix == NINFBITPATT_SP32) & ypos & (inty == 1)) ? NINFBITPATT_SP32 : ret; - ret = ((ix == NINFBITPATT_SP32) & !ypos & (inty == 1)) ? 0x80000000 : ret; - ret = ((ix == PINFBITPATT_SP32) & !ypos) ? 0 : ret; - ret = ((ix == PINFBITPATT_SP32) & ypos) ? PINFBITPATT_SP32 : ret; - ret = ax > PINFBITPATT_SP32 ? ix : ret; - ret = ny == 0 ? QNANBITPATT_SP32 : ret; - - return __clc_as_float(ret); -} -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_rootn, float, int) - -#ifdef cl_khr_fp64 -_CLC_DEF _CLC_OVERLOAD double __clc_rootn(double x, int ny) { - const double real_log2_tail = 5.76999904754328540596e-08; - const double real_log2_lead = 6.93147122859954833984e-01; - - double dny = (double)ny; - double y = 1.0 / dny; - - long ux = __clc_as_long(x); - long ax = ux & (~SIGNBIT_DP64); - int xpos = ax == ux; - - long uy = __clc_as_long(y); - long ay = uy & (~SIGNBIT_DP64); - int ypos = ay == uy; - - // Extended precision log - double v, vt; - { - int exp = (int)(ax >> 52) - 1023; - int mask_exp_1023 = exp == -1023; - double xexp = (double)exp; - long mantissa = ax & 0x000FFFFFFFFFFFFFL; - - long temp_ux = __clc_as_long(__clc_as_double(0x3ff0000000000000L | mantissa) - 1.0); - exp = ((temp_ux & 0x7FF0000000000000L) >> 52) - 2045; - double xexp1 = (double)exp; - long mantissa1 = temp_ux & 0x000FFFFFFFFFFFFFL; - - xexp = mask_exp_1023 ? xexp1 : xexp; - mantissa = mask_exp_1023 ? mantissa1 : mantissa; - - long rax = (mantissa & 0x000ff00000000000) + - ((mantissa & 0x0000080000000000) << 1); - int index = rax >> 44; - - double F = __clc_as_double(rax | 0x3FE0000000000000L); - double Y = __clc_as_double(mantissa | 0x3FE0000000000000L); - double f = F - Y; - double2 tv; - tv.s0 = USE_TABLE(log_f_inv_tbl_head, index); - tv.s1 = USE_TABLE(log_f_inv_tbl_tail, index); - double log_h = tv.s0; - double log_t = tv.s1; - double f_inv = (log_h + log_t) * f; - double r1 = __clc_as_double(__clc_as_long(f_inv) & 0xfffffffff8000000L); - double r2 = __spirv_ocl_fma(-F, r1, f) * (log_h + log_t); - double r = r1 + r2; - - double poly = __spirv_ocl_fma( - r, - __spirv_ocl_fma( - r, - __spirv_ocl_fma(r, __spirv_ocl_fma(r, 1.0 / 7.0, 1.0 / 6.0), - 1.0 / 5.0), - 1.0 / 4.0), - 1.0 / 3.0); - poly = poly * r * r * r; - - double hr1r1 = 0.5 * r1 * r1; - double poly0h = r1 + hr1r1; - double poly0t = r1 - poly0h + hr1r1; - poly = __spirv_ocl_fma(r1, r2, __spirv_ocl_fma(0.5 * r2, r2, poly)) + r2 + - poly0t; - - tv.s0 = USE_TABLE(powlog_tbl_head, index); - tv.s1 = USE_TABLE(powlog_tbl_tail, index); - log_h = tv.s0; - log_t = tv.s1; - - double resT_t = __spirv_ocl_fma(xexp, real_log2_tail, +log_t) - poly; - double resT = resT_t - poly0h; - double resH = __spirv_ocl_fma(xexp, real_log2_lead, log_h); - double resT_h = poly0h; - - double H = resT + resH; - double H_h = __clc_as_double(__clc_as_long(H) & 0xfffffffff8000000L); - double T = (resH - H + resT) + (resT_t - (resT + resT_h)) + (H - H_h); - H = H_h; - - double y_head = __clc_as_double(uy & 0xfffffffff8000000L); - double y_tail = y - y_head; - - double fnyh = __clc_as_double(__clc_as_long(dny) & 0xfffffffffff00000); - double fnyt = (double)(ny - (int)(long)fnyh); - y_tail = - __spirv_ocl_fma(-fnyt, y_head, __spirv_ocl_fma(-fnyh, y_head, 1.0)) / - dny; - - double temp = - __spirv_ocl_fma(y_tail, H, __spirv_ocl_fma(y_head, T, y_tail * T)); - v = __spirv_ocl_fma(y_head, H, temp); - vt = __spirv_ocl_fma(y_head, H, -v) + temp; - } - - // Now calculate exp of (v,vt) - - double expv; - { - const double max_exp_arg = 709.782712893384; - const double min_exp_arg = -745.1332191019411; - const double sixtyfour_by_lnof2 = 92.33248261689366; - const double lnof2_by_64_head = 0.010830424260348081; - const double lnof2_by_64_tail = -4.359010638708991e-10; - - // If v is so large that we need to return INFINITY, or so small that we - // need to return 0, set v to known values that will produce that result. Do - // not try to continue the computation with the original v and patch it up - // afterwards because v may be so large that temp is out of range of int, in - // which case that conversion, and a value based on that conversion being - // passed to __spirv_ocl_ldexp, results in undefined behavior. - v = v > max_exp_arg ? 1000.0 : v; - v = v < min_exp_arg ? -1000.0 : v; - - double temp = v * sixtyfour_by_lnof2; - int n = (int)(long)temp; - double dn = (double)n; - int j = n & 0x0000003f; - int m = n >> 6; - - double2 tv; - tv.s0 = USE_TABLE(two_to_jby64_ep_tbl_head, j); - tv.s1 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); - double f1 = tv.s0; - double f2 = tv.s1; - double f = f1 + f2; - - double r1 = __spirv_ocl_fma(dn, -lnof2_by_64_head, v); - double r2 = dn * lnof2_by_64_tail; - double r = (r1 + r2) + vt; - - double q = __spirv_ocl_fma( - r, - __spirv_ocl_fma( - r, - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, 1.38889490863777199667e-03, - 8.33336798434219616221e-03), - 4.16666666662260795726e-02), - 1.66666666665260878863e-01), - 5.00000000000000008883e-01); - q = __spirv_ocl_fma(r * r, q, r); - - expv = __spirv_ocl_fma(f, q, f2) + f1; - expv = __spirv_ocl_ldexp(expv, m); - } - - // See whether y is an integer. - // inty = 0 means not an integer. - // inty = 1 means odd integer. - // inty = 2 means even integer. - - int inty = 2 - (ny & 1); - - expv *= ((inty == 1) & !xpos) ? -1.0 : 1.0; - - long ret = __clc_as_long(expv); - - // Now all the edge cases - ret = (!xpos & (inty == 2)) ? QNANBITPATT_DP64 : ret; - long xinf = xpos ? PINFBITPATT_DP64 : NINFBITPATT_DP64; - ret = ((ax == 0L) & !ypos & (inty == 1)) ? xinf : ret; - ret = ((ax == 0L) & !ypos & (inty == 2)) ? PINFBITPATT_DP64 : ret; - ret = ((ax == 0L) & ypos & (inty == 2)) ? 0L : ret; - long xzero = xpos ? 0L : 0x8000000000000000L; - ret = ((ax == 0L) & ypos & (inty == 1)) ? xzero : ret; - ret = - ((ux == NINFBITPATT_DP64) & ypos & (inty == 1)) ? NINFBITPATT_DP64 : ret; - ret = ((ux == NINFBITPATT_DP64) & !ypos & (inty == 1)) ? 0x8000000000000000L - : ret; - ret = ((ux == PINFBITPATT_DP64) & !ypos) ? 0L : ret; - ret = ((ux == PINFBITPATT_DP64) & ypos) ? PINFBITPATT_DP64 : ret; - ret = ax > PINFBITPATT_DP64 ? ux : ret; - ret = ny == 0 ? QNANBITPATT_DP64 : ret; - return __clc_as_double(ret); -} -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_rootn, double, int) -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half __clc_rootn(half x, int ny) { - return __clc_rootn((float)x, ny); -} - -_CLC_BINARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, half, __clc_rootn, half, int) -#endif diff --git a/libclc/libspirv/lib/generic/math/clc_sw_binary.inc b/libclc/libspirv/lib/generic/math/clc_sw_binary.inc deleted file mode 100644 index 087367ef4bafd..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_sw_binary.inc +++ /dev/null @@ -1,13 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#include - -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNC(__CLC_GENTYPE x, - __CLC_GENTYPE y) { - return __CLC_SW_FUNC(x, y); -} diff --git a/libclc/libspirv/lib/generic/math/clc_sw_unary.inc b/libclc/libspirv/lib/generic/math/clc_sw_unary.inc deleted file mode 100644 index 449ca51e75172..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_sw_unary.inc +++ /dev/null @@ -1,16 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#include - -#ifndef __CLC_SW_FUNC -#define __CLC_SW_FUNC __CLC_XCONCAT(__clc_, __CLC_FUNC) -#endif - -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNC(__CLC_GENTYPE x) { - return __CLC_SW_FUNC(x); -} diff --git a/libclc/libspirv/lib/generic/math/clc_tan.cl b/libclc/libspirv/lib/generic/math/clc_tan.cl deleted file mode 100644 index 03b2172fcb621..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_tan.cl +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -_CLC_DEF _CLC_OVERLOAD float __clc_tan(float x) { - int ix = __clc_as_int(x); - int ax = ix & 0x7fffffff; - float dx = __clc_as_float(ax); - - float r0, r1; - int regn = __clc_argReductionS(&r0, &r1, dx); - - float t = __clc_tanf_piby4(r0 + r1, regn); - t = __clc_as_float(__clc_as_int(t) ^ (ix ^ ax)); - - t = ax >= PINFBITPATT_SP32 ? __clc_as_float(QNANBITPATT_SP32) : t; - // Take care of subnormals - t = (x == 0.0f) ? x : t; - return t; -} -_CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_tan, float); - -#ifdef cl_khr_fp64 -#include - -_CLC_DEF _CLC_OVERLOAD double __clc_tan(double x) { - double y = __clc_fabs(x); - - double r, rr; - int regn; - - if (y < 0x1.0p+30) - __clc_remainder_piby2_medium(y, &r, &rr, ®n); - else - __clc_remainder_piby2_large(y, &r, &rr, ®n); - - double lead, tail; - __clc_tan_piby4(r, rr, &lead, &tail); - - int2 t = __clc_as_int2(regn & 1 ? tail : lead); - t.hi ^= (x < 0.0) << 31; - - return __clc_isnan(x) || __clc_isinf(x) ? __clc_as_double(QNANBITPATT_DP64) - : __clc_as_double(t); -} -_CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_tan, double); - -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half __clc_tan(half x) { return __clc_tan((float)x); } - -_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_tan, half) - -#endif diff --git a/libclc/libspirv/lib/generic/math/clc_tanpi.cl b/libclc/libspirv/lib/generic/math/clc_tanpi.cl deleted file mode 100644 index 393dcc70a26ce..0000000000000 --- a/libclc/libspirv/lib/generic/math/clc_tanpi.cl +++ /dev/null @@ -1,144 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -#include -#include -#include - -_CLC_DEF _CLC_OVERLOAD float __clc_tanpi(float x) -{ - int ix = __clc_as_int(x); - int xsgn = ix & 0x80000000; - int xnsgn = xsgn ^ 0x80000000; - ix ^= xsgn; - float ax = __clc_as_float(ix); - int iax = (int)ax; - float r = ax - iax; - int xodd = xsgn ^ (iax & 0x1 ? 0x80000000 : 0); - - // Initialize with return for +-Inf and NaN - int ir = 0x7fc00000; - - // 2^24 <= |x| < Inf, the result is always even integer - ir = ix < 0x7f800000 ? xsgn : ir; - - // 2^23 <= |x| < 2^24, the result is always integer - ir = ix < 0x4b800000 ? xodd : ir; - - // 0x1.0p-7 <= |x| < 2^23, result depends on which 0.25 interval - - // r < 1.0 - float a = 1.0f - r; - int e = 0; - int s = xnsgn; - - // r <= 0.75 - int c = r <= 0.75f; - a = c ? r - 0.5f : a; - e = c ? 1 : e; - s = c ? xsgn : s; - - // r < 0.5 - c = r < 0.5f; - a = c ? 0.5f - r : a; - s = c ? xnsgn : s; - - // 0 < r <= 0.25 - c = r <= 0.25f; - a = c ? r : a; - e = c ? 0 : e; - s = c ? xsgn : s; - - float t = __clc_tanf_piby4(a * M_PI_F, 0); - float tr = -__spirv_ocl_native_recip(t); - int jr = s ^ __clc_as_int(e ? tr : t); - - jr = r == 0.5f ? xodd | 0x7f800000 : jr; - - ir = ix < 0x4b000000 ? jr : ir; - - return __clc_as_float(ir); -} -_CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_tanpi, float); - -#ifdef cl_khr_fp64 -#include "sincosD_piby4.h" - -_CLC_DEF _CLC_OVERLOAD double __clc_tanpi(double x) -{ - long ix = __clc_as_long(x); - long xsgn = ix & 0x8000000000000000L; - long xnsgn = xsgn ^ 0x8000000000000000L; - ix ^= xsgn; - double ax = __clc_as_double(ix); - long iax = (long)ax; - double r = ax - iax; - long xodd = xsgn ^ (iax & 0x1 ? 0x8000000000000000L : 0L); - - // Initialize with return for +-Inf and NaN - long ir = 0x7ff8000000000000L; - - // 2^53 <= |x| < Inf, the result is always even integer - ir = ix < 0x7ff0000000000000L ? xsgn : ir; - - // 2^52 <= |x| < 2^53, the result is always integer - ir = ix < 0x4340000000000000L ? xodd : ir; - - // 0x1.0p-14 <= |x| < 2^53, result depends on which 0.25 interval - - // r < 1.0 - double a = 1.0 - r; - int e = 0; - long s = xnsgn; - - // r <= 0.75 - int c = r <= 0.75; - double t = r - 0.5; - a = c ? t : a; - e = c ? 1 : e; - s = c ? xsgn : s; - - // r < 0.5 - c = r < 0.5; - t = 0.5 - r; - a = c ? t : a; - s = c ? xnsgn : s; - - // r <= 0.25 - c = r <= 0.25; - a = c ? r : a; - e = c ? 0 : e; - s = c ? xsgn : s; - - double api = a * M_PI; - double2 tt = __clc_tan_piby4(api, 0.0); - long jr = s ^ __clc_as_long(e ? tt.hi : tt.lo); - - long si = xodd | 0x7ff0000000000000L; - jr = r == 0.5 ? si : jr; - - ir = ix < 0x4330000000000000L ? jr : ir; - - return __clc_as_double(ir); -} -_CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_tanpi, double); -#endif - -#ifdef cl_khr_fp16 -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half __clc_tanpi(half x) { - return __clc_tanpi((float)x); -} - -_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_tanpi, half) - -#endif diff --git a/libclc/libspirv/lib/generic/math/exp_helper.cl b/libclc/libspirv/lib/generic/math/exp_helper.cl deleted file mode 100644 index ef7bd8f742091..0000000000000 --- a/libclc/libspirv/lib/generic/math/exp_helper.cl +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEF double __clc_exp_helper(double x, double x_min, double x_max, double r, int n) { - - int j = n & 0x3f; - int m = n >> 6; - - // 6 term tail of Taylor expansion of e^r - double z2 = r * __spirv_ocl_fma(r, - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, 0x1.6c16c16c16c17p-10, 0x1.1111111111111p-7), - 0x1.5555555555555p-5), - 0x1.5555555555555p-3), - 0x1.0000000000000p-1), - 1.0); - - double2 tv; - tv.s0 = USE_TABLE(two_to_jby64_ep_tbl_head, j); - tv.s1 = USE_TABLE(two_to_jby64_ep_tbl_tail, j); - z2 = __spirv_ocl_fma(tv.s0 + tv.s1, z2, tv.s1) + tv.s0; - - int small_value = (m < -1022) || ((m == -1022) && (z2 < 1.0)); - - int n1 = m >> 2; - int n2 = m-n1; - double z3= z2 * __clc_as_double(((long)n1 + 1023) << 52); - z3 *= __clc_as_double(((long)n2 + 1023) << 52); - - z2 = __spirv_ocl_ldexp(z2, m); - z2 = small_value ? z3: z2; - - z2 = __spirv_IsNan(x) ? x : z2; - - z2 = x > x_max ? __clc_as_double(PINFBITPATT_DP64) : z2; - z2 = x < x_min ? 0.0 : z2; - - return z2; -} - -#endif // cl_khr_fp64 diff --git a/libclc/libspirv/lib/generic/math/exp_helper.h b/libclc/libspirv/lib/generic/math/exp_helper.h deleted file mode 100644 index 00b5a7f69779a..0000000000000 --- a/libclc/libspirv/lib/generic/math/exp_helper.h +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __CLC_MATH_CLC_EXP_H__ -#define __CLC_MATH_CLC_EXP_H__ - -#define __CLC_BODY -#define __CLC_FUNCTION __clc_exp - -#include - -#undef __CLC_BODY -#undef __CLC_FUNCTION - -#endif // __CLC_MATH_CLC_EXP_H__ diff --git a/libclc/libspirv/lib/generic/math/remainder.cl b/libclc/libspirv/lib/generic/math/remainder.cl index e0579362283bb..5ccba3689351a 100644 --- a/libclc/libspirv/lib/generic/math/remainder.cl +++ b/libclc/libspirv/lib/generic/math/remainder.cl @@ -9,7 +9,7 @@ #include #include -#define __CLC_FUNC __spirv_ocl_remainder -#define __CLC_SW_FUNC __clc_remainder -#define __CLC_BODY +#define FUNCTION __spirv_ocl_remainder +#define __CLC_FUNCTION(x) __clc_remainder +#define __CLC_BODY #include diff --git a/libclc/libspirv/lib/generic/math/remquo.cl b/libclc/libspirv/lib/generic/math/remquo.cl index 7f6f6388e8375..ca3d9ad569ff4 100644 --- a/libclc/libspirv/lib/generic/math/remquo.cl +++ b/libclc/libspirv/lib/generic/math/remquo.cl @@ -6,28 +6,8 @@ // //===----------------------------------------------------------------------===// -#include - #include +#include #define __CLC_BODY -#define __CLC_ADDRESS_SPACE global -#include -#undef __CLC_ADDRESS_SPACE - -#define __CLC_BODY -#define __CLC_ADDRESS_SPACE local -#include -#undef __CLC_ADDRESS_SPACE - -#define __CLC_BODY -#define __CLC_ADDRESS_SPACE private -#include -#undef __CLC_ADDRESS_SPACE - -#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED -#define __CLC_BODY -#define __CLC_ADDRESS_SPACE generic #include -#undef __CLC_ADDRESS_SPACE -#endif diff --git a/libclc/libspirv/lib/generic/math/remquo.inc b/libclc/libspirv/lib/generic/math/remquo.inc index b350e00a339a1..97035dc01d79e 100644 --- a/libclc/libspirv/lib/generic/math/remquo.inc +++ b/libclc/libspirv/lib/generic/math/remquo.inc @@ -6,10 +6,28 @@ // //===----------------------------------------------------------------------===// -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_remquo( - __CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_ADDRESS_SPACE __CLC_INTN *q) { - __private __CLC_INTN private_q; - __CLC_GENTYPE ret = __clc_remquo(x, y, &private_q); - *q = private_q; - return ret; +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_remquo(__CLC_GENTYPE x, + __CLC_GENTYPE y, + private __CLC_INTN *q) { + return __clc_remquo(x, y, q); } + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_remquo(__CLC_GENTYPE x, + __CLC_GENTYPE y, + global __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_remquo(__CLC_GENTYPE x, + __CLC_GENTYPE y, + local __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} + +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_remquo(__CLC_GENTYPE x, + __CLC_GENTYPE y, + generic __CLC_INTN *q) { + return __clc_remquo(x, y, q); +} +#endif diff --git a/libclc/libspirv/lib/generic/math/rootn.cl b/libclc/libspirv/lib/generic/math/rootn.cl index a20f4eaea759e..cddeeb09297a2 100644 --- a/libclc/libspirv/lib/generic/math/rootn.cl +++ b/libclc/libspirv/lib/generic/math/rootn.cl @@ -6,9 +6,10 @@ // //===----------------------------------------------------------------------===// -#include - #include +#include -#define __CLC_BODY +#define FUNCTION __spirv_ocl_rootn +#define __CLC_FUNCTION(x) __clc_rootn +#define __CLC_BODY #include diff --git a/libclc/libspirv/lib/generic/math/rootn.inc b/libclc/libspirv/lib/generic/math/rootn.inc deleted file mode 100644 index c7c0feacc45b9..0000000000000 --- a/libclc/libspirv/lib/generic/math/rootn.inc +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_rootn(__CLC_GENTYPE x, - __CLC_INTN y) { - return __clc_rootn(x, y); -} diff --git a/libclc/libspirv/lib/generic/math/sincosD_piby4.h b/libclc/libspirv/lib/generic/math/sincosD_piby4.h deleted file mode 100644 index 546fee6f03c71..0000000000000 --- a/libclc/libspirv/lib/generic/math/sincosD_piby4.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2014 Advanced Micro Devices, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_INLINE double2 __libclc__sincos_piby4(double x, double xx) { - // Taylor series for sin(x) is x - x^3/3! + x^5/5! - x^7/7! ... - // = x * (1 - x^2/3! + x^4/5! - x^6/7! ... - // = x * f(w) - // where w = x*x and f(w) = (1 - w/3! + w^2/5! - w^3/7! ... - // We use a minimax approximation of (f(w) - 1) / w - // because this produces an expansion in even powers of x. - // If xx (the tail of x) is non-zero, we add a correction - // term g(x,xx) = (1-x*x/2)*xx to the result, where g(x,xx) - // is an approximation to cos(x)*sin(xx) valid because - // xx is tiny relative to x. - - // Taylor series for cos(x) is 1 - x^2/2! + x^4/4! - x^6/6! ... - // = f(w) - // where w = x*x and f(w) = (1 - w/2! + w^2/4! - w^3/6! ... - // We use a minimax approximation of (f(w) - 1 + w/2) / (w*w) - // because this produces an expansion in even powers of x. - // If xx (the tail of x) is non-zero, we subtract a correction - // term g(x,xx) = x*xx to the result, where g(x,xx) - // is an approximation to sin(x)*sin(xx) valid because - // xx is tiny relative to x. - - const double sc1 = -0.166666666666666646259241729; - const double sc2 = 0.833333333333095043065222816e-2; - const double sc3 = -0.19841269836761125688538679e-3; - const double sc4 = 0.275573161037288022676895908448e-5; - const double sc5 = -0.25051132068021699772257377197e-7; - const double sc6 = 0.159181443044859136852668200e-9; - - const double cc1 = 0.41666666666666665390037e-1; - const double cc2 = -0.13888888888887398280412e-2; - const double cc3 = 0.248015872987670414957399e-4; - const double cc4 = -0.275573172723441909470836e-6; - const double cc5 = 0.208761463822329611076335e-8; - const double cc6 = -0.113826398067944859590880e-10; - - double x2 = x * x; - double x3 = x2 * x; - double r = 0.5 * x2; - double t = 1.0 - r; - - double sp = __spirv_ocl_fma( - __spirv_ocl_fma(__spirv_ocl_fma(__spirv_ocl_fma(sc6, x2, sc5), x2, sc4), - x2, sc3), - x2, sc2); - - double cp = - t + - __spirv_ocl_fma( - __spirv_ocl_fma( - __spirv_ocl_fma( - __spirv_ocl_fma( - __spirv_ocl_fma(__spirv_ocl_fma(cc6, x2, cc5), x2, cc4), - x2, cc3), - x2, cc2), - x2, cc1), - x2 * x2, __spirv_ocl_fma(x, xx, (1.0 - t) - r)); - - double2 ret; - ret.lo = - x - __spirv_ocl_fma( - -x3, sc1, - __spirv_ocl_fma(__spirv_ocl_fma(-x3, sp, 0.5 * xx), x2, -xx)); - ret.hi = cp; - - return ret; -} - -_CLC_INLINE double2 __clc_tan_piby4(double x, double xx) { - const double piby4_lead = 7.85398163397448278999e-01; // 0x3fe921fb54442d18 - const double piby4_tail = 3.06161699786838240164e-17; // 0x3c81a62633145c06 - - // In order to maintain relative precision transform using the identity: - // tan(pi/4-x) = (1-tan(x))/(1+tan(x)) for arguments close to pi/4. - // Similarly use tan(x-pi/4) = (tan(x)-1)/(tan(x)+1) close to -pi/4. - - int ca = x > 0.68; - int cb = x < -0.68; - double transform = ca ? 1.0 : 0.0; - transform = cb ? -1.0 : transform; - - double tx = __spirv_ocl_fma(-transform, x, piby4_lead) + - __spirv_ocl_fma(-transform, xx, piby4_tail); - int c = ca | cb; - x = c ? tx : x; - xx = c ? 0.0 : xx; - - // Core Remez [2,3] approximation to tan(x+xx) on the interval [0,0.68]. - double t1 = x; - double r = __spirv_ocl_fma(2.0, x * xx, x * x); - - double a = - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, 0.224044448537022097264602535574e-3, - -0.229345080057565662883358588111e-1), - 0.372379159759792203640806338901e0); - - double b = __spirv_ocl_fma( - r, - __spirv_ocl_fma(r, - __spirv_ocl_fma(r, -0.232371494088563558304549252913e-3, - 0.260656620398645407524064091208e-1), - -0.515658515729031149329237816945e0), - 0.111713747927937668539901657944e1); - - double t2 = __spirv_ocl_fma(MATH_DIVIDE(a, b), x * r, xx); - - double tp = t1 + t2; - - // Compute -1.0/(t1 + t2) accurately - double z1 = __clc_as_double(__clc_as_long(tp) & 0xffffffff00000000L); - double z2 = t2 - (z1 - t1); - double trec = -MATH_RECIP(tp); - double trec_top = __clc_as_double(__clc_as_long(trec) & 0xffffffff00000000L); - - double tpr = __spirv_ocl_fma( - __spirv_ocl_fma(trec_top, z2, __spirv_ocl_fma(trec_top, z1, 1.0)), trec, - trec_top); - - double tpt = transform * (1.0 - MATH_DIVIDE(2.0 * tp, 1.0 + tp)); - double tptr = transform * (MATH_DIVIDE(2.0 * tp, tp - 1.0) - 1.0); - - double2 ret; - ret.lo = c ? tpt : tp; - ret.hi = c ? tptr : tpr; - return ret; -} diff --git a/libclc/libspirv/lib/generic/math/sincos_helpers.h b/libclc/libspirv/lib/generic/math/sincos_helpers.h deleted file mode 100644 index 11cb93f34850d..0000000000000 --- a/libclc/libspirv/lib/generic/math/sincos_helpers.h +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DECL void __clc_remainder_piby2_medium(double x, private double *r, - private double *rr, - private int *regn); -_CLC_DECL void __clc_remainder_piby2_large(double x, private double *r, - private double *rr, - private int *regn); -_CLC_DECL double2 __clc_sincos_piby4(double x, double xx); - -#endif