0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-02-18 09:40:12 +01:00

ircd:🆑 Move work wait function out of dtor into member; assert handle.

This commit is contained in:
Jason Volk 2021-03-17 15:50:38 -07:00
parent c0072f732c
commit 60e66cb273
2 changed files with 29 additions and 18 deletions

View file

@ -47,6 +47,8 @@ struct ircd::cl::work
public:
std::array<uint64_t, 4> profile() const;
bool wait();
work(void *const &handle); // note: RetainEvent()
work() = default;
work(work &&) noexcept;

View file

@ -299,6 +299,7 @@ try
make_deps(this, opts)
};
assert(!this->handle);
call
(
clEnqueueBarrierWithWaitList,
@ -338,6 +339,7 @@ try
make_deps(this, opts)
};
assert(!this->handle);
call
(
clEnqueueNDRangeKernel,
@ -378,6 +380,7 @@ try
make_deps(this, opts)
};
assert(!this->handle);
call
(
clEnqueueReadBuffer,
@ -473,6 +476,9 @@ ircd::cl::make_deps_default(cl::work *const &work,
if(other == work)
continue;
if(!other->handle)
continue;
if(other->context != ctx::current)
continue;
@ -1032,24 +1038,7 @@ ircd::cl::work::work(void *const &handle)
ircd::cl::work::~work()
noexcept try
{
if(!this->handle)
return;
const auto handle
{
cl_event(this->handle)
};
char status_buf[4] {0};
const auto &status
{
info<int>(clGetEventInfo, handle, CL_EVENT_COMMAND_EXECUTION_STATUS, status_buf)
};
if(status >= 0 && status != CL_COMPLETE)
handle_incomplete(*this, status);
call(clReleaseEvent, cl_event(handle));
wait();
}
catch(const std::exception &e)
{
@ -1062,6 +1051,26 @@ catch(const std::exception &e)
return;
}
bool
ircd::cl::work::wait()
{
if(!handle)
return false;
char buf[4];
const auto &status
{
info<int>(clGetEventInfo, cl_event(handle), CL_EVENT_COMMAND_EXECUTION_STATUS, buf)
};
if(status >= 0 && status != CL_COMPLETE)
handle_incomplete(*this, status);
call(clReleaseEvent, cl_event(handle));
handle = nullptr;
return true;
}
std::array<uint64_t, 4>
ircd::cl::work::profile()
const