Skip to content

Commit 56bb3dc

Browse files
committed
Fix formatting of trace on Widnows
1 parent 83bd015 commit 56bb3dc

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

sycl/source/detail/persistent_device_code_cache.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ LockCacheItem::LockCacheItem(const std::string &Path)
4949

5050
LockCacheItem::~LockCacheItem() {
5151
if (Owned && std::remove(FileName.c_str()))
52-
PersistentDeviceCodeCache::trace("Failed to release lock file: " +
53-
FileName);
52+
PersistentDeviceCodeCache::trace("Failed to release lock file: ", FileName);
5453
}
5554

5655
// Returns true if the specified format is either SPIRV or a native binary.
@@ -335,7 +334,7 @@ void PersistentDeviceCodeCache::evictItemsFromCache(
335334
throw sycl::exception(make_error_code(errc::runtime),
336335
"Failed to evict cache entry: " + FileName);
337336
} else {
338-
PersistentDeviceCodeCache::trace("File removed: " + FileName);
337+
PersistentDeviceCodeCache::trace("File removed: ", FileName);
339338
CurrCacheSize -= FileSize;
340339
}
341340
};
@@ -475,7 +474,7 @@ void PersistentDeviceCodeCache::putItemToDisc(
475474
if (Lock.isOwned()) {
476475
std::string FullFileName = FileName + ".bin";
477476
writeBinaryDataToFile(FullFileName, BinaryData[DeviceIndex]);
478-
trace("device binary has been cached: " + FullFileName);
477+
trace("device binary has been cached: ", FullFileName);
479478
writeSourceItem(FileName + ".src", Devices[DeviceIndex], SortedImgs,
480479
SpecConsts, BuildOptionsString);
481480

@@ -485,7 +484,7 @@ void PersistentDeviceCodeCache::putItemToDisc(
485484

486485
saveCurrentTimeInAFile(FileName + CacheEntryAccessTimeSuffix);
487486
} else {
488-
PersistentDeviceCodeCache::trace("cache lock not owned " + FileName);
487+
PersistentDeviceCodeCache::trace("cache lock not owned ", FileName);
489488
}
490489
} catch (std::exception &e) {
491490
PersistentDeviceCodeCache::trace(
@@ -536,13 +535,13 @@ void PersistentDeviceCodeCache::putCompiledKernelToDisc(
536535
std::string FullFileName = FileName + ".bin";
537536
writeBinaryDataToFile(FullFileName, BinaryData[DeviceIndex]);
538537
PersistentDeviceCodeCache::trace_KernelCompiler(
539-
"binary has been cached: " + FullFileName);
538+
"binary has been cached: ", FullFileName);
540539

541540
TotalSize += getFileSize(FullFileName);
542541
saveCurrentTimeInAFile(FileName + CacheEntryAccessTimeSuffix);
543542
} else {
544-
PersistentDeviceCodeCache::trace_KernelCompiler(
545-
"cache lock not owned " + FileName);
543+
PersistentDeviceCodeCache::trace_KernelCompiler("cache lock not owned ",
544+
FileName);
546545
}
547546
} catch (std::exception &e) {
548547
PersistentDeviceCodeCache::trace_KernelCompiler(
@@ -612,7 +611,7 @@ std::vector<std::vector<char>> PersistentDeviceCodeCache::getItemFromDisc(
612611
if (Binaries[DeviceIndex].empty())
613612
return {};
614613
}
615-
PersistentDeviceCodeCache::trace("using cached device binary: " + FileNames);
614+
PersistentDeviceCodeCache::trace("using cached device binary: ", FileNames);
616615
return Binaries;
617616
}
618617

@@ -660,7 +659,7 @@ PersistentDeviceCodeCache::getCompiledKernelFromDisc(
660659
if (Binaries[DeviceIndex].empty())
661660
return {};
662661
}
663-
PersistentDeviceCodeCache::trace_KernelCompiler("using cached binary: " +
662+
PersistentDeviceCodeCache::trace_KernelCompiler("using cached binary: ",
664663
FileNames);
665664
return Binaries;
666665
}
@@ -691,7 +690,7 @@ void PersistentDeviceCodeCache::writeBinaryDataToFile(
691690
FileStream.write((char *)&Size, sizeof(Size));
692691
FileStream.write(Data.data(), Size);
693692
if (FileStream.fail())
694-
trace("Failed to write to binary file " + FileName);
693+
trace("Failed to write to binary file ", FileName);
695694
}
696695

697696
/* Read built binary from persistent cache. Each persistent cache file contains
@@ -708,7 +707,7 @@ PersistentDeviceCodeCache::readBinaryDataFromFile(const std::string &FileName) {
708707
size_t NumBinaries = 0;
709708
FileStream.read((char *)&NumBinaries, sizeof(NumBinaries));
710709
if (FileStream.fail()) {
711-
trace("Failed to read number of binaries from " + FileName);
710+
trace("Failed to read number of binaries from ", FileName);
712711
return {};
713712
}
714713
// Even in the old implementation we could only put a single binary to the
@@ -723,7 +722,7 @@ PersistentDeviceCodeCache::readBinaryDataFromFile(const std::string &FileName) {
723722
FileStream.close();
724723

725724
if (FileStream.fail()) {
726-
trace("Failed to read binary file from " + FileName);
725+
trace("Failed to read binary file from ", FileName);
727726
return {};
728727
}
729728

@@ -763,7 +762,7 @@ void PersistentDeviceCodeCache::writeSourceItem(
763762
FileStream.close();
764763

765764
if (FileStream.fail()) {
766-
trace("Failed to write source file to " + FileName);
765+
trace("Failed to write source file to ", FileName);
767766
}
768767
}
769768

@@ -811,7 +810,7 @@ bool PersistentDeviceCodeCache::isCacheItemSrcEqual(
811810
FileStream.close();
812811

813812
if (FileStream.fail()) {
814-
trace("Failed to read source file from " + FileName);
813+
trace("Failed to read source file from ", FileName);
815814
}
816815

817816
return true;

sycl/source/detail/persistent_device_code_cache.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,23 @@ class PersistentDeviceCodeCache {
208208
const ur_program_handle_t &NativePrg);
209209

210210
/* Sends message to std:cerr stream when SYCL_CACHE_TRACE environemnt is set*/
211-
static void trace(const std::string &msg) {
211+
static void trace(const std::string &msg, std::string path = "") {
212212
static const bool traceEnabled =
213213
SYCLConfig<SYCL_CACHE_TRACE>::isTraceDiskCache();
214-
if (traceEnabled)
215-
std::cerr << "[Persistent Cache]: " << msg << std::endl;
214+
if (traceEnabled) {
215+
std::replace(path.begin(), path.end(), '\\', '/');
216+
std::cerr << "[Persistent Cache]: " << msg << path << std::endl;
217+
}
216218
}
217-
static void trace_KernelCompiler(const std::string &msg) {
219+
static void trace_KernelCompiler(const std::string &msg,
220+
std::string path = "") {
218221
static const bool traceEnabled =
219222
SYCLConfig<SYCL_CACHE_TRACE>::isTraceKernelCompiler();
220-
if (traceEnabled)
221-
std::cerr << "[kernel_compiler Persistent Cache]: " << msg << std::endl;
223+
if (traceEnabled) {
224+
std::replace(path.begin(), path.end(), '\\', '/');
225+
std::cerr << "[kernel_compiler Persistent Cache]: " << msg << path
226+
<< std::endl;
227+
}
222228
}
223229

224230
private:

sycl/test-e2e/KernelCompiler/kernel_compiler_cache_eviction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// RUN: %{build} -o %t.out
1818

1919
// -- Test again, with caching.
20-
// DEFINE: %{cache_vars} = env SYCL_CACHE_PERSISTENT=1 SYCL_CACHE_TRACE=7 SYCL_CACHE_DIR=%t/cache_dir SYCL_CACHE_MAX_SIZE=27000
20+
// DEFINE: %{cache_vars} = env SYCL_CACHE_PERSISTENT=1 SYCL_CACHE_TRACE=7 SYCL_CACHE_DIR=%t/cache_dir SYCL_CACHE_MAX_SIZE=30000
2121
// RUN: %if run-mode %{rm -rf %t/cache_dir%}
2222
// RUN: %{cache_vars} %{run-unfiltered-devices} %t.out 2>&1 | FileCheck %s --check-prefix=CHECK
2323

0 commit comments

Comments
 (0)