KhronosGroup / KhronosGroup/SYCL-Docs
"nd_range" behavior unclear when local size is zero
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 80
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 5
Description
### Specification Version
SYCL 2020 (Revision 11)
### Section Number(s)
Section [4.9.1.2. "nd_range class"](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#subsubsec:nd-range-class)
Section [4.9.4.2. "SYCL functions for invoking kernels"](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#subsec:invokingkernels)
### Issue Description
The specification of `nd_range::get_group_range` says:
> Return a range representing the number of groups in each dimension. This range would result from `globalSize/localSize` as provided on construction.
However, nothing prevents `localSize` from being zero. I think we should simply say that the behavior of this function is undefined when `localSize` is zero.
The specification of the `parallel_for` overloads that take an `nd_range` are a little vague about whether the `localSize` of the `nd_range` can be zero. They do say:
> Throws an `exception` with the `errc::nd_range` error code if the global size defined in the associated `executionRange` defines a non-zero index space which is not evenly divisible by the local size in each dimension.
Is a non-zero value "evenly divisible" by zero? If not, then the statement above indicates that `parallel_for` should throw an exception when the local size is zero. If this is our intent, though, it would be better to say this explicitly.
Somewhat related ... OpenCL has a way to launch an nd-range kernel with no specified local range. In this case, the driver picks a default local range. DPC++ also has an extension for this purpose [sycl_ext_oneapi_auto_local_range](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_auto_local_range.asciidoc). We could change the SYCL spec to say that specifying a local size of zero means that the implementation must choose a default local size. However, I think it might be better to introduce a new type for this instead, as the DPC++ extension does.
### Code Example (Optional)
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Read SYCL 2020 Sections 4.9.1.2 and 4.9.4.2, then compare the related sycl_ext_oneapi_auto_local_range extension. Determine which zero-local-size behavior the specification should define and update the relevant wording consistently; completion means the behavior and error conditions are unambiguous.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100