1212#include < detail/program_manager/program_manager.hpp>
1313
1414#include < cerrno>
15+ #include < chrono>
1516#include < cstdio>
1617#include < fstream>
1718#include < optional>
1819
19- #include < time.h>
20-
2120#if defined(__SYCL_RT_OS_POSIX_SUPPORT)
2221#include < unistd.h>
2322#else
@@ -252,7 +251,7 @@ void PersistentDeviceCodeCache::evictItemsFromCache(
252251 // Create a file eviction_in_progress.lock to indicate that eviction is in
253252 // progress. This file is used to prevent two processes from evicting the
254253 // cache at the same time.
255- LockCacheItem Lock{CacheRoot + " /eviction_in_progress " };
254+ LockCacheItem Lock{CacheRoot + EvictionInProgressFileSuffix };
256255 if (!Lock.isOwned ()) {
257256 // If some other process is evicting the cache, return.
258257 PersistentDeviceCodeCache::trace (
@@ -265,7 +264,7 @@ void PersistentDeviceCodeCache::evictItemsFromCache(
265264 std::vector<std::pair<uint64_t , std::string>> FilesWithAccessTime;
266265
267266 auto CollectFileAccessTime = [&FilesWithAccessTime](const std::string File) {
268- if (File.find (" _access_time.txt " ) != std::string::npos) {
267+ if (File.find (CacheEntryAccessTimeSuffix ) != std::string::npos) {
269268 std::ifstream FileStream{File};
270269 uint64_t AccessTime;
271270 FileStream >> AccessTime;
@@ -300,7 +299,7 @@ void PersistentDeviceCodeCache::evictItemsFromCache(
300299 size_t CurrCacheSize = CacheSize;
301300 for (const auto &File : FilesWithAccessTime) {
302301
303- int pos = File.second .find (" _access_time.txt " );
302+ int pos = File.second .find (CacheEntryAccessTimeSuffix );
304303 const std::string FileNameWOExt = File.second .substr (0 , pos);
305304 const std::string BinFile = FileNameWOExt + " .bin" ;
306305 const std::string SrcFile = FileNameWOExt + " .src" ;
@@ -434,7 +433,7 @@ void PersistentDeviceCodeCache::putItemToDisc(
434433 // Do not insert any new item if eviction is in progress.
435434 // Since evictions are rare, we can afford to spin lock here.
436435 const std::string EvictionInProgressFile =
437- getRootDir () + " /eviction_in_progress.lock " ;
436+ getRootDir () + EvictionInProgressFileSuffix ;
438437 // Stall until the other process finishes eviction.
439438 while (OSUtil::isPathPresent (EvictionInProgressFile))
440439 continue ;
@@ -470,7 +469,7 @@ void PersistentDeviceCodeCache::putItemToDisc(
470469 TotalSize += getFileSize (FileName + " .src" );
471470 TotalSize += getFileSize (FileName + " .bin" );
472471
473- saveCurrentTimeInAFile (FileName + " _access_time.txt " );
472+ saveCurrentTimeInAFile (FileName + CacheEntryAccessTimeSuffix );
474473 } else {
475474 PersistentDeviceCodeCache::trace (" cache lock not owned " + FileName);
476475 }
@@ -565,7 +564,7 @@ std::vector<std::vector<char>> PersistentDeviceCodeCache::getItemFromDisc(
565564 // Explicitly update the access time of the file. This is required for
566565 // eviction.
567566 if (isEvictionEnabled ())
568- saveCurrentTimeInAFile (FileName + " _access_time.txt " );
567+ saveCurrentTimeInAFile (FileName + CacheEntryAccessTimeSuffix );
569568
570569 FileNames += FullFileName + " ;" ;
571570 break ;
0 commit comments