Skip to content
Merged
28 changes: 18 additions & 10 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,26 @@ 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 << "The empty command group is supported by sycl2020"
<< std::endl;
}
break;
}

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));
detail::EventImplPtr Event;

if (!CommandGroup) {
if (getType() != detail::CG::NONE)
throw sycl::runtime_error(
"Internal Error. Command group cannot be constructed.",
PI_INVALID_OPERATION);
else
// empty cg is supported by sycl2020
Event = std::make_shared<cl::sycl::detail::event_impl>();
} else
Event = detail::Scheduler::getInstance().addCG(std::move(CommandGroup),
std::move(MQueue));

MLastEvent = detail::createSyclObjFromImpl<event>(Event);
return MLastEvent;
Expand Down
6 changes: 3 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,12 @@ int main() {
queue q(asyncHandler);

try {
// Submit a CG with no kernel or memory operation to trigger an async error
// Submit a CG with no kernel or memory operation no trigger an async error
event e = q.submit([&](handler &cgh) {});

e.wait_and_throw();
return 1;
} catch (runtime_error e) {
return 0;
} catch (runtime_error e) {
return 1;
}
}