DPC++ Runtime
Runtime libraries for oneAPI DPC++
cl::sycl::detail::context_impl Class Reference

#include <detail/context_impl.hpp>

Public Types

enum  PropertySupport { NotSupported = 0, Supported = 1, NotChecked = 2 }
 
using CachedLibProgramsT = std::map< std::pair< DeviceLibExt, RT::PiDevice >, RT::PiProgram >
 

Public Member Functions

 context_impl (const device &Device, async_handler AsyncHandler, const property_list &PropList)
 Constructs a context_impl using a single SYCL devices. More...
 
 context_impl (const std::vector< cl::sycl::device > DeviceList, async_handler AsyncHandler, const property_list &PropList)
 Constructs a context_impl using a list of SYCL devices. More...
 
 context_impl (RT::PiContext PiContext, async_handler AsyncHandler, const plugin &Plugin)
 Construct a context_impl using plug-in interoperability handle. More...
 
 ~context_impl ()
 
template<typename propertyT >
bool has_property () const
 Checks if this context_impl has a property of type propertyT. More...
 
template<typename propertyT >
propertyT get_property () const
 Gets the specified property of this context_impl. More...
 
cl_context get () const
 Gets OpenCL interoperability context handle. More...
 
bool is_host () const
 Checks if this context is a host context. More...
 
const async_handlerget_async_handler () const
 Gets asynchronous exception handler. More...
 
const plugingetPlugin () const
 
PlatformImplPtr getPlatformImpl () const
 
template<info::context param>
info::param_traits< info::context, param >::return_type get_info () const
 Queries this context for information. More...
 
RT::PiContextgetHandleRef ()
 Gets the underlying context object (if any) without reference count modification. More...
 
const RT::PiContextgetHandleRef () const
 Gets the underlying context object (if any) without reference count modification. More...
 
const std::vector< device > & getDevices () const
 Unlike ‘get_info<info::context::devices>’, this function returns a reference. More...
 
Locked< CachedLibProgramsTacquireCachedLibPrograms ()
 In contrast to user programs, which are compiled from user code, library programs come from the SYCL runtime. More...
 
KernelProgramCachegetKernelProgramCache () const
 
bool hasDevice (std::shared_ptr< detail::device_impl > Device) const
 Returns true if and only if context contains the given device. More...
 
pi_native_handle getNative () const
 Gets the native handle of the SYCL context. More...
 
bool isBufferLocationSupported () const
 

Detailed Description

Definition at line 31 of file context_impl.hpp.

Member Typedef Documentation

◆ CachedLibProgramsT

Member Enumeration Documentation

◆ PropertySupport

Enumerator
NotSupported 
Supported 
NotChecked 

Definition at line 176 of file context_impl.hpp.

Constructor & Destructor Documentation

◆ context_impl() [1/3]

cl::sycl::detail::context_impl::context_impl ( const device Device,
async_handler  AsyncHandler,
const property_list PropList 
)

Constructs a context_impl using a single SYCL devices.

The constructed context_impl will use the AsyncHandler parameter to handle exceptions. PropList carries the properties of the constructed context_impl.

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

Definition at line 28 of file context_impl.cpp.

References cl::sycl::detail::KernelProgramCache::setContextPtr().

◆ context_impl() [2/3]

cl::sycl::detail::context_impl::context_impl ( const std::vector< cl::sycl::device DeviceList,
async_handler  AsyncHandler,
const property_list PropList 
)

Constructs a context_impl using a list of SYCL devices.

Newly created instance will save each SYCL device in the list. This requres that all devices in the list are associated with the same SYCL platform. The constructed context_impl will use the AsyncHandler parameter to handle exceptions. PropList carries the properties of the constructed context_impl.

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

Definition at line 36 of file context_impl.cpp.

References __SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY, cl::sycl::detail::plugin::call(), cl::sycl::ext_oneapi_cuda, cl::sycl::detail::plugin::getBackend(), getHandleRef(), getPlugin(), cl::sycl::detail::getSyclObjImpl(), cl::sycl::property_list::has_property(), piContextCreate(), and cl::sycl::detail::KernelProgramCache::setContextPtr().

◆ context_impl() [3/3]

cl::sycl::detail::context_impl::context_impl ( RT::PiContext  PiContext,
async_handler  AsyncHandler,
const plugin Plugin 
)

Construct a context_impl using plug-in interoperability handle.

The constructed context_impl will use the AsyncHandler parameter to handle exceptions.

Parameters
PiContextis an instance of a valid plug-in context handle.
AsyncHandleris an instance of async_handler.
Pluginis the reference to the underlying Plugin that this context is associated with.

Definition at line 68 of file context_impl.cpp.

References cl::sycl::detail::plugin::call(), cl::sycl::detail::platform_impl::getPlatformFromPiDevice(), getPlugin(), cl::sycl::opencl, PI_CONTEXT_INFO_DEVICES, PI_CONTEXT_INFO_NUM_DEVICES, piContextGetInfo(), piContextRetain(), and cl::sycl::detail::KernelProgramCache::setContextPtr().

