@@ -410,24 +410,31 @@ class kernel_bundle_impl {
410410 auto BinProg = PersistentDeviceCodeCache::getCompiledKernelFromDisc (
411411 Devices[0 ], UserArgs, SourceStr);
412412 if (!BinProg.empty ()) {
413- ur_device_handle_t UrDevice = getSyclObjImpl (Devices[0 ])->getHandleRef ();
414- ur_result_t BinaryStatus = UR_RESULT_SUCCESS;
413+ std::vector<ur_device_handle_t > DeviceHandles;
414+ std::transform (Devices.begin (), Devices.end (),
415+ std::back_inserter (DeviceHandles), [](const device &Dev) {
416+ return getSyclObjImpl (Dev)->getHandleRef ();
417+ });
418+
419+ std::vector<const uint8_t *> Binaries;
420+ std::vector<size_t > Lengths;
421+ for (size_t i = 0 ; i < Devices.size (); i++) {
422+ auto BinProg = PersistentDeviceCodeCache::getCompiledKernelFromDisc (
423+ Devices[i], UserArgs, SourceStr);
424+ Binaries.push_back ((uint8_t *)(BinProg.data ()));
425+ Lengths.push_back (BinProg.size ());
426+ }
427+
415428 ur_program_properties_t Properties = {};
416429 Properties.stype = UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES;
417430 Properties.pNext = nullptr ;
418431 Properties.count = 0 ;
419432 Properties.pMetadatas = nullptr ;
420- BinaryStatus = Adapter->call_nocheck <UrApiKind::urProgramCreateWithBinary>(
421- ContextImpl->getHandleRef (), UrDevice, BinProg[0 ].size (),
422- (const unsigned char *)BinProg[0 ].data (), &Properties, &UrProgram);
423-
424- if (BinaryStatus == UR_RESULT_SUCCESS) {
425- ur_result_t Error = Adapter->call_nocheck <UrApiKind::urProgramBuildExp>(
426- UrProgram,
427- /* num devices =*/ 1 , &UrDevice, UserArgs.c_str ());
428433
429- return (Error == UR_RESULT_SUCCESS);
430- }
434+ Adapter->call <UrApiKind::urProgramCreateWithBinary>(
435+ ContextImpl->getHandleRef (), DeviceHandles.size (),
436+ DeviceHandles.data (), Lengths.data (), Binaries.data (), &Properties,
437+ &UrProgram);
431438 }
432439 return false ;
433440 }
@@ -546,9 +553,11 @@ class kernel_bundle_impl {
546553 // If caching enabled and kernel not fetched from cache, cache.
547554 if (PersistentDeviceCodeCache::isEnabled () && !FetchedFromCache &&
548555 SourceStrPtr) {
549- PersistentDeviceCodeCache::putCompiledKernelToDisc (
550- Devices[0 ], syclex::detail::userArgsAsString (BuildOptions),
551- *SourceStrPtr, UrProgram);
556+ for (const auto &Device : Devices) {
557+ PersistentDeviceCodeCache::putCompiledKernelToDisc (
558+ Device, syclex::detail::userArgsAsString (BuildOptions),
559+ *SourceStrPtr, UrProgram);
560+ }
552561 }
553562
554563 return std::make_shared<kernel_bundle_impl>(MContext, MDevices, DevImg,
0 commit comments