@@ -1596,6 +1596,25 @@ getDeviceLibPrograms(const ContextImplPtr Context,
15961596 std::vector<ur_device_handle_t > &Devices,
15971597 const std::vector<const RTDeviceBinaryImage *> &Images) {
15981598 std::vector<ur_program_handle_t > Programs;
1599+ for (auto Img : Images) {
1600+ if (!Img)
1601+ continue ;
1602+ const RTDeviceBinaryImage::PropertyRange &NewRange =
1603+ Img->getDeviceLibReqBins ();
1604+ if (!NewRange.isAvailable ())
1605+ continue ;
1606+
1607+ for (const auto &DeviceLibBinProp : NewRange) {
1608+ auto DeviceLibByteArray =
1609+ DeviceBinaryProperty (DeviceLibBinProp).asByteArray ();
1610+ DeviceLibByteArray.dropBytes (8 );
1611+ uint32_t DeviceLibExtReq =
1612+ (static_cast <uint32_t >(DeviceLibByteArray[3 ]) << 24 ) |
1613+ (static_cast <uint32_t >(DeviceLibByteArray[2 ]) << 16 ) |
1614+ (static_cast <uint32_t >(DeviceLibByteArray[1 ]) << 8 ) |
1615+ DeviceLibByteArray[0 ];
1616+ }
1617+ }
15991618 return Programs;
16001619}
16011620
@@ -1604,6 +1623,8 @@ checkDeviceLibsLinkMode(const std::vector<const RTDeviceBinaryImage *> &Images,
16041623 bool &LinkDeviceLib, bool &LegacyLinkMode) {
16051624 bool ReqMaskAvailable = false , ReqBinsAvailable = false ;
16061625 for (auto Img : Images) {
1626+ if (!Img)
1627+ continue ;
16071628 const RTDeviceBinaryImage::PropertyRange &LegacyRange =
16081629 Img->getDeviceLibReqMask ();
16091630 if (LegacyRange.isAvailable ()) {
@@ -1634,10 +1655,13 @@ static uint32_t getDeviceLibReqMaskFromImages(
16341655 const std::vector<const RTDeviceBinaryImage *> &Images) {
16351656 uint32_t DeviceLibReqMask = 0 ;
16361657 for (auto Img : Images) {
1658+ if (!Img)
1659+ continue ;
16371660 const RTDeviceBinaryImage::PropertyRange &ReqMaskRange =
16381661 Img->getDeviceLibReqMask ();
16391662 if (ReqMaskRange.isAvailable ())
1640- DeviceLibReqMask |= DeviceBinaryProperty (*(ReqMaskRange.begin ())).asUint32 ();
1663+ DeviceLibReqMask |=
1664+ DeviceBinaryProperty (*(ReqMaskRange.begin ())).asUint32 ();
16411665 }
16421666 return DeviceLibReqMask;
16431667}
@@ -2929,9 +2953,7 @@ ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel(
29292953 // An empty images vector will skip linking fallback device libraries.
29302954 auto BuildProgram =
29312955 build (std::move (ProgramManaged), detail::getSyclObjImpl (Context),
2932- CompileOpts, LinkOpts, Devs,
2933- ImagesVec,
2934- ExtraProgramsToLink);
2956+ CompileOpts, LinkOpts, Devs, ImagesVec, ExtraProgramsToLink);
29352957 ur_kernel_handle_t UrKernel{nullptr };
29362958 Adapter->call <errc::kernel_not_supported, UrApiKind::urKernelCreate>(
29372959 BuildProgram.get (), KernelName.c_str (), &UrKernel);
0 commit comments