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

The context class represents a SYCL context on which kernel functions may be executed. More...

#include <CL/sycl/context.hpp>

Public Member Functions

 context (const property_list &PropList={})
 Constructs a SYCL context instance using an instance of default_selector. More...
 
 context (const async_handler &AsyncHandler, const property_list &PropList={})
 Constructs a SYCL context instance using an instance of default_selector. More...
 
 context (const device &Device, const property_list &PropList={})
 Constructs a SYCL context instance using the provided device. More...
 
 context (const device &Device, async_handler AsyncHandler, const property_list &PropList={})
 Constructs a SYCL context instance using the provided device. More...
 
 context (const platform &Platform, const property_list &PropList={})
 Constructs a SYCL context instance using the provided platform. More...
 
 context (const platform &Platform, async_handler AsyncHandler, const property_list &PropList={})
 Constructs a SYCL context instance using the provided platform. More...
 
 context (const std::vector< device > &DeviceList, const property_list &PropList={})
 Constructs a SYCL context instance using list of devices. More...
 
 context (const std::vector< device > &DeviceList, async_handler AsyncHandler, const property_list &PropList={})
 Constructs a SYCL context instance using list of devices. More...
 
 context (cl_context ClContext, async_handler AsyncHandler={})
 Constructs a SYCL context instance from OpenCL cl_context. More...
 
template<info::context param>
info::param_traits< info::context, param >::return_type get_info () const
 Queries this SYCL context for information. More...
 
 context (const context &rhs)=default
 
 context (context &&rhs)=default
 
contextoperator= (const context &rhs)=default
 
contextoperator= (context &&rhs)=default
 
bool operator== (const context &rhs) const
 
bool operator!= (const context &rhs) const
 
template<typename propertyT >
bool has_property () const
 Checks if this context has a property of type propertyT. More...
 
template<typename propertyT >
propertyT get_property () const
 Gets the specified property of this context. More...
 
cl_context get () const
 Gets OpenCL interoperability context. More...
 
bool is_host () const
 Checks if this context is a SYCL host context. More...
 
backend get_backend () const noexcept
 Returns the backend associated with this context. More...
 
platform get_platform () const
 Gets platform associated with this SYCL context. More...
 
std::vector< deviceget_devices () const
 Gets devices associated with this SYCL context. More...
 
template<backend BackendName>
auto get_native () const -> typename interop< BackendName, context >::type
 Gets the native handle of the SYCL context. 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 context class represents a SYCL context on which kernel functions may be executed.

Definition at line 35 of file context.hpp.

Constructor & Destructor Documentation

◆ context() [1/11]

cl::sycl::context::context ( const property_list PropList = {})
explicit

Constructs a SYCL context instance using an instance of default_selector.

The instance of default_selector is used to select the associated platform and device(s). SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
PropListis an instance of property_list.

Definition at line 29 of file context.cpp.

◆ context() [2/11]

