Skip to content

[SYCL][Unit] Fix persistent cache unit tests - #23548

Open
uditagarwal97 wants to merge 1 commit into
syclfrom
private/udit/persistant_cache
Open

uditagarwal97 wants to merge 1 commit into
syclfrom
private/udit/persistant_cache

Conversation

@uditagarwal97

@uditagarwal97 uditagarwal97 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #18122

Two persistent cache unit tests fail intermittently because separate test processes share one on-disk cache directory and remove each other's files.

MultipleDevsKernelBundleTest.PersistentCache - The test is parameterized, LIT runs both the instances parallelly (for SPIRV and binary device image format respectively). This causes race over the common cache directory. To fix this, the test now creates a unique cache directory per run using llvm::sys::fs::createUniqueDirectory.

PersistentDeviceCodeCache.CorruptedCacheFiles - It's a death test (uses ASSERT_DEATH). On Windows, gtest runs
a death test by re-executing the binary, and the child re-runs the whole test. See https://google.github.io/googletest/reference/assertions.html#death . The child process inherits the environment variable from parent, so we store the unique cache directory name in an environment variable and pass it over to the child process. This ensures that there's no race between the two parameterized runs of this test and their children. Note that, the parent and child should use the same cache directory for the test to work, earlier we used to hardcode the cache directory path but that was causing a race between two parameterized runs of this test.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Relative cache paths can cause fixture setup to fail because directory creation resolves them against different locations.

1 open issue
What changed in this PR

Improves SYCL persistent-cache unit test isolation and fixes in-memory cache configuration resets.

Changes:

  • Uses unique cache directories with ownership-based cleanup.
  • Re-enables the multi-device persistent-cache test.
  • Re-parses SYCL_CACHE_IN_MEM when resetting its cached value.
File Description
sycl/​unittests/​program_manager/​MultipleDevsKernelBundle.cpp Re-enables the cache test with a unique directory.
sycl/​unittests/​kernel-and-program/​PersistentDeviceCodeCache.cpp Isolates cache directories and updates environment handling.
sycl/​source/​detail/​config.hpp Corrects cached configuration reset parsing.

Review effort: Balanced

Comment on lines +161 to +163
ASSERT_NO_ERROR(llvm::sys::fs::create_directories(RootSYCLCacheDir));
ASSERT_NO_ERROR(llvm::sys::fs::createUniqueDirectory(
RootSYCLCacheDir + "/pdcc", UniqueDir));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be an overkill - we never use a relative SYCL_CACHE_DIR in unit tests, so would not run into this problem.

@uditagarwal97
uditagarwal97 marked this pull request as ready for review October 19, 2026 23:23
@uditagarwal97
uditagarwal97 requested a review from a team as a code owner October 19, 2026 23:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sporadic unit test fail on Linux MultipleDevsKernelBundleTest/PersistentCache

2 participants