DPC++ Runtime
Runtime libraries for oneAPI DPC++
sycl::_V1::detail::device_impl Class Reference

#include <detail/device_impl.hpp>

Public Member Functions

 device_impl ()
 Constructs a SYCL device instance as a host device. More...
 
 device_impl (pi_native_handle, const PluginPtr &Plugin)
 Constructs a SYCL device instance using the provided raw device handle. More...
 
 device_impl (sycl::detail::pi::PiDevice Device, PlatformImplPtr Platform)
 Constructs a SYCL device instance using the provided PI device instance. More...
 
 device_impl (sycl::detail::pi::PiDevice Device, const PluginPtr &Plugin)
 Constructs a SYCL device instance using the provided PI device instance. More...
 
 ~device_impl ()
 
cl_device_id get () const
 Get instance of OpenCL device. More...
 
sycl::detail::pi::PiDevicegetHandleRef ()
 Get reference to PI device. More...
 
const sycl::detail::pi::PiDevicegetHandleRef () const
 Get constant reference to PI device. More...
 
bool is_host () const
 Check if SYCL device is a host device. More...
 
bool is_cpu () const
 Check if device is a CPU device. More...
 
bool is_gpu () const
 Check if device is a GPU device. More...
 
bool is_accelerator () const
 Check if device is an accelerator device. More...
 
sycl::detail::pi::PiDeviceType get_device_type () const
 Return device type. More...
 
platform get_platform () const
 Get associated SYCL platform. More...
 
const PluginPtrgetPlugin () const
 
bool has_extension (const std::string &ExtensionName) const
 Check SYCL extension support by device. More...
 
std::vector< devicecreate_sub_devices (const cl_device_partition_property *Properties, size_t SubDevicesCount) const
 
std::vector< devicecreate_sub_devices (size_t ComputeUnits) const
 Partition device into sub devices. More...
 
std::vector< devicecreate_sub_devices (const std::vector< size_t > &Counts) const
 Partition device into sub devices. More...
 
std::vector< devicecreate_sub_devices (info::partition_affinity_domain AffinityDomain) const
 Partition device into sub devices. More...
 
std::vector< devicecreate_sub_devices () const
 Partition device into sub devices. More...
 
bool is_partition_supported (info::partition_property Prop) const
 Check if desired partition property supported by device. More...
 
template<typename Param >
Param::return_type get_info () const
 Queries this SYCL device for information requested by the template parameter param. More...
 
template<typename Param >
Param::return_type get_backend_info () const
 Queries SYCL queue for SYCL backend-specific information. More...
 
bool is_affinity_supported (info::partition_affinity_domain AffinityDomain) const
 Check if affinity partitioning by specified domain is supported by device. More...
 
pi_native_handle getNative () const
 Gets the native handle of the SYCL device. More...
 
bool has (aspect Aspect) const
 Indicates if the SYCL device has the given feature. More...
 
bool isAssertFailSupported () const
 
bool isRootDevice () const
 
std::string getDeviceName () const
 
bool extOneapiArchitectureIs (ext::oneapi::experimental::architecture Arch) const
 
bool extOneapiArchitectureIs (ext::oneapi::experimental::arch_category Category) const
 
bool extOneapiCanCompile (ext::oneapi::experimental::source_language Language)
 
sycl::ext::oneapi::experimental::forward_progress_guarantee getProgressGuarantee (ext::oneapi::experimental::execution_scope threadScope, ext::oneapi::experimental::execution_scope coordinationScope) const
 
bool supportsForwardProgress (ext::oneapi::experimental::forward_progress_guarantee guarantee, ext::oneapi::experimental::execution_scope threadScope, ext::oneapi::experimental::execution_scope coordinationScope) const
 
ext::oneapi::experimental::forward_progress_guarantee getImmediateProgressGuarantee (ext::oneapi::experimental::execution_scope coordination_scope) const
 
uint64_t getCurrentDeviceTime ()
 Gets the current device timestamp. More...
 
bool isGetDeviceAndHostTimerSupported ()
 Check clGetDeviceAndHostTimer is available for fallback profiling. More...
 
backend getBackend () const
 Get the backend of this device. More...
 
PlatformImplPtr getPlatformImpl () const
 Get the platform impl serving this device. More...
 
std::string get_device_info_string (sycl::detail::pi::PiDeviceInfo InfoCode) const
 Get device info string. More...
 
ext::oneapi::experimental::architecture getDeviceArch () const
 Get device architecture. More...
 

