Skip to content

[libclc] Move native_(exp10|powr|tan) to CLC library #134080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions libclc/clc/include/clc/math/clc_native_exp10.h
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions libclc/clc/include/clc/math/clc_native_powr.h
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions libclc/clc/include/clc/math/clc_native_tan.h
Original file line number Diff line number Diff line change
@@ -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__
3 changes: 3 additions & 0 deletions libclc/clc/lib/generic/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,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
Expand Down
16 changes: 16 additions & 0 deletions libclc/clc/lib/generic/math/clc_native_exp10.cl
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 16 additions & 0 deletions libclc/clc/lib/generic/math/clc_native_powr.cl
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 16 additions & 0 deletions libclc/clc/lib/generic/math/clc_native_tan.cl
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion libclc/generic/include/clc/math/native_divide.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libclc/generic/include/clc/math/native_powr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion libclc/generic/lib/math/native_exp10.cl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
5 changes: 4 additions & 1 deletion libclc/generic/lib/math/native_powr.cl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
5 changes: 4 additions & 1 deletion libclc/generic/lib/math/native_tan.cl
Original file line number Diff line number Diff line change
Expand Up @@ -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>