#include <detail/context_impl.hpp>
Public Types | |
enum | PropertySupport { NotSupported = 0 , Supported = 1 , NotChecked = 2 } |
using | CachedLibProgramsT = std::map< std::pair< DeviceLibExt, ur_device_handle_t >, ur_program_handle_t > |
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< sycl::device > DeviceList, async_handler AsyncHandler, const property_list &PropList) | |
Constructs a context_impl using a list of SYCL devices. More... | |
context_impl (ur_context_handle_t UrContext, async_handler AsyncHandler, const PluginPtr &Plugin, const std::vector< sycl::device > &DeviceList={}, bool OwnedByRuntime=true) | |
Construct a context_impl using plug-in interoperability handle. More... | |
~context_impl () | |
cl_context | get () const |
Gets OpenCL interoperability context handle. More... | |
const async_handler & | get_async_handler () const |
Gets asynchronous exception handler. More... | |
const PluginPtr & | getPlugin () const |
PlatformImplPtr | getPlatformImpl () const |
template<typename Param > | |
Param::return_type | get_info () const |
Queries this context for information. More... | |
template<typename Param > | |
Param::return_type | get_backend_info () const |
Queries SYCL queue for SYCL backend-specific information. More... | |
ur_context_handle_t & | getHandleRef () |
Gets the underlying context object (if any) without reference count modification. More... | |
const ur_context_handle_t & | getHandleRef () 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< CachedLibProgramsT > | acquireCachedLibPrograms () |
In contrast to user programs, which are compiled from user code, library programs come from the SYCL runtime. More... | |
KernelProgramCache & | getKernelProgramCache () const |
bool | hasDevice (std::shared_ptr< detail::device_impl > Device) const |
Returns true if and only if context contains the given device. More... | |
bool | isDeviceValid (DeviceImplPtr Device) |
Returns true if and only if the device can be used within this context. More... | |
backend | getBackend () const |
DeviceImplPtr | findMatchingDeviceImpl (ur_device_handle_t &DeviceUR) const |
Given a UR device, returns the matching shared_ptr<device_impl> within this context. More... | |
ur_native_handle_t | getNative () const |
Gets the native handle of the SYCL context. More... | |
bool | isBufferLocationSupported () const |
void | addAssociatedDeviceGlobal (const void *DeviceGlobalPtr) |
Adds an associated device global to the tracked associates. More... | |
void | addDeviceGlobalInitializer (ur_program_handle_t Program, const std::vector< device > &Devs, const RTDeviceBinaryImage *BinImage) |
Adds a device global initializer. More... | |
std::vector< ur_event_handle_t > | initializeDeviceGlobals (ur_program_handle_t NativePrg, const std::shared_ptr< queue_impl > &QueueImpl) |
Initializes device globals for a program on the associated queue. More... | |
void | memcpyToHostOnlyDeviceGlobal (const std::shared_ptr< device_impl > &DeviceImpl, const void *DeviceGlobalPtr, const void *Src, size_t DeviceGlobalTSize, bool IsDeviceImageScoped, size_t NumBytes, size_t Offset) |
void | memcpyFromHostOnlyDeviceGlobal (const std::shared_ptr< device_impl > &DeviceImpl, void *Dest, const void *DeviceGlobalPtr, bool IsDeviceImageScoped, size_t NumBytes, size_t Offset) |
std::optional< ur_program_handle_t > | getProgramForDeviceGlobal (const device &Device, DeviceGlobalMapEntry *DeviceGlobalEntry) |
Gets a program associated with a device global from the cache. More... | |
std::optional< ur_program_handle_t > | getProgramForHostPipe (const device &Device, HostPipeMapEntry *HostPipeEntry) |
Gets a program associated with a HostPipe Entry from the cache. More... | |
std::optional< ur_program_handle_t > | getProgramForDevImgs (const device &Device, const std::set< std::uintptr_t > &ImgIdentifiers, const std::string &ObjectTypeName) |
Gets a program associated with Dev / Images pairs. More... | |
bool | isOwnedByRuntime () |
const property_list & | getPropList () const |
Definition at line 32 of file context_impl.hpp.
using sycl::_V1::detail::context_impl::CachedLibProgramsT = std::map<std::pair<DeviceLibExt, ur_device_handle_t>, ur_program_handle_t> |
Definition at line 129 of file context_impl.hpp.
Enumerator | |
---|---|
NotSupported | |
Supported | |
NotChecked |
Definition at line 243 of file context_impl.hpp.
sycl::_V1::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.
Device | is an instance of SYCL device. |
AsyncHandler | is an instance of async_handler. |
PropList | is an instance of property_list. |
Definition at line 29 of file context_impl.cpp.
References sycl::_V1::detail::KernelProgramCache::setContextPtr().
sycl::_V1::detail::context_impl::context_impl | ( | const std::vector< 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.
DeviceList | is a list of SYCL device instances. |
AsyncHandler | is an instance of async_handler. |
PropList | is an instance of property_list. |
Definition at line 38 of file context_impl.cpp.
References getPlugin(), sycl::_V1::detail::getSyclObjImpl(), and sycl::_V1::detail::KernelProgramCache::setContextPtr().
sycl::_V1::detail::context_impl::context_impl | ( | ur_context_handle_t | UrContext, |
async_handler | AsyncHandler, | ||
const PluginPtr & | Plugin, | ||
const std::vector< sycl::device > & | DeviceList = {} , |
||
bool | OwnedByRuntime = true |
||
) |
Construct a context_impl using plug-in interoperability handle.
The constructed context_impl will use the AsyncHandler parameter to handle exceptions.
UrContext | is an instance of a valid plug-in context handle. |
AsyncHandler | is an instance of async_handler. |
Plugin | is the reference to the underlying Plugin that this |
OwnedByRuntime | is the flag if ownership is kept by user or transferred to runtime |
Definition at line 68 of file context_impl.cpp.
References getBackend(), sycl::_V1::detail::platform_impl::getPlatformFromUrDevice(), getPlugin(), sycl::_V1::detail::getSyclObjImpl(), sycl::_V1::invalid, sycl::_V1::make_error_code(), and sycl::_V1::detail::KernelProgramCache::setContextPtr().
sycl::_V1::detail::context_impl::~context_impl | ( | ) |
|
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 -> #<ur program with assert functions> cl_intel_devicelib_complex -> #<ur program with complex functions> etc.
See ‘doc/design/DeviceLibExtensions.rst’ for more details.
Definition at line 146 of file context_impl.hpp.
void sycl::_V1::detail::context_impl::addAssociatedDeviceGlobal | ( | const void * | DeviceGlobalPtr | ) |
Adds an associated device global to the tracked associates.
Definition at line 315 of file context_impl.cpp.
void sycl::_V1::detail::context_impl::addDeviceGlobalInitializer | ( | ur_program_handle_t | Program, |
const std::vector< device > & | Devs, | ||
const RTDeviceBinaryImage * | BinImage | ||
) |
Adds a device global initializer.
Definition at line 320 of file context_impl.cpp.
References getHandleRef(), and sycl::_V1::detail::getSyclObjImpl().
DeviceImplPtr sycl::_V1::detail::context_impl::findMatchingDeviceImpl | ( | ur_device_handle_t & | DeviceUR | ) | const |
Given a UR device, returns the matching shared_ptr<device_impl> within this context.
May return nullptr if no match discovered.
Definition at line 284 of file context_impl.cpp.
References getHandleRef(), and sycl::_V1::detail::getSyclObjImpl().
cl_context sycl::_V1::detail::context_impl::get | ( | ) | const |
Gets OpenCL interoperability context handle.
Definition at line 114 of file context_impl.cpp.
References getPlugin().
const async_handler & sycl::_V1::detail::context_impl::get_async_handler | ( | ) | const |
Gets asynchronous exception handler.
Definition at line 145 of file context_impl.cpp.
Param::return_type sycl::_V1::detail::context_impl::get_backend_info | ( | ) | const |
Queries SYCL queue for SYCL backend-specific information.
The return type depends on information being queried.
Param::return_type sycl::_V1::detail::context_impl::get_info | ( | ) | const |
Queries this context for information.
The return type depends on information being queried.
|
inline |
Definition at line 186 of file context_impl.hpp.
Referenced by context_impl(), and getNative().
|
inline |
Unlike ‘get_info<info::context::devices>’, this function returns a reference.
Definition at line 127 of file context_impl.hpp.
Referenced by sycl::_V1::detail::DeviceGlobalMapEntry::removeAssociatedResources().
ur_context_handle_t & sycl::_V1::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.
Definition at line 266 of file context_impl.cpp.
Referenced by addDeviceGlobalInitializer(), sycl::_V1::detail::usm::alignedAllocInternal(), findMatchingDeviceImpl(), sycl::_V1::detail::usm::freeInternal(), and getNative().
const ur_context_handle_t & sycl::_V1::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.
Definition at line 267 of file context_impl.cpp.
KernelProgramCache & sycl::_V1::detail::context_impl::getKernelProgramCache | ( | ) | const |
Definition at line 271 of file context_impl.cpp.
ur_native_handle_t sycl::_V1::detail::context_impl::getNative | ( | ) | const |
Gets the native handle of the SYCL context.
Definition at line 292 of file context_impl.cpp.
References getBackend(), getHandleRef(), getPlugin(), and sycl::_V1::opencl.
|
inline |
Definition at line 92 of file context_impl.hpp.
|
inline |
Definition at line 89 of file context_impl.hpp.
Referenced by sycl::_V1::detail::usm::alignedAllocInternal(), context_impl(), sycl::_V1::detail::usm::freeInternal(), get(), getNative(), initializeDeviceGlobals(), sycl::_V1::detail::DeviceGlobalMapEntry::removeAssociatedResources(), and ~context_impl().
std::optional< ur_program_handle_t > sycl::_V1::detail::context_impl::getProgramForDeviceGlobal | ( | const device & | Device, |
DeviceGlobalMapEntry * | DeviceGlobalEntry | ||
) |
Gets a program associated with a device global from the cache.
Definition at line 522 of file context_impl.cpp.
References getProgramForDevImgs(), and sycl::_V1::detail::DeviceGlobalMapEntry::MImageIdentifiers.
std::optional< ur_program_handle_t > sycl::_V1::detail::context_impl::getProgramForDevImgs | ( | const device & | Device, |
const std::set< std::uintptr_t > & | ImgIdentifiers, | ||
const std::string & | ObjectTypeName | ||
) |
Gets a program associated with Dev / Images pairs.
Definition at line 479 of file context_impl.cpp.
References sycl::_V1::detail::KernelProgramCache::acquireCachedPrograms(), sycl::_V1::build, sycl::_V1::detail::getSyclObjImpl(), sycl::_V1::invalid, sycl::_V1::make_error_code(), and sycl::_V1::detail::set_ur_error().
Referenced by getProgramForDeviceGlobal(), and getProgramForHostPipe().
std::optional< ur_program_handle_t > sycl::_V1::detail::context_impl::getProgramForHostPipe | ( | const device & | Device, |
HostPipeMapEntry * | HostPipeEntry | ||
) |
Gets a program associated with a HostPipe Entry from the cache.
Definition at line 529 of file context_impl.cpp.
References sycl::_V1::detail::HostPipeMapEntry::getDevBinImage(), sycl::_V1::detail::RTDeviceBinaryImage::getImageID(), and getProgramForDevImgs().
|
inline |
Definition at line 245 of file context_impl.hpp.
bool sycl::_V1::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 275 of file context_impl.cpp.
References sycl::_V1::detail::getSyclObjImpl().
Referenced by isDeviceValid().
std::vector< ur_event_handle_t > sycl::_V1::detail::context_impl::initializeDeviceGlobals | ( | ur_program_handle_t | NativePrg, |
const std::shared_ptr< queue_impl > & | QueueImpl | ||
) |
Initializes device globals for a program on the associated queue.
Definition at line 330 of file context_impl.cpp.
References sycl::_V1::detail::ProgramManager::getDeviceGlobalEntries(), sycl::_V1::detail::DeviceGlobalUSMMem::getInitEvent(), sycl::_V1::detail::ProgramManager::getInstance(), getPlugin(), and sycl::_V1::detail::DeviceGlobalUSMMem::getPtr().
bool sycl::_V1::detail::context_impl::isBufferLocationSupported | ( | ) | const |
Definition at line 301 of file context_impl.cpp.
References NotChecked, NotSupported, and Supported.
|
inline |
Returns true if and only if the device can be used within this context.
For OpenCL this is currently equivalent to hasDevice, for other backends it returns true if the device is either a member of the context or a descendant of a member.
Definition at line 159 of file context_impl.hpp.
References sycl::_V1::detail::getSyclObjImpl(), hasDevice(), and sycl::_V1::opencl.
|
inline |
Definition at line 241 of file context_impl.hpp.
void sycl::_V1::detail::context_impl::memcpyFromHostOnlyDeviceGlobal | ( | const std::shared_ptr< device_impl > & | DeviceImpl, |
void * | Dest, | ||
const void * | DeviceGlobalPtr, | ||
bool | IsDeviceImageScoped, | ||
size_t | NumBytes, | ||
size_t | Offset | ||
) |
Definition at line 455 of file context_impl.cpp.
References sycl::_V1::ext::oneapi::experimental::fill().
void sycl::_V1::detail::context_impl::memcpyToHostOnlyDeviceGlobal | ( | const std::shared_ptr< device_impl > & | DeviceImpl, |
const void * | DeviceGlobalPtr, | ||
const void * | Src, | ||
size_t | DeviceGlobalTSize, | ||
bool | IsDeviceImageScoped, | ||
size_t | NumBytes, | ||
size_t | Offset | ||
) |
Definition at line 433 of file context_impl.cpp.