Static Public Member Functions

static std::shared_ptr< device_implgetHostDeviceImpl ()
 Gets the single instance of the Host Device. More...
 
template<typename ReturnT >
static ReturnT getProgressGuaranteesUpTo (ext::oneapi::experimental::forward_progress_guarantee guarantee)
 
static sycl::ext::oneapi::experimental::forward_progress_guarantee getHostProgressGuarantee (sycl::ext::oneapi::experimental::execution_scope threadScope, sycl::ext::oneapi::experimental::execution_scope coordinationScope)
 

Detailed Description

Definition at line 36 of file device_impl.hpp.

Constructor & Destructor Documentation

◆ device_impl() [1/4]

sycl::_V1::detail::device_impl::device_impl ( )

Constructs a SYCL device instance as a host device.

Definition at line 20 of file device_impl.cpp.

◆ device_impl() [2/4]

sycl::_V1::detail::device_impl::device_impl ( pi_native_handle  InteropDeviceHandle,
const PluginPtr Plugin 
)
explicit

Constructs a SYCL device instance using the provided raw device handle.

Definition at line 25 of file device_impl.cpp.

◆ device_impl() [3/4]

sycl::_V1::detail::device_impl::device_impl ( sycl::detail::pi::PiDevice  Device,
PlatformImplPtr  Platform 
)
explicit

Constructs a SYCL device instance using the provided PI device instance.

Definition at line 29 of file device_impl.cpp.

◆ device_impl() [4/4]

sycl::_V1::detail::device_impl::device_impl ( sycl::detail::pi::PiDevice  Device,
const PluginPtr Plugin 
)
explicit

Constructs a SYCL device instance using the provided PI device instance.

Definition at line 34 of file device_impl.cpp.

◆ ~device_impl()

sycl::_V1::detail::device_impl::~device_impl ( )

Definition at line 86 of file device_impl.cpp.

References __SYCL_CHECK_OCL_CODE_NO_EXC, getPlugin(), and piDeviceRelease().

Member Function Documentation

◆ create_sub_devices() [1/5]

std::vector< device > sycl::_V1::detail::device_impl::create_sub_devices ( ) const

Partition device into sub devices.

If this SYCL device does not support info::partition_property::ext_intel_partition_by_cslice a feature_not_supported exception must be thrown.

Returns
a vector class of sub devices partitioned from this SYCL device at a granularity of "cslice" (compute slice).

Definition at line 321 of file device_impl.cpp.

References sycl::_V1::info::ext_intel_partition_by_cslice, getPlugin(), is_partition_supported(), PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE, and piDevicePartition().

Referenced by create_sub_devices().

◆ create_sub_devices() [2/5]

std::vector< device > sycl::_V1::detail::device_impl::create_sub_devices ( const cl_device_partition_property *  Properties,
size_t  SubDevicesCount 
) const

◆ create_sub_devices() [3/5]

std::vector< device > sycl::_V1::detail::device_impl::create_sub_devices ( const std::vector< size_t > &  Counts) const

Partition device into sub devices.

If this SYCL device does not support info::partition_property::partition_by_counts a feature_not_supported exception must be thrown.

Parameters
Countsis a std::vector of desired compute units in sub devices.
Returns
a std::vector of sub devices partitioned from this SYCL device by count sizes based on the Counts parameter.

Definition at line 250 of file device_impl.cpp.

References create_sub_devices(), sycl::_V1::invalid, is_partition_supported(), sycl::_V1::info::partition_by_counts, PI_DEVICE_PARTITION_BY_COUNTS, and PI_DEVICE_PARTITION_BY_COUNTS_LIST_END.

◆ create_sub_devices() [4/5]

std::vector< device > sycl::_V1::detail::device_impl::create_sub_devices ( info::partition_affinity_domain  AffinityDomain) const

Partition device into sub devices.

If this SYCL device does not support info::partition_property::partition_by_affinity_domain or the SYCL device does not support info::affinity_domain provided a feature_not_supported exception must be thrown.

Parameters
AffinityDomainis one of the values described in Table 4.20 of SYCL Spec
Returns
a vector class of sub devices partitioned from this SYCL device by affinity domain based on the AffinityDomain parameter

Definition at line 292 of file device_impl.cpp.

References sycl::_V1::detail::affinityDomainToString(), create_sub_devices(), getPlugin(), is_affinity_supported(), is_partition_supported(), sycl::_V1::info::partition_by_affinity_domain, PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, and piDevicePartition().

