diff --git a/sycl/source/detail/helpers.cpp b/sycl/source/detail/helpers.cpp index af6f0cb3c112..3502aba5a54a 100644 --- a/sycl/source/detail/helpers.cpp +++ b/sycl/source/detail/helpers.cpp @@ -39,9 +39,9 @@ markBufferAsInternal(const std::shared_ptr &BufImpl) { BufImpl->markAsInternal(); } -std::tuple -retrieveKernelBinary(queue_impl &Queue, KernelNameStrRefT KernelName, - CGExecKernel *KernelCG) { +const RTDeviceBinaryImage *retrieveKernelBinary(queue_impl &Queue, + KernelNameStrRefT KernelName, + CGExecKernel *KernelCG) { device_impl &Dev = Queue.getDeviceImpl(); bool isNvidia = Dev.getBackend() == backend::ext_oneapi_cuda; bool isHIP = Dev.getBackend() == backend::ext_oneapi_hip; @@ -58,36 +58,22 @@ retrieveKernelBinary(queue_impl &Queue, KernelNameStrRefT KernelName, return DI->getFormat() == SYCL_DEVICE_BINARY_TYPE_LLVMIR_BITCODE && DI->getRawData().DeviceTargetSpec == TargetSpec; }); - if (DeviceImage == DeviceImages.end()) { - return {nullptr, nullptr}; - } - context_impl &ContextImpl = Queue.getContextImpl(); - ur_program_handle_t Program = - detail::ProgramManager::getInstance().createURProgram( - **DeviceImage, ContextImpl, {createSyclObjFromImpl(Dev)}); - return {*DeviceImage, Program}; + assert(DeviceImage != DeviceImages.end() && + "Failed to obtain a binary image."); + return *DeviceImage; } - const RTDeviceBinaryImage *DeviceImage = nullptr; - ur_program_handle_t Program = nullptr; - auto KernelBundleImpl = KernelCG->getKernelBundle(); - if (KernelCG->MSyclKernel != nullptr) { - DeviceImage = KernelCG->MSyclKernel->getDeviceImage()->get_bin_image_ref(); - Program = KernelCG->MSyclKernel->getDeviceImage()->get_ur_program_ref(); - } else if (auto SyclKernelImpl = - KernelBundleImpl ? KernelBundleImpl->tryGetKernel(KernelName) - : std::shared_ptr{nullptr}) { - // Retrieve the device image from the kernel bundle. - DeviceImage = SyclKernelImpl->getDeviceImage()->get_bin_image_ref(); - Program = SyclKernelImpl->getDeviceImage()->get_ur_program_ref(); - } else { - context_impl &ContextImpl = Queue.getContextImpl(); - DeviceImage = &detail::ProgramManager::getInstance().getDeviceImage( - KernelName, ContextImpl, Dev); - Program = detail::ProgramManager::getInstance().createURProgram( - *DeviceImage, ContextImpl, {createSyclObjFromImpl(Dev)}); - } - return {DeviceImage, Program}; + if (KernelCG->MSyclKernel != nullptr) + return KernelCG->MSyclKernel->getDeviceImage()->get_bin_image_ref(); + + if (auto KernelBundleImpl = KernelCG->getKernelBundle()) + if (auto SyclKernelImpl = KernelBundleImpl->tryGetKernel(KernelName)) + // Retrieve the device image from the kernel bundle. + return SyclKernelImpl->getDeviceImage()->get_bin_image_ref(); + + context_impl &ContextImpl = Queue.getContextImpl(); + return &detail::ProgramManager::getInstance().getDeviceImage( + KernelName, ContextImpl, Dev); } } // namespace detail diff --git a/sycl/source/detail/helpers.hpp b/sycl/source/detail/helpers.hpp index dba0cbd60751..f1db524533ba 100644 --- a/sycl/source/detail/helpers.hpp +++ b/sycl/source/detail/helpers.hpp @@ -23,7 +23,7 @@ class CGExecKernel; class queue_impl; class RTDeviceBinaryImage; -std::tuple +const RTDeviceBinaryImage * retrieveKernelBinary(queue_impl &Queue, KernelNameStrRefT KernelName, CGExecKernel *CGKernel = nullptr); } // namespace detail diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index d26ccba7895a..e1d64461f20b 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -3260,8 +3260,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const RTDeviceBinaryImage *BinImage = nullptr; if (detail::SYCLConfig::get()) { - std::tie(BinImage, std::ignore) = - retrieveKernelBinary(*MQueue, KernelName); + BinImage = retrieveKernelBinary(*MQueue, KernelName); assert(BinImage && "Failed to obtain a binary image."); } enqueueImpKernel( diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 1e729b2100eb..94f758d0ede4 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -597,7 +597,7 @@ event handler::finalize() { #endif const detail::RTDeviceBinaryImage *BinImage = nullptr; if (detail::SYCLConfig::get()) { - std::tie(BinImage, std::ignore) = detail::retrieveKernelBinary( + BinImage = detail::retrieveKernelBinary( impl->get_queue(), toKernelNameStrT(MKernelName)); assert(BinImage && "Failed to obtain a binary image."); }