Skip to content

[libclc] Move 'half' builtins to CLC library #139563

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 2 commits into from
May 12, 2025
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
1 change: 0 additions & 1 deletion libclc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ include( GNUInstallDirs )
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
amdgcn-amdhsa/lib/SOURCES;
amdgcn/lib/SOURCES;
amdgpu/lib/SOURCES;
clspv/lib/SOURCES;
generic/lib/SOURCES;
ptx-nvidiacl/lib/SOURCES;
Expand Down
9 changes: 0 additions & 9 deletions libclc/amdgpu/lib/SOURCES

This file was deleted.

21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_cos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_COS_H__
#define __CLC_MATH_CLC_HALF_COS_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_cos
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_COS_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_divide.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_DIVIDE_H__
#define __CLC_MATH_CLC_HALF_DIVIDE_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_divide
#define __CLC_BODY <clc/shared/binary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_DIVIDE_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_exp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_EXP_H__
#define __CLC_MATH_CLC_HALF_EXP_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_exp
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_EXP_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_exp10.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_EXP10_H__
#define __CLC_MATH_CLC_HALF_EXP10_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_exp10
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_EXP10_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_exp2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_EXP2_H__
#define __CLC_MATH_CLC_HALF_EXP2_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_exp2
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_EXP2_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_LOG_H__
#define __CLC_MATH_CLC_HALF_LOG_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_log
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_LOG_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_log10.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_LOG10_H__
#define __CLC_MATH_CLC_HALF_LOG10_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_log10
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_LOG10_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_log2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_LOG2_H__
#define __CLC_MATH_CLC_HALF_LOG2_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_log2
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_LOG2_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_powr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_POWR_H__
#define __CLC_MATH_CLC_HALF_POWR_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_powr
#define __CLC_BODY <clc/shared/binary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_POWR_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_recip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_RECIP_H__
#define __CLC_MATH_CLC_HALF_RECIP_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_recip
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_RECIP_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_rsqrt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_RSQRT_H__
#define __CLC_MATH_CLC_HALF_RSQRT_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_rsqrt
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_RSQRT_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_sin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_SIN_H__
#define __CLC_MATH_CLC_HALF_SIN_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_sin
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_SIN_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_sqrt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_SQRT_H__
#define __CLC_MATH_CLC_HALF_SQRT_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_sqrt
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_SQRT_H__
21 changes: 21 additions & 0 deletions libclc/clc/include/clc/math/clc_half_tan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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_HALF_TAN_H__
#define __CLC_MATH_CLC_HALF_TAN_H__

#define __FLOAT_ONLY
#define __CLC_FUNCTION __clc_half_tan
#define __CLC_BODY <clc/shared/unary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_TAN_H__
9 changes: 9 additions & 0 deletions libclc/clc/lib/amdgpu/SOURCES
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
math/clc_half_exp10.cl
math/clc_half_exp2.cl
math/clc_half_exp.cl
math/clc_half_log10.cl
math/clc_half_log2.cl
math/clc_half_log.cl
math/clc_half_recip.cl
math/clc_half_rsqrt.cl
math/clc_half_sqrt.cl
math/clc_native_exp2.cl
math/clc_native_exp.cl
math/clc_native_log10.cl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include <clc/clc.h>
#include <clc/math/clc_native_exp.h>

#define __CLC_FUNC exp
#define __FLOAT_ONLY
#define __CLC_BODY <half_native_unary.inc>
#define __CLC_BODY <clc_half_native_unary.inc>
#include <clc/math/gentype.inc>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include <clc/clc.h>
#include <clc/math/clc_native_exp10.h>

#define __CLC_FUNC exp10
#define __FLOAT_ONLY
#define __CLC_BODY <half_native_unary.inc>
#define __CLC_BODY <clc_half_native_unary.inc>
#include <clc/math/gentype.inc>
15 changes: 15 additions & 0 deletions libclc/clc/lib/amdgpu/math/clc_half_exp2.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//===----------------------------------------------------------------------===//
//
// 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>

#define __CLC_FUNC exp2
#define __FLOAT_ONLY
#define __CLC_BODY <clc_half_native_unary.inc>
#include <clc/math/gentype.inc>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include <clc/clc.h>
#include <clc/math/clc_native_log.h>

#define __CLC_FUNC log
#define __FLOAT_ONLY
#define __CLC_BODY <half_native_unary.inc>
#define __CLC_BODY <clc_half_native_unary.inc>
#include <clc/math/gentype.inc>
Loading
Loading