//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include #include #include #include _LIBSYCL_BEGIN_NAMESPACE_SYCL device::device() : device(default_selector_v) {} bool device::is_cpu() const { return impl->isCPU(); } bool device::is_gpu() const { return impl->isGPU(); } bool device::is_accelerator() const { return impl->isAccelerator(); } platform device::get_platform() const { return detail::createSyclObjFromImpl(impl->getPlatformImpl()); } backend device::get_backend() const noexcept { return impl->getBackend(); } std::vector device::get_devices(info::device_type DeviceType) { std::vector Devices; // Not calling platform::get_devices to avoid multiple vector packing for (auto &PlatformImpl : detail::PlatformImpl::getPlatforms()) { assert(PlatformImpl && "PlatformImpl can not be nullptr"); PlatformImpl->iterateDevices( DeviceType, [&Devices](detail::DeviceImpl *DevImpl) { assert(DevImpl && "Device impl can't be nullptr"); Devices.push_back(detail::createSyclObjFromImpl(*DevImpl)); }); } return Devices; } template std::vector device::create_sub_devices(size_t ComputeUnits) const { throw exception(make_error_code(errc::feature_not_supported), "Partitioning is not supported."); } template _LIBSYCL_EXPORT std::vector device::create_sub_devices( size_t ComputeUnits) const; template std::vector device::create_sub_devices(const std::vector &Counts) const { throw exception(make_error_code(errc::feature_not_supported), "Partitioning is not supported."); } template _LIBSYCL_EXPORT std::vector device::create_sub_devices( const std::vector &Counts) const; template std::vector device::create_sub_devices( info::partition_affinity_domain AffinityDomain) const { throw exception(make_error_code(errc::feature_not_supported), "Partitioning is not supported."); } template _LIBSYCL_EXPORT std::vector device::create_sub_devices< info::partition_property::partition_by_affinity_domain>( info::partition_affinity_domain AffinityDomain) const; bool device::has(aspect Aspect) const { return impl->has(Aspect); } template detail::is_device_info_desc_t device::get_info() const { return impl->getInfo(); } template <> _LIBSYCL_EXPORT detail::is_device_info_desc_t device::get_info() const { static_assert( std::is_same_v); return get_platform(); } #define _LIBSYCL_EXPORT_GET_INFO(Desc) \ template _LIBSYCL_EXPORT detail::is_device_info_desc_t \ device::get_info() const; _LIBSYCL_EXPORT_GET_INFO(device_type) _LIBSYCL_EXPORT_GET_INFO(name) _LIBSYCL_EXPORT_GET_INFO(vendor) _LIBSYCL_EXPORT_GET_INFO(driver_version) #undef _LIBSYCL_EXPORT_GET_INFO _LIBSYCL_END_NAMESPACE_SYCL