0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

ircd:🆑 Additional informational interfaces; kernel names; typing.

This commit is contained in:
Jason Volk 2021-09-22 10:11:22 -07:00
parent aea6c79fc2
commit c05e5e09de
2 changed files with 108 additions and 7 deletions

View file

@ -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<uint64_t, 4> 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<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;

View file

@ -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<ulong>(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<uint>(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<const char *>(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<const cl::data *>(object)
};
return nullptr; //TODO: XXX
}
case CL_COMMAND_NDRANGE_KERNEL:
{
const auto kern
{
reinterpret_cast<const cl::kern *>(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<int>(clGetEventInfo, handle, CL_EVENT_COMMAND_TYPE, buf);
}
int
ircd::cl::wait_event(work &work,
const int status,