◆ create_sub_devices() [5/5]

std::vector< device > sycl::_V1::detail::device_impl::create_sub_devices ( size_t  ComputeUnits) const

Partition device into sub devices.

If this SYCL device does not support info::partition_property::partition_equally a feature_not_supported exception must be thrown.

Parameters
ComputeUnitsis a desired count of compute units in each sub device.
Returns
A vector class of sub devices partitioned equally from this SYCL device based on the ComputeUnits parameter.

Definition at line 226 of file device_impl.cpp.

References create_sub_devices(), sycl::_V1::invalid, is_partition_supported(), sycl::_V1::info::partition_equally, and PI_DEVICE_PARTITION_EQUALLY.

◆ extOneapiArchitectureIs() [1/2]

bool sycl::_V1::detail::device_impl::extOneapiArchitectureIs ( ext::oneapi::experimental::arch_category  Category) const
inline

◆ extOneapiArchitectureIs() [2/2]

bool sycl::_V1::detail::device_impl::extOneapiArchitectureIs ( ext::oneapi::experimental::architecture  Arch) const
inline

Definition at line 245 of file device_impl.hpp.

References getDeviceArch().

◆ extOneapiCanCompile()

bool sycl::_V1::detail::device_impl::extOneapiCanCompile ( ext::oneapi::experimental::source_language  Language)

◆ get()

cl_device_id sycl::_V1::detail::device_impl::get ( ) const

Get instance of OpenCL device.

Returns
a valid cl_device_id instance in accordance with the requirements described in 4.3.1.

Definition at line 103 of file device_impl.cpp.

References getNative(), getPlugin(), and piDeviceRetain().

Referenced by has().

◆ get_backend_info()

template<typename Param >
Param::return_type sycl::_V1::detail::device_impl::get_backend_info ( ) const

Queries SYCL queue for SYCL backend-specific information.

The return type depends on information being queried.

◆ get_device_info_string()

std::string sycl::_V1::detail::device_impl::get_device_info_string ( sycl::detail::pi::PiDeviceInfo  InfoCode) const
inline

Get device info string.

Definition at line 168 of file device_info.hpp.

References getHandleRef(), getPlugin(), and piDeviceGetInfo().

Referenced by has_extension().

◆ get_device_type()

sycl::detail::pi::PiDeviceType sycl::_V1::detail::device_impl::get_device_type ( ) const
inline

Return device type.

Returns
the type of the device

Definition at line 113 of file device_impl.hpp.

◆ get_info()

template<typename Param >
Param::return_type sycl::_V1::detail::device_impl::get_info

Queries this SYCL device for information requested by the template parameter param.

Specializations of info::param_traits must be defined in accordance with the info parameters in Table 4.20 of SYCL Spec to facilitate returning the type associated with the param parameter.

Returns
device info of type described in Table 4.20.

Definition at line 119 of file device_impl.cpp.

References is_host().

Referenced by sycl::_V1::detail::enqueue_kernel_launch::handleInvalidWorkGroupSize(), sycl::_V1::detail::enqueue_kernel_launch::handleOutOfResources(), and has().

◆ get_platform()

platform sycl::_V1::detail::device_impl::get_platform ( ) const

Get associated SYCL platform.

If this SYCL device is an OpenCL device then the SYCL platform must encapsulate the OpenCL cl_plaform_id associated with the underlying OpenCL cl_device_id of this SYCL device. If this SYCL device is a host device then the SYCL platform must be a host platform. The value returned must be equal to that returned by get_info<info::device::platform>().

Returns
The associated SYCL platform.

Definition at line 114 of file device_impl.cpp.

Referenced by sycl::_V1::detail::enqueue_kernel_launch::handleInvalidWorkGroupSize(), and sycl::_V1::detail::enqueue_kernel_launch::handleOutOfResources().

◆ getBackend()

backend sycl::_V1::detail::device_impl::getBackend ( ) const
inline

Get the backend of this device.

Definition at line 310 of file device_impl.hpp.

Referenced by extOneapiCanCompile(), getImmediateProgressGuarantee(), getNative(), and has().

◆ getCurrentDeviceTime()

uint64_t sycl::_V1::detail::device_impl::getCurrentDeviceTime ( )

Gets the current device timestamp.

Exceptions
sycl::feature_not_supportedif feature is not supported on device

Definition at line 795 of file device_impl.cpp.

References getPlugin(), piGetDeviceAndHostTimer(), and piPluginGetLastError().

◆ getDeviceArch()

ext::oneapi::experimental::architecture sycl::_V1::detail::device_impl::getDeviceArch ( ) const

Get device architecture.

Definition at line 775 of file device_impl.cpp.

Referenced by extOneapiArchitectureIs().

◆ getDeviceName()

std::string sycl::_V1::detail::device_impl::getDeviceName ( ) const

Definition at line 768 of file device_impl.cpp.

◆ getHandleRef() [1/2]

◆ getHandleRef() [2/2]

const sycl::detail::pi::PiDevice& sycl::_V1::detail::device_impl::getHandleRef ( ) const
inline

Get constant reference to PI device.

For host device an exception is thrown

Returns
constant reference to PI device

Definition at line 80 of file device_impl.hpp.

◆ getHostDeviceImpl()

std::shared_ptr< device_impl > sycl::_V1::detail::device_impl::getHostDeviceImpl ( )
static

Gets the single instance of the Host Device.

Returns
the host device_impl singleton

Definition at line 757 of file device_impl.cpp.

Referenced by sycl::_V1::detail::platform_impl::get_devices(), and sycl::_V1::detail::Scheduler::Scheduler().

◆ getHostProgressGuarantee()

sycl::ext::oneapi::experimental::forward_progress_guarantee sycl::_V1::detail::device_impl::getHostProgressGuarantee ( sycl::ext::oneapi::experimental::execution_scope  threadScope,
sycl::ext::oneapi::experimental::execution_scope  coordinationScope 
)
static

Definition at line 870 of file device_impl.cpp.

◆ getImmediateProgressGuarantee()

ext::oneapi::experimental::forward_progress_guarantee sycl::_V1::detail::device_impl::getImmediateProgressGuarantee ( ext::oneapi::experimental::execution_scope  coordination_scope) const

◆ getNative()

pi_native_handle sycl::_V1::detail::device_impl::getNative ( ) const

Gets the native handle of the SYCL device.

Returns
a native handle.

Definition at line 343 of file device_impl.cpp.

References getBackend(), getHandleRef(), getPlugin(), sycl::_V1::opencl, piDeviceRetain(), and piextDeviceGetNativeHandle().

Referenced by get().

◆ getPlatformImpl()

PlatformImplPtr sycl::_V1::detail::device_impl::getPlatformImpl ( ) const
inline

Get the platform impl serving this device.

Returns
PlatformImplPtr

Definition at line 314 of file device_impl.hpp.

◆ getPlugin()

◆ getProgressGuarantee()

sycl::ext::oneapi::experimental::forward_progress_guarantee sycl::_V1::detail::device_impl::getProgressGuarantee ( ext::oneapi::experimental::execution_scope  threadScope,
ext::oneapi::experimental::execution_scope  coordinationScope 
) const

Definition at line 881 of file device_impl.cpp.

References getImmediateProgressGuarantee().

Referenced by supportsForwardProgress().

◆ getProgressGuaranteesUpTo()

template<typename ReturnT >
static ReturnT sycl::_V1::detail::device_impl::getProgressGuaranteesUpTo ( ext::oneapi::experimental::forward_progress_guarantee  guarantee)
inlinestatic

Definition at line 267 of file device_impl.hpp.

◆ has()

bool sycl::_V1::detail::device_impl::has ( aspect  Aspect) const

Indicates if the SYCL device has the given feature.

Parameters
Aspectis one of the values in Table 4.20 of the SYCL 2020 Provisional Spec.
Returns
true if the SYCL device has the given feature.

Definition at line 352 of file device_impl.cpp.

References any_of(), sycl::_V1::ext_oneapi_cuda, sycl::_V1::ext_oneapi_level_zero, get(), get_info(), getBackend(), getHandleRef(), getPlugin(), has_extension(), is_accelerator(), is_cpu(), is_gpu(), is_host(), isAssertFailSupported(), sycl::_V1::opencl, PI_DEVICE_INFO_DEVICE_ID, PI_DEVICE_INFO_GPU_EU_COUNT, PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH, PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU, PI_DEVICE_INFO_GPU_SLICES, PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, PI_DEVICE_INFO_IMAGE_SUPPORT, PI_DEVICE_INFO_PCI_ADDRESS, PI_DEVICE_INFO_UUID, PI_EXT_INTEL_DEVICE_INFO_ESIMD_SUPPORT, PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY, PI_EXT_INTEL_DEVICE_INFO_MEMORY_BUS_WIDTH, PI_EXT_INTEL_DEVICE_INFO_MEMORY_CLOCK_RATE, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_IMAGES_1D_USM_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_IMAGES_2D_USM_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D, PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM, PI_EXT_ONEAPI_DEVICE_INFO_COMMAND_BUFFER_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_CUBEMAP_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_CUDA_ASYNC_BARRIER, PI_EXT_ONEAPI_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_INTEROP_MEMORY_IMPORT_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_MIPMAP_ANISOTROPY_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_MIPMAP_LEVEL_REFERENCE_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_MIPMAP_SUPPORT, PI_EXT_ONEAPI_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT, PI_FALSE, PI_USM_CONCURRENT_ATOMIC_ACCESS, and piDeviceGetInfo().

