diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index d4753b22ed01..dbbc29261d3b 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -266,20 +266,22 @@ set_source_files_properties( # CLC builtins ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_cos.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_divide.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp10.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp2.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_exp.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log10.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log2.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_log.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_powr.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_recip.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_rsqrt.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_sin.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_sqrt.cl + ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/generic/math/clc_native_tan.cl # Target-specific CLC builtins ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_exp2.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_exp.cl ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/amdgpu/math/clc_native_log10.cl - # Target-specific OpenCL builtins ${CMAKE_CURRENT_SOURCE_DIR}/clc/lib/r600/math/clc_native_rsqrt.cl # OpenCL builtins ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/math/native_cos.cl diff --git a/libclc/clc/include/clc/math/clc_native_exp10.h b/libclc/clc/include/clc/math/clc_native_exp10.h new file mode 100644 index 000000000000..302482d670cc --- /dev/null +++ b/libclc/clc/include/clc/math/clc_native_exp10.h @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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_NATIVE_EXP10_H__ +#define __CLC_MATH_CLC_NATIVE_EXP10_H__ + +#define __FLOAT_ONLY +#define __CLC_FUNCTION __clc_native_exp10 +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION +#undef __FLOAT_ONLY + +#endif // __CLC_MATH_CLC_NATIVE_EXP10_H__ diff --git a/libclc/clc/include/clc/math/clc_native_powr.h b/libclc/clc/include/clc/math/clc_native_powr.h new file mode 100644 index 000000000000..55d409fffaab --- /dev/null +++ b/libclc/clc/include/clc/math/clc_native_powr.h @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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_NATIVE_POWR_H__ +#define __CLC_MATH_CLC_NATIVE_POWR_H__ + +#define __FLOAT_ONLY +#define __CLC_FUNCTION __clc_native_powr +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION +#undef __FLOAT_ONLY + +#endif // __CLC_MATH_CLC_NATIVE_POWR_H__ diff --git a/libclc/clc/include/clc/math/clc_native_tan.h b/libclc/clc/include/clc/math/clc_native_tan.h new file mode 100644 index 000000000000..5fc96f8d1797 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_native_tan.h @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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_NATIVE_TAN_H__ +#define __CLC_MATH_CLC_NATIVE_TAN_H__ + +#define __FLOAT_ONLY +#define __CLC_FUNCTION __clc_native_tan +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION +#undef __FLOAT_ONLY + +#endif // __CLC_MATH_CLC_NATIVE_TAN_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 25549af552a3..2e9878e6eaa4 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -58,14 +58,17 @@ math/clc_nan.cl math/clc_native_cos.cl math/clc_native_divide.cl math/clc_native_exp.cl +math/clc_native_exp10.cl math/clc_native_exp2.cl math/clc_native_log.cl math/clc_native_log10.cl math/clc_native_log2.cl +math/clc_native_powr.cl math/clc_native_rsqrt.cl math/clc_native_recip.cl math/clc_native_sin.cl math/clc_native_sqrt.cl +math/clc_native_tan.cl math/clc_nextafter.cl math/clc_pow.cl math/clc_pown.cl diff --git a/libclc/clc/lib/generic/math/clc_native_exp10.cl b/libclc/clc/lib/generic/math/clc_native_exp10.cl new file mode 100644 index 000000000000..7ca5d1992c61 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_native_exp10.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 + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/libclc/generic/lib/math/native_exp10.inc b/libclc/clc/lib/generic/math/clc_native_exp10.inc similarity index 75% rename from libclc/generic/lib/math/native_exp10.inc rename to libclc/clc/lib/generic/math/clc_native_exp10.inc index d704152b962e..c002b5444f43 100644 --- a/libclc/generic/lib/math/native_exp10.inc +++ b/libclc/clc/lib/generic/math/clc_native_exp10.inc @@ -6,6 +6,6 @@ // //===----------------------------------------------------------------------===// -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_exp10(__CLC_GENTYPE val) { - return native_exp2(val * M_LOG210_F); +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_exp10(__CLC_GENTYPE val) { + return __clc_native_exp2(val * M_LOG210_F); } diff --git a/libclc/clc/lib/generic/math/clc_native_powr.cl b/libclc/clc/lib/generic/math/clc_native_powr.cl new file mode 100644 index 000000000000..7c7dcaf8c508 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_native_powr.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 + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/libclc/generic/lib/math/native_powr.inc b/libclc/clc/lib/generic/math/clc_native_powr.inc similarity index 69% rename from libclc/generic/lib/math/native_powr.inc rename to libclc/clc/lib/generic/math/clc_native_powr.inc index eae4d1b0b5fd..51bd8b5ceb58 100644 --- a/libclc/generic/lib/math/native_powr.inc +++ b/libclc/clc/lib/generic/math/clc_native_powr.inc @@ -6,8 +6,9 @@ // //===----------------------------------------------------------------------===// -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_powr(__CLC_GENTYPE x, __CLC_GENTYPE y) { +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_powr(__CLC_GENTYPE x, + __CLC_GENTYPE y) { // x^y == 2^{log2 x^y} == 2^{y * log2 x} // for x < 0 propagate nan created by log2 - return native_exp2(y * native_log2(x)); + return __clc_native_exp2(y * __clc_native_log2(x)); } diff --git a/libclc/clc/lib/generic/math/clc_native_tan.cl b/libclc/clc/lib/generic/math/clc_native_tan.cl new file mode 100644 index 000000000000..a9ac46688c8f --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_native_tan.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 + +#define __FLOAT_ONLY +#define __CLC_BODY + +#include diff --git a/libclc/generic/lib/math/native_tan.inc b/libclc/clc/lib/generic/math/clc_native_tan.inc similarity index 73% rename from libclc/generic/lib/math/native_tan.inc rename to libclc/clc/lib/generic/math/clc_native_tan.inc index 02e05de74d67..f61a78968a75 100644 --- a/libclc/generic/lib/math/native_tan.inc +++ b/libclc/clc/lib/generic/math/clc_native_tan.inc @@ -6,6 +6,6 @@ // //===----------------------------------------------------------------------===// -_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_tan(__CLC_GENTYPE val) { - return native_sin(val) / native_cos(val); +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_tan(__CLC_GENTYPE val) { + return __clc_native_sin(val) / __clc_native_cos(val); } diff --git a/libclc/generic/include/clc/math/native_divide.h b/libclc/generic/include/clc/math/native_divide.h index 2dd4aad46c3b..3989a256cf94 100644 --- a/libclc/generic/include/clc/math/native_divide.h +++ b/libclc/generic/include/clc/math/native_divide.h @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#define __CLC_BODY +#define __CLC_BODY #define __CLC_FUNCTION native_divide #include diff --git a/libclc/generic/include/clc/math/native_powr.h b/libclc/generic/include/clc/math/native_powr.h index e6fdb81d3cff..19ae2d1ef9a0 100644 --- a/libclc/generic/include/clc/math/native_powr.h +++ b/libclc/generic/include/clc/math/native_powr.h @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#define __CLC_BODY +#define __CLC_BODY #define __CLC_FUNCTION native_powr #include diff --git a/libclc/generic/lib/math/native_exp10.cl b/libclc/generic/lib/math/native_exp10.cl index 4accc5b3c030..a7f3711cbedf 100644 --- a/libclc/generic/lib/math/native_exp10.cl +++ b/libclc/generic/lib/math/native_exp10.cl @@ -7,7 +7,10 @@ //===----------------------------------------------------------------------===// #include +#include -#define __CLC_BODY #define __FLOAT_ONLY +#define FUNCTION native_exp10 +#define __CLC_BODY + #include diff --git a/libclc/generic/lib/math/native_powr.cl b/libclc/generic/lib/math/native_powr.cl index a6d6c7a4417f..31a650b79b60 100644 --- a/libclc/generic/lib/math/native_powr.cl +++ b/libclc/generic/lib/math/native_powr.cl @@ -7,7 +7,10 @@ //===----------------------------------------------------------------------===// #include +#include -#define __CLC_BODY #define __FLOAT_ONLY +#define FUNCTION native_powr +#define __CLC_BODY + #include diff --git a/libclc/generic/lib/math/native_tan.cl b/libclc/generic/lib/math/native_tan.cl index c73795f725d8..2b474ed46a5b 100644 --- a/libclc/generic/lib/math/native_tan.cl +++ b/libclc/generic/lib/math/native_tan.cl @@ -7,7 +7,10 @@ //===----------------------------------------------------------------------===// #include +#include -#define __CLC_BODY #define __FLOAT_ONLY +#define FUNCTION native_tan +#define __CLC_BODY + #include