[llvm] [libsycl] Introduce Kernel name based cache (PR #225865)
Sergey Semenov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 12:55:37 PDT 2026
================
@@ -45,9 +50,31 @@ class DeviceKernelInfo {
/// \return the device image containing the device code of this kernel.
DeviceImageManager &getDeviceImage() const { return MDeviceImage; }
+ /// Returns a cache entry for pair key \p Context & \p Device if successful,
+ /// null otherwise
+ ol_symbol_handle_t tryGetCachedKernel(ContextImpl *Context,
+ ol_device_handle_t Device);
+
+ /// Adds \p Kernel to the cache by using the pair key \p Context & \p Device
+ void addCachedKernel(ContextImpl *Context, ol_device_handle_t Device,
+ ol_symbol_handle_t Kernel);
+
+ /// Removes every cache entry keyed by \p Context, regardless of device.
+ /// Called by ContextImpl when it is being destroyed.
+ void removeCachedKernelsFor(ContextImpl *Context);
+
private:
std::string_view MName;
DeviceImageManager &MDeviceImage;
+
+ using CacheKeyT = std::pair<ContextImpl *, ol_device_handle_t>;
+ struct CacheKeyHash {
+ std::size_t operator()(const CacheKeyT &Key) const noexcept {
+ return std::hash<ContextImpl *>{}(Key.first);
----------------
sergey-semenov wrote:
Shouldn't we have the device part of the key be represented in the hash too?
https://github.com/llvm/llvm-project/pull/225865
More information about the llvm-commits
mailing list