From 0925c2525b93515b1430a5b9b9355ba7a9e59cee Mon Sep 17 00:00:00 2001 From: Steffen Larsen Date: Thu, 14 Oct 2021 14:11:34 +0300 Subject: [PATCH] [SYCL] Use secondary queue in assert post-processing For submissions with a secondary queue the post-process lambda currently captures the secondary queue but does not pass it along. These changes uses the secondary queue if it is not a host queue. Signed-off-by: Steffen Larsen --- sycl/include/CL/sycl/queue.hpp | 37 +++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index 80c13abe4d10f..1bef957e87679 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -295,22 +295,31 @@ class __SYCL_EXPORT queue { event Event; #if __SYCL_USE_FALLBACK_ASSERT - auto PostProcess = [this, &SecondaryQueue, &CodeLoc]( - bool IsKernel, bool KernelUsesAssert, event &E) { - if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) && - KernelUsesAssert) { - // __devicelib_assert_fail isn't supported by Device-side Runtime - // Linking against fallback impl of __devicelib_assert_fail is performed - // by program manager class - submitAssertCapture(*this, E, /* SecondaryQueue = */ nullptr, CodeLoc); - } - }; + if (!is_host()) { + auto PostProcess = [this, &SecondaryQueue, &CodeLoc]( + bool IsKernel, bool KernelUsesAssert, event &E) { + if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) && + KernelUsesAssert) { + // Only secondary queues on devices need to be added to the assert + // capture. + // TODO: Handle case where primary queue is host but the secondary + // queue is not. + queue *DeviceSecondaryQueue = + SecondaryQueue.is_host() ? nullptr : &SecondaryQueue; + // __devicelib_assert_fail isn't supported by Device-side Runtime + // Linking against fallback impl of __devicelib_assert_fail is + // performed by program manager class + submitAssertCapture(*this, E, DeviceSecondaryQueue, CodeLoc); + } + }; - Event = - submit_impl_and_postprocess(CGF, SecondaryQueue, CodeLoc, PostProcess); -#else - Event = submit_impl(CGF, SecondaryQueue, CodeLoc); + Event = submit_impl_and_postprocess(CGF, SecondaryQueue, CodeLoc, + PostProcess); + } else #endif // __SYCL_USE_FALLBACK_ASSERT + { + Event = submit_impl(CGF, SecondaryQueue, CodeLoc); + } return Event; }