Skip to content

[SYCL] Fix multi-device support for persistent cache #16056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,20 +415,15 @@ class kernel_bundle_impl {

std::vector<const uint8_t *> Binaries;
std::vector<size_t> Lengths;
std::vector<std::vector<std::vector<char>>> PersistentBinaries;
for (size_t i = 0; i < Devices.size(); i++) {
std::vector<std::vector<char>> BinProg =
PersistentDeviceCodeCache::getCompiledKernelFromDisc(
Devices[i], UserArgs, SourceStr);

// exit if any device binary is missing
if (BinProg.empty()) {
return false;
}
PersistentBinaries.push_back(BinProg);

Binaries.push_back((uint8_t *)(PersistentBinaries[i][0].data()));
Lengths.push_back(PersistentBinaries[i][0].size());
std::vector<std::vector<char>> BinProgs =
PersistentDeviceCodeCache::getCompiledKernelFromDisc(Devices, UserArgs,
SourceStr);
if (BinProgs.empty()) {
return false;
}
for (auto &BinProg : BinProgs) {
Binaries.push_back((uint8_t *)(BinProg.data()));
Lengths.push_back(BinProg.size());
}

ur_program_properties_t Properties = {};
Expand Down Expand Up @@ -564,11 +559,9 @@ class kernel_bundle_impl {
// If caching enabled and kernel not fetched from cache, cache.
if (PersistentDeviceCodeCache::isEnabled() && !FetchedFromCache &&
SourceStrPtr) {
for (const auto &Device : Devices) {
PersistentDeviceCodeCache::putCompiledKernelToDisc(
Device, syclex::detail::userArgsAsString(BuildOptions),
*SourceStrPtr, UrProgram);
}
PersistentDeviceCodeCache::putCompiledKernelToDisc(
Devices, syclex::detail::userArgsAsString(BuildOptions),
*SourceStrPtr, UrProgram);
}

return std::make_shared<kernel_bundle_impl>(MContext, MDevices, DevImg,
Expand Down
Loading
Loading