27 inline namespace _V1 {
73 const std::vector<sycl::device> &DeviceList = {},
74 bool OwnedByRuntime =
true);
98 cl_context
get()
const;
119 template <
typename Param>
typename Param::return_type
get_info()
const;
124 template <
typename Param>
149 const std::vector<device> &
getDevices()
const {
return MDevices; }
152 std::map<std::pair<DeviceLibExt, sycl::detail::pi::PiDevice>,
169 return {MCachedLibPrograms, MCachedLibProgramsMutex};
175 bool hasDevice(std::shared_ptr<detail::device_impl> Device)
const;
189 if (Device->isRootDevice())
192 Device->get_info<info::device::parent_device>());
200 assert(MPlatform &&
"MPlatform must be not null");
201 return MPlatform->getBackend();
222 const std::vector<device> &Devs,
226 std::vector<sycl::detail::pi::PiEvent>
228 const std::shared_ptr<queue_impl> &QueueImpl);
231 const std::shared_ptr<device_impl> &DeviceImpl,
232 const void *DeviceGlobalPtr,
const void *Src,
size_t DeviceGlobalTSize,
233 bool IsDeviceImageScoped,
size_t NumBytes,
size_t Offset);
237 void *Dest,
const void *DeviceGlobalPtr,
238 bool IsDeviceImageScoped,
size_t NumBytes,
242 std::optional<sycl::detail::pi::PiProgram>
246 std::optional<sycl::detail::pi::PiProgram>
250 std::optional<sycl::detail::pi::PiProgram>
252 const std::set<std::uintptr_t> &ImgIdentifiers,
253 const std::string &ObjectTypeName);
260 bool MOwnedByRuntime;
262 std::vector<device> MDevices;
268 std::mutex MCachedLibProgramsMutex;
272 std::set<const void *> MAssociatedDeviceGlobals;
273 std::mutex MAssociatedDeviceGlobalsMutex;
275 struct DeviceGlobalInitializer {
276 DeviceGlobalInitializer() =
default;
278 : MBinImage(BinImage) {
285 void ClearEvents(
const PluginPtr &Plugin);
288 const RTDeviceBinaryImage *MBinImage =
nullptr;
291 std::mutex MDeviceGlobalInitMutex;
300 bool MDeviceGlobalsFullyInitialized =
false;
304 std::vector<sycl::detail::pi::PiEvent> MDeviceGlobalInitEvents;
307 std::map<std::pair<sycl::detail::pi::PiProgram, sycl::detail::pi::PiDevice>,
308 DeviceGlobalInitializer>
309 MDeviceGlobalInitializers;
310 std::mutex MDeviceGlobalInitializersMutex;
317 std::map<std::pair<const void *, std::optional<sycl::detail::pi::PiDevice>>,
318 std::unique_ptr<std::byte[]>>
319 MDeviceGlobalUnregisteredData;
320 std::mutex MDeviceGlobalUnregisteredDataMutex;
323 template <
typename T,
typename Capabilities>
325 std::vector<T> &CapabilityList) {
327 std::vector<T> NewCapabilityList;
328 std::vector<T> DeviceCapabilities = Device.
get_info<Capabilities>();
329 std::set_intersection(
330 CapabilityList.begin(), CapabilityList.end(),
331 DeviceCapabilities.begin(), DeviceCapabilities.end(),
332 std::inserter(NewCapabilityList, NewCapabilityList.begin()));
333 CapabilityList = NewCapabilityList;
335 CapabilityList.shrink_to_fit();
Represents a reference to value with appropriate lock acquired.
const PropertyRange & getDeviceGlobals() const
propertyT get_property() const
Gets the specified property of this context_impl.
bool hasDevice(std::shared_ptr< detail::device_impl > Device) const
Returns true if and only if context contains the given device.
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.
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(sycl::detail::pi::PiProgram Program, const std::vector< device > &Devs, const RTDeviceBinaryImage *BinImage)
Adds a device global initializer.
pi_native_handle getNative() const
Gets the native handle of the SYCL context.
bool isBufferLocationSupported() const
void addAssociatedDeviceGlobal(const void *DeviceGlobalPtr)
Adds an associated device global to the tracked associates.
std::optional< sycl::detail::pi::PiProgram > getProgramForDeviceGlobal(const device &Device, DeviceGlobalMapEntry *DeviceGlobalEntry)
Gets a program associated with a device global from the cache.
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.
std::map< std::pair< DeviceLibExt, sycl::detail::pi::PiDevice >, sycl::detail::pi::PiProgram > CachedLibProgramsT
std::optional< sycl::detail::pi::PiProgram > getProgramForDevImgs(const device &Device, const std::set< std::uintptr_t > &ImgIdentifiers, const std::string &ObjectTypeName)
Gets a program associated with Dev / Images pairs.
void memcpyFromHostOnlyDeviceGlobal(const std::shared_ptr< device_impl > &DeviceImpl, void *Dest, const void *DeviceGlobalPtr, bool IsDeviceImageScoped, size_t NumBytes, size_t Offset)
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
std::vector< sycl::detail::pi::PiEvent > initializeDeviceGlobals(pi::PiProgram NativePrg, const std::shared_ptr< queue_impl > &QueueImpl)
Initializes device globals for a program on the associated queue.
std::optional< sycl::detail::pi::PiProgram > getProgramForHostPipe(const device &Device, HostPipeMapEntry *HostPipeEntry)
Gets a program associated with a HostPipe Entry from the cache.
Param::return_type get_backend_info() const
Queries SYCL queue for SYCL backend-specific information.
const PluginPtr & getPlugin() const
bool has_property() const noexcept
Checks if this context_impl has a property of type propertyT.
PlatformImplPtr getPlatformImpl() const
bool is_host() const
Checks if this context is a host context.
cl_context get() const
Gets OpenCL interoperability context handle.
const async_handler & get_async_handler() const
Gets asynchronous exception handler.
DeviceImplPtr findMatchingDeviceImpl(sycl::detail::pi::PiDevice &DevicePI) const
Given a PiDevice, returns the matching shared_ptr<device_impl> within this context.
sycl::detail::pi::PiContext & getHandleRef()
Gets the underlying context object (if any) without reference count modification.
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.
bool has_property() const noexcept
PropT get_property() const
decltype(Obj::impl) 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
uintptr_t pi_native_handle
C++ wrapper of extern "C" PI interfaces.
_Abi const simd< _Tp, _Abi > & noexcept