Skip to content

[SYCL] Improve handling of large reqd_work_group_size values #10620

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 16 commits into from
Aug 10, 2023

Conversation

jzc
Copy link
Contributor

@jzc jzc commented Jul 28, 2023

When a kernel with a large (unsupported) work-group size is submitted, the backend would fail upon trying build the program, and throw the wrong exception (compile_program_error with errc::build, but it should just be a sycl::exception with errc::kernel_not_supported according to 5.8.1. Kernel attributes).

This PR adds a check before building to validate the reqd_work_group_size.

Additionally, another bug in sycl-post-link was fixed. The bug occurred when a kernel was decorated with a multi-dimensional required work-group size and two dimensions had the same value. Due to how sycl-post-link worked, the attached metadata on the device image would include fewer dimensions than specified. (e.g. If the decorated with reqd_work_group_size(16, 16), then the device image would appear as if decorated by reqd_work_group_size(16).)

@jzc jzc temporarily deployed to aws July 28, 2023 23:06 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to aws July 31, 2023 17:14 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to aws July 31, 2023 18:10 — with GitHub Actions Inactive
@jzc jzc marked this pull request as ready for review August 1, 2023 14:42
@jzc jzc requested review from a team as code owners August 1, 2023 14:42
@jzc jzc requested a review from cperkinsintel August 1, 2023 14:42
@jzc jzc changed the title [SYCL] Improve handling of large reqd_sub_group_size values [SYCL] Improve handling of large reqd_work_group_size values Aug 1, 2023
@jzc jzc temporarily deployed to aws August 3, 2023 22:45 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to aws August 3, 2023 23:26 — with GitHub Actions Inactive
uint64_t ReqdWGSizeAllDimsTotal = 1;
std::vector<uint64_t> ReqdWGSizeVec;
size_t ReqdWGSizeAllDimsTotal = 1;
std::vector<size_t> ReqdWGSizeVec;
int Dims = 0;
while (!ReqdWGSize.empty()) {
// The reqd_work_group_size data is stored as uint32_t's,
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment should be updated that only old binaries store reqd_work_group_size as 32-bit.
We should also put TODOs to both runtime and the compiler to remove that extra _size_t property once ABI break is allowed again

@jzc jzc temporarily deployed to aws August 4, 2023 21:31 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to aws August 4, 2023 22:13 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to aws August 8, 2023 15:11 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to aws August 8, 2023 17:33 — with GitHub Actions Inactive
Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

llvm/ part LGTM.

@intel/sycl-language-enabling-triage: FYI

Copy link
Contributor

@maarquitos14 maarquitos14 left a comment

Choose a reason for hiding this comment

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

LGTM.

@AlexeySachkov AlexeySachkov merged commit 25c3666 into intel:sycl Aug 10, 2023
@dm-vodopyanov
Copy link
Contributor

@jzc can you please fix the failure in post-commit?

https://github.com/intel/llvm/actions/runs/5819408460/job/15777743360

bader pushed a commit that referenced this pull request Aug 10, 2023
Post commit started to failed on
25c3666
(#10620) for macOS build because:

```
error: no viable overloaded '='
        ReqdWorkGroupSize = NewReqdWorkGroupSize;

note: candidate function not viable: no known conversion from 'llvm::SmallVector<size_t, 3>' (aka 'SmallVector<unsigned long, 3>') to 'const std::optional<llvm::SmallVector<unsigned long long, 3>>' for 1st argument
    _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional&) = default;
mdtoguchi pushed a commit to mdtoguchi/llvm that referenced this pull request Oct 18, 2023
…0620)

When a kernel with a large (unsupported) work-group size is submitted,
the backend would fail upon trying build the program, and throw the
wrong exception (compile_program_error with `errc::build`, but it should
just be a `sycl::exception` with `errc::kernel_not_supported` according
to [5.8.1. Kernel
attributes](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:kernel.attributes)).


https://github.com/intel/llvm/blob/b65969014f001f9730349a5caad5c2b85c9bc378/sycl/source/detail/program_manager/program_manager.cpp#L749

This PR adds a check before building to validate the
`reqd_work_group_size`.

Additionally, another bug in `sycl-post-link` was fixed. The bug
occurred when a kernel was decorated with a multi-dimensional required
work-group size and two dimensions had the same value. Due to how
`sycl-post-link` worked, the attached metadata on the device image would
include fewer dimensions than specified. (e.g. If the decorated with
`reqd_work_group_size(16, 16)`, then the device image would appear as if
decorated by `reqd_work_group_size(16)`.)
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.

5 participants