Skip to content

[SYCL][NVPTX][AMDGPU] Use __builtin_nearbyint in cmath wrapper#21971

Open
Maetveis wants to merge 2 commits intointel:syclfrom
Maetveis:cmath-use-builtin-nearbyint
Open

[SYCL][NVPTX][AMDGPU] Use __builtin_nearbyint in cmath wrapper#21971
Maetveis wants to merge 2 commits intointel:syclfrom
Maetveis:cmath-use-builtin-nearbyint

Conversation

@Maetveis
Copy link
Copy Markdown
Contributor

@Maetveis Maetveis commented May 8, 2026

Instead of using __nv_nearbyint and __ocml_nearbyint from device libraries, use __builtin_nearbyint in the cmath wrapper. Both targets have native support for nearbyint so we don't need to call out to the device library. Both CUDA and HIP compilation already does this in __clang_{cuda,hip}_math.h. We can then also remove SYCL_EXTERNAL use from this header, to fix #21652.

Fixes #21652.

Instead of using `__nv_nearbyint` and `__ocml_nearbyint` from device libraries,
use `__builtin_nearbyint` in the cmath wrapper. Both targets have native
support for nearbyint so we don't need to call out to the device library.
Both CUDA and HIP compilation already does this in `__clang_{cuda,hip}_math.h`.
We can then also remove `SYCL_EXTERNAL` use from this header, to fix intel#21652.

Fixes intel#21652.
@Maetveis Maetveis requested a review from a team as a code owner May 8, 2026 14:35
@Maetveis Maetveis requested review from bader and cperkinsintel May 8, 2026 14:35
Comment thread sycl/test/regression/include_cmath_no_rdc.cpp Outdated
Copy link
Copy Markdown
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compilation with -fno-sycl-rdc is broken due to __sycl_cmath_wrapper_impl.hpp (missing definition of SYCL_EXTERNAL)

2 participants