diff --git a/shared/source/compiler_interface/default_cache_config.cpp b/shared/source/compiler_interface/default_cache_config.cpp index af9edef712..9bf0b80c4a 100644 --- a/shared/source/compiler_interface/default_cache_config.cpp +++ b/shared/source/compiler_interface/default_cache_config.cpp @@ -53,6 +53,10 @@ CompilerCacheConfig getDefaultCompilerCacheConfig() { ret.cacheSize = std::numeric_limits::max(); } + if (ret.enabled) { + PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stdout, "NEO_CACHE_PERSISTENT is enabled. Cache is located in: %s\n\n", + ret.cacheDir.c_str()); + } return ret; } diff --git a/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp index 8b347f6c27..4601141234 100644 --- a/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp @@ -7,11 +7,13 @@ #include "shared/source/compiler_interface/compiler_cache.h" #include "shared/source/compiler_interface/compiler_interface.h" +#include "shared/source/compiler_interface/default_cache_config.h" #include "shared/source/compiler_interface/intermediate_representations.h" #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/hash.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/string.h" +#include "shared/source/os_interface/sys_calls_common.h" #include "shared/source/utilities/io_functions.h" #include "shared/test/common/device_binary_format/patchtokens_tests.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" @@ -30,6 +32,11 @@ #include using namespace NEO; +namespace NEO { +namespace SysCalls { +extern bool pathExistsMock; +} // namespace SysCalls +} // namespace NEO TEST(HashGeneration, givenMisalignedBufferWhenPassedToUpdateFunctionThenProperPtrDataIsUsed) { Hash hash; @@ -338,6 +345,27 @@ TEST(CompilerCacheTests, GivenNonExistantConfigWhenLoadingFromCacheThenNullIsRet EXPECT_EQ(0U, size); } +TEST(CompilerCacheTests, GivenPrintDebugMessagesWhenCacheIsEnabledThenMessageWithPathIsPrintedToStdout) { + DebugManagerStateRestore restorer; + debugManager.flags.PrintDebugMessages.set(true); + + std::unordered_map mockableEnvs; + VariableBackup *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs); + + bool pathExistsMock = true; + VariableBackup pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock); + + mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; + mockableEnvs["NEO_CACHE_DIR"] = "ult\\directory\\"; + + testing::internal::CaptureStdout(); + auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); + std::string output = testing::internal::GetCapturedStdout(); + + EXPECT_TRUE(cacheConfig.enabled); + EXPECT_STREQ(output.c_str(), "NEO_CACHE_PERSISTENT is enabled. Cache is located in: ult\\directory\\\n\n"); +} + TEST(CompilerInterfaceCachedTests, GivenNoCachedBinaryWhenBuildingThenErrorIsReturned) { TranslationInput inputArgs{IGC::CodeType::oclC, IGC::CodeType::oclGenBin};