diff --git a/opencl/doc/FAQ.md b/opencl/doc/FAQ.md index 2fa7f7cf4a..0a0421d571 100644 --- a/opencl/doc/FAQ.md +++ b/opencl/doc/FAQ.md @@ -119,7 +119,7 @@ reuse previously cached kernel binaries instead of compiling kernels from source ##### Environment flags NEO_CACHE_PERSISTENT - integer value to enable (1)/disable (0) on-disk binary cache. When enabled - Neo will try to cache and reuse compiled binaries. Default is off. + Neo will try to cache and reuse compiled binaries. Default is on. NEO_CACHE_DIR - path to persistent cache directory. Default values are %LocalAppData%\NEO\neo_compiler_cache if %LocalAppData% is found. If none of environment diff --git a/opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp b/opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp index 0898e5d66b..4eddf7cc14 100644 --- a/opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp +++ b/opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp @@ -267,4 +267,23 @@ TEST_F(CompilerCacheTest, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSi EXPECT_EQ(cacheConfig.cacheDir, "ult\\directory\\"); } +TEST_F(CompilerCacheTest, GivenCachePathExistsAndNoEnvVarsSetWhenGetDefaultCompilerCacheConfigThenCacheIsEnabled) { + bool pathExistsMock = true; + VariableBackup pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock); + + SysCalls::shGetKnownFolderPathResult = S_OK; + + const wchar_t *localAppDataPath = L"C:\\Users\\user1\\AppData\\Local"; + wcscpy(SysCalls::shGetKnownFolderSetPath, localAppDataPath); + + auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); + + const std::string expectedCacheDirPath = "C:\\Users\\user1\\AppData\\Local\\NEO\\neo_compiler_cache"; + + EXPECT_TRUE(cacheConfig.enabled); + EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheSize, static_cast(MemoryConstants::gigaByte)); + EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath); +} + } // namespace NEO diff --git a/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp b/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp index db034d1c3b..89e5fabebd 100644 --- a/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp +++ b/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp @@ -16,7 +16,7 @@ namespace NEO { int64_t defaultCacheEnabled() { - return 0l; + return 1l; } std::string getKnownFolderPath(REFKNOWNFOLDERID rfid) { diff --git a/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp b/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp index af7ae9dc90..588315daec 100644 --- a/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp +++ b/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp @@ -807,6 +807,10 @@ TEST_F(CompilerCacheWindowsTest, givenCacheBinaryWhenRenameTempFileBinaryToPrope EXPECT_EQ(0u, SysCalls::writeFileCalled); } +TEST(CompilerCacheHelperWindowsTest, whenDefaultCacheEnabledIsCalledThenReturnCorrectValue) { + EXPECT_EQ(1l, NEO::defaultCacheEnabled()); +} + TEST(CompilerCacheHelperWindowsTest, givenFindFirstFileASuccessWhenGetFileModificationTimeThenFindCloseIsCalled) { VariableBackup findFirstFileAResultBackup(&SysCalls::findFirstFileAResult, reinterpret_cast(0x1234)); VariableBackup findCloseCalledBackup(&SysCalls::findCloseCalled, 0u);