cl::sycl::context::context ( const async_handler AsyncHandler,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using an instance of default_selector.

The instance of default_selector is used to select the associated platform and device(s). The constructed SYCL context will use the AsyncHandler parameter to handle exceptions. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
AsyncHandleris an instance of async_handler.
PropListis an instance of property_list.

Definition at line 32 of file context.cpp.

◆ context() [3/11]

cl::sycl::context::context ( const device Device,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using the provided device.

Newly created context is associated with the Device and the SYCL platform that is associated with the Device. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
Deviceis an instance of SYCL device.
PropListis an instance of property_list.

Definition at line 36 of file context.cpp.

◆ context() [4/11]

cl::sycl::context::context ( const device Device,
async_handler  AsyncHandler,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using the provided device.

Newly created context is associated with the Device and the SYCL platform that is associated with the Device. The constructed SYCL context will use the AsyncHandler parameter to handle exceptions. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
Deviceis an instance of SYCL device.
AsyncHandleris an instance of async_handler.
PropListis an instance of property_list.

Definition at line 39 of file context.cpp.

◆ context() [5/11]

cl::sycl::context::context ( const platform Platform,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using the provided platform.

Newly created context is associated with the Platform and with each SYCL device that is associated with the Platform. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
Platformis an instance of SYCL platform.
PropListis an instance of property_list.

Definition at line 43 of file context.cpp.

◆ context() [6/11]

cl::sycl::context::context ( const platform Platform,
async_handler  AsyncHandler,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using the provided platform.

Newly created context is associated with the Platform and with each SYCL device that is associated with the Platform. The constructed SYCL context will use the AsyncHandler parameter to handle exceptions. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
Platformis an instance of SYCL platform.
AsyncHandleris an instance of async_handler.
PropListis an instance of property_list.

Definition at line 46 of file context.cpp.

◆ context() [7/11]

cl::sycl::context::context ( const std::vector< device > &  DeviceList,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using list of devices.

Newly created context will be associated with each SYCL device in the DeviceList. This requires that all SYCL devices in the list have the same associated SYCL platform. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
DeviceListis a list of SYCL device instances.
PropListis an instance of property_list.

Definition at line 50 of file context.cpp.

◆ context() [8/11]

cl::sycl::context::context ( const std::vector< device > &  DeviceList,
async_handler  AsyncHandler,
const property_list PropList = {} 
)
explicit

Constructs a SYCL context instance using list of devices.

Newly created context will be associated with each SYCL device in the DeviceList. This requires that all SYCL devices in the list have the same associated SYCL platform. The constructed SYCL context will use the AsyncHandler parameter to handle exceptions. SYCL properties are passed to the constructed SYCL context through PropList.

Parameters
DeviceListis a list of SYCL device instances.
AsyncHandleris an instance of async_handler.
PropListis an instance of property_list.

Definition at line 54 of file context.cpp.

References cl::sycl::device::get_platform(), cl::sycl::detail::getSyclObjImpl(), PI_INVALID_DEVICE, and PI_INVALID_VALUE.

◆ context() [9/11]

cl::sycl::context::context ( cl_context  ClContext,
async_handler  AsyncHandler = {} 
)

Constructs a SYCL context instance from OpenCL cl_context.

ClContext is retained on SYCL context instantiation. The constructed SYCL context will use the AsyncHandler parameter to handle exceptions.

Parameters
ClContextis an instance of OpenCL cl_context.
AsyncHandleris an instance of async_handler.

Definition at line 84 of file context.cpp.

◆ context() [10/11]

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

◆ context() [11/11]

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

Member Function Documentation

◆ get()

cl_context cl::sycl::context::get ( ) const

Gets OpenCL interoperability context.

The OpenCL cl_context handle is retained on return.

Returns
a valid instance of OpenCL cl_context.

Definition at line 117 of file context.cpp.

◆ get_backend()

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

Returns the backend associated with this context.

Returns
the backend associated with this context.

Definition at line 121 of file context.cpp.

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

◆ get_devices()

std::vector< device > cl::sycl::context::get_devices ( ) const

◆ get_info()

template<info::context param>
info::param_traits<info::context, param>::return_type cl::sycl::context::get_info ( ) const

Queries this SYCL context for information.

The return type depends on information being queried.

◆ get_native()

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

Gets the native handle of the SYCL context.

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

Definition at line 220 of file context.hpp.

◆ get_platform()

platform cl::sycl::context::get_platform ( ) const

Gets platform associated with this SYCL context.

Returns
a valid instance of SYCL platform.

Definition at line 123 of file context.cpp.

References cl::sycl::info::platform.

Referenced by cl::sycl::detail::isDeviceBinaryTypeSupported().

◆ get_property()

template<typename propertyT >
propertyT cl::sycl::context::get_property ( ) const

Gets the specified property of this context.

Throws invalid_object_error if this context does not have a property of type propertyT.

Returns
a copy of the property of type propertyT.

◆ has_property()

template<typename propertyT >
bool cl::sycl::context::has_property ( ) const

Checks if this context has a property of type propertyT.

Returns
true if this context has a property of type propertyT.

◆ is_host()

◆ operator!=()

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

Definition at line 172 of file context.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

Definition at line 170 of file context.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: