KhronosGroup / KhronosGroup/SYCL-Docs
Types in the `std` namespace do not need to be prohibited as kernel names due to forward declaration requirements
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 80
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 5
Description
[SYCL 2020 section 5.2, "Naming of kernels"](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:naming.kernels) includes the following note:
> The requirement that a kernel name be forward declarable makes some types for kernel names illegal, such as anything declared in the `std` namespace (adding a declaration to namespace `std` leads to undefined behavior).
It is correct that C++ programs are prohibited from adding declarations in the `std` namespace ([\[namespace.std\]](https://eel.is/c++draft/namespace.std)), but that does not imply that an existing type in the `std` namespace cannot be used as a kernel name.
```
#include
#include
int main() {
sycl::queue q;
q.submit(
[=](sycl::handler &cgh) {
cgh.single_task>(
[=]{}
);
}
);
q.wait();
}
```
The requirement for forward declarable types is presumably intended to accommodate implementations like DPC++ that use the integration header technique to make kernel details discovered during device compilation available during host compilation. In that case, the integration header is a detail of the implementation and not subject to the prohibition on adding declarations to the `std` namespace (an argument can be made that the SYCL library implementation is distinct from the C++ implementation and is therefore not exempt from the `std` namespace rule, but DPC++ at least does not require that distinction).
To be clear, I don't think there are any benefits to be gained by allowing types declared in the `std` namespace to be used as kernel names; I just disagree with the explanation in the referenced note and would prefer to see the note replaced with a normative requirement that simply prohibits the use of types (directly or indirectly) declared in the `std` namespace from being used as kernel names.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.