Skip to content

[SYCL] Decouple <sycl/builtins.hpp> from <sycl/usm.hpp>#22312

Open
koparasy wants to merge 1 commit into
intel:syclfrom
koparasy:remove/algorithm
Open

[SYCL] Decouple <sycl/builtins.hpp> from <sycl/usm.hpp>#22312
koparasy wants to merge 1 commit into
intel:syclfrom
koparasy:remove/algorithm

Conversation

@koparasy

Copy link
Copy Markdown
Contributor

<sycl/usm.hpp> transitively pulled in <sycl/builtins.hpp> (and through it <sycl/half_type.hpp>, , vec/marray definitions, libc device declarations like __assert_fail, etc.). User code and tests came to rely on this implicit re-export chain.

Once sycl_khr_split_headers ships, <sycl/usm.hpp> is meant to deliver only USM symbols. Keeping the <sycl/builtins.hpp> include would either defeat the purpose of split-headers or force a source break later.

Fix the dependency now:

  • Drop <sycl/builtins.hpp> and from <sycl/usm.hpp>.
  • Replace four unqualified max(...) callsites (which previously resolved to sycl::max via builtins) with inline ternaries.
  • Add the explicit headers each affected test/common helper actually needs:
    • for std::any_of / all_of / find / sort etc.
    • <sycl/half_type.hpp> for sycl::half as a complete type.
    • <sycl/vector.hpp> for sycl::vec.
    • <sycl/marray.hpp> for sycl::marray.
    • <sycl/builtins.hpp> for sycl math builtins or device-side
      assert / libc declarations.

<sycl/usm.hpp> transitively pulled in <sycl/builtins.hpp> (and through it
<sycl/half_type.hpp>, <algorithm>, vec/marray definitions, libc device
declarations like __assert_fail, etc.). User code and tests came to rely
on this implicit re-export chain.

Once sycl_khr_split_headers ships, <sycl/usm.hpp> is meant to deliver
only USM symbols. Keeping the <sycl/builtins.hpp> include would either
defeat the purpose of split-headers or force a source break later.

Fix the dependency now:

  * Drop <sycl/builtins.hpp> and <algorithm> from <sycl/usm.hpp>.
  * Replace four unqualified max(...) callsites (which previously
    resolved to sycl::max via builtins) with inline ternaries.
  * Add the explicit headers each affected test/common helper actually
    needs:
      - <algorithm>             for std::any_of / all_of / find / sort etc.
      - <sycl/half_type.hpp>    for sycl::half as a complete type.
      - <sycl/vector.hpp>       for sycl::vec.
      - <sycl/marray.hpp>       for sycl::marray.
      - <sycl/builtins.hpp>     for sycl math builtins or device-side
                                assert / libc declarations.

Also fixes ordering bugs where <algorithm> was included after the
header that used it, or inside a function body.
@koparasy koparasy requested review from a team as code owners June 13, 2026 00:48
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.

1 participant