0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd:🆑 Zero size data construction no-op.

This commit is contained in:
Jason Volk 2021-04-14 20:56:01 -07:00
parent eba5d7f586
commit fac509e306

View file

@ -1438,6 +1438,9 @@ ircd::cl::data::data(const size_t size_,
ircd::size(buf)?: size_
};
if(!size)
return;
cl_mem_flags flags {0};
flags |= wonly? CL_MEM_WRITE_ONLY: CL_MEM_READ_WRITE;
flags |= ircd::size(buf)? CL_MEM_COPY_HOST_PTR: 0;
@ -1453,16 +1456,19 @@ ircd::cl::data::data(const size_t size_,
ircd::cl::data::data(const size_t size_,
const const_buffer &buf)
{
const auto ptr
const auto &ptr
{
ircd::size(buf)? ircd::data(buf): nullptr
};
const auto size
const auto &size
{
ircd::size(buf)?: size_
};
if(!size)
return;
cl_mem_flags flags {0};
flags |= CL_MEM_READ_ONLY;
flags |= ircd::size(buf)? CL_MEM_COPY_HOST_PTR: 0;
@ -1478,23 +1484,44 @@ ircd::cl::data::data(const size_t size_,
ircd::cl::data::data(const mutable_buffer &buf,
const bool wonly)
{
const auto &size
{
ircd::size(buf)
};
if(!size)
return;
cl_mem_flags flags {0};
flags |= CL_MEM_USE_HOST_PTR;
flags |= wonly? CL_MEM_WRITE_ONLY: CL_MEM_READ_WRITE;
int err {CL_SUCCESS};
handle = clCreateBuffer(primary, flags, ircd::size(buf), ircd::data(buf), &err);
handle = clCreateBuffer(primary, flags, size, ircd::data(buf), &err);
throw_on_error(err);
}
ircd::cl::data::data(const const_buffer &buf)
{
const auto &ptr
{
mutable_cast(ircd::data(buf))
};
const auto &size
{
ircd::size(buf)
};
if(!size)
return;
cl_mem_flags flags {0};
flags |= CL_MEM_USE_HOST_PTR;
flags |= CL_MEM_READ_ONLY;
int err {CL_SUCCESS};
handle = clCreateBuffer(primary, flags, ircd::size(buf), mutable_cast(ircd::data(buf)), &err);
handle = clCreateBuffer(primary, flags, size, ptr, &err);
throw_on_error(err);
}