Skip to content

[SYCL] Fix include loop and use-before-def #8407

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

Merged
merged 3 commits into from
Mar 9, 2023

Conversation

ldrumm
Copy link
Contributor

@ldrumm ldrumm commented Feb 20, 2023

There are two issues present here that aren't obviously visible:

  1. The sycl::half_type alias isn't defined in sycl/half_type.hpp; it actually comes from detail/generic_type_lists.hpp seemingly accidentally.
  2. detail/type_traits.hpp transitively includes sycl/half_type.hpp as it has templates that use sycl::half. However, the half implementation itself needs type_traits.hpp for computing alignment. Depending on the order of headers included, this causes an unfulfillable declaration-before-use issue in client code. In doing so ESIMD was found to be guilty of not including all the correct headers.

There are many such transitive header issues lurking which keep the headers tightly coupled and the final preprocess very large. Until they are solved in a more general way I've had to introduce some copy-paste for the vector_alignment helper to avoid including type_traits.hpp inside half_type.hpp.

This patch is a prerequisite of the future complex_half group algorithms work ending up in a working order

@ldrumm ldrumm requested review from a team as code owners February 20, 2023 15:07
@ldrumm ldrumm temporarily deployed to aws February 21, 2023 05:55 — with GitHub Actions Inactive
There are two issues present here that aren't obviously visible:
  1. The `sycl::half_type` alias isn't defined in sycl/half_type.hpp; it
  actually comes from detail/generic_type_lists.hpp seemingly
  accidentally.
  2. detail/type_traits.hpp transitively includes sycl/half_type.hpp as
     it has templates that use sycl::half. However, the half
     implementation itself needs type_traits.hpp for computing
     alignment. Depending on the order of headers included, this causes
     an unfulfillable declaration-before-use issue in client code. In
     doing so ESIMD was found to be guilty of not including all the
     correct headers.

There are many such transitive header issues lurking which keep the
headers tightly coupled and the final preprocess very large. Until they
are solved in a more general way I've had to introduce some copy-paste
for the `vector_alignment` helper to avoid including type_traits.hpp
inside half_type.hpp.

This patch is a prerequisite of the future complex_half group algorithms
work ending up in a working order
@ldrumm ldrumm force-pushed the half-include-order branch from a8982c1 to e4b3590 Compare February 21, 2023 11:25
detail/helpers.hpp was needed by spirv_ops.cpp for the inline definition
of detail::memcpy, but including such caused a circular ordering issue.

There's no need to forward declare an inline function that's immediately
needed, so hoist it into its own header that can easily be included in
both users.
@ldrumm ldrumm temporarily deployed to aws February 21, 2023 13:23 — with GitHub Actions Inactive
@ldrumm ldrumm temporarily deployed to aws February 21, 2023 14:00 — with GitHub Actions Inactive
@ldrumm
Copy link
Contributor Author

ldrumm commented Feb 28, 2023

If anyone has bandwidth to look at this I'd appreciate it; It's a prerequisite of making 7120 work

@ldrumm
Copy link
Contributor Author

ldrumm commented Mar 3, 2023

@intel/llvm-gatekeepers

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! Just a small comment about the repeat code, but otherwise LGTM!

If reviewers are slow to react, please feel free to ping.

@steffenlarsen
Copy link
Contributor

@intel/dpcpp-esimd-reviewers - Friendly ping.

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

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

esimd.hpp lgtm

@ldrumm
Copy link
Contributor Author

ldrumm commented Mar 3, 2023 via email

@ldrumm ldrumm temporarily deployed to aws March 3, 2023 16:47 — with GitHub Actions Inactive
@ldrumm ldrumm force-pushed the half-include-order branch from 443255c to 06830e7 Compare March 3, 2023 19:10
@ldrumm ldrumm temporarily deployed to aws March 3, 2023 19:18 — with GitHub Actions Inactive
@ldrumm ldrumm force-pushed the half-include-order branch from 06830e7 to 95728c8 Compare March 6, 2023 14:50
@ldrumm ldrumm temporarily deployed to aws March 6, 2023 20:01 — with GitHub Actions Inactive
@ldrumm
Copy link
Contributor Author

ldrumm commented Mar 7, 2023

Is it worth rerunning the HIP timeouts?

@steffenlarsen
Copy link
Contributor

Is it worth rerunning the HIP timeouts?

Not at the moment. They are considered unsupported for now will be disabled with intel/llvm-test-suite#1639.

@ldrumm ldrumm temporarily deployed to aws March 8, 2023 12:24 — with GitHub Actions Inactive
@ldrumm ldrumm temporarily deployed to aws March 9, 2023 08:59 — with GitHub Actions Inactive
@ldrumm ldrumm temporarily deployed to aws March 9, 2023 09:38 — with GitHub Actions Inactive
@steffenlarsen steffenlarsen merged commit beced80 into intel:sycl Mar 9, 2023
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.

3 participants