mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 16:46:50 +01:00
ircd:🆑 Improve queue profiling wrapper related.
This commit is contained in:
parent
85b2256f6b
commit
8ffdddf860
2 changed files with 55 additions and 23 deletions
|
@ -52,6 +52,8 @@ namespace ircd::cl
|
||||||
struct ircd::cl::work
|
struct ircd::cl::work
|
||||||
:instance_list<cl::work>
|
:instance_list<cl::work>
|
||||||
{
|
{
|
||||||
|
struct prof;
|
||||||
|
|
||||||
void *handle {nullptr};
|
void *handle {nullptr};
|
||||||
ctx::ctx *context {ctx::current};
|
ctx::ctx *context {ctx::current};
|
||||||
void *object {nullptr};
|
void *object {nullptr};
|
||||||
|
@ -61,7 +63,6 @@ struct ircd::cl::work
|
||||||
public:
|
public:
|
||||||
int type() const;
|
int type() const;
|
||||||
const char *name() const;
|
const char *name() const;
|
||||||
std::array<uint64_t, 4> profile() const;
|
|
||||||
|
|
||||||
void wait(const uint = 0);
|
void wait(const uint = 0);
|
||||||
|
|
||||||
|
@ -74,6 +75,28 @@ struct ircd::cl::work
|
||||||
~work() noexcept;
|
~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
|
/// cl_mem wrapping
|
||||||
struct ircd::cl::data
|
struct ircd::cl::data
|
||||||
{
|
{
|
||||||
|
|
53
ircd/cl.cc
53
ircd/cl.cc
|
@ -2007,28 +2007,6 @@ catch(const std::exception &e)
|
||||||
throw;
|
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 *
|
const char *
|
||||||
ircd::cl::work::name()
|
ircd::cl::work::name()
|
||||||
const
|
const
|
||||||
|
@ -2080,6 +2058,37 @@ const
|
||||||
return info<int>(clGetEventInfo, handle, CL_EVENT_COMMAND_TYPE, buf);
|
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
|
int
|
||||||
ircd::cl::wait_event(work &work,
|
ircd::cl::wait_event(work &work,
|
||||||
const int status,
|
const int status,
|
||||||
|
|
Loading…
Reference in a new issue