Skip to content
Merged
14 changes: 10 additions & 4 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,21 @@ 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<cl::sycl::detail::event_impl>();
MLastEvent = detail::createSyclObjFromImpl<event>(Event);
return MLastEvent;
}

if (!CommandGroup)
if (!CommandGroup) {
throw sycl::runtime_error(
"Internal Error. Command group cannot be constructed.",
PI_INVALID_OPERATION);
}

detail::EventImplPtr Event = detail::Scheduler::getInstance().addCG(
std::move(CommandGroup), std::move(MQueue));
Expand Down
7 changes: 4 additions & 3 deletions sycl/test/basic_tests/event_async_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}