Skip to content

Commit b4d91c3

Browse files
authored
[SYCL][HIP] add missing nearbyint and rint (#16373)
Failed to compile OneDNN using DPCPP on AMD with sycl because the code [here](https://github.com/oneapi-src/oneDNN/blob/c852fdc60073a1ae298618c4faf26487b4144755/src/gpu/generic/sycl/eltwise_kernels.hpp#L137) that will run on the device actually calls `nearbyintf` [here](https://github.com/oneapi-src/oneDNN/blob/c852fdc60073a1ae298618c4faf26487b4144755/src/common/math_utils.hpp#L120-L131) , but `nearbyintf` lacks a symbolic definition. Same solution as #11177 but go straight to the `__ocml` symbols
1 parent 3bfa66d commit b4d91c3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

libdevice/cmath_wrapper.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,14 @@ DEVICE_EXTERN_C_INLINE
200200
float rintf(float x) { return __nv_rintf(x); }
201201
#endif // __NVPTX__
202202

203+
#ifdef __AMDGCN__
204+
extern "C" SYCL_EXTERNAL float __ocml_nearbyint_f32(float);
205+
DEVICE_EXTERN_C_INLINE
206+
float nearbyintf(float x) { return __ocml_nearbyint_f32(x); }
207+
208+
extern "C" SYCL_EXTERNAL float __ocml_rint_f32(float);
209+
DEVICE_EXTERN_C_INLINE
210+
float rintf(float x) { return __ocml_rint_f32(x); }
211+
#endif // __AMDGCN__
212+
203213
#endif // __SPIR__ || __SPIRV__ || __NVPTX__ || __AMDGCN__

libdevice/cmath_wrapper_fp64.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ DEVICE_EXTERN_C_INLINE
190190
double rint(double x) { return __nv_rint(x); }
191191
#endif // __NVPTX__
192192

193+
#ifdef __AMDGCN__
194+
extern "C" SYCL_EXTERNAL double __ocml_nearbyint_f64(double);
195+
DEVICE_EXTERN_C_INLINE
196+
double nearbyint(double x) { return __ocml_nearbyint_f64(x); }
197+
198+
extern "C" SYCL_EXTERNAL double __ocml_rint_f64(double);
199+
DEVICE_EXTERN_C_INLINE
200+
double rint(double x) { return __ocml_rint_f64(x); }
201+
#endif // __AMDGCN__
202+
193203
#if defined(_MSC_VER)
194204
#include <math.h>
195205
// FLOAT PROPERTIES

0 commit comments

Comments
 (0)