mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-14 17:06:38 +00:00
[libclc] Move native_(exp10|powr|tan) to CLC library (#134080)
These are the three remaining native builtins not yet ported. There are elementwise versions of exp10 and tan which correspond to the intrinsics, which may be preferable to the current versions which route through other native builtins. Those could be changed in a follow-up if desired.
This commit is contained in:
parent
4a4d41e723
commit
ddc48fefe3
@ -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
|
||||
|
22
libclc/clc/include/clc/math/clc_native_exp10.h
Normal file
22
libclc/clc/include/clc/math/clc_native_exp10.h
Normal file
@ -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 <clc/shared/unary_decl.inc>
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
#undef __CLC_BODY
|
||||
#undef __CLC_FUNCTION
|
||||
#undef __FLOAT_ONLY
|
||||
|
||||
#endif // __CLC_MATH_CLC_NATIVE_EXP10_H__
|
22
libclc/clc/include/clc/math/clc_native_powr.h
Normal file
22
libclc/clc/include/clc/math/clc_native_powr.h
Normal file
@ -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 <clc/shared/binary_decl.inc>
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
#undef __CLC_BODY
|
||||
#undef __CLC_FUNCTION
|
||||
#undef __FLOAT_ONLY
|
||||
|
||||
#endif // __CLC_MATH_CLC_NATIVE_POWR_H__
|
22
libclc/clc/include/clc/math/clc_native_tan.h
Normal file
22
libclc/clc/include/clc/math/clc_native_tan.h
Normal file
@ -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 <clc/shared/unary_decl.inc>
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
#undef __CLC_BODY
|
||||
#undef __CLC_FUNCTION
|
||||
#undef __FLOAT_ONLY
|
||||
|
||||
#endif // __CLC_MATH_CLC_NATIVE_TAN_H__
|
@ -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
|
||||
|
16
libclc/clc/lib/generic/math/clc_native_exp10.cl
Normal file
16
libclc/clc/lib/generic/math/clc_native_exp10.cl
Normal file
@ -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 <clc/float/definitions.h>
|
||||
#include <clc/internal/clc.h>
|
||||
#include <clc/math/clc_native_exp2.h>
|
||||
|
||||
#define __FLOAT_ONLY
|
||||
#define __CLC_BODY <clc_native_exp10.inc>
|
||||
|
||||
#include <clc/math/gentype.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);
|
||||
}
|
16
libclc/clc/lib/generic/math/clc_native_powr.cl
Normal file
16
libclc/clc/lib/generic/math/clc_native_powr.cl
Normal file
@ -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 <clc/internal/clc.h>
|
||||
#include <clc/math/clc_native_exp2.h>
|
||||
#include <clc/math/clc_native_log2.h>
|
||||
|
||||
#define __FLOAT_ONLY
|
||||
#define __CLC_BODY <clc_native_powr.inc>
|
||||
|
||||
#include <clc/math/gentype.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));
|
||||
}
|
16
libclc/clc/lib/generic/math/clc_native_tan.cl
Normal file
16
libclc/clc/lib/generic/math/clc_native_tan.cl
Normal file
@ -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 <clc/internal/clc.h>
|
||||
#include <clc/math/clc_native_cos.h>
|
||||
#include <clc/math/clc_native_sin.h>
|
||||
|
||||
#define __FLOAT_ONLY
|
||||
#define __CLC_BODY <clc_native_tan.inc>
|
||||
|
||||
#include <clc/math/gentype.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);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define __CLC_BODY <clc/math/binary_decl_tt.inc>
|
||||
#define __CLC_BODY <clc/shared/binary_decl.inc>
|
||||
#define __CLC_FUNCTION native_divide
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define __CLC_BODY <clc/math/binary_decl_tt.inc>
|
||||
#define __CLC_BODY <clc/shared/binary_decl.inc>
|
||||
#define __CLC_FUNCTION native_powr
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
@ -7,7 +7,10 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/clc.h>
|
||||
#include <clc/math/clc_native_exp10.h>
|
||||
|
||||
#define __CLC_BODY <native_exp10.inc>
|
||||
#define __FLOAT_ONLY
|
||||
#define FUNCTION native_exp10
|
||||
#define __CLC_BODY <clc/shared/unary_def.inc>
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
@ -7,7 +7,10 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/clc.h>
|
||||
#include <clc/math/clc_native_powr.h>
|
||||
|
||||
#define __CLC_BODY <native_powr.inc>
|
||||
#define __FLOAT_ONLY
|
||||
#define FUNCTION native_powr
|
||||
#define __CLC_BODY <clc/shared/binary_def.inc>
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
@ -7,7 +7,10 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/clc.h>
|
||||
#include <clc/math/clc_native_tan.h>
|
||||
|
||||
#define __CLC_BODY <native_tan.inc>
|
||||
#define __FLOAT_ONLY
|
||||
#define FUNCTION native_tan
|
||||
#define __CLC_BODY <clc/shared/unary_def.inc>
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
Loading…
x
Reference in New Issue
Block a user