@@ -134,7 +134,6 @@ class KernelProgramCache {
134
134
#pragma warning(pop)
135
135
#endif
136
136
};
137
- using ProgramBuildResultPtr = std::shared_ptr<ProgramBuildResult>;
138
137
139
138
/* Drop LinkOptions and CompileOptions from CacheKey since they are only used
140
139
* when debugging environment variables are set and we can just ignore them
@@ -179,7 +178,8 @@ class KernelProgramCache {
179
178
};
180
179
181
180
struct ProgramCache {
182
- emhash8::HashMap<ProgramCacheKeyT, ProgramBuildResultPtr> Cache;
181
+ emhash8::HashMap<ProgramCacheKeyT, std::shared_ptr<ProgramBuildResult>>
182
+ Cache;
183
183
UnorderedMultimap<CommonProgramKeyT, ProgramCacheKeyT> KeyMap;
184
184
// Mapping between a UR program and its size.
185
185
std::unordered_map<ur_program_handle_t , size_t > ProgramSizeMap;
@@ -193,11 +193,9 @@ class KernelProgramCache {
193
193
size_t size () const noexcept { return Cache.size (); }
194
194
};
195
195
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 *>> {
201
199
const adapter_impl &MAdapter;
202
200
KernelBuildResult (const adapter_impl &Adapter) : MAdapter(Adapter) {
203
201
Val.first = nullptr ;
@@ -214,10 +212,10 @@ class KernelProgramCache {
214
212
}
215
213
}
216
214
};
217
- using KernelBuildResultPtr = std::shared_ptr<KernelBuildResult>;
218
215
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>>>;
221
219
222
220
class FastKernelSubcacheWrapper {
223
221
public:
@@ -339,8 +337,7 @@ class KernelProgramCache {
339
337
};
340
338
341
339
~KernelProgramCache () = default ;
342
-
343
- void setContextPtr (const ContextPtr &AContext) { MParentContext = AContext; }
340
+ KernelProgramCache (context_impl &Ctx) : MParentContext(Ctx) {}
344
341
345
342
// Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is
346
343
// set.
@@ -404,7 +401,7 @@ class KernelProgramCache {
404
401
return {MEvictionList, MProgramEvictionListMutex};
405
402
}
406
403
407
- std::pair<ProgramBuildResultPtr , bool >
404
+ std::pair<std::shared_ptr<ProgramBuildResult> , bool >
408
405
getOrInsertProgram (const ProgramCacheKeyT &CacheKey) {
409
406
auto LockedCache = acquireCachedPrograms ();
410
407
auto &ProgCache = LockedCache.get ();
@@ -444,7 +441,7 @@ class KernelProgramCache {
444
441
return DidInsert;
445
442
}
446
443
447
- std::pair<KernelBuildResultPtr , bool >
444
+ std::pair<std::shared_ptr<KernelBuildResult> , bool >
448
445
getOrInsertKernel (ur_program_handle_t Program, KernelNameStrRefT KernelName) {
449
446
auto LockedCache = acquireKernelsPerProgramCache ();
450
447
auto &Cache = LockedCache.get ()[Program];
@@ -850,7 +847,7 @@ class KernelProgramCache {
850
847
851
848
ProgramCache MCachedPrograms;
852
849
KernelCacheT MKernelsPerProgramCache;
853
- ContextPtr MParentContext;
850
+ context_impl & MParentContext;
854
851
855
852
using FastKernelCacheMutexT = SpinLock;
856
853
using FastKernelCacheReadLockT = std::lock_guard<FastKernelCacheMutexT>;
0 commit comments