0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:🆑 Improve queue profiling wrapper related.

This commit is contained in:
Jason Volk 2021-10-03 15:31:04 -07:00
parent 85b2256f6b
commit 8ffdddf860
2 changed files with 55 additions and 23 deletions

View file

@ -52,6 +52,8 @@ namespace ircd::cl
struct ircd::cl::work
:instance_list<cl::work>
{
struct prof;
void *handle {nullptr};
ctx::ctx *context {ctx::current};
void *object {nullptr};
@ -61,7 +63,6 @@ struct ircd::cl::work
public:
int type() const;
const char *name() const;
std::array<uint64_t, 4> profile() const;
void wait(const uint = 0);
@ -74,6 +75,28 @@ struct ircd::cl::work
~work() noexcept;
};
/// Queue profiling convenience
struct ircd::cl::work::prof
:std::array<nanoseconds, 5>
{
enum phase :int;
prof(const cl::work &);
prof() = default;
};
/// cl_profiling_info wrapper
enum ircd::cl::work::prof::phase
:int
{
QUEUE,
SUBMIT,
START,
END,
COMPLETE,
_NUM_
};
/// cl_mem wrapping
struct ircd::cl::data
{

View file

@ -2007,28 +2007,6 @@ catch(const std::exception &e)
throw;
}
std::array<uint64_t, 4>
ircd::cl::work::profile()
const
{
const auto handle
{
cl_event(this->handle)
};
if(!profile_queue || !handle)
return {0};
char buf[4][8];
return std::array<uint64_t, 4>
{
info<size_t>(clGetEventProfilingInfo, handle, CL_PROFILING_COMMAND_QUEUED, buf[0]),
info<size_t>(clGetEventProfilingInfo, handle, CL_PROFILING_COMMAND_SUBMIT, buf[1]),
info<size_t>(clGetEventProfilingInfo, handle, CL_PROFILING_COMMAND_START, buf[2]),
info<size_t>(clGetEventProfilingInfo, handle, CL_PROFILING_COMMAND_END, buf[3]),
};
}
const char *
ircd::cl::work::name()
const
@ -2080,6 +2058,37 @@ const
return info<int>(clGetEventInfo, handle, CL_EVENT_COMMAND_TYPE, buf);
}
//
// cl::work::prof
//
ircd::cl::work::prof::prof(const cl::work &w)
{
const auto h
{
cl_event(w.handle)
};
if(!profile_queue || !h)
{
for(uint i(0); i < this->size(); ++i)
(*this)[i] = 0ns;
return;
}
char b[5][8];
(*this)[0] = info<nanoseconds>(clGetEventProfilingInfo, h, CL_PROFILING_COMMAND_QUEUED, b[0]);
(*this)[1] = info<nanoseconds>(clGetEventProfilingInfo, h, CL_PROFILING_COMMAND_SUBMIT, b[1]);
(*this)[2] = info<nanoseconds>(clGetEventProfilingInfo, h, CL_PROFILING_COMMAND_START, b[2]);
(*this)[3] = info<nanoseconds>(clGetEventProfilingInfo, h, CL_PROFILING_COMMAND_END, b[3]);
(*this)[4] = info<nanoseconds>(clGetEventProfilingInfo, h, CL_PROFILING_COMMAND_COMPLETE, b[4]);
}
//
// cl::work (internal)
//
int
ircd::cl::wait_event(work &work,
const int status,