Skip to content

[SYCL][NFC] Update includes in DPC++ headers. #10648

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 37 commits into from
Aug 7, 2023
Merged

Conversation

bader
Copy link
Contributor

@bader bader commented Aug 2, 2023

These changes were done in semi-automatic mode by include what you
use
tool. The
caveat is that this tool doesn't support SYCL compilation mode, so it analyses
only host code and I had to manually adjust includes for the device compilation.
The tool annotated each include with the symbols declared in the included header
and used in the code.

I tired to apply following structure to includes where it's possible:

// <copyright header>

#pragma once

#include "local/includes"

#include <sycl/includes>

#ifdef ..
#include <conditional/includes>
#endif

#include <standard_library>

Removed sycl/include/sycl/detail/sycl_fe_intrins.hpp and
sycl/include/sycl/detail/service_kernel_names.hpp - declarations from these headers
are used only once, so there is sense in moving them to a separate headers.

I've put a few comments for follow-up actions:

  1. sycl/include/sycl/handler.hpp includes 57 headers, which seems to much.
  2. sycl/include/sycl/info/info_desc.hpp and
    sycl/include/sycl/detail/info_desc_helpers.hpp - includes .def files, which
    depend on previous includes, doesn't sound like a good idea.
  3. sycl/include/sycl/detail/kernel_desc.hpp - uses __SYCL_EXPORT, which doesn't
    sounds right to me, but I might be missing something.

@bader bader temporarily deployed to aws August 2, 2023 03:45 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws August 2, 2023 04:25 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws August 2, 2023 22:36 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws August 2, 2023 23:18 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws August 3, 2023 03:37 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws August 3, 2023 04:09 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws August 3, 2023 04:48 — with GitHub Actions Inactive
@bader bader changed the title [SYCL][NFC] Remove unused includes [SYCL][NFC] Update includes in DPC++ headers. Aug 3, 2023
@bader bader marked this pull request as ready for review August 3, 2023 05:52
@bader bader requested review from a team, victor-eds, Naghasan and sommerlukas as code owners August 3, 2023 05:52
@bader bader requested a review from bso-intel August 3, 2023 05:52
Copy link
Contributor Author

@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.

Additional notes for reviewers.

While working on this patch I relied on our tests, so I highly recommend to pay
close attention to the code that potentially could be cut by pre-processor. If
you see something unexpected, please, let me and code owners know, so we improve
the situation with dependencies.

I'm encourage you to look at includes and symbols imported from them and think
about either using forward declaration or (if possible) moving the code from
DPC++ headers to DPC++ runtime library.

Something I haven't mentioned in the code comments -
sycl/include/sycl/info/info_desc.hpp declares descriptors for all SYCL objects.
I think it better to split this header to have a one header with info descriptor
per SYCL object.

@@ -8,12 +8,13 @@

#pragma once

#include <sycl/id.hpp>
#include <sycl/access/access.hpp> // for mode, placeholder, target
#include <sycl/buffer.hpp> // for range
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm... should it be

Suggested change
#include <sycl/buffer.hpp> // for range
#include <sycl/range.hpp> // for range

?
🤔

Comment on lines +12 to +15
#include <sycl/detail/item_base.hpp> // for id, range
#include <sycl/id.hpp> // for id
#include <sycl/item.hpp> // for item
#include <sycl/range.hpp> // for range
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we really need #include <sycl/detail/item_base.hpp>?

@bader bader temporarily deployed to aws August 3, 2023 06:02 — with GitHub Actions Inactive
Copy link
Contributor

@sommerlukas sommerlukas left a comment

Choose a reason for hiding this comment

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

I only reviewed the following files relating to kernel fusion, those look good.

fusion_properties.hpp
fusion_wrapper.hpp
jit_device_binaries.cpp

@bader bader temporarily deployed to aws August 3, 2023 07:50 — with GitHub Actions Inactive
Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

graph.hpp changes LGTM.

Do have a question about maintenance, what are the expectations for preserving this IWYU correctness in future contributions? Are contributors expected to run this tool locally?

@bader
Copy link
Contributor Author

bader commented Aug 3, 2023

Do have a question about maintenance, what are the expectations for preserving this IWYU correctness in future contributions? Are contributors expected to run this tool locally?

Based on my experience with the tool, I don't think we should expect contributors to run this tool locally. I suggest we don't change contribution policy.

@bader
Copy link
Contributor Author

bader commented Aug 4, 2023

@intel/llvm-reviewers-runtime, ping.

@bader bader merged commit c0483d7 into intel:sycl Aug 7, 2023
@bader bader deleted the iwyu-full branch August 7, 2023 18:13
mdtoguchi pushed a commit to mdtoguchi/llvm that referenced this pull request Oct 18, 2023
These changes were done in semi-automatic mode by [include what you
use](https://github.com/include-what-you-use/include-what-you-use/)
tool. The
caveat is that this tool doesn't support SYCL compilation mode, so it
analyses
only host code and I had to manually adjust includes for the device
compilation.
The tool annotated each include with the symbols declared in the
included header
and used in the code.

I tired to apply following structure to includes where it's possible:
```c++
// <copyright header>

#pragma once

#include "local/includes"

#include <sycl/includes>

#ifdef ..
#include <conditional/includes>
#endif

#include <standard_library>
```

Removed sycl/include/sycl/detail/sycl_fe_intrins.hpp and
sycl/include/sycl/detail/service_kernel_names.hpp - declarations from
these headers
are used only once, so there is sense in moving them to a separate
headers.

I've put a few comments for follow-up actions:

1. sycl/include/sycl/handler.hpp includes 57 headers, which seems to
much.
2. sycl/include/sycl/info/info_desc.hpp and
sycl/include/sycl/detail/info_desc_helpers.hpp - includes .def files,
which
   depend on previous includes, doesn't sound like a good idea.
3. sycl/include/sycl/detail/kernel_desc.hpp - uses __SYCL_EXPORT, which
doesn't
   sounds right to me, but I might be missing something.
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