Skip to content

Commit c73ad02

Browse files
authored
[libc][libm][GPU] Add missing vendor entrypoints to the GPU version of libm (llvm#66034)
This patch populates the GPU version of `libm` with missing vendor entrypoints. The vendor math entrypoints are disabled by default but can be enabled with the CMake option `LIBC_GPU_VENDOR_MATH=ON`.
1 parent a91a664 commit c73ad02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1190
-86
lines changed

libc/config/gpu/entrypoints.txt

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,19 @@ set(TARGET_LIBC_ENTRYPOINTS
125125

126126
set(TARGET_LIBM_ENTRYPOINTS
127127
# math.h entrypoints
128+
libc.src.math.acos
128129
libc.src.math.acosf
130+
libc.src.math.acosh
129131
libc.src.math.acoshf
132+
libc.src.math.asin
130133
libc.src.math.asinf
134+
libc.src.math.asinh
131135
libc.src.math.asinhf
136+
libc.src.math.atan
132137
libc.src.math.atanf
138+
libc.src.math.atan2
139+
libc.src.math.atan2f
140+
libc.src.math.atanh
133141
libc.src.math.atanhf
134142
libc.src.math.ceil
135143
libc.src.math.ceilf
@@ -139,9 +147,15 @@ set(TARGET_LIBM_ENTRYPOINTS
139147
libc.src.math.cosf
140148
libc.src.math.cosh
141149
libc.src.math.coshf
150+
libc.src.math.erf
151+
libc.src.math.erff
152+
libc.src.math.exp10
142153
libc.src.math.exp10f
154+
libc.src.math.exp2
143155
libc.src.math.exp2f
156+
libc.src.math.exp
144157
libc.src.math.expf
158+
libc.src.math.expm1
145159
libc.src.math.expm1f
146160
libc.src.math.fabs
147161
libc.src.math.fabsf
@@ -169,15 +183,26 @@ set(TARGET_LIBM_ENTRYPOINTS
169183
libc.src.math.llrintf
170184
libc.src.math.llround
171185
libc.src.math.llroundf
172-
libc.src.math.pow
173-
libc.src.math.powf
174-
libc.src.math.sin
186+
libc.src.math.log10
187+
libc.src.math.log10f
188+
libc.src.math.log1p
189+
libc.src.math.log1pf
190+
libc.src.math.log2
191+
libc.src.math.log2f
192+
libc.src.math.log
193+
libc.src.math.logf
194+
libc.src.math.lrint
195+
libc.src.math.lrintf
196+
libc.src.math.lround
197+
libc.src.math.lroundf
175198
libc.src.math.modf
176199
libc.src.math.modff
177200
libc.src.math.nearbyint
178201
libc.src.math.nearbyintf
179202
libc.src.math.nextafter
180203
libc.src.math.nextafterf
204+
libc.src.math.pow
205+
libc.src.math.powf
181206
libc.src.math.remainder
182207
libc.src.math.remainderf
183208
libc.src.math.remquo
@@ -188,6 +213,10 @@ set(TARGET_LIBM_ENTRYPOINTS
188213
libc.src.math.roundf
189214
libc.src.math.scalbn
190215
libc.src.math.scalbnf
216+
libc.src.math.sin
217+
libc.src.math.sinf
218+
libc.src.math.sincos
219+
libc.src.math.sincosf
191220
libc.src.math.sinh
192221
libc.src.math.sinhf
193222
libc.src.math.sqrt
@@ -196,6 +225,8 @@ set(TARGET_LIBM_ENTRYPOINTS
196225
libc.src.math.tanf
197226
libc.src.math.tanh
198227
libc.src.math.tanhf
228+
libc.src.math.tgamma
229+
libc.src.math.tgammaf
199230
libc.src.math.trunc
200231
libc.src.math.truncf
201232
)

libc/src/math/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,23 @@ function(add_math_entrypoint_object name)
5454
)
5555
endfunction()
5656

57+
add_math_entrypoint_object(acos)
5758
add_math_entrypoint_object(acosf)
59+
add_math_entrypoint_object(acosh)
5860
add_math_entrypoint_object(acoshf)
5961

62+
add_math_entrypoint_object(asin)
6063
add_math_entrypoint_object(asinf)
64+
add_math_entrypoint_object(asinh)
6165
add_math_entrypoint_object(asinhf)
6266

67+
add_math_entrypoint_object(atan)
6368
add_math_entrypoint_object(atanf)
6469

70+
add_math_entrypoint_object(atan2)
71+
add_math_entrypoint_object(atan2f)
72+
73+
add_math_entrypoint_object(atanh)
6574
add_math_entrypoint_object(atanhf)
6675

6776
add_math_entrypoint_object(ceil)
@@ -77,6 +86,7 @@ add_math_entrypoint_object(cosf)
7786
add_math_entrypoint_object(cosh)
7887
add_math_entrypoint_object(coshf)
7988

89+
add_math_entrypoint_object(erf)
8090
add_math_entrypoint_object(erff)
8191

8292
add_math_entrypoint_object(exp)
@@ -199,6 +209,7 @@ add_math_entrypoint_object(scalbn)
199209
add_math_entrypoint_object(scalbnf)
200210
add_math_entrypoint_object(scalbnl)
201211

212+
add_math_entrypoint_object(sincos)
202213
add_math_entrypoint_object(sincosf)
203214

204215
add_math_entrypoint_object(sin)
@@ -217,6 +228,9 @@ add_math_entrypoint_object(tanf)
217228
add_math_entrypoint_object(tanh)
218229
add_math_entrypoint_object(tanhf)
219230

231+
add_math_entrypoint_object(tgamma)
232+
add_math_entrypoint_object(tgammaf)
233+
220234
add_math_entrypoint_object(trunc)
221235
add_math_entrypoint_object(truncf)
222236
add_math_entrypoint_object(truncl)

libc/src/math/acos.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for acos --------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ACOS_H
10+
#define LLVM_LIBC_SRC_MATH_ACOS_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double acos(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ACOS_H

libc/src/math/acosh.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for acosh -------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ACOSH_H
10+
#define LLVM_LIBC_SRC_MATH_ACOSH_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double acosh(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ACOSH_H

libc/src/math/asin.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for asin --------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ASIN_H
10+
#define LLVM_LIBC_SRC_MATH_ASIN_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double asin(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ASIN_H

libc/src/math/asinh.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for asinh -------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ASINH_H
10+
#define LLVM_LIBC_SRC_MATH_ASINH_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double asinh(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ASINH_H

libc/src/math/atan.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for atan --------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ATAN_H
10+
#define LLVM_LIBC_SRC_MATH_ATAN_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double atan(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ATAN_H

libc/src/math/atan2.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for atan2 -------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ATAN2_H
10+
#define LLVM_LIBC_SRC_MATH_ATAN2_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double atan2(double x, double y);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ATAN2_H

libc/src/math/atan2f.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for atan2f ------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ATAN2F_H
10+
#define LLVM_LIBC_SRC_MATH_ATAN2F_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
float atan2f(float x, float y);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ATAN2F_H

libc/src/math/atanh.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for atanh -------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ATANH_H
10+
#define LLVM_LIBC_SRC_MATH_ATANH_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double atanh(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ATANH_H

libc/src/math/erf.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Implementation header for erf ---------------------------*- C++ -*-===//
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+
#ifndef LLVM_LIBC_SRC_MATH_ERF_H
10+
#define LLVM_LIBC_SRC_MATH_ERF_H
11+
12+
namespace LIBC_NAMESPACE {
13+
14+
double erf(double x);
15+
16+
} // namespace LIBC_NAMESPACE
17+
18+
#endif // LLVM_LIBC_SRC_MATH_ERF_H

0 commit comments

Comments
 (0)