Skip to content

Commit faaba28

Browse files
authored
[LIBCLC][HIP] Add HIP AMD support for ilogb, log2, remainder (#5272)
Fixing bug due to incorrect naming of remainder.cl as remainer.cl.
1 parent 0ba377f commit faaba28

File tree

8 files changed

+78
-2
lines changed

8 files changed

+78
-2
lines changed

libclc/amdgcn-amdhsa/libspirv/SOURCES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ math/fmin.cl
3131
math/fmod.cl
3232
math/frexp.cl
3333
math/hypot.cl
34+
math/ilogb.cl
3435
math/ldexp.cl
3536
math/lgamma.cl
3637
math/log.cl
38+
math/log2.cl
3739
math/log10.cl
3840
math/log1p.cl
3941
math/logb.cl
4042
math/mangle_common.h
4143
math/modf.cl
4244
math/nextafter.cl
4345
math/pow.cl
46+
math/remainder.cl
4447
math/round.cl
4548
math/rsqrt.cl
4649
math/sin.cl
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 <clcmacro.h>
10+
#include <spirv/spirv.h>
11+
12+
int __ocml_ilogb_f64(double);
13+
int __ocml_ilogb_f32(float);
14+
15+
_CLC_DEFINE_UNARY_BUILTIN(int, __spirv_ocl_ilogb, __ocml_ilogb_f32, float)
16+
17+
#ifdef cl_khr_fp64
18+
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
19+
20+
_CLC_DEFINE_UNARY_BUILTIN(int, __spirv_ocl_ilogb, __ocml_ilogb_f64, double)
21+
#endif
22+
23+
#ifdef cl_khr_fp16
24+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
25+
26+
_CLC_OVERLOAD _CLC_DEF int __spirv_ocl_ilogb(half x) {
27+
float t = x;
28+
return __spirv_ocl_ilogb(t);
29+
}
30+
31+
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, int, __spirv_ocl_ilogb, half);
32+
#endif
33+
34+
#undef __CLC_BUILTIN
35+
#undef __CLC_BUILTIN_F
36+
#undef __CLC_FUNCTION
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 <clcmacro.h>
10+
#include <spirv/spirv.h>
11+
12+
double __ocml_log2_f64(double);
13+
float __ocml_log2_f32(float);
14+
15+
#define __CLC_FUNCTION __spirv_ocl_log2
16+
#define __CLC_BUILTIN __ocml_log2
17+
#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, _f32)
18+
#define __CLC_BUILTIN_D __CLC_XCONCAT(__CLC_BUILTIN, _f64)
19+
#include <math/unary_builtin.inc>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 <spirv/spirv.h>
10+
11+
float __ocml_remainder_f32(float,float);
12+
double __ocml_remainder_f64(double,double);
13+
14+
#define __CLC_FUNCTION __spirv_ocl_remainder
15+
#define __CLC_BUILTIN __ocml_remainder
16+
#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, _f32)
17+
#define __CLC_BUILTIN_D __CLC_XCONCAT(__CLC_BUILTIN, _f64)
18+
#include <math/binary_builtin.inc>

libclc/generic/libspirv/SOURCES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ math/nextafter.cl
165165
math/pow.cl
166166
math/pown.cl
167167
math/powr.cl
168-
math/remainer.cl
168+
math/remainder.cl
169169
math/remquo.cl
170170
math/rint.cl
171171
math/rootn.cl

libclc/ptx-nvidiacl/libspirv/SOURCES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ math/native_sqrt.cl
5555
math/native_tan.cl
5656
math/nextafter.cl
5757
math/pow.cl
58-
math/remainer.cl
58+
math/remainder.cl
5959
math/round.cl
6060
math/rsqrt.cl
6161
math/sin.cl

0 commit comments

Comments
 (0)