KhronosGroup / KhronosGroup/SYCL-Docs
Can the types used for kernel names be fundamental or compound types?
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 80
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 5
Description
### Specification Version
SYCL 2020 (Revision 9)
### Section Number(s)
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:naming.kernels
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#kernel-name
### Issue Description
The kernel name requirements described in [SYCL 2020 section 5.2, "Naming of kernels"](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:naming.kernels) appear to prohibit the use of C++ fundamental ([\[basic.fundamental\]](https://eel.is/c++draft/basic.fundamental): `void`, `int`, `float`, `decltype(nullptr)`, etc...) or compound ([\[basic.compound\]](https://eel.is/c++draft/basic.compound): array, function, pointers, references, member pointers, etc...) types that are not user-declared as kernel name types via the requirement that kernel name types be forward declarable at namespace scope (there is no syntax to forward declare, for example, the type `int`).
> - The kernel name is a C++ typename.
> - **The kernel name must be forward declarable at namespace scope (including global namespace scope)** and may not be forward declared other than at namespace scope. ...
> ...
Further, the ["kernel name" term defined in the glossary](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#kernel-name) states that:
> A kernel name is a class type ...
The apparent prohibition against fundamental types and compound types that are not user-declared is rather subtle and at least some existing implementations allow their use without a diagnostic. For example, the DPC++ oneAPI compiler accepts the following example (both with and without `-fno-sycl-unnamed-lambda`; see https://godbolt.org/z/KxehKM6bK).
```
#include
void f(sycl::handler &h) {
h.single_task([]{});
}
void g(sycl::handler &h) {
h.single_task([]{});
}
```
This issue has been filed to request that the SYCL specification be clarified to explicitly state whether fundamental and compound types that are not user-declared are permitted as kernel name types.
### Code Example (Optional)
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.