Skip to content

Commit 6456fe8

Browse files
authored
[SYCL] Fix multi-device support for persistent cache (#16056)
Associated UR PR: oneapi-src/unified-runtime#2313
1 parent 2636a8b commit 6456fe8

File tree

6 files changed

+300
-210
lines changed

6 files changed

+300
-210
lines changed

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -415,20 +415,15 @@ class kernel_bundle_impl {
415415

416416
std::vector<const uint8_t *> Binaries;
417417
std::vector<size_t> Lengths;
418-
std::vector<std::vector<std::vector<char>>> PersistentBinaries;
419-
for (size_t i = 0; i < Devices.size(); i++) {
420-
std::vector<std::vector<char>> BinProg =
421-
PersistentDeviceCodeCache::getCompiledKernelFromDisc(
422-
Devices[i], UserArgs, SourceStr);
423-
424-
// exit if any device binary is missing
425-
if (BinProg.empty()) {
426-
return false;
427-
}
428-
PersistentBinaries.push_back(BinProg);
429-
430-
Binaries.push_back((uint8_t *)(PersistentBinaries[i][0].data()));
431-
Lengths.push_back(PersistentBinaries[i][0].size());
418+
std::vector<std::vector<char>> BinProgs =
419+
PersistentDeviceCodeCache::getCompiledKernelFromDisc(Devices, UserArgs,
420+
SourceStr);
421+
if (BinProgs.empty()) {
422+
return false;
423+
}
424+
for (auto &BinProg : BinProgs) {
425+
Binaries.push_back((uint8_t *)(BinProg.data()));
426+
Lengths.push_back(BinProg.size());
432427
}
433428

434429
ur_program_properties_t Properties = {};
@@ -564,11 +559,9 @@ class kernel_bundle_impl {
564559
// If caching enabled and kernel not fetched from cache, cache.
565560
if (PersistentDeviceCodeCache::isEnabled() && !FetchedFromCache &&
566561
SourceStrPtr) {
567-
for (const auto &Device : Devices) {
568-
PersistentDeviceCodeCache::putCompiledKernelToDisc(
569-
Device, syclex::detail::userArgsAsString(BuildOptions),
570-
*SourceStrPtr, UrProgram);
571-
}
562+
PersistentDeviceCodeCache::putCompiledKernelToDisc(
563+
Devices, syclex::detail::userArgsAsString(BuildOptions),
564+
*SourceStrPtr, UrProgram);
572565
}
573566

574567
return std::make_shared<kernel_bundle_impl>(MContext, MDevices, DevImg,

0 commit comments

Comments
 (0)