Skip to content

Commit 698b13d

Browse files
committed
load all fallback device libraries when loading kernel from file
Signed-off-by: Ge Jin <[email protected]>
1 parent 5c59cdf commit 698b13d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

sycl/include/CL/sycl/detail/pi.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ class DeviceBinaryImage {
245245
ConstIterator begin() const { return ConstIterator(Begin); }
246246
ConstIterator end() const { return ConstIterator(End); }
247247
friend class DeviceBinaryImage;
248+
bool isAvailable() const { return !(Begin == nullptr); }
248249

249250
private:
250251
PropertyRange() : Begin(nullptr), End(nullptr) {}

sycl/source/detail/program_manager/program_manager.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -982,10 +982,16 @@ void ProgramManager::flushSpecConstants(const program_impl &Prg,
982982
Prg.flush_spec_constants(*Img, NativePrg);
983983
}
984984

985+
// If the kernel is loaded from spv file, it may not include DeviceLib require
986+
// mask, sycl runtime won't know which fallback device libraries are needed. In
987+
// such case, the safest way is to load all fallback device libraries.
985988
uint32_t ProgramManager::getDeviceLibReqMask(const RTDeviceBinaryImage &Img) {
986989
const pi::DeviceBinaryImage::PropertyRange &DLMRange =
987990
Img.getDeviceLibReqMask();
988-
return pi::DeviceBinaryProperty(*(DLMRange.begin())).asUint32();
991+
if (DLMRange.isAvailable())
992+
return pi::DeviceBinaryProperty(*(DLMRange.begin())).asUint32();
993+
else
994+
return 0xFFFFFFFF;
989995
}
990996

991997
} // namespace detail

0 commit comments

Comments
 (0)