diff --git a/libclc/generic/include/clcmacro.h b/libclc/generic/include/clcmacro.h index d7c0c3474bd1a..d4167a8e4529e 100644 --- a/libclc/generic/include/clcmacro.h +++ b/libclc/generic/include/clcmacro.h @@ -134,14 +134,14 @@ ADDR_SPACE, ARG2_TYPE) \ DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ADDR_SPACE ARG2_TYPE##2 * y) { \ return (RET_TYPE##2)( \ - FUNCTION(x.x, (ARG2_TYPE *)y), \ + FUNCTION(x.x, (ADDR_SPACE ARG2_TYPE *)y), \ FUNCTION(x.y, \ (ADDR_SPACE ARG2_TYPE *)((ADDR_SPACE ARG2_TYPE *)y + 1))); \ } \ \ DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ADDR_SPACE ARG2_TYPE##3 * y) { \ return (RET_TYPE##3)( \ - FUNCTION(x.x, (ARG2_TYPE *)y), \ + FUNCTION(x.x, (ADDR_SPACE ARG2_TYPE *)y), \ FUNCTION(x.y, \ (ADDR_SPACE ARG2_TYPE *)((ADDR_SPACE ARG2_TYPE *)y + 1)), \ FUNCTION(x.z, \ @@ -150,14 +150,14 @@ \ DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ADDR_SPACE ARG2_TYPE##4 * y) { \ return (RET_TYPE##4)( \ - FUNCTION(x.lo, (ARG2_TYPE##2 *)y), \ + FUNCTION(x.lo, (ADDR_SPACE ARG2_TYPE##2 *)y), \ FUNCTION(x.hi, \ (ADDR_SPACE ARG2_TYPE##2 *)((ADDR_SPACE ARG2_TYPE *)y + 2))); \ } \ \ DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ADDR_SPACE ARG2_TYPE##8 * y) { \ return (RET_TYPE##8)( \ - FUNCTION(x.lo, (ARG2_TYPE##4 *)y), \ + FUNCTION(x.lo, (ADDR_SPACE ARG2_TYPE##4 *)y), \ FUNCTION(x.hi, \ (ADDR_SPACE ARG2_TYPE##4 *)((ADDR_SPACE ARG2_TYPE *)y + 4))); \ } \ @@ -165,11 +165,20 @@ DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, \ ADDR_SPACE ARG2_TYPE##16 * y) { \ return (RET_TYPE##16)( \ - FUNCTION(x.lo, (ARG2_TYPE##8 *)y), \ + FUNCTION(x.lo, (ADDR_SPACE ARG2_TYPE##8 *)y), \ FUNCTION(x.hi, \ (ADDR_SPACE ARG2_TYPE##8 *)((ADDR_SPACE ARG2_TYPE *)y + 8))); \ } +#define _CLC_DEFINE_TERNARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, \ + ARG2_TYPE, ARG3_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y, \ + ARG3_TYPE z) { \ + return BUILTIN(x, y, z); \ + } \ + _CLC_TERNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, \ + ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) + #define _CLC_DEFINE_BINARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, \ ARG2_TYPE) \ _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ diff --git a/libclc/ptx-nvidiacl/include/libdevice.h b/libclc/ptx-nvidiacl/include/libdevice.h index fefc6ea54385a..5b1c8f6e9bee4 100644 --- a/libclc/ptx-nvidiacl/include/libdevice.h +++ b/libclc/ptx-nvidiacl/include/libdevice.h @@ -9,58 +9,363 @@ #ifndef PTX_NVIDIACL_LIBDEVICE_H #define PTX_NVIDIACL_LIBDEVICE_H -#define __LIBDEVICE_UNARY_BUILTIN_F(BUILTIN) float __nv_##BUILTIN##f(float); -#define __LIBDEVICE_BINARY_BUILTIN_F(BUILTIN) \ - float __nv_##BUILTIN##f(float, float); +#include #ifdef cl_khr_fp64 - #pragma OPENCL EXTENSION cl_khr_fp64 : enable - -#define __LIBDEVICE_UNARY_BUILTIN_D(BUILTIN) double __nv_##BUILTIN(double); -#define __LIBDEVICE_BINARY_BUILTIN_D(BUILTIN) \ - double __nv_##BUILTIN(double, double); - -#else - -#define __LIBDEVICE_UNARY_BUILTIN_D(BUILTIN) - #endif -#define __LIBDEVICE_UNARY_BUILTIN(BUILTIN) \ - __LIBDEVICE_UNARY_BUILTIN_F(BUILTIN) \ - __LIBDEVICE_UNARY_BUILTIN_D(BUILTIN) - -#define __LIBDEVICE_BINARY_BUILTIN(BUILTIN) \ - __LIBDEVICE_BINARY_BUILTIN_F(BUILTIN) \ - __LIBDEVICE_BINARY_BUILTIN_D(BUILTIN) - -__LIBDEVICE_UNARY_BUILTIN(acos) -__LIBDEVICE_UNARY_BUILTIN(acosh) -__LIBDEVICE_UNARY_BUILTIN(asin) -__LIBDEVICE_UNARY_BUILTIN(asinh) -__LIBDEVICE_UNARY_BUILTIN(atan) -__LIBDEVICE_UNARY_BUILTIN(atanh) -__LIBDEVICE_UNARY_BUILTIN(cbrt) -__LIBDEVICE_UNARY_BUILTIN(ceil) -__LIBDEVICE_UNARY_BUILTIN(cos) -__LIBDEVICE_UNARY_BUILTIN(cosh) -__LIBDEVICE_UNARY_BUILTIN(cospi) -__LIBDEVICE_UNARY_BUILTIN(erf) -__LIBDEVICE_UNARY_BUILTIN(erfc) -__LIBDEVICE_UNARY_BUILTIN(exp) -__LIBDEVICE_UNARY_BUILTIN(exp2) -__LIBDEVICE_UNARY_BUILTIN(exp10) -__LIBDEVICE_UNARY_BUILTIN(expm1) -__LIBDEVICE_UNARY_BUILTIN(fabs) -__LIBDEVICE_UNARY_BUILTIN(floor) -__LIBDEVICE_UNARY_BUILTIN_F(fast_exp) -__LIBDEVICE_UNARY_BUILTIN_F(fast_exp10) -__LIBDEVICE_UNARY_BUILTIN(lgamma) -__LIBDEVICE_UNARY_BUILTIN(sqrt) +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif -__LIBDEVICE_BINARY_BUILTIN(fmax) -__LIBDEVICE_BINARY_BUILTIN(fmin) -__LIBDEVICE_BINARY_BUILTIN(fmod) +int __nv_abs(int); +double __nv_acos(double); +float __nv_acosf(float); +double __nv_acosh(double); +float __nv_acoshf(float); +double __nv_asin(double); +float __nv_asinf(float); +double __nv_asinh(double); +float __nv_asinhf(float); +double __nv_atan(double); +double __nv_atan2(double, double); +float __nv_atan2f(float, float); +float __nv_atanf(float); +double __nv_atanh(double); +float __nv_atanhf(float); +int __nv_brev(int); +long __nv_brevll(long); +int __nv_byte_perm(int, int, int); +double __nv_cbrt(double); +float __nv_cbrtf(float); +double __nv_ceil(double); +float __nv_ceilf(float); +int __nv_clz(int); +int __nv_clzll(long); +double __nv_copysign(double, double); +float __nv_copysignf(float, float); +double __nv_cos(double); +float __nv_cosf(float); +double __nv_cosh(double); +float __nv_coshf(float); +double __nv_cospi(double); +float __nv_cospif(float); +double __nv_cyl_bessel_i0(double); +float __nv_cyl_bessel_i0f(float); +double __nv_cyl_bessel_i1(double); +float __nv_cyl_bessel_i1f(float); +double __nv_dadd_rd(double, double); +double __nv_dadd_rn(double, double); +double __nv_dadd_ru(double, double); +double __nv_dadd_rz(double, double); +double __nv_ddiv_rd(double, double); +double __nv_ddiv_rn(double, double); +double __nv_ddiv_ru(double, double); +double __nv_ddiv_rz(double, double); +double __nv_dmul_rd(double, double); +double __nv_dmul_rn(double, double); +double __nv_dmul_ru(double, double); +double __nv_dmul_rz(double, double); +float __nv_double2float_rd(double); +float __nv_double2float_rn(double); +float __nv_double2float_ru(double); +float __nv_double2float_rz(double); +int __nv_double2hiint(double); +int __nv_double2int_rd(double); +int __nv_double2int_rn(double); +int __nv_double2int_ru(double); +int __nv_double2int_rz(double); +long __nv_double2ll_rd(double); +long __nv_double2ll_rn(double); +long __nv_double2ll_ru(double); +long __nv_double2ll_rz(double); +int __nv_double2loint(double); +int __nv_double2uint_rd(double); +int __nv_double2uint_rn(double); +int __nv_double2uint_ru(double); +int __nv_double2uint_rz(double); +long __nv_double2ull_rd(double); +long __nv_double2ull_rn(double); +long __nv_double2ull_ru(double); +long __nv_double2ull_rz(double); +long __nv_double_as_longlong(double); +double __nv_drcp_rd(double); +double __nv_drcp_rn(double); +double __nv_drcp_ru(double); +double __nv_drcp_rz(double); +double __nv_dsqrt_rd(double); +double __nv_dsqrt_rn(double); +double __nv_dsqrt_ru(double); +double __nv_dsqrt_rz(double); +double __nv_dsub_rd(double, double); +double __nv_dsub_rn(double, double); +double __nv_dsub_ru(double, double); +double __nv_dsub_rz(double, double); +double __nv_erf(double); +double __nv_erfc(double); +float __nv_erfcf(float); +double __nv_erfcinv(double); +float __nv_erfcinvf(float); +double __nv_erfcx(double); +float __nv_erfcxf(float); +float __nv_erff(float); +double __nv_erfinv(double); +float __nv_erfinvf(float); +double __nv_exp(double); +double __nv_exp10(double); +float __nv_exp10f(float); +double __nv_exp2(double); +float __nv_exp2f(float); +float __nv_expf(float); +double __nv_expm1(double); +float __nv_expm1f(float); +double __nv_fabs(double); +float __nv_fabsf(float); +float __nv_fadd_rd(float, float); +float __nv_fadd_rn(float, float); +float __nv_fadd_ru(float, float); +float __nv_fadd_rz(float, float); +float __nv_fast_cosf(float); +float __nv_fast_exp10f(float); +float __nv_fast_expf(float); +float __nv_fast_fdividef(float, float); +float __nv_fast_log10f(float); +float __nv_fast_log2f(float); +float __nv_fast_logf(float); +float __nv_fast_powf(float, float); +void __nv_fast_sincosf(float, float *, float *); +float __nv_fast_sinf(float); +float __nv_fast_tanf(float); +double __nv_fdim(double, double); +float __nv_fdimf(float, float); +float __nv_fdiv_rd(float, float); +float __nv_fdiv_rn(float, float); +float __nv_fdiv_ru(float, float); +float __nv_fdiv_rz(float, float); +int __nv_ffs(int); +int __nv_ffsll(long); +int __nv_finitef(float); +ushort __nv_float2half_rn(float); +int __nv_float2int_rd(float); +int __nv_float2int_rn(float); +int __nv_float2int_ru(float); +int __nv_float2int_rz(float); +long __nv_float2ll_rd(float); +long __nv_float2ll_rn(float); +long __nv_float2ll_ru(float); +long __nv_float2ll_rz(float); +int __nv_float2uint_rd(float); +int __nv_float2uint_rn(float); +int __nv_float2uint_ru(float); +int __nv_float2uint_rz(float); +long __nv_float2ull_rd(float); +long __nv_float2ull_rn(float); +long __nv_float2ull_ru(float); +long __nv_float2ull_rz(float); +int __nv_float_as_int(float); +int __nv_float_as_uint(float); +double __nv_floor(double); +float __nv_floorf(float); +double __nv_fma(double, double, double); +double __nv_fma_rd(double, double, double); +double __nv_fma_rn(double, double, double); +double __nv_fma_ru(double, double, double); +double __nv_fma_rz(double, double, double); +float __nv_fmaf(float, float, float); +float __nv_fmaf_ieee_rd(float, float, float); +float __nv_fmaf_ieee_rn(float, float, float); +float __nv_fmaf_ieee_ru(float, float, float); +float __nv_fmaf_ieee_rz(float, float, float); +float __nv_fmaf_rd(float, float, float); +float __nv_fmaf_rn(float, float, float); +float __nv_fmaf_ru(float, float, float); +float __nv_fmaf_rz(float, float, float); +double __nv_fmax(double, double); +float __nv_fmaxf(float, float); +double __nv_fmin(double, double); +float __nv_fminf(float, float); +double __nv_fmod(double, double); +float __nv_fmodf(float, float); +float __nv_fmul_rd(float, float); +float __nv_fmul_rn(float, float); +float __nv_fmul_ru(float, float); +float __nv_fmul_rz(float, float); +float __nv_frcp_rd(float); +float __nv_frcp_rn(float); +float __nv_frcp_ru(float); +float __nv_frcp_rz(float); +double __nv_frexp(double, int *); +float __nv_frexpf(float, int *); +float __nv_frsqrt_rn(float); +float __nv_fsqrt_rd(float); +float __nv_fsqrt_rn(float); +float __nv_fsqrt_ru(float); +float __nv_fsqrt_rz(float); +float __nv_fsub_rd(float, float); +float __nv_fsub_rn(float, float); +float __nv_fsub_ru(float, float); +float __nv_fsub_rz(float, float); +int __nv_hadd(int, int); +float __nv_half2float(ushort); +double __nv_hiloint2double(int, int); +double __nv_hypot(double, double); +float __nv_hypotf(float, float); +int __nv_ilogb(double); +int __nv_ilogbf(float); +double __nv_int2double_rn(int); +float __nv_int2float_rd(int); +float __nv_int2float_rn(int); +float __nv_int2float_ru(int); +float __nv_int2float_rz(int); +float __nv_int_as_float(int); +int __nv_isfinited(double); +int __nv_isinfd(double); +int __nv_isinff(float); +int __nv_isnand(double); +int __nv_isnanf(float); +double __nv_j0(double); +float __nv_j0f(float); +double __nv_j1(double); +float __nv_j1f(float); +double __nv_jn(int, double); +float __nv_jnf(int, float); +double __nv_ldexp(double, int); +float __nv_ldexpf(float, int); +double __nv_lgamma(double); +float __nv_lgammaf(float); +double __nv_ll2double_rd(long); +double __nv_ll2double_rn(long); +double __nv_ll2double_ru(long); +double __nv_ll2double_rz(long); +float __nv_ll2float_rd(long); +float __nv_ll2float_rn(long); +float __nv_ll2float_ru(long); +float __nv_ll2float_rz(long); +long __nv_llabs(long); +long __nv_llmax(long, long); +long __nv_llmin(long, long); +long __nv_llrint(double); +long __nv_llrintf(float); +long __nv_llround(double); +long __nv_llroundf(float); +double __nv_log(double); +double __nv_log10(double); +float __nv_log10f(float); +double __nv_log1p(double); +float __nv_log1pf(float); +double __nv_log2(double); +float __nv_log2f(float); +double __nv_logb(double); +float __nv_logbf(float); +float __nv_logf(float); +double __nv_longlong_as_double(long); +int __nv_max(int, int); +int __nv_min(int, int); +double __nv_modf(double, double *); +float __nv_modff(float, float *); +int __nv_mul24(int, int); +long __nv_mul64hi(long, long); +int __nv_mulhi(int, int); +double __nv_nan(char *); +float __nv_nanf(char *); +double __nv_nearbyint(double); +float __nv_nearbyintf(float); +double __nv_nextafter(double, double); +float __nv_nextafterf(float, float); +double __nv_norm(int, double *); +double __nv_norm3d(double, double, double); +float __nv_norm3df(float, float, float); +double __nv_norm4d(double, double, double, double); +float __nv_norm4df(float, float, float, float); +double __nv_normcdf(double); +float __nv_normcdff(float); +double __nv_normcdfinv(double); +float __nv_normcdfinvf(float); +float __nv_normf(int, float *); +int __nv_popc(int); +int __nv_popcll(long); +double __nv_pow(double, double); +float __nv_powf(float, float); +double __nv_powi(double, int); +float __nv_powif(float, int); +double __nv_rcbrt(double); +float __nv_rcbrtf(float); +double __nv_rcp64h(double); +double __nv_remainder(double, double); +float __nv_remainderf(float, float); +double __nv_remquo(double, double, int *); +float __nv_remquof(float, float, int *); +int __nv_rhadd(int, int); +double __nv_rhypot(double, double); +float __nv_rhypotf(float, float); +double __nv_rint(double); +float __nv_rintf(float); +double __nv_rnorm(int, double *); +double __nv_rnorm3d(double, double, double); +float __nv_rnorm3df(float, float, float); +double __nv_rnorm4d(double, double, double, double); +float __nv_rnorm4df(float, float, float, float); +float __nv_rnormf(int, float *); +double __nv_round(double); +float __nv_roundf(float); +double __nv_rsqrt(double); +float __nv_rsqrtf(float); +int __nv_sad(int, int, int); +float __nv_saturatef(float); +double __nv_scalbn(double, int); +float __nv_scalbnf(float, int); +int __nv_signbitd(double); +int __nv_signbitf(float); +double __nv_sin(double); +void __nv_sincos(double, double *, double *); +void __nv_sincosf(float, float *, float *); +void __nv_sincospi(double, double *, double *); +void __nv_sincospif(float, float *, float *); +float __nv_sinf(float); +double __nv_sinh(double); +float __nv_sinhf(float); +double __nv_sinpi(double); +float __nv_sinpif(float); +double __nv_sqrt(double); +float __nv_sqrtf(float); +double __nv_tan(double); +float __nv_tanf(float); +double __nv_tanh(double); +float __nv_tanhf(float); +double __nv_tgamma(double); +float __nv_tgammaf(float); +double __nv_trunc(double); +float __nv_truncf(float); +int __nv_uhadd(int, int); +double __nv_uint2double_rn(int); +float __nv_uint2float_rd(int); +float __nv_uint2float_rn(int); +float __nv_uint2float_ru(int); +float __nv_uint2float_rz(int); +float __nv_uint_as_float(int); +double __nv_ull2double_rd(long); +double __nv_ull2double_rn(long); +double __nv_ull2double_ru(long); +double __nv_ull2double_rz(long); +float __nv_ull2float_rd(long); +float __nv_ull2float_rn(long); +float __nv_ull2float_ru(long); +float __nv_ull2float_rz(long); +long __nv_ullmax(long, long); +long __nv_ullmin(long, long); +int __nv_umax(int, int); +int __nv_umin(int, int); +int __nv_umul24(int, int); +long __nv_umul64hi(long, long); +int __nv_umulhi(int, int); +int __nv_urhadd(int, int); +int __nv_usad(int, int, int); +double __nv_y0(double); +float __nv_y0f(float); +double __nv_y1(double); +float __nv_y1f(float); +double __nv_yn(int, double); +float __nv_ynf(int, float); #endif diff --git a/libclc/ptx-nvidiacl/libspirv/SOURCES b/libclc/ptx-nvidiacl/libspirv/SOURCES index cd0d24b20a2fb..5500fff575cf1 100644 --- a/libclc/ptx-nvidiacl/libspirv/SOURCES +++ b/libclc/ptx-nvidiacl/libspirv/SOURCES @@ -2,24 +2,19 @@ atomic/loadstore_helpers.ll cl_khr_int64_extended_atomics/minmax_helpers.ll integer/mul24.cl integer/mul_hi.cl -synchronization/barrier.cl -workitem/get_global_id.cl -workitem/get_global_offset.cl -workitem/get_global_size.cl -workitem/get_group_id.cl -workitem/get_local_id.cl -workitem/get_local_size.cl -workitem/get_num_groups.cl math/acos.cl math/acosh.cl math/asin.cl math/asinh.cl math/atan.cl +math/atan2.cl math/atanh.cl math/cbrt.cl math/ceil.cl +math/copysign.cl math/cos.cl math/cosh.cl +math/cospi.cl math/erf.cl math/erfc.cl math/exp.cl @@ -27,12 +22,57 @@ math/exp10.cl math/exp2.cl math/expm1.cl math/fabs.cl +math/fdim.cl math/floor.cl +math/fma.cl math/fmax.cl math/fmin.cl math/fmod.cl +math/frexp.cl +math/hypot.cl +math/ilogb.cl +math/ldexp.cl math/lgamma.cl +math/log.cl +math/log10.cl +math/log1p.cl +math/log2.cl +math/logb.cl +math/modf.cl +math/native_cos.cl math/native_exp.cl math/native_exp10.cl math/native_exp2.cl +math/native_log.cl +math/native_log10.cl +math/native_log2.cl +math/native_powr.cl +math/native_rsqrt.cl +math/native_sin.cl +math/native_sqrt.cl +math/native_tan.cl +math/nextafter.cl +math/pow.cl +math/remainer.cl +math/round.cl +math/rsqrt.cl +math/sin.cl +math/sincos.cl +math/sinh.cl +math/sinpi.cl math/sqrt.cl +math/tan.cl +math/tanh.cl +math/tgamma.cl +math/trunc.cl +relational/isfinite.cl +relational/isinf.cl +relational/isnan.cl +synchronization/barrier.cl +workitem/get_global_id.cl +workitem/get_global_offset.cl +workitem/get_global_size.cl +workitem/get_group_id.cl +workitem/get_local_id.cl +workitem/get_local_size.cl +workitem/get_num_groups.cl diff --git a/libclc/ptx-nvidiacl/libspirv/math/atan2.cl b/libclc/ptx-nvidiacl/libspirv/math/atan2.cl new file mode 100644 index 0000000000000..6568171d2f32b --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/atan2.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_atan2 +#define __CLC_BUILTIN __nv_atan2 +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/copysign.cl b/libclc/ptx-nvidiacl/libspirv/math/copysign.cl new file mode 100644 index 0000000000000..be93c43ee376d --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/copysign.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_copysign +#define __CLC_BUILTIN __nv_copysign +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/cospi.cl b/libclc/ptx-nvidiacl/libspirv/math/cospi.cl new file mode 100644 index 0000000000000..a6558715d8e5e --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/cospi.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_cospi +#define __CLC_BUILTIN __nv_cospi +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/fdim.cl b/libclc/ptx-nvidiacl/libspirv/math/fdim.cl new file mode 100644 index 0000000000000..8c43a4ee71669 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/fdim.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_fdim +#define __CLC_BUILTIN __nv_fdim +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/fma.cl b/libclc/ptx-nvidiacl/libspirv/math/fma.cl new file mode 100644 index 0000000000000..f887289c03b29 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/fma.cl @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +_CLC_DEFINE_TERNARY_BUILTIN(float, __spirv_ocl_fma, __nv_fmaf, float, float, + float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEFINE_TERNARY_BUILTIN(double, __spirv_ocl_fma, __nv_fma, double, double, + double) + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEFINE_TERNARY_BUILTIN(half, __spirv_ocl_fma, __nv_fmaf, half, half, half) + +#endif + +#undef __CLC_BUILTIN +#undef __CLC_BUILTIN_F +#undef __CLC_FUNCTION diff --git a/libclc/ptx-nvidiacl/libspirv/math/fma.inc b/libclc/ptx-nvidiacl/libspirv/math/fma.inc new file mode 100644 index 0000000000000..637bcda82fb28 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/fma.inc @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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_DEF _CLC_OVERLOAD __CLC_GENTYPE __spirv_ocl_fma(__CLC_GENTYPE a, + __CLC_GENTYPE b, + __CLC_GENTYPE c) { +#if __CLC_FPSIZE == 32 && HAVE_HW_FMA32() == 0 + return __clc_sw_fma(a, b, c); +#else + return __clc_fma(a, b, c); +#endif +} diff --git a/libclc/ptx-nvidiacl/libspirv/math/frexp.cl b/libclc/ptx-nvidiacl/libspirv/math/frexp.cl new file mode 100644 index 0000000000000..92482d7e3148e --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/frexp.cl @@ -0,0 +1,85 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +_CLC_OVERLOAD _CLC_DEF float __clc_spirv_ocl_frexp(float x, private int *ep) { + return __nv_frexpf(x, ep); +} + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double __clc_spirv_ocl_frexp(double x, private int *ep) { + return __nv_frexp(x, ep); +} + +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF half __clc_spirv_ocl_frexp(half x, private int *ep) { + float t = x; + return __nv_frexpf(t, ep); +} + +#endif + +#define __CLC_ADDRESS_SPACE private +#define __CLC_GENTYPE float +#include +#undef __CLC_GENTYPE +#ifdef cl_khr_fp64 +#define __CLC_GENTYPE double +#include +#undef __CLC_GENTYPE +#endif +#ifdef cl_khr_fp16 +#define __CLC_GENTYPE half +#include +#undef __CLC_GENTYPE +#endif +#undef __CLC_ADDRESS_SPACE + +#define __CLC_ADDRESS_SPACE global +#define __CLC_GENTYPE float +#include +#undef __CLC_GENTYPE +#ifdef cl_khr_fp64 +#define __CLC_GENTYPE double +#include +#undef __CLC_GENTYPE +#endif +#ifdef cl_khr_fp16 +#define __CLC_GENTYPE half +#include +#undef __CLC_GENTYPE +#endif +#undef __CLC_ADDRESS_SPACE + +#define __CLC_ADDRESS_SPACE local +#define __CLC_GENTYPE float +#include +#undef __CLC_GENTYPE +#ifdef cl_khr_fp64 +#define __CLC_GENTYPE double +#include +#undef __CLC_GENTYPE +#endif +#ifdef cl_khr_fp16 +#define __CLC_GENTYPE half +#include +#undef __CLC_GENTYPE +#endif +#undef __CLC_ADDRESS_SPACE diff --git a/libclc/ptx-nvidiacl/libspirv/math/frexp.inc b/libclc/ptx-nvidiacl/libspirv/math/frexp.inc new file mode 100644 index 0000000000000..7aae487664706 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/frexp.inc @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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_frexp(__CLC_GENTYPE x, __CLC_ADDRESS_SPACE int *ep) { + int t_ep; + __CLC_GENTYPE res = __clc_spirv_ocl_frexp(x, &t_ep); + *ep = t_ep; + return res; +} + +#define __CLC_GENTYPE_VEC __CLC_XCONCAT(__CLC_GENTYPE, 2) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE_VEC +__spirv_ocl_frexp(__CLC_GENTYPE_VEC x, __CLC_ADDRESS_SPACE int2 *ep) { + int ep_x; + int ep_y; + __CLC_GENTYPE_VEC res = (__CLC_GENTYPE_VEC)(__spirv_ocl_frexp(x.x, &ep_x), + __spirv_ocl_frexp(x.y, &ep_y)); + *ep = (int2)(ep_x, ep_y); + return res; +} + +#undef __CLC_GENTYPE_VEC +#define __CLC_GENTYPE_VEC __CLC_XCONCAT(__CLC_GENTYPE, 3) + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE_VEC +__spirv_ocl_frexp(__CLC_GENTYPE_VEC x, __CLC_ADDRESS_SPACE int3 *ep) { + int ep_x; + int ep_y; + int ep_z; + __CLC_GENTYPE_VEC res = (__CLC_GENTYPE_VEC)(__spirv_ocl_frexp(x.x, &ep_x), + __spirv_ocl_frexp(x.y, &ep_y), + __spirv_ocl_frexp(x.z, &ep_z)); + *ep = (int3)(ep_x, ep_y, ep_z); + return res; +} + +#define __CLC_VECTORIZE_FREXP_IMPL(GENTYPE, VEC_LEN, HALF_VEC_LEN) \ + _CLC_OVERLOAD _CLC_DEF GENTYPE __spirv_ocl_frexp( \ + GENTYPE x, __CLC_ADDRESS_SPACE int##VEC_LEN *ep) { \ + int##HALF_VEC_LEN ep_lo; \ + int##HALF_VEC_LEN ep_hi; \ + GENTYPE res = (GENTYPE)(__spirv_ocl_frexp(x.lo, &ep_lo), \ + __spirv_ocl_frexp(x.hi, &ep_lo)); \ + *ep = (int##VEC_LEN)(ep_lo, ep_hi); \ + return res; \ + } + +#define __CLC_VECTORIZE_FREXP(VEC_LEN, HALF_VEC_LEN) \ + __CLC_VECTORIZE_FREXP_IMPL(__CLC_XCONCAT(__CLC_GENTYPE, VEC_LEN), VEC_LEN, \ + HALF_VEC_LEN) + +__CLC_VECTORIZE_FREXP(4, 2) +__CLC_VECTORIZE_FREXP(8, 4) +__CLC_VECTORIZE_FREXP(16, 8) + +#undef __CLC_GENTYPE_VEC +#undef __CLC_VECTORIZE_FREXP diff --git a/libclc/ptx-nvidiacl/libspirv/math/hypot.cl b/libclc/ptx-nvidiacl/libspirv/math/hypot.cl new file mode 100644 index 0000000000000..7075c75e18aa5 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/hypot.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_hypot +#define __CLC_BUILTIN __nv_hypot +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/ilogb.cl b/libclc/ptx-nvidiacl/libspirv/math/ilogb.cl new file mode 100644 index 0000000000000..7969225cdf957 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/ilogb.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include "utils.h" +#include +#include + +_CLC_DEFINE_UNARY_BUILTIN(int, __spirv_ocl_ilogb, __nv_ilogbf, float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEFINE_UNARY_BUILTIN(int, __spirv_ocl_ilogb, __nv_ilogb, double) +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_OVERLOAD _CLC_DEF int __spirv_ocl_ilogb(half x) { + float t = x; + return __spirv_ocl_ilogb(t); +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, int, __spirv_ocl_ilogb, half); +#endif + +#undef __CLC_BUILTIN +#undef __CLC_BUILTIN_F +#undef __CLC_FUNCTION diff --git a/libclc/ptx-nvidiacl/libspirv/math/ldexp.cl b/libclc/ptx-nvidiacl/libspirv/math/ldexp.cl new file mode 100644 index 0000000000000..22bf805f88794 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/ldexp.cl @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include +#include +#include + +_CLC_DEFINE_BINARY_BUILTIN(float, __spirv_ocl_ldexp, __nv_ldexpf, float, int) +_CLC_DEFINE_BINARY_BUILTIN(float, __spirv_ocl_ldexp, __nv_ldexpf, float, uint) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_DEFINE_BINARY_BUILTIN(double, __spirv_ocl_ldexp, __nv_ldexp, double, int) +_CLC_DEFINE_BINARY_BUILTIN(double, __spirv_ocl_ldexp, __nv_ldexp, double, uint) +#endif + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +_CLC_DEFINE_BINARY_BUILTIN(half, __spirv_ocl_ldexp, __nv_ldexpf, half, int) +_CLC_DEFINE_BINARY_BUILTIN(half, __spirv_ocl_ldexp, __nv_ldexpf, half, uint) +#endif diff --git a/libclc/ptx-nvidiacl/libspirv/math/log.cl b/libclc/ptx-nvidiacl/libspirv/math/log.cl new file mode 100644 index 0000000000000..de1cabbaa0300 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/log.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_log +#define __CLC_BUILTIN __nv_log +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/log10.cl b/libclc/ptx-nvidiacl/libspirv/math/log10.cl new file mode 100644 index 0000000000000..fe4992e2a9637 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/log10.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_log10 +#define __CLC_BUILTIN __nv_log10 +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/log1p.cl b/libclc/ptx-nvidiacl/libspirv/math/log1p.cl new file mode 100644 index 0000000000000..817de3ca2136f --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/log1p.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_log1p +#define __CLC_BUILTIN __nv_log1p +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/log2.cl b/libclc/ptx-nvidiacl/libspirv/math/log2.cl new file mode 100644 index 0000000000000..1d10d3a67881f --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/log2.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_log2 +#define __CLC_BUILTIN __nv_log2 +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/logb.cl b/libclc/ptx-nvidiacl/libspirv/math/logb.cl new file mode 100644 index 0000000000000..1992679264054 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/logb.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_logb +#define __CLC_BUILTIN __nv_logb +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/modf.cl b/libclc/ptx-nvidiacl/libspirv/math/modf.cl new file mode 100644 index 0000000000000..8553d240d73e7 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/modf.cl @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_MODF_IMPL(ADDRSPACE, BUILTIN, FP_TYPE, ARG_TYPE) \ + _CLC_OVERLOAD _CLC_DEF ARG_TYPE __spirv_ocl_modf(ARG_TYPE x, \ + ADDRSPACE ARG_TYPE *iptr) { \ + FP_TYPE stack_iptr; \ + ARG_TYPE ret = BUILTIN(x, &stack_iptr); \ + *iptr = stack_iptr; \ + return ret; \ + } + +#define __CLC_MODF(BUILTIN, FP_TYPE, ARG_TYPE) \ + __CLC_MODF_IMPL(private, BUILTIN, FP_TYPE, ARG_TYPE) \ + __CLC_MODF_IMPL(local, BUILTIN, FP_TYPE, ARG_TYPE) \ + __CLC_MODF_IMPL(global, BUILTIN, FP_TYPE, ARG_TYPE) + +__CLC_MODF(__nv_modff, float, float) + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __spirv_ocl_modf, float, + private, float) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __spirv_ocl_modf, float, + local, float) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __spirv_ocl_modf, float, + global, float) + +#ifdef cl_khr_fp64 +__CLC_MODF(__nv_modf, double, double) + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __spirv_ocl_modf, double, + private, double) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __spirv_ocl_modf, double, + local, double) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __spirv_ocl_modf, double, + global, double) +#endif + +#ifdef cl_khr_fp16 +__CLC_MODF(__nv_modff, float, half) + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_modf, half, + private, half) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_modf, half, + local, half) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_modf, half, + global, half) +#endif diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_cos.cl b/libclc/ptx-nvidiacl/libspirv/math/native_cos.cl new file mode 100644 index 0000000000000..ce6afb9b60970 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_cos.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_cos +#define __CLC_BUILTIN __nv_fast_cos +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#define __FLOAT_ONLY +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_log.cl b/libclc/ptx-nvidiacl/libspirv/math/native_log.cl new file mode 100644 index 0000000000000..1446adedc9cba --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_log.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_log +#define __CLC_BUILTIN __nv_fast_log +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#define __FLOAT_ONLY +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_log10.cl b/libclc/ptx-nvidiacl/libspirv/math/native_log10.cl new file mode 100644 index 0000000000000..1c2e7b4bf4f04 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_log10.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_log10 +#define __CLC_BUILTIN __nv_fast_log10 +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#define __FLOAT_ONLY +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_log2.cl b/libclc/ptx-nvidiacl/libspirv/math/native_log2.cl new file mode 100644 index 0000000000000..4178d389960ef --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_log2.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_log2 +#define __CLC_BUILTIN __nv_fast_log2 +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#define __FLOAT_ONLY +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_powr.cl b/libclc/ptx-nvidiacl/libspirv/math/native_powr.cl new file mode 100644 index 0000000000000..b7a2abdf22786 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_powr.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_powr +#define __CLC_BUILTIN __nv_fast_pow +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#define __FLOAT_ONLY +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_rsqrt.cl b/libclc/ptx-nvidiacl/libspirv/math/native_rsqrt.cl new file mode 100644 index 0000000000000..4fe33bdf995b7 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_rsqrt.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_rsqrt +#define __CLC_BUILTIN __nv_rsqrt +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_sin.cl b/libclc/ptx-nvidiacl/libspirv/math/native_sin.cl new file mode 100644 index 0000000000000..bee9782c1d88e --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_sin.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_sin +#define __CLC_BUILTIN __nv_sin +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_sqrt.cl b/libclc/ptx-nvidiacl/libspirv/math/native_sqrt.cl new file mode 100644 index 0000000000000..917fc46ea0eee --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_sqrt.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_sqrt +#define __CLC_BUILTIN __nv_sqrt +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/native_tan.cl b/libclc/ptx-nvidiacl/libspirv/math/native_tan.cl new file mode 100644 index 0000000000000..7bd247e677462 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/native_tan.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_native_tan +#define __CLC_BUILTIN __nv_tan +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/nextafter.cl b/libclc/ptx-nvidiacl/libspirv/math/nextafter.cl new file mode 100644 index 0000000000000..c6a2183bc261e --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/nextafter.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h> +#include + +#define __CLC_FUNCTION __spirv_ocl_nextafter +#define __CLC_BUILTIN __nv_nextafter +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/pow.cl b/libclc/ptx-nvidiacl/libspirv/math/pow.cl new file mode 100644 index 0000000000000..3e1c29fd05b94 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/pow.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_pow +#define __CLC_BUILTIN __nv_pow +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/remainer.cl b/libclc/ptx-nvidiacl/libspirv/math/remainer.cl new file mode 100644 index 0000000000000..ab1b183a1c5a9 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/remainer.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" + +#define __CLC_FUNCTION __spirv_ocl_remainder +#define __CLC_BUILTIN __nv_remainder +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/round.cl b/libclc/ptx-nvidiacl/libspirv/math/round.cl new file mode 100644 index 0000000000000..03b35fadaab18 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/round.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_round +#define __CLC_BUILTIN __nv_round +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/rsqrt.cl b/libclc/ptx-nvidiacl/libspirv/math/rsqrt.cl new file mode 100644 index 0000000000000..0d7f5963296ee --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/rsqrt.cl @@ -0,0 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" + +#define __CLC_FUNCTION __spirv_ocl_rsqrt +#define __CLC_BUILTIN __nv_rsqrt +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/sin.cl b/libclc/ptx-nvidiacl/libspirv/math/sin.cl new file mode 100644 index 0000000000000..e0cff1f81636f --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/sin.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_sin +#define __CLC_BUILTIN __nv_sin +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) + +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/sincos.cl b/libclc/ptx-nvidiacl/libspirv/math/sincos.cl new file mode 100644 index 0000000000000..69660dc075f18 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/sincos.cl @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_SINCOS_IMPL(ADDRSPACE, BUILTIN, FP_TYPE, ARG_TYPE) \ + _CLC_OVERLOAD _CLC_DEF ARG_TYPE __spirv_ocl_sincos( \ + ARG_TYPE x, ADDRSPACE ARG_TYPE *cosval_ptr) { \ + FP_TYPE sinval; \ + FP_TYPE cosval; \ + BUILTIN(x, &sinval, &cosval); \ + *cosval_ptr = cosval; \ + return sinval; \ + } + +#define __CLC_SINCOS(BUILTIN, FP_TYPE, ARG_TYPE) \ + __CLC_SINCOS_IMPL(global, BUILTIN, FP_TYPE, ARG_TYPE) \ + __CLC_SINCOS_IMPL(local, BUILTIN, FP_TYPE, ARG_TYPE) \ + __CLC_SINCOS_IMPL(private, BUILTIN, FP_TYPE, ARG_TYPE) + +__CLC_SINCOS(__nv_sincosf, float, float) + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __spirv_ocl_sincos, float, + private, float) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __spirv_ocl_sincos, float, + local, float) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __spirv_ocl_sincos, float, + global, float) + +#ifdef cl_khr_fp64 +__CLC_SINCOS(__nv_sincos, double, double) + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __spirv_ocl_sincos, + double, private, double) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __spirv_ocl_sincos, + double, local, double) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __spirv_ocl_sincos, + double, global, double) +#endif + +#ifdef cl_khr_fp16 +__CLC_SINCOS(__nv_sincosf, float, half) + +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_sincos, half, + private, half) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_sincos, half, + local, half) +_CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_sincos, half, + global, half) +#endif diff --git a/libclc/ptx-nvidiacl/libspirv/math/sinh.cl b/libclc/ptx-nvidiacl/libspirv/math/sinh.cl new file mode 100644 index 0000000000000..14aa53c3b777c --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/sinh.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_sinh +#define __CLC_BUILTIN __nv_sinh +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) + +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/sinpi.cl b/libclc/ptx-nvidiacl/libspirv/math/sinpi.cl new file mode 100644 index 0000000000000..d8cb96c2b01d0 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/sinpi.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_sinpi +#define __CLC_BUILTIN __nv_sinpi +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/tan.cl b/libclc/ptx-nvidiacl/libspirv/math/tan.cl new file mode 100644 index 0000000000000..d5b2b920505ee --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/tan.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_tan +#define __CLC_BUILTIN __nv_tan +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/tanh.cl b/libclc/ptx-nvidiacl/libspirv/math/tanh.cl new file mode 100644 index 0000000000000..f443c36c04117 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/tanh.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_tanh +#define __CLC_BUILTIN __nv_tanh +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/tgamma.cl b/libclc/ptx-nvidiacl/libspirv/math/tgamma.cl new file mode 100644 index 0000000000000..a49848ca53ef2 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/tgamma.cl @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_tgamma +#define __CLC_BUILTIN __nv_tgamma +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) + +#include diff --git a/libclc/ptx-nvidiacl/libspirv/math/trunc.cl b/libclc/ptx-nvidiacl/libspirv/math/trunc.cl new file mode 100644 index 0000000000000..27ae065fb0d04 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/math/trunc.cl @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#define __CLC_FUNCTION __spirv_ocl_trunc +#define __CLC_BUILTIN __nv_trunc +#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, f) +#include diff --git a/libclc/ptx-nvidiacl/libspirv/relational/isfinite.cl b/libclc/ptx-nvidiacl/libspirv/relational/isfinite.cl new file mode 100644 index 0000000000000..cc51a7fa76115 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/relational/isfinite.cl @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsFinite(double x) { + return __nv_isfinited(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsFinite, double) + +#endif + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsFinite(float x) { + return __nv_isfinited(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsFinite, float) + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsFinite(half x) { + return __nv_isfinited(x); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsFinite, half) + +#endif diff --git a/libclc/ptx-nvidiacl/libspirv/relational/isinf.cl b/libclc/ptx-nvidiacl/libspirv/relational/isinf.cl new file mode 100644 index 0000000000000..ceaf14bb8843f --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/relational/isinf.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsInf(float x) { return __nv_isinff(x); } + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsInf, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsInf(double x) { return __nv_isinfd(x); } + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsInf, double) +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsInf(half x) { + float f = x; + return __spirv_IsInf(f); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsInf, half) +#endif diff --git a/libclc/ptx-nvidiacl/libspirv/relational/isnan.cl b/libclc/ptx-nvidiacl/libspirv/relational/isnan.cl new file mode 100644 index 0000000000000..64b061cc2bc67 --- /dev/null +++ b/libclc/ptx-nvidiacl/libspirv/relational/isnan.cl @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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/libdevice.h" +#include + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsNan(float x) { return __nv_isnanf(x); } + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsNan, float) + +#ifdef cl_khr_fp64 + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsNan(double x) { return __nv_isnand(x); } + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsNan, double) +#endif + +#ifdef cl_khr_fp16 + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +_CLC_DEF _CLC_OVERLOAD bool __spirv_IsNan(half x) { + float f = x; + return __spirv_IsNan(f); +} + +_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(schar, __spirv_IsNan, half) +#endif