mirror of
https://github.com/matrix-construct/construct
synced 2025-01-04 20:04:30 +01:00
ircd:🆑 Preempt callback; improve status checks, error code.
This commit is contained in:
parent
3389c23feb
commit
047eb1a384
1 changed files with 19 additions and 3 deletions
22
ircd/cl.cc
22
ircd/cl.cc
|
@ -900,6 +900,22 @@ ircd::cl::handle_offload()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int status; try
|
||||||
|
{
|
||||||
|
char buf[4] {0};
|
||||||
|
status = info<int>(clGetEventInfo, p.event, CL_EVENT_COMMAND_EXECUTION_STATUS, buf);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
status = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(status < 0 || status == CL_COMPLETE)
|
||||||
|
{
|
||||||
|
handle_event(p.event, status, p.ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto res
|
const auto res
|
||||||
{
|
{
|
||||||
clSetEventCallback(p.event, CL_COMPLETE, &handle_event, p.ctx)
|
clSetEventCallback(p.event, CL_COMPLETE, &handle_event, p.ctx)
|
||||||
|
@ -921,7 +937,7 @@ ircd::cl::handle_event(cl_event event,
|
||||||
void *const priv)
|
void *const priv)
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
assert(status == CL_COMPLETE);
|
always_assert(status < 0 || status == CL_COMPLETE);
|
||||||
|
|
||||||
// Prepare response to the main thread. The event pointer is anulled to
|
// Prepare response to the main thread. The event pointer is anulled to
|
||||||
// indicate completion.
|
// indicate completion.
|
||||||
|
@ -1024,13 +1040,13 @@ noexcept try
|
||||||
cl_event(this->handle)
|
cl_event(this->handle)
|
||||||
};
|
};
|
||||||
|
|
||||||
char status_buf[8] {0};
|
char status_buf[4] {0};
|
||||||
const auto &status
|
const auto &status
|
||||||
{
|
{
|
||||||
info<int>(clGetEventInfo, handle, CL_EVENT_COMMAND_EXECUTION_STATUS, status_buf)
|
info<int>(clGetEventInfo, handle, CL_EVENT_COMMAND_EXECUTION_STATUS, status_buf)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(status != CL_COMPLETE)
|
if(status >= 0 && status != CL_COMPLETE)
|
||||||
handle_incomplete(*this, status);
|
handle_incomplete(*this, status);
|
||||||
|
|
||||||
call(clReleaseEvent, cl_event(handle));
|
call(clReleaseEvent, cl_event(handle));
|
||||||
|
|
Loading…
Reference in a new issue