27 inline namespace _V1 {
73 const std::vector<sycl::device> &DeviceList = {},
74 bool OwnedByRuntime =
true);
81 cl_context
get()
const;
97 template <
typename Param>
typename Param::return_type
get_info()
const;
102 template <
typename Param>
127 const std::vector<device> &
getDevices()
const {
return MDevices; }
130 std::map<std::pair<DeviceLibExt, ur_device_handle_t>,
131 ur_program_handle_t>;
147 return {MCachedLibPrograms, MCachedLibProgramsMutex};
153 bool hasDevice(std::shared_ptr<detail::device_impl> Device)
const;
161 if (Device->isRootDevice()) {
162 if (Device->has(aspect::ext_oneapi_is_component)) {
165 auto CompositeDevice = Device->get_info<
166 ext::oneapi::experimental::info::device::composite_device>();
179 Device->get_info<info::device::parent_device>());
187 assert(MPlatform &&
"MPlatform must be not null");
188 return MPlatform->getBackend();
208 const std::vector<device> &Devs,
212 std::vector<ur_event_handle_t>
214 const std::shared_ptr<queue_impl> &QueueImpl);
217 const std::shared_ptr<device_impl> &DeviceImpl,
218 const void *DeviceGlobalPtr,
const void *Src,
size_t DeviceGlobalTSize,
219 bool IsDeviceImageScoped,
size_t NumBytes,
size_t Offset);
223 void *Dest,
const void *DeviceGlobalPtr,
224 bool IsDeviceImageScoped,
size_t NumBytes,
228 std::optional<ur_program_handle_t>
232 std::optional<ur_program_handle_t>
236 std::optional<ur_program_handle_t>
238 const std::set<std::uintptr_t> &ImgIdentifiers,
239 const std::string &ObjectTypeName);
248 bool MOwnedByRuntime;
250 std::vector<device> MDevices;
251 ur_context_handle_t MContext;
255 std::mutex MCachedLibProgramsMutex;
259 std::set<const void *> MAssociatedDeviceGlobals;
260 std::mutex MAssociatedDeviceGlobalsMutex;
262 struct DeviceGlobalInitializer {
263 DeviceGlobalInitializer() =
default;
265 : MBinImage(BinImage) {
272 void ClearEvents(
const PluginPtr &Plugin);
275 const RTDeviceBinaryImage *MBinImage =
nullptr;
278 std::mutex MDeviceGlobalInitMutex;
287 bool MDeviceGlobalsFullyInitialized =
false;
291 std::vector<ur_event_handle_t> MDeviceGlobalInitEvents;
294 std::map<std::pair<ur_program_handle_t, ur_device_handle_t>,
295 DeviceGlobalInitializer>
296 MDeviceGlobalInitializers;
297 std::mutex MDeviceGlobalInitializersMutex;
304 std::map<std::pair<const void *, std::optional<ur_device_handle_t>>,
305 std::unique_ptr<std::byte[]>>
306 MDeviceGlobalUnregisteredData;
307 std::mutex MDeviceGlobalUnregisteredDataMutex;
310 template <
typename T,
typename Capabilities>
312 std::vector<T> &CapabilityList) {
314 std::vector<T> NewCapabilityList;
315 std::vector<T> DeviceCapabilities = Device.
get_info<Capabilities>();
316 std::set_intersection(
317 CapabilityList.begin(), CapabilityList.end(),
318 DeviceCapabilities.begin(), DeviceCapabilities.end(),
319 std::inserter(NewCapabilityList, NewCapabilityList.begin()));
320 CapabilityList = NewCapabilityList;
322 CapabilityList.shrink_to_fit();
Represents a reference to value with appropriate lock acquired.
const PropertyRange & getDeviceGlobals() const
bool hasDevice(std::shared_ptr< detail::device_impl > Device) const
Returns true if and only if context contains the given device.
ur_context_handle_t & getHandleRef()
Gets the underlying context object (if any) without reference count modification.
context_impl(const device &Device, async_handler AsyncHandler, const property_list &PropList)
Constructs a context_impl using a single SYCL devices.
bool isDeviceValid(DeviceImplPtr Device)
Returns true if and only if the device can be used within this context.
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.
Locked< CachedLibProgramsT > acquireCachedLibPrograms()
In contrast to user programs, which are compiled from user code, library programs come from the SYCL ...
KernelProgramCache & getKernelProgramCache() const
void addDeviceGlobalInitializer(ur_program_handle_t Program, const std::vector< device > &Devs, const RTDeviceBinaryImage *BinImage)
Adds a device global initializer.
bool isBufferLocationSupported() const
void addAssociatedDeviceGlobal(const void *DeviceGlobalPtr)
Adds an associated device global to the tracked associates.
const property_list & getPropList() const
const std::vector< device > & getDevices() const
Unlike ‘get_info<info::context::devices>’, this function returns a reference.
Param::return_type get_info() const
Queries this context for information.
DeviceImplPtr findMatchingDeviceImpl(ur_device_handle_t &DeviceUR) const
Given a UR device, returns the matching shared_ptr<device_impl> within this context.
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.
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 > getProgramForHostPipe(const device &Device, HostPipeMapEntry *HostPipeEntry)
Gets a program associated with a HostPipe Entry from the cache.
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)
backend getBackend() const
Param::return_type get_backend_info() const
Queries SYCL queue for SYCL backend-specific information.
std::map< std::pair< DeviceLibExt, ur_device_handle_t >, ur_program_handle_t > CachedLibProgramsT
const PluginPtr & getPlugin() const
PlatformImplPtr getPlatformImpl() const
ur_native_handle_t getNative() const
Gets the native handle of the SYCL context.
cl_context get() const
Gets OpenCL interoperability context handle.
const async_handler & get_async_handler() const
Gets asynchronous exception handler.
std::optional< ur_program_handle_t > getProgramForDeviceGlobal(const device &Device, DeviceGlobalMapEntry *DeviceGlobalEntry)
Gets a program associated with a device global from the cache.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
detail::is_device_info_desc< Param >::return_type get_info() const
Queries this SYCL device for information requested by the template parameter param.
Objects of the property_list class are containers for the SYCL properties.
decltype(Obj::impl) const & getSyclObjImpl(const Obj &SyclObject)
void GetCapabilitiesIntersectionSet(const std::vector< sycl::device > &Devices, std::vector< T > &CapabilityList)
std::shared_ptr< plugin > PluginPtr
std::shared_ptr< detail::platform_impl > PlatformImplPtr
std::shared_ptr< device_impl > DeviceImplPtr
std::function< void(sycl::exception_list)> async_handler
C++ utilities for Unified Runtime integration.