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

ircd:🆑 Add kernel workgroup info convenience interface.

This commit is contained in:
Jason Volk 2021-04-03 12:23:52 -07:00
parent 019f16cb5e
commit 86d985a42f
2 changed files with 56 additions and 0 deletions

View file

@ -111,6 +111,12 @@ struct ircd::cl::kern
void *handle {nullptr};
public:
std::array<size_t, 3> 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;
size_t local_mem_size(void *dev = nullptr) const;
size_t stack_mem_size(void *dev = nullptr) const;
void arg(const int, data &);
void arg(const int, const const_buffer &);
template<class T> void arg(const int, const T &);

View file

@ -939,6 +939,56 @@ ircd::cl::kern::arg(const int i,
call(clSetKernelArg, cl_kernel(handle), i, ircd::size(buf), ircd::data(buf));
}
std::array<size_t, 3>
ircd::cl::kern::compile_group_size(void *const dev)
const
{
char buf[24];
const auto handle(cl_kernel(this->handle));
constexpr auto flag(CL_KERNEL_COMPILE_WORK_GROUP_SIZE);
return info<std::array<size_t, 3>>(clGetKernelWorkGroupInfo, handle, cl_device_id(dev), flag, buf);
}
size_t
ircd::cl::kern::preferred_group_size_multiple(void *const dev)
const
{
char buf[16];
const auto handle(cl_kernel(this->handle));
constexpr auto flag(CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE);
return info<size_t>(clGetKernelWorkGroupInfo, handle, cl_device_id(dev), flag, buf);
}
size_t
ircd::cl::kern::group_size(void *const dev)
const
{
char buf[16];
const auto handle(cl_kernel(this->handle));
constexpr auto flag(CL_KERNEL_WORK_GROUP_SIZE);
return info<size_t>(clGetKernelWorkGroupInfo, handle, cl_device_id(dev), flag, buf);
}
size_t
ircd::cl::kern::local_mem_size(void *const dev)
const
{
char buf[16];
const auto handle(cl_kernel(this->handle));
constexpr auto flag(CL_KERNEL_LOCAL_MEM_SIZE);
return info<ulong>(clGetKernelWorkGroupInfo, handle, cl_device_id(dev), flag, buf);
}
size_t
ircd::cl::kern::stack_mem_size(void *const dev)
const
{
char buf[16];
const auto handle(cl_kernel(this->handle));
constexpr auto flag(CL_KERNEL_PRIVATE_MEM_SIZE);
return info<ulong>(clGetKernelWorkGroupInfo, handle, cl_device_id(dev), flag, buf);
}
//
// code
//