DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
cl::sycl::device Class Reference

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

#include <CL/sycl/device.hpp>

Public Member Functions

 device ()
 Constructs a SYCL device instance as a host device. More...
 
 device (cl_device_id DeviceId)
 Constructs a SYCL device instance from an OpenCL cl_device_id in accordance with the requirements described in 4.3.1. More...
 
 device (const device_selector &DeviceSelector)
 Constructs a SYCL device instance using the device selected by the DeviceSelector 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
 
cl_device_id get () const
 Get instance of device. More...
 
bool is_host () const
 Check if 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...
 
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::device param>
info::param_traits< info::device, 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...
 
template<backend BackendName>
auto get_native () const -> typename interop< BackendName, device >::type
 Gets the native handle of the SYCL device. More...
 
bool has (aspect Aspect) const
 Indicates if the SYCL device has the given feature. 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 >
detail::add_pointer_t< typename decltype(T::impl)::element_type > detail::getRawSyclObjImpl (const T &SyclObject)
 
template<class T >
T detail::createSyclObjFromImpl (decltype(T::impl) ImplObj)
 

Detailed Description

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

Definition at line 34 of file device.hpp.

Constructor & Destructor Documentation

◆ device() [1/5]

cl::sycl::device::device ( )

Constructs a SYCL device instance as a host device.

Definition at line 32 of file device.cpp.

◆ device() [2/5]

cl::sycl::device::device ( cl_device_id  DeviceId)
explicit

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

Definition at line 34 of file device.cpp.

References cl::sycl::detail::platform_impl::getPlatformFromPiDevice(), and piextDeviceCreateWithNativeHandle().

◆ device() [3/5]

cl::sycl::device::device ( const device_selector DeviceSelector)
explicit

Constructs a SYCL device instance using the device selected by the DeviceSelector provided.

Parameters
DeviceSelectorSYCL device selector to be used (see 4.6.1.1).

Definition at line 47 of file device.cpp.

References cl::sycl::device_selector::select_device().

◆ device() [4/5]

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

◆ device() [5/5]

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

Member Function Documentation

◆ create_sub_devices() [1/3]

template<info::partition_property prop>
std::vector< device > cl::sycl::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 123 of file device.cpp.

◆ create_sub_devices() [2/3]

template<info::partition_property prop>
std::vector< device > cl::sycl::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 132 of file device.cpp.

◆ create_sub_devices() [3/3]

template<info::partition_property prop>
std::vector< device > cl::sycl::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 113 of file device.cpp.

◆ get()

cl_device_id cl::sycl::device::get ( ) const

Get instance of device.

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

Definition at line 100 of file device.cpp.

◆ get_backend()

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

Returns the backend associated with this device.

Returns
the backend associated with this device.

Definition at line 159 of file device.cpp.

References cl::sycl::detail::getImplBackend().

◆ get_devices()

std::vector< device > cl::sycl::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 51 of file device.cpp.

References cl::sycl::info::all, cl::sycl::detail::device_filter_list::backendCompatible(), cl::sycl::detail::device_filter_list::containsHost(), cl::sycl::detail::force_type(), cl::sycl::detail::SYCLConfig< Config >::get(), cl::sycl::detail::get_forced_type(), cl::sycl::platform::get_platforms(), cl::sycl::info::host, and cl::sycl::detail::match_types().

Referenced by cl::sycl::ext::oneapi::detail::filter_selector_impl::filter_selector_impl(), and cl::sycl::detail::find_device_intersection().

◆ get_info()

template<info::device param>
info::param_traits< info::device, param >::return_type cl::sycl::device::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 147 of file device.cpp.

Referenced by cl::sycl::isForcedDevice(), cl::sycl::ext::oneapi::detail::filter_selector_impl::operator()(), cl::sycl::default_selector::operator()(), cl::sycl::ext::oneapi::detail::reduGetMaxNumConcurrentWorkGroups(), cl::sycl::ext::oneapi::detail::reduGetMaxWGSize(), and cl::sycl::device_selector::select_device().

◆ get_native()

template<backend BackendName>
auto cl::sycl::device::get_native ( ) const -> typename interop<BackendName, device>::type
inline

Gets the native handle of the SYCL device.

Returns
a native handle, the type of which defined by the backend.

Definition at line 188 of file device.hpp.

◆ get_platform()

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

Referenced by cl::sycl::context::context(), cl::sycl::ext::intel::platform_selector::operator()(), and cl::sycl::platform::platform().

◆ has()

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

Referenced by cl::sycl::handler::parallel_for().

◆ has_extension()

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

◆ is_accelerator()

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

Check if device is an accelerator device.

Returns
true if SYCL device is an accelerator device

Definition at line 108 of file device.cpp.

Referenced by cl::sycl::detail::deviceToString(), cl::sycl::default_selector::operator()(), and cl::sycl::accelerator_selector::operator()().

◆ is_cpu()

bool cl::sycl::device::is_cpu ( ) const

Check if device is a CPU device.

Returns
true if SYCL device is a CPU device

Definition at line 104 of file device.cpp.

Referenced by cl::sycl::detail::deviceToString(), cl::sycl::default_selector::operator()(), and cl::sycl::cpu_selector::operator()().

◆ is_gpu()

bool cl::sycl::device::is_gpu ( ) const

Check if device is a GPU device.

Returns
true if SYCL device is a GPU device

Definition at line 106 of file device.cpp.

Referenced by cl::sycl::detail::deviceToString(), cl::sycl::default_selector::operator()(), cl::sycl::gpu_selector::operator()(), and cl::sycl::ext::oneapi::detail::reduGetMaxNumConcurrentWorkGroups().

◆ is_host()

bool cl::sycl::device::is_host ( ) const

◆ operator!=()

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

Definition at line 54 of file device.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

Definition at line 52 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 >
detail::add_pointer_t<typename decltype(T::impl)::element_type> detail::getRawSyclObjImpl ( const T SyclObject)
friend

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