Skip to content

[libclc] Move pow, powr & pown to the CLC library #133294

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 1 commit into from
Mar 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
//
//===----------------------------------------------------------------------===//

_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE pown(__CLC_GENTYPE a, __CLC_INTN b);
#include <clc/utils.h>

_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
__CLC_INTN y);
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
//
//===----------------------------------------------------------------------===//

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE pown(__CLC_GENTYPE x, __CLC_INTN y) {
return __clc_pown(x, y);
#include <clc/utils.h>

#ifndef __CLC_FUNCTION
#define __CLC_FUNCTION(x) __CLC_CONCAT(__clc_, x)
#endif

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_INTN y) {
return __CLC_FUNCTION(FUNCTION)(x, y);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_MATH_CLC_POW_H__
#define __CLC_MATH_CLC_POW_H__

#define __CLC_BODY <clc/shared/binary_decl.inc>
#define __CLC_FUNCTION __clc_pow
#define __CLC_BODY <clc/math/binary_decl_tt.inc>

#include <clc/math/gentype.inc>

#undef __CLC_BODY
#undef __CLC_FUNCTION

#endif // __CLC_MATH_CLC_POW_H__
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
//
//===----------------------------------------------------------------------===//

#define __CLC_BODY <math/clc_pown.inc>
#ifndef __CLC_MATH_CLC_POWN_H__
#define __CLC_MATH_CLC_POWN_H__

#define __CLC_BODY <clc/math/binary_decl_with_int_second_arg.inc>
#define __CLC_FUNCTION __clc_pown

#include <clc/math/gentype.inc>

#undef __CLC_BODY
#undef __CLC_FUNCTION

#endif // __CLC_MATH_CLC_POWN_H__
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_MATH_CLC_POWR_H__
#define __CLC_MATH_CLC_POWR_H__

#define __CLC_BODY <clc/shared/binary_decl.inc>
#define __CLC_FUNCTION __clc_powr
#define __CLC_BODY <clc/math/binary_decl_tt.inc>

#include <clc/math/gentype.inc>

#undef __CLC_BODY
#undef __CLC_FUNCTION

#endif // __CLC_MATH_CLC_POWR_H__
15 changes: 10 additions & 5 deletions libclc/clc/include/clc/math/tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,20 @@

#define USE_TABLE(NAME, IDX) TABLE_MANGLE(NAME)(IDX)

TABLE_FUNCTION_DECL(float2, log_inv_tbl_ep);
TABLE_FUNCTION_DECL(float2, log2_tbl);
TABLE_FUNCTION_DECL(float2, log10_tbl);
TABLE_FUNCTION_DECL(uint4, pibits_tbl);
TABLE_FUNCTION_DECL(float2, sinhcosh_tbl);
TABLE_FUNCTION_DECL(float2, cbrt_tbl);
TABLE_FUNCTION_DECL(float, exp_tbl);
TABLE_FUNCTION_DECL(float2, exp_tbl_ep);

CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl_ep_head);
CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl_ep_tail);
CLC_TABLE_FUNCTION_DECL(float, loge_tbl_lo);
CLC_TABLE_FUNCTION_DECL(float, loge_tbl_hi);
CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl);
CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_head);
CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_tail);

#ifdef cl_khr_fp64

Expand All @@ -81,14 +83,17 @@ CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);
CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_tail);
TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl);
CLC_TABLE_FUNCTION_DECL(double, two_to_jby64_ep_tbl_head);
CLC_TABLE_FUNCTION_DECL(double, two_to_jby64_ep_tbl_tail);
TABLE_FUNCTION_DECL(double2, sinh_tbl);
TABLE_FUNCTION_DECL(double2, cosh_tbl);
TABLE_FUNCTION_DECL(double, cbrt_inv_tbl);
TABLE_FUNCTION_DECL(double2, cbrt_dbl_tbl);
TABLE_FUNCTION_DECL(double2, cbrt_rem_tbl);
TABLE_FUNCTION_DECL(double2, powlog_tbl);
TABLE_FUNCTION_DECL(double2, log_f_inv_tbl);
CLC_TABLE_FUNCTION_DECL(double, powlog_tbl_head);
CLC_TABLE_FUNCTION_DECL(double, powlog_tbl_tail);
CLC_TABLE_FUNCTION_DECL(double, log_f_inv_tbl_head);
CLC_TABLE_FUNCTION_DECL(double, log_f_inv_tbl_tail);

#endif // cl_khr_fp64

Expand Down
3 changes: 3 additions & 0 deletions libclc/clc/lib/generic/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ math/clc_mad.cl
math/clc_modf.cl
math/clc_nan.cl
math/clc_nextafter.cl
math/clc_pow.cl
math/clc_pown.cl
math/clc_powr.cl
math/clc_remainder.cl
math/clc_remquo.cl
math/clc_rint.cl
Expand Down
22 changes: 22 additions & 0 deletions libclc/clc/lib/generic/math/clc_pow.cl
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
//
//===----------------------------------------------------------------------===//

#include <clc/clc_convert.h>
#include <clc/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/math/clc_fabs.h>
#include <clc/math/clc_fma.h>
#include <clc/math/clc_ldexp.h>
#include <clc/math/clc_mad.h>
#include <clc/math/clc_subnormal_config.h>
#include <clc/math/math.h>
#include <clc/math/tables.h>
#include <clc/relational/clc_select.h>

#define __CLC_BODY <clc_pow.inc>
#include <clc/math/gentype.inc>
Loading