Description
Describe the bug
Different headers make different assumptions about the meaning of detail
, which can lead to issues when headers are moved or included in new places. There are many instances of this, but I'll give one concrete example below to illustrate the problem.
sub_group_mask.hpp defines sycl::detail::Builder
:
llvm/sycl/include/sycl/ext/oneapi/sub_group_mask.hpp
Lines 17 to 21 in c5c7ac2
...and then refers to that definition as detail::Builder
inside of a class defined in sycl::ext::oneapi
:
llvm/sycl/include/sycl/ext/oneapi/sub_group_mask.hpp
Lines 23 to 33 in c5c7ac2
Everything in sycl::ext::oneapi
is in sycl
, so the reference to detail
resolves to sycl::detail
in this case when the header is compiled in isolation. However, if any header defines a detail
namespace in sycl::ext
or sycl::ext::oneapi
, detail
resolves to sycl::ext::detail
or sycl::ext::oneapi::detail
and Builder
cannot be found.
There are several such nested detail
namespaces around, e.g. in atomic_ref.hpp:
llvm/sycl/include/sycl/ext/oneapi/atomic_ref.hpp
Lines 24 to 30 in c5c7ac2
My suggestion is to use sycl::detail::
everywhere, and remove all of these nested namespaces. Details are details.
To Reproduce
Include sub_group_mask.hpp after a definition of a nested detail
namespace (e.g. sycl::ext::oneapi::detail
).
Environment (please complete the following information):
- OS: Linux
- Target device and vendor: N/A
- DPC++ version: c5c7ac2
- Dependencies version: N/A
Additional context
@bader has suggested previously that it is desirable to be able to include separate headers for different SYCL functionality. I think cleaning this up is a precursor to that -- if we encourage developers to start including headers that aren't sycl.hpp, it's very likely they'll encounter issues like this. I encountered it while trying to add some new functionality, and @steffenlarsen has encountered this issue previously as well.