21 inline namespace _V1 {
26 auto Plugin = sycl::detail::ur::getPlugin<backend::opencl>();
27 ur_platform_handle_t UrPlatform =
nullptr;
28 Plugin->call<detail::UrApiKind::urPlatformCreateWithNativeHandle>(
29 detail::ur::cast<ur_native_handle_t>(PlatformId), Plugin->getUrAdapter(),
30 nullptr, &UrPlatform);
38 *
this = dev_selector.select_device().get_platform();
43 bool platform::has_extension(detail::string_view ExtName)
const {
44 return impl->has_extension(ExtName.data());
48 return impl->get_devices(DeviceType);
61 template <
typename Param>
64 platform::get_info_impl()
const {
68 ur_native_handle_t platform::getNative()
const {
return impl->getNative(); }
72 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, PiCode) \
73 template __SYCL_EXPORT detail::ABINeutralT_t<ReturnT> \
74 platform::get_info_impl<info::platform::Desc>() const;
76 #include <sycl/info/platform_traits.def>
77 #undef __SYCL_PARAM_TRAITS_SPEC
79 template <
typename Param>
82 return impl->get_backend_info<Param>();
85 #define __SYCL_PARAM_TRAITS_SPEC(DescType, Desc, ReturnT, Picode) \
86 template __SYCL_EXPORT ReturnT \
87 platform::get_backend_info<info::DescType::Desc>() const;
89 #include <sycl/info/sycl_backend_traits.def>
91 #undef __SYCL_PARAM_TRAITS_SPEC
95 throw std::runtime_error(
"SYCL default contexts are not enabled");
99 std::unordered_map<detail::PlatformImplPtr, detail::ContextImplPtr>
100 &PlatformToDefaultContextCache =
103 std::lock_guard<std::mutex> Lock{
107 auto It = PlatformToDefaultContextCache.find(impl);
108 if (PlatformToDefaultContextCache.end() == It)
109 std::tie(It, std::ignore) = PlatformToDefaultContextCache.insert(
112 return detail::createSyclObjFromImpl<context>(It->second);
121 std::vector<device> Composites;
122 std::vector<device> Result;
123 for (
auto &Dev : GPUDevices) {
124 if (!Dev.has(sycl::aspect::ext_oneapi_is_component))
127 auto Composite = Dev.get_info<
128 sycl::ext::oneapi::experimental::info::device::composite_device>();
129 if (std::find(Composites.begin(), Composites.end(), Composite) ==
131 Composites.push_back(Composite);
133 for (
const auto &Composite : Composites) {
134 auto Components = Composite.get_info<
135 sycl::ext::oneapi::experimental::info::device::component_devices>();
140 size_t ComponentsFound = std::count_if(
141 Components.begin(), Components.end(), [&](
const device &d) {
142 return std::find(GPUDevices.begin(), GPUDevices.end(), d) !=
145 if (ComponentsFound == Components.size())
146 Result.push_back(Composite);
154 const char *StringVal = Val ?
"1" :
"0";
The context class represents a SYCL context on which kernel functions may be executed.
std::unordered_map< PlatformImplPtr, ContextImplPtr > & getPlatformToDefaultContextCache()
std::mutex & getPlatformToDefaultContextCacheMutex()
static GlobalHandler & instance()
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
platform get_platform() const
Get associated SYCL platform.
constexpr tuple_element< I, tuple< Types... > >::type & get(sycl::detail::tuple< Types... > &Arg) noexcept
auto convert_to_abi_neutral(ParamT &&Info)
decltype(Obj::impl) const & getSyclObjImpl(const Obj &SyclObject)
void enable_ext_oneapi_default_context(bool Val)
Allows to enable/disable "Default Context" extension.
typename ABINeutralT< T >::type ABINeutralT_t
int default_selector_v(const device &dev)
_Abi const simd< _Tp, _Abi > & noexcept
C++ utilities for Unified Runtime integration.