Skip to content

Commit b52977b

Browse files
authored
[libclc] Move pow, powr & pown to the CLC library (#133294)
These functions were already nominally in the CLC library. Similar to others, these builtins are now vectorized and are not broken down into scalar types.
1 parent 0a74cbf commit b52977b

30 files changed

+1930
-2047
lines changed

libclc/generic/include/clc/math/pown.inc renamed to libclc/clc/include/clc/math/binary_decl_with_int_second_arg.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE pown(__CLC_GENTYPE a, __CLC_INTN b);
9+
#include <clc/utils.h>
10+
11+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
12+
__CLC_INTN y);

libclc/generic/lib/math/pown.inc renamed to libclc/clc/include/clc/math/binary_def_with_int_second_arg.inc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE pown(__CLC_GENTYPE x, __CLC_INTN y) {
10-
return __clc_pown(x, y);
9+
#include <clc/utils.h>
10+
11+
#ifndef __CLC_FUNCTION
12+
#define __CLC_FUNCTION(x) __CLC_CONCAT(__clc_, x)
13+
#endif
14+
15+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x, __CLC_INTN y) {
16+
return __CLC_FUNCTION(FUNCTION)(x, y);
1117
}

libclc/generic/include/math/clc_pow.h renamed to libclc/clc/include/clc/math/clc_pow.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_MATH_CLC_POW_H__
10+
#define __CLC_MATH_CLC_POW_H__
11+
12+
#define __CLC_BODY <clc/shared/binary_decl.inc>
913
#define __CLC_FUNCTION __clc_pow
10-
#define __CLC_BODY <clc/math/binary_decl_tt.inc>
14+
1115
#include <clc/math/gentype.inc>
16+
1217
#undef __CLC_BODY
1318
#undef __CLC_FUNCTION
19+
20+
#endif // __CLC_MATH_CLC_POW_H__

libclc/generic/include/math/clc_pown.h renamed to libclc/clc/include/clc/math/clc_pown.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#define __CLC_BODY <math/clc_pown.inc>
9+
#ifndef __CLC_MATH_CLC_POWN_H__
10+
#define __CLC_MATH_CLC_POWN_H__
11+
12+
#define __CLC_BODY <clc/math/binary_decl_with_int_second_arg.inc>
13+
#define __CLC_FUNCTION __clc_pown
14+
1015
#include <clc/math/gentype.inc>
16+
1117
#undef __CLC_BODY
18+
#undef __CLC_FUNCTION
19+
20+
#endif // __CLC_MATH_CLC_POWN_H__

libclc/generic/include/math/clc_powr.h renamed to libclc/clc/include/clc/math/clc_powr.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __CLC_MATH_CLC_POWR_H__
10+
#define __CLC_MATH_CLC_POWR_H__
11+
12+
#define __CLC_BODY <clc/shared/binary_decl.inc>
913
#define __CLC_FUNCTION __clc_powr
10-
#define __CLC_BODY <clc/math/binary_decl_tt.inc>
14+
1115
#include <clc/math/gentype.inc>
16+
1217
#undef __CLC_BODY
1318
#undef __CLC_FUNCTION
19+
20+
#endif // __CLC_MATH_CLC_POWR_H__

libclc/clc/include/clc/math/tables.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,20 @@
5959

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

62-
TABLE_FUNCTION_DECL(float2, log_inv_tbl_ep);
6362
TABLE_FUNCTION_DECL(float2, log2_tbl);
6463
TABLE_FUNCTION_DECL(float2, log10_tbl);
6564
TABLE_FUNCTION_DECL(uint4, pibits_tbl);
6665
TABLE_FUNCTION_DECL(float2, sinhcosh_tbl);
6766
TABLE_FUNCTION_DECL(float2, cbrt_tbl);
6867
TABLE_FUNCTION_DECL(float, exp_tbl);
69-
TABLE_FUNCTION_DECL(float2, exp_tbl_ep);
7068

69+
CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl_ep_head);
70+
CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl_ep_tail);
7171
CLC_TABLE_FUNCTION_DECL(float, loge_tbl_lo);
7272
CLC_TABLE_FUNCTION_DECL(float, loge_tbl_hi);
7373
CLC_TABLE_FUNCTION_DECL(float, log_inv_tbl);
74+
CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_head);
75+
CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_tail);
7476

7577
#ifdef cl_khr_fp64
7678

@@ -81,14 +83,17 @@ CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
8183
CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
8284
CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);
8385
CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_tail);
84-
TABLE_FUNCTION_DECL(double2, two_to_jby64_ep_tbl);
86+
CLC_TABLE_FUNCTION_DECL(double, two_to_jby64_ep_tbl_head);
87+
CLC_TABLE_FUNCTION_DECL(double, two_to_jby64_ep_tbl_tail);
8588
TABLE_FUNCTION_DECL(double2, sinh_tbl);
8689
TABLE_FUNCTION_DECL(double2, cosh_tbl);
8790
TABLE_FUNCTION_DECL(double, cbrt_inv_tbl);
8891
TABLE_FUNCTION_DECL(double2, cbrt_dbl_tbl);
8992
TABLE_FUNCTION_DECL(double2, cbrt_rem_tbl);
90-
TABLE_FUNCTION_DECL(double2, powlog_tbl);
91-
TABLE_FUNCTION_DECL(double2, log_f_inv_tbl);
93+
CLC_TABLE_FUNCTION_DECL(double, powlog_tbl_head);
94+
CLC_TABLE_FUNCTION_DECL(double, powlog_tbl_tail);
95+
CLC_TABLE_FUNCTION_DECL(double, log_f_inv_tbl_head);
96+
CLC_TABLE_FUNCTION_DECL(double, log_f_inv_tbl_tail);
9297

9398
#endif // cl_khr_fp64
9499

libclc/clc/lib/generic/SOURCES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ math/clc_mad.cl
4646
math/clc_modf.cl
4747
math/clc_nan.cl
4848
math/clc_nextafter.cl
49+
math/clc_pow.cl
50+
math/clc_pown.cl
51+
math/clc_powr.cl
4952
math/clc_remainder.cl
5053
math/clc_remquo.cl
5154
math/clc_rint.cl
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include <clc/clc_convert.h>
10+
#include <clc/clcmacro.h>
11+
#include <clc/internal/clc.h>
12+
#include <clc/math/clc_fabs.h>
13+
#include <clc/math/clc_fma.h>
14+
#include <clc/math/clc_ldexp.h>
15+
#include <clc/math/clc_mad.h>
16+
#include <clc/math/clc_subnormal_config.h>
17+
#include <clc/math/math.h>
18+
#include <clc/math/tables.h>
19+
#include <clc/relational/clc_select.h>
20+
21+
#define __CLC_BODY <clc_pow.inc>
22+
#include <clc/math/gentype.inc>

0 commit comments

Comments
 (0)