mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd:🆑 Reorder the kern::range lists for common construction; minor fixes.
This commit is contained in:
parent
e403565029
commit
51d2ac4b33
2 changed files with 36 additions and 15 deletions
|
@ -123,9 +123,9 @@ struct ircd::cl::kern
|
||||||
struct ircd::cl::kern::range
|
struct ircd::cl::kern::range
|
||||||
{
|
{
|
||||||
std::array<size_t, 5>
|
std::array<size_t, 5>
|
||||||
offset { 0, 0, 0, 0, 0 },
|
|
||||||
global { 0, 0, 0, 0, 0 },
|
global { 0, 0, 0, 0, 0 },
|
||||||
local { 0, 0, 0, 0, 0 };
|
local { 0, 0, 0, 0, 0 },
|
||||||
|
offset { 0, 0, 0, 0, 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Construction enqueues the task; destruction waits for completion.
|
/// Construction enqueues the task; destruction waits for completion.
|
||||||
|
|
47
ircd/cl.cc
47
ircd/cl.cc
|
@ -1032,7 +1032,7 @@ namespace ircd::cl
|
||||||
struct completion;
|
struct completion;
|
||||||
|
|
||||||
static void handle_event(cl_event, cl_int, void *) noexcept;
|
static void handle_event(cl_event, cl_int, void *) noexcept;
|
||||||
static void handle_incomplete(work &, const int &);
|
static int handle_incomplete(work &, const int &, const int);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ircd::cl::completion
|
struct ircd::cl::completion
|
||||||
|
@ -1055,9 +1055,10 @@ noexcept
|
||||||
cl::sync();
|
cl::sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
ircd::cl::handle_incomplete(work &work,
|
ircd::cl::handle_incomplete(work &work,
|
||||||
const int &status)
|
const int &status,
|
||||||
|
const int desired)
|
||||||
{
|
{
|
||||||
completion c
|
completion c
|
||||||
{
|
{
|
||||||
|
@ -1069,17 +1070,17 @@ ircd::cl::handle_incomplete(work &work,
|
||||||
(
|
(
|
||||||
clSetEventCallback,
|
clSetEventCallback,
|
||||||
cl_event(work.handle),
|
cl_event(work.handle),
|
||||||
CL_COMPLETE,
|
desired,
|
||||||
&handle_event,
|
&handle_event,
|
||||||
&c
|
&c
|
||||||
);
|
);
|
||||||
|
|
||||||
c.dock.wait([&c]
|
c.dock.wait([&c, &desired]
|
||||||
{
|
{
|
||||||
return !c.event || c.status == CL_COMPLETE;
|
return !c.event || c.status == desired;
|
||||||
});
|
});
|
||||||
|
|
||||||
throw_on_error(c.status);
|
return c.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1093,7 +1094,7 @@ noexcept
|
||||||
reinterpret_cast<completion *>(priv)
|
reinterpret_cast<completion *>(priv)
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(c.event != nullptr);
|
assert(event != nullptr);
|
||||||
c->status = status;
|
c->status = status;
|
||||||
c->dock.notify_one();
|
c->dock.notify_one();
|
||||||
}
|
}
|
||||||
|
@ -1113,7 +1114,8 @@ noexcept try
|
||||||
{
|
{
|
||||||
const unwind free{[this]
|
const unwind free{[this]
|
||||||
{
|
{
|
||||||
call(clReleaseEvent, cl_event(handle));
|
if(likely(handle))
|
||||||
|
call(clReleaseEvent, cl_event(handle));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
wait();
|
wait();
|
||||||
|
@ -1131,21 +1133,40 @@ catch(const std::exception &e)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::cl::work::wait()
|
ircd::cl::work::wait()
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if(!handle)
|
if(!handle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char buf[4] {0};
|
char buf[4];
|
||||||
const int status
|
int status
|
||||||
{
|
{
|
||||||
info<int>(clGetEventInfo, cl_event(handle), CL_EVENT_COMMAND_EXECUTION_STATUS, buf)
|
info<int>(clGetEventInfo, cl_event(handle), CL_EVENT_COMMAND_EXECUTION_STATUS, buf)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(status >= 0 && status != CL_COMPLETE)
|
if(likely(status == CL_COMPLETE))
|
||||||
handle_incomplete(*this, status);
|
return false;
|
||||||
|
|
||||||
|
if(unlikely(status >= 0))
|
||||||
|
status = handle_incomplete(*this, status, CL_COMPLETE);
|
||||||
|
|
||||||
|
if(unlikely(status < 0))
|
||||||
|
throw_on_error(status);
|
||||||
|
|
||||||
|
assert(status == CL_COMPLETE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
log::error
|
||||||
|
{
|
||||||
|
log, "work(%p) :%s",
|
||||||
|
this,
|
||||||
|
e.what(),
|
||||||
|
};
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
std::array<uint64_t, 4>
|
std::array<uint64_t, 4>
|
||||||
ircd::cl::work::profile()
|
ircd::cl::work::profile()
|
||||||
|
|
Loading…
Reference in a new issue