From c05e5e09de94d838c245ab705d21eee678ed4eb3 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 22 Sep 2021 10:11:22 -0700 Subject: [PATCH] ircd::cl: Additional informational interfaces; kernel names; typing. --- include/ircd/cl.h | 6 +++ ircd/cl.cc | 109 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 108 insertions(+), 7 deletions(-) diff --git a/include/ircd/cl.h b/include/ircd/cl.h index d799a96f4..3f6ea4572 100644 --- a/include/ircd/cl.h +++ b/include/ircd/cl.h @@ -51,10 +51,13 @@ struct ircd::cl::work { void *handle {nullptr}; ctx::ctx *context {ctx::current}; + void *object {nullptr}; static void init(), fini() noexcept; public: + int type() const; + const char *name() const; std::array profile() const; void wait(const uint = 0); @@ -118,6 +121,9 @@ struct ircd::cl::kern void *handle {nullptr}; public: + const char *name() const; + uint argc() const; + std::array compile_group_size(void *dev = nullptr) const; size_t preferred_group_size_multiple(void *dev = nullptr) const; size_t group_size(void *dev = nullptr) const; diff --git a/ircd/cl.cc b/ircd/cl.cc index 3c15e0544..d1a58c8c7 100644 --- a/ircd/cl.cc +++ b/ircd/cl.cc @@ -643,6 +643,9 @@ try make_deps(this, opts) }; + assert(!this->object); + this->object = &kern; + assert(!this->handle); call ( @@ -692,11 +695,8 @@ try queue[0][0] }; - const auto deps - { - make_deps(this, opts) - }; - + assert(src.handle); + assert(dst.handle); const size_t size { opts.size == -1UL? @@ -707,8 +707,14 @@ try if(!size) return; - assert(src.handle); - assert(dst.handle); + assert(!this->object); + this->object = &dst; + + const auto deps + { + make_deps(this, opts) + }; + assert(!this->handle); call ( @@ -759,6 +765,9 @@ try if(!size) return; + assert(!this->object); + this->object = &data; + const auto deps { make_deps(this, opts) @@ -818,6 +827,9 @@ try if(!size) return; + assert(!this->object); + this->object = &data; + const auto deps { make_deps(this, opts) @@ -888,6 +900,9 @@ try assert(size_t(size) <= data.size()); assert(size_t(offset) <= data.size()); + assert(!this->object); + this->object = &data; + const auto deps { make_deps(this, opts) @@ -1002,6 +1017,9 @@ try assert(size_t(size) <= data.size()); assert(size_t(offset) <= data.size()); + assert(!this->object); + this->object = &data; + const auto deps { make_deps(this, opts) @@ -1299,6 +1317,32 @@ const return info(clGetKernelWorkGroupInfo, handle, cl_device_id(dev), flag, buf); } +uint +ircd::cl::kern::argc() +const +{ + const auto handle + { + cl_kernel(this->handle) + }; + + char buf[sizeof(uint)]; + return info(clGetKernelInfo, handle, CL_KERNEL_NUM_ARGS, buf); +} + +const char * +ircd::cl::kern::name() +const +{ + const auto handle + { + cl_kernel(this->handle) + }; + + char buf[sizeof(const char *)]; + return info(clGetKernelInfo, handle, CL_KERNEL_FUNCTION_NAME, buf); +} + // // code // @@ -1894,6 +1938,57 @@ const }; } +const char * +ircd::cl::work::name() +const +{ + switch(const auto type(this->type()); type) + { + default: + return nullptr; + + case CL_COMMAND_READ_BUFFER: + case CL_COMMAND_WRITE_BUFFER: + case CL_COMMAND_COPY_BUFFER: + case CL_COMMAND_MAP_BUFFER: + case CL_COMMAND_UNMAP_MEM_OBJECT: + { + const auto data + { + reinterpret_cast(object) + }; + + return nullptr; //TODO: XXX + } + + case CL_COMMAND_NDRANGE_KERNEL: + { + const auto kern + { + reinterpret_cast(object) + }; + + return kern->name(); + } + }; +} + +int +ircd::cl::work::type() +const +{ + const auto handle + { + cl_event(this->handle) + }; + + if(!handle) + return 0; + + char buf[4]; + return info(clGetEventInfo, handle, CL_EVENT_COMMAND_TYPE, buf); +} + int ircd::cl::wait_event(work &work, const int status,