Skip to content

Commit

Permalink
[SYCL] Fix multi-device support for persistent cache (#16056)
Browse files Browse the repository at this point in the history
  • Loading branch information
againull authored Nov 14, 2024
1 parent 2636a8b commit 6456fe8
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 210 deletions.
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

0 comments on commit 6456fe8

Please sign in to comment.