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

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

#include <sycl/context.hpp>

Inheritance diagram for sycl::_V1::context:
Collaboration diagram for sycl::_V1::context:

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...
 
template<typename Param >
detail::is_context_info_desc< Param >::return_type get_info () const
 Constructs a SYCL context instance from OpenCL cl_context. 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 noexcept
 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...
 
 __SYCL2020_DEPRECATED ("is_host() is deprecated as the host device is no longer supported.") bool is_host() const
 Gets OpenCL interoperability 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...
 
- Public Member Functions inherited from sycl::_V1::detail::OwnerLessBase< context >
bool ext_oneapi_owner_before (const ext::oneapi::detail::weak_object_base< context > &Other) const noexcept
 Compares the object against a weak object using an owner-based implementation-defined ordering. More...
 
bool ext_oneapi_owner_before (const context &Other) const noexcept
 Compares the object against another object using an owner-based implementation-defined ordering. More...
 

Friends

template<backend Backend, class SyclT >
auto get_native (const SyclT &Obj) -> backend_return_t< Backend, SyclT >
 
template<class T >
std::add_pointer_t< typename decltype(T::impl)::element_type > detail::getRawSyclObjImpl (const T &SyclObject)
 
template<class 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 41 of file context.hpp.

Constructor & Destructor Documentation

◆ context() [1/10]

sycl::_V1::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 30 of file context.cpp.

◆ context() [2/10]

sycl::_V1::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 33 of file context.cpp.

◆ context() [3/10]

sycl::_V1::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 37 of file context.cpp.

◆ context() [4/10]

sycl::_V1::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 40 of file context.cpp.

◆ context() [5/10]

sycl::_V1::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 44 of file context.cpp.

◆ context() [6/10]

sycl::_V1::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 47 of file context.cpp.

◆ context() [7/10]

sycl::_V1::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 51 of file context.cpp.

◆ context() [8/10]

sycl::_V1::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 55 of file context.cpp.

References any_of(), sycl::_V1::device::get_platform(), and sycl::_V1::detail::getSyclObjImpl().

◆ context() [9/10]

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

◆ context() [10/10]

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

Member Function Documentation

◆ __SYCL2020_DEPRECATED()

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

Gets OpenCL interoperability context.

The OpenCL cl_context handle is retained on return.

Returns
a valid instance of OpenCL cl_context. Checks if this context is a SYCL host context.
true if this context is a SYCL host context.

◆ get_backend()

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

Returns the backend associated with this context.

Returns
the backend associated with this context.

Definition at line 133 of file context.cpp.

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

◆ get_devices()

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

◆ get_info()

template<typename Param >
detail::is_context_info_desc< Param >::return_type sycl::_V1::context::get_info

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. Queries this SYCL context for information.

The return type depends on information being queried.

Definition at line 95 of file context.cpp.

Referenced by sycl::_V1::kernel::get_context().

◆ get_platform()

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

Gets platform associated with this SYCL context.

Returns
a valid instance of SYCL platform.

Definition at line 135 of file context.cpp.

Referenced by sycl::_V1::detail::usm::alignedAllocHost(), and sycl::_V1::detail::isDeviceBinaryTypeSupported().

◆ get_property()

template<typename propertyT >
propertyT sycl::_V1::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 sycl::_V1::context::has_property ( ) const
noexcept

Checks if this context has a property of type propertyT.

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

◆ operator!=()

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

Definition at line 178 of file context.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

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

◆ get_native

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

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