DPC++ Runtime
Runtime libraries for oneAPI DPC++
sycl::_V1::device Class Reference

The SYCL device class encapsulates a single SYCL device on which kernels may be executed. More...

#include <sycl/device.hpp>

Inheritance diagram for sycl::_V1::device:
Collaboration diagram for sycl::_V1::device:

Public Member Functions

 device ()
 Constructs a SYCL device instance using the default device. More...
 
 __SYCL2020_DEPRECATED ("SYCL 1.2.1 device selectors are deprecated. Please " "use SYCL 2020 device selectors instead.") explicit device(const device_selector &DeviceSelector)
 Constructs a SYCL device instance from an OpenCL cl_device_id in accordance with the requirements described in 4.3.1. More...
 
template<typename DeviceSelector , typename = detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
 device (const DeviceSelector &deviceSelector)
 Constructs a SYCL device instance using the device identified by the device selector provided. More...
 
bool operator== (const device &rhs) const
 
bool operator!= (const device &rhs) const
 
 device (const device &rhs)=default
 
 device (device &&rhs)=default
 
deviceoperator= (const device &rhs)=default
 
deviceoperator= (device &&rhs)=default
 
void ext_oneapi_enable_peer_access (const device &peer)
 
void ext_oneapi_disable_peer_access (const device &peer)
 
bool ext_oneapi_can_access_peer (const device &peer, ext::oneapi::peer_access value=ext::oneapi::peer_access::access_supported)
 
 __SYCL2020_DEPRECATED ("is_host() is deprecated as the host device is no longer supported.") bool is_host() const
 Get instance of 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...
 
platform get_platform () const
 Get associated SYCL platform. More...
 
template<info::partition_property prop>
std::vector< devicecreate_sub_devices (size_t ComputeUnits) const
 Partition device into sub devices. More...
 
template<info::partition_property prop>
std::vector< devicecreate_sub_devices (const std::vector< size_t > &Counts) const
 Partition device into sub devices. More...
 
template<info::partition_property prop>
std::vector< devicecreate_sub_devices (info::partition_affinity_domain AffinityDomain) const
 Partition device into sub devices. More...
 
template<info::partition_property prop>
std::vector< devicecreate_sub_devices () const
 Partition device into sub devices. More...
 
template<typename Param >
detail::is_device_info_desc< Param >::return_type get_info () const
 Queries this SYCL device for information requested by the template parameter param. More...
 
bool has_extension (const std::string &extension_name) const
 Check SYCL extension support by device. More...
 
backend get_backend () const noexcept
 Returns the backend associated with this device. More...
 
bool has (aspect Aspect) const __SYCL_WARN_IMAGE_ASPECT(Aspect)
 Indicates if the SYCL device has the given feature. More...
 
bool ext_oneapi_architecture_is (ext::oneapi::experimental::architecture arch)
 Indicates if the SYCL device architecture equals to the one passed to the function. More...
 
- Public Member Functions inherited from sycl::_V1::detail::OwnerLessBase< device >
bool ext_oneapi_owner_before (const ext::oneapi::detail::weak_object_base< device > &Other) const noexcept
 Compares the object against a weak object using an owner-based implementation-defined ordering. More...
 
bool ext_oneapi_owner_before (const device &Other) const noexcept
 Compares the object against another object using an owner-based implementation-defined ordering. More...
 

Static Public Member Functions

static std::vector< deviceget_devices (info::device_type deviceType=info::device_type::all)
 Query available SYCL devices. More...
 

Friends

template<class T >
std::add_pointer_t< typename decltype(T::impl)::element_typedetail::getRawSyclObjImpl (const T &SyclObject)
 
template<class T >
detail::createSyclObjFromImpl (decltype(T::impl) ImplObj)
 
template<backend BackendName, class SyclObjectT >
auto get_native (const SyclObjectT &Obj) -> backend_return_t< BackendName, SyclObjectT >
 

Detailed Description

The SYCL device class encapsulates a single SYCL device on which kernels may be executed.

Definition at line 59 of file device.hpp.

Constructor & Destructor Documentation

◆ device() [1/4]

sycl::_V1::device::device ( )

Constructs a SYCL device instance using the default device.

Definition at line 33 of file device.cpp.

◆ device() [2/4]

template<typename DeviceSelector , typename = detail::EnableIfSYCL2020DeviceSelectorInvocable<DeviceSelector>>
sycl::_V1::device::device ( const DeviceSelector &  deviceSelector)
inlineexplicit

Constructs a SYCL device instance using the device identified by the device selector provided.

Parameters
DeviceSelectoris SYCL 2020 Device Selector, a simple callable that takes a device and returns an int

Definition at line 87 of file device.hpp.

◆ device() [3/4]

sycl::_V1::device::device ( const device rhs)
default

◆ device() [4/4]

sycl::_V1::device::device ( device &&  rhs)
default

Member Function Documentation

◆ __SYCL2020_DEPRECATED() [1/2]

sycl::_V1::device::__SYCL2020_DEPRECATED ( "is_host() is deprecated as the host device is no longer supported."  ) const

Get instance of device.

Returns
a valid cl_device_id instance in accordance with the requirements described in 4.3.1. Check if device is a host device
true if SYCL device is a host device

◆ __SYCL2020_DEPRECATED() [2/2]

sycl::_V1::device::__SYCL2020_DEPRECATED ( "SYCL 1.2.1 device selectors are deprecated. Please " "use SYCL 2020 device selectors instead."  ) const &

Constructs a SYCL device instance from an OpenCL cl_device_id in accordance with the requirements described in 4.3.1.

Parameters
DeviceIdis OpenCL device represented with cl_device_id Constructs a SYCL device instance using the device selected by the DeviceSelector provided.
DeviceSelectorSYCL 1.2.1 device_selector to be used (see 4.6.1.1).

◆ create_sub_devices() [1/4]

template<info::partition_property prop>
std::vector< device > sycl::_V1::device::create_sub_devices

Partition device into sub devices.

Available only when prop is info::partition_property::ext_intel_partition_by_cslice. 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 123 of file device.cpp.

◆ create_sub_devices() [2/4]

template<info::partition_property prop>
std::vector< device > sycl::_V1::device::create_sub_devices ( const std::vector< size_t > &  Counts) const

Partition device into sub devices.

Available only when prop is info::partition_property::partition_by_counts. 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 104 of file device.cpp.

◆ create_sub_devices() [3/4]

template<info::partition_property prop>
std::vector< device > sycl::_V1::device::create_sub_devices ( info::partition_affinity_domain  AffinityDomain) const

Partition device into sub devices.

Available only when prop is info::partition_property::partition_by_affinity_domain. 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 113 of file device.cpp.

◆ create_sub_devices() [4/4]

template<info::partition_property prop>
std::vector< device > sycl::_V1::device::create_sub_devices ( size_t  ComputeUnits) const

Partition device into sub devices.

Available only when prop is info::partition_property::partition_equally. 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 from this SYCL device equally based on the ComputeUnits parameter.

Definition at line 94 of file device.cpp.

Referenced by sycl::_V1::detail::amendDeviceAndSubDevices().

◆ ext_oneapi_architecture_is()

bool sycl::_V1::device::ext_oneapi_architecture_is ( ext::oneapi::experimental::architecture  arch)

Indicates if the SYCL device architecture equals to the one passed to the function.

Parameters
archis one of the architectures from architecture enum described in sycl_ext_oneapi_device_architecture specification.
Returns
true if the SYCL device architecture equals to the one passed to the function.

Definition at line 257 of file device.cpp.

◆ ext_oneapi_can_access_peer()

◆ ext_oneapi_disable_peer_access()

void sycl::_V1::device::ext_oneapi_disable_peer_access ( const device peer)

Definition at line 220 of file device.cpp.

References piextDisablePeerAccess().

◆ ext_oneapi_enable_peer_access()

void sycl::_V1::device::ext_oneapi_enable_peer_access ( const device peer)

Definition at line 211 of file device.cpp.

References piextEnablePeerAccess().

◆ get_backend()

backend sycl::_V1::device::get_backend ( ) const
noexcept

◆ get_devices()

std::vector< device > sycl::_V1::device::get_devices ( info::device_type  deviceType = info::device_type::all)
static

Query available SYCL devices.

The returned std::vector must contain a single SYCL device that is a host device, permitted by the deviceType parameter

Parameters
deviceTypeis one of the values described in A.3 of SYCL Spec
Returns
a std::vector containing all SYCL devices available in the system of the device type specified

Definition at line 52 of file device.cpp.

References sycl::_V1::detail::ods_target_list::backendCompatible(), sycl::_V1::detail::device_filter_list::backendCompatible(), sycl::_V1::detail::SYCLConfig< Config >::get(), and sycl::_V1::platform::get_platforms().

Referenced by sycl::_V1::ext::oneapi::detail::filter_selector_impl::filter_selector_impl(), sycl::_V1::detail::find_device_intersection(), sycl::_V1::make_device< backend::ext_oneapi_cuda >(), sycl::_V1::make_device< backend::ext_oneapi_hip >(), and sycl::_V1::detail::select_device().

◆ get_info()

◆ get_platform()

platform sycl::_V1::device::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 91 of file device.cpp.

Referenced by sycl::_V1::context::context(), and sycl::_V1::ext::intel::detail::selectDeviceByPlatform().

◆ has()

bool sycl::_V1::device::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 209 of file device.cpp.

Referenced by sycl::_V1::detail::checkDevSupportDeviceRequirements(), and sycl::_V1::detail::NDRangeReduction< reduction::strategy::group_reduce_and_last_wg_detection >::run().

◆ has_extension()

bool sycl::_V1::device::has_extension ( const std::string &  extension_name) const

Check SYCL extension support by device.

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

Definition at line 130 of file device.cpp.

Referenced by sycl::_V1::ext::intel::experimental::pipe< _name, _dataT, _min_capacity, _propertiesT, class >::read(), and sycl::_V1::ext::intel::experimental::pipe< _name, _dataT, _min_capacity, _propertiesT, class >::write().

◆ is_accelerator()

bool sycl::_V1::device::is_accelerator ( ) const

◆ is_cpu()

◆ is_gpu()

◆ operator!=()

bool sycl::_V1::device::operator!= ( const device rhs) const
inline

Definition at line 92 of file device.hpp.

◆ operator=() [1/2]

device& sycl::_V1::device::operator= ( const device rhs)
default

◆ operator=() [2/2]

device& sycl::_V1::device::operator= ( device &&  rhs)
default

◆ operator==()

bool sycl::_V1::device::operator== ( const device rhs) const
inline

Definition at line 90 of file device.hpp.

Friends And Related Function Documentation

◆ detail::createSyclObjFromImpl

template<class T >
T detail::createSyclObjFromImpl ( decltype(T::impl)  ImplObj)
friend

◆ detail::getRawSyclObjImpl

template<class T >
std::add_pointer_t<typename decltype(T::impl)::element_type> detail::getRawSyclObjImpl ( const T &  SyclObject)
friend

◆ get_native

template<backend BackendName, class SyclObjectT >
auto get_native ( const SyclObjectT &  Obj) -> backend_return_t< BackendName, SyclObjectT >
friend

Definition at line 136 of file backend.hpp.


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