Skip to content

[SYCL][NFCI] Move abs and div to cstdlib header #19671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: sycl
Choose a base branch
from

Conversation

bader
Copy link
Contributor

@bader bader commented Jul 31, 2025

These functions are declared in cmath and use data type defined in
cstdlib. Some cmath implementations include cstdlib implicitly, but
not all of them. Moving declarations to a standalone header removes
dependency on cmath implementation.

These functions are declared in cmath and use data type defined in
cstdlib. Some cmath implementations include cstdlib implicitly, but
not all of them. Moving declarations to a standalone header removes
dependency on cmath implementation.
bader added 2 commits July 31, 2025 15:40
Remove std::div and std::abs overloads and remove xfail mark for the
test.

Align cstdlib declaration with cppreference:
1. Make all declarations overloadable.
2. Fix function name for div(long long, long long) overload and add
   missing overload.
3. Add std::* variants.
@bader bader marked this pull request as ready for review July 31, 2025 23:20
@bader bader requested a review from a team as a code owner July 31, 2025 23:20
@bader
Copy link
Contributor Author

bader commented Aug 1, 2025

run_prebuilt_e2e_tests (E2E tests on Intel Ponte Vecchio GPU, ["Linux", "pvc"], -u 1001 --device=... / E2E tests on Intel Ponte Vecchio GPU failure doesn't seem to be related to the change. The test doesn't use abs or div functions and there is known issue with this test on PVC. See #19662.

@jinge90
Copy link
Contributor

jinge90 commented Aug 1, 2025

Hi, @bader
Can we keep the functions in libdevice? They are used by OMP offloading as well.
If can't, we can only build them for OMP offloading side.
Thanks very much.

@bader
Copy link
Contributor Author

bader commented Aug 1, 2025

Can we keep the functions in libdevice? They are used by OMP offloading as well. If can't, we can only build them for OMP offloading side. Thanks very much.

There is no sense in making any changes for OpenMP offloading in this repository because OpenMP offloading is not supported/tested here.

In the upstream OpenMP offloading uses clang's headers to implement abs on AMD GPU. I suggest using the same approach for SPIR-V targets in other repositories as well.
The same applies to div if it's needed for OpenMP offloading.

@sarnex, are you working on something similar in the upstream?

Copy link
Contributor

@Maetveis Maetveis left a comment

Choose a reason for hiding this comment

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

This will conflict with #19620. Can you apply the changes here I did to these functions, I don't want it to be lost during conflict resolution.

@sarnex
Copy link
Contributor

sarnex commented Aug 1, 2025

@sarnex, are you working on something similar in the upstream?

I haven't begun to think about how we will deal with libdevice in OMP upstream, however I agree we should match whatever the community does as best as possible.

@bader bader temporarily deployed to WindowsCILock August 1, 2025 20:39 — with GitHub Actions Inactive
@bader bader temporarily deployed to WindowsCILock August 1, 2025 20:39 — with GitHub Actions Inactive
@bader bader temporarily deployed to WindowsCILock August 2, 2025 02:02 — with GitHub Actions Inactive
@bader bader temporarily deployed to WindowsCILock August 2, 2025 02:30 — with GitHub Actions Inactive
@bader bader temporarily deployed to WindowsCILock August 2, 2025 02:30 — with GitHub Actions Inactive
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.

4 participants