Skip to content

Commit

Permalink
[SYCL][HIP] add missing nearbyint and rint (#16373)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MoveCloudROY authored Dec 30, 2024
1 parent 3bfa66d commit b4d91c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libdevice/cmath_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,14 @@ DEVICE_EXTERN_C_INLINE
float rintf(float x) { return __nv_rintf(x); }
#endif // __NVPTX__

#ifdef __AMDGCN__
extern "C" SYCL_EXTERNAL float __ocml_nearbyint_f32(float);
DEVICE_EXTERN_C_INLINE
float nearbyintf(float x) { return __ocml_nearbyint_f32(x); }

extern "C" SYCL_EXTERNAL float __ocml_rint_f32(float);
DEVICE_EXTERN_C_INLINE
float rintf(float x) { return __ocml_rint_f32(x); }
#endif // __AMDGCN__

#endif // __SPIR__ || __SPIRV__ || __NVPTX__ || __AMDGCN__
10 changes: 10 additions & 0 deletions libdevice/cmath_wrapper_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ DEVICE_EXTERN_C_INLINE
double rint(double x) { return __nv_rint(x); }
#endif // __NVPTX__

#ifdef __AMDGCN__
extern "C" SYCL_EXTERNAL double __ocml_nearbyint_f64(double);
DEVICE_EXTERN_C_INLINE
double nearbyint(double x) { return __ocml_nearbyint_f64(x); }

extern "C" SYCL_EXTERNAL double __ocml_rint_f64(double);
DEVICE_EXTERN_C_INLINE
double rint(double x) { return __ocml_rint_f64(x); }
#endif // __AMDGCN__

#if defined(_MSC_VER)
#include <math.h>
// FLOAT PROPERTIES
Expand Down

0 comments on commit b4d91c3

Please sign in to comment.