Skip to content

Commit 7ac48ae

Browse files
committed
Improve GPU caching.
1 parent a1e483a commit 7ac48ae

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,14 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(
549549
// FIXME: on CPU we can't re-use results unless "Dev" is a root device already
550550
// due to Intel OpenCL CPU bug(?). This solution is tested only on Intel GPU
551551
// implementation.
552-
if (Dev->is_gpu())
553-
while (!Dev->isRootDevice()) {
554-
auto ParentDev =
555-
detail::getSyclObjImpl(Dev->get_info<info::device::parent_device>());
556-
Dev = ParentDev;
552+
DeviceImplPtr KeyDev = Dev;
553+
if (KeyDev->is_gpu())
554+
while (!KeyDev->isRootDevice()) {
555+
auto ParentDev = detail::getSyclObjImpl(
556+
KeyDev->get_info<info::device::parent_device>());
557+
KeyDev = ParentDev;
557558
}
558-
const RT::PiDevice PiDevice = Dev->getHandleRef();
559+
const RT::PiDevice PiDevice = KeyDev->getHandleRef();
559560

560561
auto BuildResult = getOrBuild<PiProgramT, compile_program_error>(
561562
Cache,
@@ -592,7 +593,17 @@ ProgramManager::getOrCreateKernel(OSModuleHandle M,
592593
Prg->stableSerializeSpecConstRegistry(SpecConsts);
593594
}
594595
applyOptionsFromEnvironment(CompileOpts, LinkOpts);
595-
const RT::PiDevice PiDevice = DeviceImpl->getHandleRef();
596+
597+
auto Dev = DeviceImpl;
598+
bool IsGPUDevice = Dev->is_gpu();
599+
while (!Dev->isRootDevice()) {
600+
auto ParentDev =
601+
detail::getSyclObjImpl(Dev->get_info<info::device::parent_device>());
602+
if (!ContextImpl->hasDevice(ParentDev) && !IsGPUDevice)
603+
break;
604+
Dev = ParentDev;
605+
}
606+
const RT::PiDevice PiDevice = Dev->getHandleRef();
596607

597608
auto key = std::make_tuple(std::move(SpecConsts), M, PiDevice,
598609
CompileOpts + LinkOpts, KernelName);

0 commit comments

Comments
 (0)