◆ ~context_impl()

cl::sycl::detail::context_impl::~context_impl ( )

Member Function Documentation

◆ acquireCachedLibPrograms()

Locked<CachedLibProgramsT> cl::sycl::detail::context_impl::acquireCachedLibPrograms ( )
inline

In contrast to user programs, which are compiled from user code, library programs come from the SYCL runtime.

They are identified by the corresponding extension:

cl_intel_devicelib_assert -> #<pi_program with assert functions> cl_intel_devicelib_complex -> #<pi_program with complex functions> etc.

See ‘doc/design/DeviceLibExtensions.rst’ for more details.

Returns
an instance of sycl::detail::Locked which wraps a map with device library programs and the corresponding lock for synchronized access.

Definition at line 159 of file context_impl.hpp.

◆ get()

cl_context cl::sycl::detail::context_impl::get ( ) const

Gets OpenCL interoperability context handle.

Returns
an instance of OpenCL cl_context.

Definition at line 106 of file context_impl.cpp.

References cl::sycl::detail::plugin::call(), getPlugin(), PI_INVALID_CONTEXT, and piContextRetain().

◆ get_async_handler()

const async_handler & cl::sycl::detail::context_impl::get_async_handler ( ) const

Gets asynchronous exception handler.

Returns
an instance of SYCL async_handler.

Definition at line 130 of file context_impl.cpp.

◆ get_info()

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

Queries this context for information.

The return type depends on information being queried.

◆ get_property()

template<typename propertyT >
propertyT cl::sycl::detail::context_impl::get_property ( ) const
inline

Gets the specified property of this context_impl.

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

Returns
a copy of the property of type propertyT.

Definition at line 87 of file context_impl.hpp.

◆ getDevices()

const std::vector<device>& cl::sycl::detail::context_impl::getDevices ( ) const
inline

Unlike ‘get_info<info::context::devices>’, this function returns a reference.

Definition at line 141 of file context_impl.hpp.

◆ getHandleRef() [1/2]

const RT::PiContext & cl::sycl::detail::context_impl::getHandleRef ( )

Gets the underlying context object (if any) without reference count modification.

Caller must ensure the returned object lives on stack only. It can also be safely passed to the underlying native runtime API. Warning. Returned reference will be invalid if context_impl was destroyed.

Returns
an instance of raw plug-in context handle.

Definition at line 187 of file context_impl.cpp.

Referenced by context_impl(), and getNative().

◆ getHandleRef() [2/2]

const RT::PiContext& cl::sycl::detail::context_impl::getHandleRef ( ) const

Gets the underlying context object (if any) without reference count modification.

Caller must ensure the returned object lives on stack only. It can also be safely passed to the underlying native runtime API. Warning. Returned reference will be invalid if context_impl was destroyed.

Returns
an instance of raw plug-in context handle.

◆ getKernelProgramCache()

KernelProgramCache & cl::sycl::detail::context_impl::getKernelProgramCache ( ) const

Definition at line 190 of file context_impl.cpp.

◆ getNative()

pi_native_handle cl::sycl::detail::context_impl::getNative ( ) const

Gets the native handle of the SYCL context.

Returns
a native handle.

Definition at line 202 of file context_impl.cpp.

References getHandleRef(), getPlugin(), cl::sycl::opencl, piContextRetain(), and piextContextGetNativeHandle().

◆ getPlatformImpl()

PlatformImplPtr cl::sycl::detail::context_impl::getPlatformImpl ( ) const
inline
Returns
the PlatformImpl associated with this context.

Definition at line 110 of file context_impl.hpp.

◆ getPlugin()

const plugin& cl::sycl::detail::context_impl::getPlugin ( ) const
inline
Returns
the Plugin associated with the platform of this context.

Definition at line 107 of file context_impl.hpp.

Referenced by context_impl(), get(), getNative(), and ~context_impl().

◆ has_property()

template<typename propertyT >
bool cl::sycl::detail::context_impl::has_property ( ) const
inline

Checks if this context_impl has a property of type propertyT.

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

Definition at line 77 of file context_impl.hpp.

◆ hasDevice()

bool cl::sycl::detail::context_impl::hasDevice ( std::shared_ptr< detail::device_impl Device) const

Returns true if and only if context contains the given device.

Definition at line 194 of file context_impl.cpp.

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

◆ is_host()

bool cl::sycl::detail::context_impl::is_host ( ) const

Checks if this context is a host context.

Returns
true if this context is a host context.

Definition at line 117 of file context_impl.cpp.

◆ isBufferLocationSupported()

bool cl::sycl::detail::context_impl::isBufferLocationSupported ( ) const

Definition at line 211 of file context_impl.cpp.

References NotChecked, NotSupported, and Supported.


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