@@ -360,29 +360,29 @@ class KernelProgramCache {
360360 template <typename KeyT, typename ValT>
361361 void saveKernel (KeyT &&CacheKey, ValT &&CacheVal) {
362362
363- ur_program_handle_t Program = std::get<3 >(CacheVal);
364- // Save kernel in fast cache only if the corresponding program is also
365- // in the cache.
366- {
367- auto LockedCache = acquireCachedPrograms ();
368- auto &ProgCache = LockedCache.get ();
369- if (ProgCache.ProgramSizeMap .find (Program) ==
370- ProgCache.ProgramSizeMap .end ())
371- return ;
363+ if (SYCLConfig<SYCL_IN_MEM_CACHE_EVICTION_THRESHOLD>::
364+ isProgramCacheEvictionEnabled ()) {
365+
366+ ur_program_handle_t Program = std::get<3 >(CacheVal);
367+ // Save kernel in fast cache only if the corresponding program is also
368+ // in the cache.
369+ {
370+ auto LockedCache = acquireCachedPrograms ();
371+ auto &ProgCache = LockedCache.get ();
372+ if (ProgCache.ProgramSizeMap .find (Program) ==
373+ ProgCache.ProgramSizeMap .end ())
374+ return ;
375+ }
376+
377+ // Save reference between the program and the fast cache key.
378+ MProgramToKernelFastCacheKeyMap[Program].emplace_back (CacheKey);
372379 }
373380
374381 std::unique_lock<std::mutex> Lock (MKernelFastCacheMutex);
375382 // if no insertion took place, thus some other thread has already inserted
376383 // smth in the cache
377384 traceKernel (" Kernel inserted." , std::get<3 >(CacheKey), true );
378385 MKernelFastCache.emplace (CacheKey, CacheVal);
379-
380- if (SYCLConfig<
381- SYCL_IN_MEM_CACHE_EVICTION_THRESHOLD>::getProgramCacheSize ()) {
382-
383- // Save reference between the program and the fast cache key.
384- MProgramToKernelFastCacheKeyMap[Program].emplace_back (CacheKey);
385- }
386386 }
387387
388388 // Evict programs from cache to free up space.
0 commit comments