diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index c7c1f6c06ab2c..4a875a5d411f5 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -202,9 +202,13 @@ event handler::finalize() { std::move(MRequirements), std::move(MEvents), MCGType, MCodeLoc)); break; case detail::CG::NONE: - throw runtime_error("Command group submitted without a kernel or a " - "explicit memory operation.", - PI_INVALID_OPERATION); + if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_ALL)) { + std::cout << "WARNING: An empty command group is submitted." << std::endl; + } + detail::EventImplPtr Event = + std::make_shared(); + MLastEvent = detail::createSyclObjFromImpl(Event); + return MLastEvent; } if (!CommandGroup) diff --git a/sycl/test/basic_tests/event_async_exception.cpp b/sycl/test/basic_tests/event_async_exception.cpp index 1f39ebd20e5fb..819a25710ffd5 100644 --- a/sycl/test/basic_tests/event_async_exception.cpp +++ b/sycl/test/basic_tests/event_async_exception.cpp @@ -28,12 +28,13 @@ int main() { queue q(asyncHandler); try { - // Submit a CG with no kernel or memory operation to trigger an async error + // Check that submitting a CG with no kernel or memory operation doesn't produce + // an async exception event e = q.submit([&](handler &cgh) {}); e.wait_and_throw(); - return 1; - } catch (runtime_error e) { return 0; + } catch (runtime_error e) { + return 1; } }