From d69f8ffb9c4780177c211922d399a4aa568f0e6a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 17 Mar 2021 17:12:58 -0700 Subject: [PATCH] ircd::cl::data: Add basic property interface wrappings. --- include/ircd/cl.h | 4 ++++ ircd/cl.cc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/ircd/cl.h b/include/ircd/cl.h index 9d00172ee..ecf079d7e 100644 --- a/include/ircd/cl.h +++ b/include/ircd/cl.h @@ -64,6 +64,10 @@ struct ircd::cl::data void *handle {nullptr}; public: + uint flags() const; + size_t size() const; + char *ptr() const; // host only + data(const size_t, const mutable_buffer &, const bool wonly = false); // device rw data(const size_t, const const_buffer &); // device ro data(const mutable_buffer &, const bool wonly = false); // host rw diff --git a/ircd/cl.cc b/ircd/cl.cc index 8f2290e67..d5a01777d 100644 --- a/ircd/cl.cc +++ b/ircd/cl.cc @@ -813,6 +813,36 @@ catch(const std::exception &e) return; } +char * +ircd::cl::data::ptr() +const +{ + assert(handle); + + char buf[sizeof(void *)] {0}; + return info(clGetMemObjectInfo, cl_mem(mutable_cast(handle)), CL_MEM_SIZE, buf); +} + +size_t +ircd::cl::data::size() +const +{ + assert(handle); + + char buf[sizeof(size_t)] {0}; + return info(clGetMemObjectInfo, cl_mem(mutable_cast(handle)), CL_MEM_SIZE, buf); +} + +uint +ircd::cl::data::flags() +const +{ + assert(handle); + + char buf[sizeof(uint)] {0}; + return info(clGetMemObjectInfo, cl_mem(mutable_cast(handle)), CL_MEM_FLAGS, buf); +} + // // cl::work (event) //