[SYCL] Restore the nd_range default constructor - #22949
Open
arnavprabhu wants to merge 1 commit into
Open
Conversation
PR intel#22908 removed nd_range's default constructor to align with the SYCL 2020 specification, which does not define one. That broke code which relies on default-constructing an nd_range and assigning it later, most notably CuTe's launch_policy used by PyTorch's XPU flash-attention kernels. Restore the constructor as a backwards-compatibility extension and add a test that checks it zero-initializes the constituent ranges. Fixes intel#22940
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22940
Problem
PR #22908 removed
nd_range's default constructor (nd_range() = default;)to align the class with the SYCL 2020 specification, which does not declare
one. That broke code which default-constructs an
nd_rangeand assigns itlater. The most visible casualty is CuTe's
launch_policy(
include/cute/util/compat/launch_policy.hpp), used by PyTorch's XPUflash-attention kernels, which holds an
nd_range<3>member that getsdefault-initialized:
Change
Restore
nd_range() = default;as a backwards-compatibility extension. Allthree members (
globalSize,localSize,offset) arerange/idobjects,both of which keep zero-initializing default constructors, so a
default-constructed
nd_rangeis well-defined and produces zeroed ranges.A comment in the header notes that the constructor is an extension beyond
SYCL 2020 and why it is kept.
Test plan
sycl/test/basic_tests/nd_range.cppto default-construct annd_range<3>and assert the constituent ranges and offset arezero-initialized.