Referenced by sycl::_V1::detail::usm::alignedAllocInternal().

◆ has_extension()

bool sycl::_V1::detail::device_impl::has_extension ( const std::string &  ExtensionName) const

Check SYCL extension support by device.

Parameters
ExtensionNameis a name of queried extension.
Returns
true if SYCL device supports the extension.

Definition at line 182 of file device_impl.cpp.

References get_device_info_string().

Referenced by sycl::_V1::detail::usm::alignedAllocInternal(), and has().

◆ is_accelerator()

bool sycl::_V1::detail::device_impl::is_accelerator ( ) const
inline

Check if device is an accelerator device.

Returns
true if SYCL device is an accelerator device

Definition at line 106 of file device_impl.hpp.

References is_host(), and PI_DEVICE_TYPE_ACC.

Referenced by has().

◆ is_affinity_supported()

bool sycl::_V1::detail::device_impl::is_affinity_supported ( info::partition_affinity_domain  AffinityDomain) const

Check if affinity partitioning by specified domain is supported by device.

Parameters
AffinityDomainis one of the values described in Table 4.20 of SYCL Spec
Returns
true if AffinityDomain is supported by device.

Definition at line 96 of file device_impl.cpp.

Referenced by create_sub_devices().

◆ is_cpu()

bool sycl::_V1::detail::device_impl::is_cpu ( ) const
inline

Check if device is a CPU device.

Returns
true if SYCL device is a CPU device

Definition at line 96 of file device_impl.hpp.

References is_host(), and PI_DEVICE_TYPE_CPU.

Referenced by getImmediateProgressGuarantee(), and has().

◆ is_gpu()

bool sycl::_V1::detail::device_impl::is_gpu ( ) const
inline

Check if device is a GPU device.

Returns
true if SYCL device is a GPU device

Definition at line 101 of file device_impl.hpp.

References is_host(), and PI_DEVICE_TYPE_GPU.

Referenced by getImmediateProgressGuarantee(), and has().

◆ is_host()

bool sycl::_V1::detail::device_impl::is_host ( ) const
inline

Check if SYCL device is a host device.

Returns
true if SYCL device is a host device

Definition at line 91 of file device_impl.hpp.

Referenced by get_info(), has(), is_accelerator(), is_cpu(), and is_gpu().

◆ is_partition_supported()

bool sycl::_V1::detail::device_impl::is_partition_supported ( info::partition_property  Prop) const

Check if desired partition property supported by device.

Parameters
Propis one of info::partition_property::(partition_equally, partition_by_counts, partition_by_affinity_domain)
Returns
true if Prop is supported by device.

Definition at line 191 of file device_impl.cpp.

Referenced by create_sub_devices().

◆ isAssertFailSupported()

bool sycl::_V1::detail::device_impl::isAssertFailSupported ( ) const

Definition at line 764 of file device_impl.cpp.

Referenced by has().

◆ isGetDeviceAndHostTimerSupported()

bool sycl::_V1::detail::device_impl::isGetDeviceAndHostTimerSupported ( )

Check clGetDeviceAndHostTimer is available for fallback profiling.

Definition at line 848 of file device_impl.cpp.

References getPlugin(), and piGetDeviceAndHostTimer().

◆ isRootDevice()

bool sycl::_V1::detail::device_impl::isRootDevice ( ) const
inline

Definition at line 240 of file device_impl.hpp.

◆ supportsForwardProgress()

bool sycl::_V1::detail::device_impl::supportsForwardProgress ( ext::oneapi::experimental::forward_progress_guarantee  guarantee,
ext::oneapi::experimental::execution_scope  threadScope,
ext::oneapi::experimental::execution_scope  coordinationScope 
) const

Definition at line 905 of file device_impl.cpp.

References getProgressGuarantee().


The documentation for this class was generated from the following files: