KhronosGroup / KhronosGroup/SYCL-Docs
Can the types used for kernel names be enumeration or union 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 allow the use of an unscoped enumeration type with a fixed underlying type ([\[dcl.enum\]](https://eel.is/c++draft/dcl.enum)), a scoped enumeration type ([\[dcl.enum\]](https://eel.is/c++draft/dcl.enum)), or a union type ([\[class.union\]](https://eel.is/c++draft/class.union)). The relevant requirements are:
> - 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. ...
However, 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 ...
Note that the C++ standard explicitly states that a union is a class type ([\[class.union.general\]p1](https://eel.is/c++draft/class.union.general#1)).
The DPC++ oneAPI compiler accepts the following example without a diagnostic (both with and without `-fno-sycl-unnamed-lambda`; see https://godbolt.org/z/sfc8qT1TT).
```
#include
enum UE : int;
void f(sycl::handler &h) {
h.single_task([]{});
}
enum class SE;
void g(sycl::handler &h) {
h.single_task([]{});
}
union U;
void h(sycl::handler &h) {
h.single_task([]{});
}
```
This issue has been filed to request that the SYCL specification be clarified to explicitly state whether enumeration and union types 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.