aboutsummaryrefslogtreecommitdiff
path: root/libclc/clc
diff options
context:
space:
mode:
Diffstat (limited to 'libclc/clc')
-rw-r--r--libclc/clc/include/clc/math/unary_def_via_fp32.inc11
-rw-r--r--libclc/clc/lib/amdgcn/SOURCES2
-rw-r--r--libclc/clc/lib/generic/geometric/clc_normalize.inc17
-rw-r--r--libclc/clc/lib/generic/math/clc_erf.cl26
-rw-r--r--libclc/clc/lib/generic/math/clc_erfc.cl24
-rw-r--r--libclc/clc/lib/generic/math/clc_fmax.cl47
-rw-r--r--libclc/clc/lib/generic/math/clc_fmin.cl46
-rw-r--r--libclc/clc/lib/generic/math/clc_tgamma.cl26
-rw-r--r--libclc/clc/lib/r600/SOURCES2
-rw-r--r--libclc/clc/lib/r600/math/clc_fmax.cl41
-rw-r--r--libclc/clc/lib/r600/math/clc_fmin.cl42
-rw-r--r--libclc/clc/lib/spirv/SOURCES2
-rw-r--r--libclc/clc/lib/spirv/math/clc_fmax.cl (renamed from libclc/clc/lib/amdgcn/math/clc_fmax.cl)21
-rw-r--r--libclc/clc/lib/spirv/math/clc_fmin.cl (renamed from libclc/clc/lib/amdgcn/math/clc_fmin.cl)20
14 files changed, 38 insertions, 289 deletions
diff --git a/libclc/clc/include/clc/math/unary_def_via_fp32.inc b/libclc/clc/include/clc/math/unary_def_via_fp32.inc
deleted file mode 100644
index f109e8e..0000000
--- a/libclc/clc/include/clc/math/unary_def_via_fp32.inc
+++ /dev/null
@@ -1,11 +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 FUNCTION(__CLC_GENTYPE x) {
- return __CLC_CONVERT_GENTYPE(FUNCTION(__CLC_CONVERT_FLOATN(x)));
-}
diff --git a/libclc/clc/lib/amdgcn/SOURCES b/libclc/clc/lib/amdgcn/SOURCES
index 7bec174..d91f085 100644
--- a/libclc/clc/lib/amdgcn/SOURCES
+++ b/libclc/clc/lib/amdgcn/SOURCES
@@ -1,5 +1,3 @@
-math/clc_fmax.cl
-math/clc_fmin.cl
math/clc_ldexp_override.cl
workitem/clc_get_global_offset.cl
workitem/clc_get_global_size.cl
diff --git a/libclc/clc/lib/generic/geometric/clc_normalize.inc b/libclc/clc/lib/generic/geometric/clc_normalize.inc
index 8a47c6d..9b2cbc8 100644
--- a/libclc/clc/lib/generic/geometric/clc_normalize.inc
+++ b/libclc/clc/lib/generic/geometric/clc_normalize.inc
@@ -10,15 +10,8 @@
#if (__CLC_VECSIZE_OR_1 == 1 || __CLC_VECSIZE_OR_1 == 2 || \
__CLC_VECSIZE_OR_1 == 3 || __CLC_VECSIZE_OR_1 == 4)
-// Until we have a native FP16 implementation, go via FP32
-#if __CLC_FPSIZE == 16
-
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
- return __CLC_CONVERT_GENTYPE(__clc_normalize(__CLC_CONVERT_FLOATN(p)));
-}
-
// Scalar normalize
-#elif defined(__CLC_SCALAR)
+#if defined(__CLC_SCALAR)
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
return __clc_sign(p);
@@ -27,7 +20,13 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
// Vector normalize
#else
-#if __CLC_FPSIZE == 32
+#if __CLC_FPSIZE == 16
+
+#define MIN_VAL HALF_MIN
+#define MAX_SQRT 0x1.0p+8h
+#define MIN_SQRT 0x1.0p-8h
+
+#elif __CLC_FPSIZE == 32
#define MIN_VAL FLT_MIN
#define MAX_SQRT 0x1.0p+86F
diff --git a/libclc/clc/lib/generic/math/clc_erf.cl b/libclc/clc/lib/generic/math/clc_erf.cl
index 17fee3e..bea3924 100644
--- a/libclc/clc/lib/generic/math/clc_erf.cl
+++ b/libclc/clc/lib/generic/math/clc_erf.cl
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/math/clc_exp.h>
#include <clc/math/clc_fabs.h>
@@ -211,12 +210,6 @@ _CLC_OVERLOAD _CLC_DEF float __clc_erf(float x) {
return ret;
}
-#define __FLOAT_ONLY
-#define FUNCTION __clc_erf
-#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
@@ -500,24 +493,19 @@ _CLC_OVERLOAD _CLC_DEF double __clc_erf(double y) {
return y < 0.0 ? -ret : ret;
}
-#define __DOUBLE_ONLY
-#define FUNCTION __clc_erf
-#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
#endif
#ifdef cl_khr_fp16
-#include <clc/clc_convert.h>
-
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
// Forward the half version of this builtin onto the float one
-#define __HALF_ONLY
-#define FUNCTION __clc_erf
-#define __CLC_BODY <clc/math/unary_def_via_fp32.inc>
-#include <clc/math/gentype.inc>
+_CLC_OVERLOAD _CLC_DEF half __clc_erf(half x) {
+ return (half)__clc_erf((float)x);
+}
#endif
+
+#define FUNCTION __clc_erf
+#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/generic/math/clc_erfc.cl b/libclc/clc/lib/generic/math/clc_erfc.cl
index 77f8959..fab6960 100644
--- a/libclc/clc/lib/generic/math/clc_erfc.cl
+++ b/libclc/clc/lib/generic/math/clc_erfc.cl
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/math/clc_exp.h>
#include <clc/math/clc_fabs.h>
@@ -211,12 +210,6 @@ _CLC_OVERLOAD _CLC_DEF float __clc_erfc(float x) {
return ret;
}
-#define __FLOAT_ONLY
-#define FUNCTION __clc_erfc
-#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
@@ -509,12 +502,6 @@ _CLC_OVERLOAD _CLC_DEF double __clc_erfc(double x) {
return ret;
}
-#define __DOUBLE_ONLY
-#define FUNCTION __clc_erfc
-#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
#endif
#ifdef cl_khr_fp16
@@ -524,9 +511,12 @@ _CLC_OVERLOAD _CLC_DEF double __clc_erfc(double x) {
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
// Forward the half version of this builtin onto the float one
-#define __HALF_ONLY
-#define FUNCTION __clc_erfc
-#define __CLC_BODY <clc/math/unary_def_via_fp32.inc>
-#include <clc/math/gentype.inc>
+_CLC_OVERLOAD _CLC_DEF half __clc_erfc(half x) {
+ return (half)__clc_erfc((float)x);
+}
#endif
+
+#define FUNCTION __clc_erfc
+#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/generic/math/clc_fmax.cl b/libclc/clc/lib/generic/math/clc_fmax.cl
index 5ebbf1b..b334207 100644
--- a/libclc/clc/lib/generic/math/clc_fmax.cl
+++ b/libclc/clc/lib/generic/math/clc_fmax.cl
@@ -6,53 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
-#include <clc/relational/clc_isnan.h>
-#define __FLOAT_ONLY
-#define __CLC_MIN_VECSIZE 1
#define FUNCTION __clc_fmax
-#define __IMPL_FUNCTION __builtin_fmaxf
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef __CLC_MIN_VECSIZE
-#undef FUNCTION
-#undef __IMPL_FUNCTION
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-#define __DOUBLE_ONLY
-#define __CLC_MIN_VECSIZE 1
-#define FUNCTION __clc_fmax
-#define __IMPL_FUNCTION __builtin_fmax
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef __CLC_MIN_VECSIZE
-#undef FUNCTION
-#undef __IMPL_FUNCTION
+#define __IMPL_FUNCTION(x) __builtin_elementwise_maximumnum
+#define __CLC_BODY <clc/shared/binary_def.inc>
-#endif
-
-#ifdef cl_khr_fp16
-
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
-_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
- if (__clc_isnan(x))
- return y;
- if (__clc_isnan(y))
- return x;
- return (x < y) ? y : x;
-}
-
-#define __HALF_ONLY
-#define __CLC_SUPPORTED_VECSIZE_OR_1 2
-#define FUNCTION __clc_fmax
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
#include <clc/math/gentype.inc>
-#undef FUNCTION
-
-#endif
diff --git a/libclc/clc/lib/generic/math/clc_fmin.cl b/libclc/clc/lib/generic/math/clc_fmin.cl
index 5bddbb8..d21bb8d 100644
--- a/libclc/clc/lib/generic/math/clc_fmin.cl
+++ b/libclc/clc/lib/generic/math/clc_fmin.cl
@@ -6,52 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
-#include <clc/relational/clc_isnan.h>
-#define __FLOAT_ONLY
-#define __CLC_MIN_VECSIZE 1
#define FUNCTION __clc_fmin
-#define __IMPL_FUNCTION __builtin_fminf
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef __CLC_MIN_VECSIZE
-#undef FUNCTION
-#undef __IMPL_FUNCTION
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-#define __DOUBLE_ONLY
-#define __CLC_MIN_VECSIZE 1
-#define FUNCTION __clc_fmin
-#define __IMPL_FUNCTION __builtin_fmin
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef __CLC_MIN_VECSIZE
-#undef FUNCTION
-#undef __IMPL_FUNCTION
+#define __IMPL_FUNCTION(x) __builtin_elementwise_minimumnum
+#define __CLC_BODY <clc/shared/binary_def.inc>
-#endif
-
-#ifdef cl_khr_fp16
-
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
-_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) {
- if (__clc_isnan(x))
- return y;
- if (__clc_isnan(y))
- return x;
- return (y < x) ? y : x;
-}
-
-#define __HALF_ONLY
-#define __CLC_SUPPORTED_VECSIZE_OR_1 2
-#define FUNCTION __clc_fmin
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
#include <clc/math/gentype.inc>
-
-#endif
diff --git a/libclc/clc/lib/generic/math/clc_tgamma.cl b/libclc/clc/lib/generic/math/clc_tgamma.cl
index e0fed98..83b09cc 100644
--- a/libclc/clc/lib/generic/math/clc_tgamma.cl
+++ b/libclc/clc/lib/generic/math/clc_tgamma.cl
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include <clc/clcmacro.h>
#include <clc/float/definitions.h>
#include <clc/internal/clc.h>
#include <clc/math/clc_exp.h>
@@ -32,12 +31,6 @@ _CLC_OVERLOAD _CLC_DEF float __clc_tgamma(float x) {
return g;
}
-#define __FLOAT_ONLY
-#define FUNCTION __clc_tgamma
-#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
@@ -59,24 +52,19 @@ _CLC_OVERLOAD _CLC_DEF double __clc_tgamma(double x) {
return g;
}
-#define __DOUBLE_ONLY
-#define FUNCTION __clc_tgamma
-#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
#endif
#ifdef cl_khr_fp16
-#include <clc/clc_convert.h>
-
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
// Forward the half version of this builtin onto the float one
-#define __HALF_ONLY
-#define FUNCTION __clc_tgamma
-#define __CLC_BODY <clc/math/unary_def_via_fp32.inc>
-#include <clc/math/gentype.inc>
+_CLC_OVERLOAD _CLC_DEF half __clc_tgamma(half x) {
+ return (half)__clc_tgamma((float)x);
+}
#endif
+
+#define FUNCTION __clc_tgamma
+#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/r600/SOURCES b/libclc/clc/lib/r600/SOURCES
index 75d32f4..8d5caf1 100644
--- a/libclc/clc/lib/r600/SOURCES
+++ b/libclc/clc/lib/r600/SOURCES
@@ -1,4 +1,2 @@
-math/clc_fmax.cl
-math/clc_fmin.cl
math/clc_native_rsqrt.cl
math/clc_rsqrt_override.cl
diff --git a/libclc/clc/lib/r600/math/clc_fmax.cl b/libclc/clc/lib/r600/math/clc_fmax.cl
deleted file mode 100644
index 689e51a..0000000
--- a/libclc/clc/lib/r600/math/clc_fmax.cl
+++ /dev/null
@@ -1,41 +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/clcmacro.h>
-#include <clc/internal/clc.h>
-#include <clc/math/math.h>
-
-_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) {
- // Flush denormals if not enabled. Otherwise fmax instruction flushes the
- // values for comparison, but outputs original denormal
- x = __clc_flush_denormal_if_not_supported(x);
- y = __clc_flush_denormal_if_not_supported(y);
- return __builtin_fmaxf(x, y);
-}
-
-#define __FLOAT_ONLY
-#define FUNCTION __clc_fmax
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) {
- return __builtin_fmax(x, y);
-}
-
-#define __DOUBLE_ONLY
-#define FUNCTION __clc_fmax
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
-#endif
diff --git a/libclc/clc/lib/r600/math/clc_fmin.cl b/libclc/clc/lib/r600/math/clc_fmin.cl
deleted file mode 100644
index 22cb704..0000000
--- a/libclc/clc/lib/r600/math/clc_fmin.cl
+++ /dev/null
@@ -1,42 +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/clcmacro.h>
-#include <clc/internal/clc.h>
-#include <clc/math/math.h>
-
-_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) {
- // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise
- // fmin instruction flushes the values for comparison, but outputs original
- // denormal
- x = __clc_flush_denormal_if_not_supported(x);
- y = __clc_flush_denormal_if_not_supported(y);
- return __builtin_fminf(x, y);
-}
-
-#define __FLOAT_ONLY
-#define FUNCTION __clc_fmin
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) {
- return __builtin_fmin(x, y);
-}
-
-#define __DOUBLE_ONLY
-#define FUNCTION __clc_fmin
-#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
-#include <clc/math/gentype.inc>
-#undef FUNCTION
-
-#endif
diff --git a/libclc/clc/lib/spirv/SOURCES b/libclc/clc/lib/spirv/SOURCES
index cd6e0b2..07bc7aa 100644
--- a/libclc/clc/lib/spirv/SOURCES
+++ b/libclc/clc/lib/spirv/SOURCES
@@ -1 +1,3 @@
+math/clc_fmax.cl
+math/clc_fmin.cl
math/clc_runtime_has_hw_fma32.cl
diff --git a/libclc/clc/lib/amdgcn/math/clc_fmax.cl b/libclc/clc/lib/spirv/math/clc_fmax.cl
index cea90a7..be660fe 100644
--- a/libclc/clc/lib/amdgcn/math/clc_fmax.cl
+++ b/libclc/clc/lib/spirv/math/clc_fmax.cl
@@ -8,40 +8,23 @@
#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
-#include <clc/relational/clc_isnan.h>
_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) {
- // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise
- // fmax instruction flushes the values for comparison, but outputs original
- // denormal
- x = __builtin_canonicalizef(x);
- y = __builtin_canonicalizef(y);
return __builtin_fmaxf(x, y);
}
#ifdef cl_khr_fp64
-
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) {
- x = __builtin_canonicalize(x);
- y = __builtin_canonicalize(y);
return __builtin_fmax(x, y);
}
-
#endif
-#ifdef cl_khr_fp16
+#ifdef cl_khr_fp16
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
- if (__clc_isnan(x))
- return y;
- if (__clc_isnan(y))
- return x;
- return (y < x) ? x : y;
+ return __builtin_fmaxf16(x, y);
}
-
#endif
#define FUNCTION __clc_fmax
diff --git a/libclc/clc/lib/amdgcn/math/clc_fmin.cl b/libclc/clc/lib/spirv/math/clc_fmin.cl
index 12bb0c6..9f3fa66 100644
--- a/libclc/clc/lib/amdgcn/math/clc_fmin.cl
+++ b/libclc/clc/lib/spirv/math/clc_fmin.cl
@@ -8,41 +8,23 @@
#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
-#include <clc/relational/clc_isnan.h>
_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) {
- // fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise
- // fmin instruction flushes the values for comparison, but outputs original
- // denormal
- x = __builtin_canonicalizef(x);
- y = __builtin_canonicalizef(y);
return __builtin_fminf(x, y);
}
#ifdef cl_khr_fp64
-
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) {
- x = __builtin_canonicalize(x);
- y = __builtin_canonicalize(y);
return __builtin_fmin(x, y);
}
-
#endif
#ifdef cl_khr_fp16
-
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) {
- if (__clc_isnan(x))
- return y;
- if (__clc_isnan(y))
- return x;
- return (y < x) ? y : x;
+ return __builtin_fminf16(x, y);
}
-
#endif
#define FUNCTION __clc_fmin