Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions libdevice/cmath_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,17 @@ float nearbyintf(float x) { return __nv_nearbyintf(x); }
extern "C" SYCL_EXTERNAL float __nv_rintf(float);
DEVICE_EXTERN_C_INLINE
float rintf(float x) { return __nv_rintf(x); }
#endif // __NVPTX__

#ifdef __AMDGCN__
#elif defined(__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__
#else
DEVICE_EXTERN_C_INLINE
float rintf(float x) { return __spirv_ocl_rint(x); }
#endif

#endif // __SPIR__ || __SPIRV__ || __NVPTX__ || __AMDGCN__
9 changes: 5 additions & 4 deletions libdevice/cmath_wrapper_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,18 @@ double nearbyint(double x) { return __nv_nearbyint(x); }
extern "C" SYCL_EXTERNAL double __nv_rint(double);
DEVICE_EXTERN_C_INLINE
double rint(double x) { return __nv_rint(x); }
#endif // __NVPTX__

#ifdef __AMDGCN__
#elif defined(__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__
#else
DEVICE_EXTERN_C_INLINE
double rint(double x) { return __spirv_ocl_rint(x); }
#endif

#if defined(_MSC_VER)
#include <math.h>
Expand Down
12 changes: 12 additions & 0 deletions libdevice/test/check_cmath.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
REQUIRES: libsycldevice

Check functions in fp32 libdevice spirv file.

RUN: llvm-spirv --spirv-target-env=SPV-IR -r %libsycldevice_spv_dir/libsycl-cmath.spv -o %t.bc
RUN: llvm-dis %t.bc -o %t.ll
RUN: FileCheck %s --input-file %t.ll

CHECK: target triple ={{.*}}spir64

CHECK-LABEL: define spir_func float @rintf(
CHECK: call spir_func float @_Z16__spirv_ocl_rintf(