Skip to content

Commit 0ef26d3

Browse files
authored
[SYCL][CUDA] Add missing nearbyint (#11177)
`nearbyint` was missing for NVPTX. `nearbyint` is not found in `libclc`, so instead of the usual `libdevice->libclc->native_bc_lib` it was necessary to just skip libclc and go straight to the `__nv` symbols which are found in nvvm libdevice.
1 parent 60633fe commit 0ef26d3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

libdevice/cmath_wrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,11 @@ float asinhf(float x) { return __devicelib_asinhf(x); }
153153

154154
DEVICE_EXTERN_C_INLINE
155155
float atanhf(float x) { return __devicelib_atanhf(x); }
156+
157+
#ifdef __NVPTX__
158+
extern "C" SYCL_EXTERNAL float __nv_nearbyintf(float);
159+
DEVICE_EXTERN_C_INLINE
160+
float nearbyintf(float x) { return __nv_nearbyintf(x); }
161+
#endif // __NVPTX__
162+
156163
#endif // __SPIR__ || __NVPTX__

libdevice/cmath_wrapper_fp64.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ double atanh(double x) { return __devicelib_atanh(x); }
143143
DEVICE_EXTERN_C_INLINE
144144
double scalbn(double x, int exp) { return __devicelib_scalbn(x, exp); }
145145

146+
#ifdef __NVPTX__
147+
extern "C" SYCL_EXTERNAL double __nv_nearbyint(double);
148+
DEVICE_EXTERN_C_INLINE
149+
double nearbyint(double x) { return __nv_nearbyint(x); }
150+
#endif // __NVPTX__
151+
146152
#if defined(_MSC_VER)
147153
#include <math.h>
148154
// FLOAT PROPERTIES

0 commit comments

Comments
 (0)