@@ -134,7 +134,6 @@ class KernelProgramCache {
134134#pragma  warning(pop)
135135#endif 
136136  };
137-   using  ProgramBuildResultPtr = std::shared_ptr<ProgramBuildResult>;
138137
139138  /*  Drop LinkOptions and CompileOptions from CacheKey since they are only used
140139   * when debugging environment variables are set and we can just ignore them 
@@ -179,7 +178,8 @@ class KernelProgramCache {
179178  };
180179
181180  struct  ProgramCache  {
182-     emhash8::HashMap<ProgramCacheKeyT, ProgramBuildResultPtr> Cache;
181+     emhash8::HashMap<ProgramCacheKeyT, std::shared_ptr<ProgramBuildResult>>
182+         Cache;
183183    UnorderedMultimap<CommonProgramKeyT, ProgramCacheKeyT> KeyMap;
184184    //  Mapping between a UR program and its size.
185185    std::unordered_map<ur_program_handle_t , size_t > ProgramSizeMap;
@@ -193,11 +193,9 @@ class KernelProgramCache {
193193    size_t  size () const  noexcept  { return  Cache.size (); }
194194  };
195195
196-   using  ContextPtr = context_impl *;
197- 
198-   using  KernelArgMaskPairT =
199-       std::pair<ur_kernel_handle_t , const  KernelArgMask *>;
200-   struct  KernelBuildResult  : public  BuildResult <KernelArgMaskPairT> {
196+   struct  KernelBuildResult 
197+       : public BuildResult<
198+             std::pair<ur_kernel_handle_t , const  KernelArgMask *>> {
201199    const  adapter_impl &MAdapter;
202200    KernelBuildResult (const  adapter_impl &Adapter) : MAdapter(Adapter) {
203201      Val.first  = nullptr ;
@@ -214,10 +212,10 @@ class KernelProgramCache {
214212      }
215213    }
216214  };
217-   using  KernelBuildResultPtr = std::shared_ptr<KernelBuildResult>;
218215
219-   using  KernelByNameT = emhash8::HashMap<KernelNameStrT, KernelBuildResultPtr>;
220-   using  KernelCacheT = emhash8::HashMap<ur_program_handle_t , KernelByNameT>;
216+   using  KernelCacheT = emhash8::HashMap<
217+       ur_program_handle_t ,
218+       emhash8::HashMap<KernelNameStrT, std::shared_ptr<KernelBuildResult>>>;
221219
222220  class  FastKernelSubcacheWrapper  {
223221  public: 
@@ -339,8 +337,7 @@ class KernelProgramCache {
339337  };
340338
341339  ~KernelProgramCache () = default ;
342- 
343-   void  setContextPtr (const  ContextPtr &AContext) { MParentContext = AContext; }
340+   KernelProgramCache (context_impl &Ctx) : MParentContext(Ctx) {}
344341
345342  //  Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is
346343  //  set.
@@ -404,7 +401,7 @@ class KernelProgramCache {
404401    return  {MEvictionList, MProgramEvictionListMutex};
405402  }
406403
407-   std::pair<ProgramBuildResultPtr , bool >
404+   std::pair<std::shared_ptr<ProgramBuildResult> , bool >
408405  getOrInsertProgram (const  ProgramCacheKeyT &CacheKey) {
409406    auto  LockedCache = acquireCachedPrograms ();
410407    auto  &ProgCache = LockedCache.get ();
@@ -444,7 +441,7 @@ class KernelProgramCache {
444441    return  DidInsert;
445442  }
446443
447-   std::pair<KernelBuildResultPtr , bool >
444+   std::pair<std::shared_ptr<KernelBuildResult> , bool >
448445  getOrInsertKernel (ur_program_handle_t  Program, KernelNameStrRefT KernelName) {
449446    auto  LockedCache = acquireKernelsPerProgramCache ();
450447    auto  &Cache = LockedCache.get ()[Program];
@@ -850,7 +847,7 @@ class KernelProgramCache {
850847
851848  ProgramCache MCachedPrograms;
852849  KernelCacheT MKernelsPerProgramCache;
853-   ContextPtr  MParentContext;
850+   context_impl & MParentContext;
854851
855852  using  FastKernelCacheMutexT = SpinLock;
856853  using  FastKernelCacheReadLockT = std::lock_guard<FastKernelCacheMutexT>;
0 commit comments