mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
clover: Switch device objects to the new model.
Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
parent
49a49e0742
commit
c9e009b74d
9 changed files with 145 additions and 146 deletions
|
|
@ -27,28 +27,23 @@ using namespace clover;
|
|||
|
||||
PUBLIC cl_context
|
||||
clCreateContext(const cl_context_properties *props, cl_uint num_devs,
|
||||
const cl_device_id *devs,
|
||||
const cl_device_id *d_devs,
|
||||
void (CL_CALLBACK *pfn_notify)(const char *, const void *,
|
||||
size_t, void *),
|
||||
void *user_data, cl_int *errcode_ret) try {
|
||||
auto devs = map(addresses(), objs(d_devs, num_devs));
|
||||
auto mprops = property_map(props);
|
||||
|
||||
if (!devs || !num_devs ||
|
||||
(!pfn_notify && user_data))
|
||||
if (!pfn_notify && user_data)
|
||||
throw error(CL_INVALID_VALUE);
|
||||
|
||||
if (any_of(is_zero(), range(devs, num_devs)))
|
||||
throw error(CL_INVALID_DEVICE);
|
||||
|
||||
for (auto p : mprops) {
|
||||
if (p.first != CL_CONTEXT_PLATFORM)
|
||||
throw error(CL_INVALID_PROPERTY);
|
||||
}
|
||||
|
||||
ret_error(errcode_ret, CL_SUCCESS);
|
||||
return new context(
|
||||
property_vector(mprops),
|
||||
std::vector<cl_device_id>(devs, devs + num_devs));
|
||||
return new context(property_vector(mprops), devs);
|
||||
|
||||
} catch(error &e) {
|
||||
ret_error(errcode_ret, e);
|
||||
|
|
|
|||
|
|
@ -28,52 +28,53 @@ using namespace clover;
|
|||
|
||||
PUBLIC cl_int
|
||||
clGetDeviceIDs(cl_platform_id d_platform, cl_device_type device_type,
|
||||
cl_uint num_entries, cl_device_id *devices,
|
||||
cl_uint *num_devices) {
|
||||
cl_uint num_entries, cl_device_id *rd_devices,
|
||||
cl_uint *rnum_devices) try {
|
||||
auto &platform = obj(d_platform);
|
||||
std::vector<cl_device_id> devs;
|
||||
std::vector<cl_device_id> d_devs;
|
||||
|
||||
if ((!num_entries && devices) ||
|
||||
(!num_devices && !devices))
|
||||
return CL_INVALID_VALUE;
|
||||
if ((!num_entries && rd_devices) ||
|
||||
(!rnum_devices && !rd_devices))
|
||||
throw error(CL_INVALID_VALUE);
|
||||
|
||||
// Collect matching devices
|
||||
for (device &dev : platform) {
|
||||
if (((device_type & CL_DEVICE_TYPE_DEFAULT) &&
|
||||
&dev == &platform.front()) ||
|
||||
(device_type & dev.type()))
|
||||
devs.push_back(&dev);
|
||||
d_devs.push_back(desc(dev));
|
||||
}
|
||||
|
||||
if (devs.empty())
|
||||
return CL_DEVICE_NOT_FOUND;
|
||||
if (d_devs.empty())
|
||||
throw error(CL_DEVICE_NOT_FOUND);
|
||||
|
||||
// ...and return the requested data.
|
||||
if (num_devices)
|
||||
*num_devices = devs.size();
|
||||
if (devices)
|
||||
std::copy_n(devs.begin(),
|
||||
std::min((cl_uint)devs.size(), num_entries),
|
||||
devices);
|
||||
if (rnum_devices)
|
||||
*rnum_devices = d_devs.size();
|
||||
if (rd_devices)
|
||||
copy(range(d_devs.begin(),
|
||||
std::min((unsigned)d_devs.size(), num_entries)),
|
||||
rd_devices);
|
||||
|
||||
return CL_SUCCESS;
|
||||
|
||||
} catch (error &e) {
|
||||
return e.get();
|
||||
}
|
||||
|
||||
PUBLIC cl_int
|
||||
clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
||||
clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
|
||||
size_t size, void *r_buf, size_t *r_size) try {
|
||||
property_buffer buf { r_buf, size, r_size };
|
||||
|
||||
if (!dev)
|
||||
return CL_INVALID_DEVICE;
|
||||
auto &dev = obj(d_dev);
|
||||
|
||||
switch (param) {
|
||||
case CL_DEVICE_TYPE:
|
||||
buf.as_scalar<cl_device_type>() = dev->type();
|
||||
buf.as_scalar<cl_device_type>() = dev.type();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_VENDOR_ID:
|
||||
buf.as_scalar<cl_uint>() = dev->vendor_id();
|
||||
buf.as_scalar<cl_uint>() = dev.vendor_id();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_COMPUTE_UNITS:
|
||||
|
|
@ -81,15 +82,15 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:
|
||||
buf.as_scalar<cl_uint>() = dev->max_block_size().size();
|
||||
buf.as_scalar<cl_uint>() = dev.max_block_size().size();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_WORK_ITEM_SIZES:
|
||||
buf.as_vector<size_t>() = dev->max_block_size();
|
||||
buf.as_vector<size_t>() = dev.max_block_size();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_WORK_GROUP_SIZE:
|
||||
buf.as_scalar<size_t>() = dev->max_threads_per_block();
|
||||
buf.as_scalar<size_t>() = dev.max_threads_per_block();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR:
|
||||
|
|
@ -129,26 +130,26 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_MAX_READ_IMAGE_ARGS:
|
||||
buf.as_scalar<cl_uint>() = dev->max_images_read();
|
||||
buf.as_scalar<cl_uint>() = dev.max_images_read();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_WRITE_IMAGE_ARGS:
|
||||
buf.as_scalar<cl_uint>() = dev->max_images_write();
|
||||
buf.as_scalar<cl_uint>() = dev.max_images_write();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_MEM_ALLOC_SIZE:
|
||||
buf.as_scalar<cl_ulong>() = dev->max_mem_alloc_size();
|
||||
buf.as_scalar<cl_ulong>() = dev.max_mem_alloc_size();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_IMAGE2D_MAX_WIDTH:
|
||||
case CL_DEVICE_IMAGE2D_MAX_HEIGHT:
|
||||
buf.as_scalar<size_t>() = 1 << dev->max_image_levels_2d();
|
||||
buf.as_scalar<size_t>() = 1 << dev.max_image_levels_2d();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_IMAGE3D_MAX_WIDTH:
|
||||
case CL_DEVICE_IMAGE3D_MAX_HEIGHT:
|
||||
case CL_DEVICE_IMAGE3D_MAX_DEPTH:
|
||||
buf.as_scalar<size_t>() = 1 << dev->max_image_levels_3d();
|
||||
buf.as_scalar<size_t>() = 1 << dev.max_image_levels_3d();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_IMAGE_SUPPORT:
|
||||
|
|
@ -156,11 +157,11 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_MAX_PARAMETER_SIZE:
|
||||
buf.as_scalar<size_t>() = dev->max_mem_input();
|
||||
buf.as_scalar<size_t>() = dev.max_mem_input();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_SAMPLERS:
|
||||
buf.as_scalar<cl_uint>() = dev->max_samplers();
|
||||
buf.as_scalar<cl_uint>() = dev.max_samplers();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MEM_BASE_ADDR_ALIGN:
|
||||
|
|
@ -186,15 +187,15 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_GLOBAL_MEM_SIZE:
|
||||
buf.as_scalar<cl_ulong>() = dev->max_mem_global();
|
||||
buf.as_scalar<cl_ulong>() = dev.max_mem_global();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:
|
||||
buf.as_scalar<cl_ulong>() = dev->max_const_buffer_size();
|
||||
buf.as_scalar<cl_ulong>() = dev.max_const_buffer_size();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_MAX_CONSTANT_ARGS:
|
||||
buf.as_scalar<cl_uint>() = dev->max_const_buffers();
|
||||
buf.as_scalar<cl_uint>() = dev.max_const_buffers();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_LOCAL_MEM_TYPE:
|
||||
|
|
@ -202,7 +203,7 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_LOCAL_MEM_SIZE:
|
||||
buf.as_scalar<cl_ulong>() = dev->max_mem_local();
|
||||
buf.as_scalar<cl_ulong>() = dev.max_mem_local();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_ERROR_CORRECTION_SUPPORT:
|
||||
|
|
@ -214,7 +215,7 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_ENDIAN_LITTLE:
|
||||
buf.as_scalar<cl_bool>() = (dev->endianness() == PIPE_ENDIAN_LITTLE);
|
||||
buf.as_scalar<cl_bool>() = (dev.endianness() == PIPE_ENDIAN_LITTLE);
|
||||
break;
|
||||
|
||||
case CL_DEVICE_AVAILABLE:
|
||||
|
|
@ -231,11 +232,11 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_NAME:
|
||||
buf.as_string() = dev->device_name();
|
||||
buf.as_string() = dev.device_name();
|
||||
break;
|
||||
|
||||
case CL_DEVICE_VENDOR:
|
||||
buf.as_string() = dev->vendor_name();
|
||||
buf.as_string() = dev.vendor_name();
|
||||
break;
|
||||
|
||||
case CL_DRIVER_VERSION:
|
||||
|
|
@ -255,7 +256,7 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
|
|||
break;
|
||||
|
||||
case CL_DEVICE_PLATFORM:
|
||||
buf.as_scalar<cl_platform_id>() = desc(dev->platform);
|
||||
buf.as_scalar<cl_platform_id>() = desc(dev.platform);
|
||||
break;
|
||||
|
||||
case CL_DEVICE_HOST_UNIFIED_MEMORY:
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ clGetKernelWorkGroupInfo(cl_kernel kern, cl_device_id dev,
|
|||
return CL_INVALID_KERNEL;
|
||||
|
||||
if ((!dev && kern->prog.binaries().size() != 1) ||
|
||||
(dev && !kern->prog.binaries().count(dev)))
|
||||
(dev && !kern->prog.binaries().count(pobj(dev))))
|
||||
return CL_INVALID_DEVICE;
|
||||
|
||||
switch (param) {
|
||||
|
|
|
|||
|
|
@ -54,19 +54,21 @@ clCreateProgramWithSource(cl_context ctx, cl_uint count,
|
|||
}
|
||||
|
||||
PUBLIC cl_program
|
||||
clCreateProgramWithBinary(cl_context ctx, cl_uint count,
|
||||
const cl_device_id *devs, const size_t *lengths,
|
||||
clCreateProgramWithBinary(cl_context ctx, cl_uint n,
|
||||
const cl_device_id *d_devs, const size_t *lengths,
|
||||
const unsigned char **binaries, cl_int *status_ret,
|
||||
cl_int *errcode_ret) try {
|
||||
auto devs = objs(d_devs, n);
|
||||
|
||||
if (!ctx)
|
||||
throw error(CL_INVALID_CONTEXT);
|
||||
|
||||
if (!count || !devs || !lengths || !binaries)
|
||||
if (!lengths || !binaries)
|
||||
throw error(CL_INVALID_VALUE);
|
||||
|
||||
if (any_of([&](const cl_device_id dev) {
|
||||
return !ctx->has_device(dev);
|
||||
}, range(devs, count)))
|
||||
if (any_of([&](device &dev) {
|
||||
return !ctx->has_device(&dev);
|
||||
}, devs))
|
||||
throw error(CL_INVALID_DEVICE);
|
||||
|
||||
// Deserialize the provided binaries,
|
||||
|
|
@ -85,8 +87,8 @@ clCreateProgramWithBinary(cl_context ctx, cl_uint count,
|
|||
return { CL_INVALID_BINARY, {} };
|
||||
}
|
||||
},
|
||||
range(binaries, count),
|
||||
range(lengths, count));
|
||||
range(binaries, n),
|
||||
range(lengths, n));
|
||||
|
||||
// update the status array,
|
||||
if (status_ret)
|
||||
|
|
@ -100,8 +102,7 @@ clCreateProgramWithBinary(cl_context ctx, cl_uint count,
|
|||
|
||||
// initialize a program object with them.
|
||||
ret_error(errcode_ret, CL_SUCCESS);
|
||||
return new program(*ctx, { devs, devs + count },
|
||||
map(values(), modules));
|
||||
return new program(*ctx, map(addresses(), devs), map(values(), modules));
|
||||
|
||||
} catch (error &e) {
|
||||
ret_error(errcode_ret, e);
|
||||
|
|
@ -144,11 +145,11 @@ clBuildProgram(cl_program prog, cl_uint count, const cl_device_id *devs,
|
|||
|
||||
if (devs) {
|
||||
if (any_of([&](const cl_device_id dev) {
|
||||
return !prog->ctx.has_device(dev);
|
||||
return !prog->ctx.has_device(pobj(dev));
|
||||
}, range(devs, count)))
|
||||
throw error(CL_INVALID_DEVICE);
|
||||
|
||||
prog->build({ devs, devs + count }, opts);
|
||||
prog->build(map(addresses(), objs(devs, count)), opts);
|
||||
} else {
|
||||
prog->build(prog->ctx.devs, opts);
|
||||
}
|
||||
|
|
@ -234,20 +235,20 @@ clGetProgramBuildInfo(cl_program prog, cl_device_id dev,
|
|||
if (!prog)
|
||||
return CL_INVALID_PROGRAM;
|
||||
|
||||
if (!prog->ctx.has_device(dev))
|
||||
if (!prog->ctx.has_device(pobj(dev)))
|
||||
return CL_INVALID_DEVICE;
|
||||
|
||||
switch (param) {
|
||||
case CL_PROGRAM_BUILD_STATUS:
|
||||
buf.as_scalar<cl_build_status>() = prog->build_status(dev);
|
||||
buf.as_scalar<cl_build_status>() = prog->build_status(pobj(dev));
|
||||
break;
|
||||
|
||||
case CL_PROGRAM_BUILD_OPTIONS:
|
||||
buf.as_string() = prog->build_opts(dev);
|
||||
buf.as_string() = prog->build_opts(pobj(dev));
|
||||
break;
|
||||
|
||||
case CL_PROGRAM_BUILD_LOG:
|
||||
buf.as_string() = prog->build_log(dev);
|
||||
buf.as_string() = prog->build_log(pobj(dev));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -26,13 +26,15 @@
|
|||
using namespace clover;
|
||||
|
||||
PUBLIC cl_command_queue
|
||||
clCreateCommandQueue(cl_context ctx, cl_device_id dev,
|
||||
clCreateCommandQueue(cl_context ctx, cl_device_id d_dev,
|
||||
cl_command_queue_properties props,
|
||||
cl_int *errcode_ret) try {
|
||||
auto &dev = obj(d_dev);
|
||||
|
||||
if (!ctx)
|
||||
throw error(CL_INVALID_CONTEXT);
|
||||
|
||||
if (!ctx->has_device(dev))
|
||||
if (!ctx->has_device(&dev))
|
||||
throw error(CL_INVALID_DEVICE);
|
||||
|
||||
if (props & ~(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE |
|
||||
|
|
@ -40,7 +42,7 @@ clCreateCommandQueue(cl_context ctx, cl_device_id dev,
|
|||
throw error(CL_INVALID_VALUE);
|
||||
|
||||
ret_error(errcode_ret, CL_SUCCESS);
|
||||
return new command_queue(*ctx, *dev, props);
|
||||
return new command_queue(*ctx, dev, props);
|
||||
|
||||
} catch (error &e) {
|
||||
ret_error(errcode_ret, e);
|
||||
|
|
|
|||
|
|
@ -38,29 +38,28 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
_cl_device_id::_cl_device_id(clover::platform &platform,
|
||||
pipe_loader_device *ldev) :
|
||||
device::device(clover::platform &platform, pipe_loader_device *ldev) :
|
||||
platform(platform), ldev(ldev) {
|
||||
pipe = pipe_loader_create_screen(ldev, PIPE_SEARCH_DIR);
|
||||
if (!pipe || !pipe->get_param(pipe, PIPE_CAP_COMPUTE))
|
||||
throw error(CL_INVALID_DEVICE);
|
||||
}
|
||||
|
||||
_cl_device_id::_cl_device_id(_cl_device_id &&dev) :
|
||||
device::device(device &&dev) :
|
||||
platform(dev.platform), pipe(dev.pipe), ldev(dev.ldev) {
|
||||
dev.pipe = NULL;
|
||||
dev.ldev = NULL;
|
||||
}
|
||||
|
||||
_cl_device_id::~_cl_device_id() {
|
||||
device::~device() {
|
||||
if (pipe)
|
||||
pipe->destroy(pipe);
|
||||
if (ldev)
|
||||
pipe_loader_release(&ldev, 1);
|
||||
}
|
||||
|
||||
_cl_device_id &
|
||||
_cl_device_id::operator=(_cl_device_id dev) {
|
||||
device &
|
||||
device::operator=(device dev) {
|
||||
assert(&platform == &dev.platform);
|
||||
|
||||
std::swap(pipe, dev.pipe);
|
||||
|
|
@ -70,7 +69,7 @@ _cl_device_id::operator=(_cl_device_id dev) {
|
|||
}
|
||||
|
||||
cl_device_type
|
||||
_cl_device_id::type() const {
|
||||
device::type() const {
|
||||
switch (ldev->type) {
|
||||
case PIPE_LOADER_DEVICE_SOFTWARE:
|
||||
return CL_DEVICE_TYPE_CPU;
|
||||
|
|
@ -83,7 +82,7 @@ _cl_device_id::type() const {
|
|||
}
|
||||
|
||||
cl_uint
|
||||
_cl_device_id::vendor_id() const {
|
||||
device::vendor_id() const {
|
||||
switch (ldev->type) {
|
||||
case PIPE_LOADER_DEVICE_SOFTWARE:
|
||||
return 0;
|
||||
|
|
@ -96,104 +95,103 @@ _cl_device_id::vendor_id() const {
|
|||
}
|
||||
|
||||
size_t
|
||||
_cl_device_id::max_images_read() const {
|
||||
device::max_images_read() const {
|
||||
return PIPE_MAX_SHADER_RESOURCES;
|
||||
}
|
||||
|
||||
size_t
|
||||
_cl_device_id::max_images_write() const {
|
||||
device::max_images_write() const {
|
||||
return PIPE_MAX_SHADER_RESOURCES;
|
||||
}
|
||||
|
||||
cl_uint
|
||||
_cl_device_id::max_image_levels_2d() const {
|
||||
device::max_image_levels_2d() const {
|
||||
return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
|
||||
}
|
||||
|
||||
cl_uint
|
||||
_cl_device_id::max_image_levels_3d() const {
|
||||
device::max_image_levels_3d() const {
|
||||
return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_3D_LEVELS);
|
||||
}
|
||||
|
||||
cl_uint
|
||||
_cl_device_id::max_samplers() const {
|
||||
device::max_samplers() const {
|
||||
return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
|
||||
PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
|
||||
}
|
||||
|
||||
cl_ulong
|
||||
_cl_device_id::max_mem_global() const {
|
||||
device::max_mem_global() const {
|
||||
return get_compute_param<uint64_t>(pipe,
|
||||
PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE)[0];
|
||||
}
|
||||
|
||||
cl_ulong
|
||||
_cl_device_id::max_mem_local() const {
|
||||
device::max_mem_local() const {
|
||||
return get_compute_param<uint64_t>(pipe,
|
||||
PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE)[0];
|
||||
}
|
||||
|
||||
cl_ulong
|
||||
_cl_device_id::max_mem_input() const {
|
||||
device::max_mem_input() const {
|
||||
return get_compute_param<uint64_t>(pipe,
|
||||
PIPE_COMPUTE_CAP_MAX_INPUT_SIZE)[0];
|
||||
}
|
||||
|
||||
cl_ulong
|
||||
_cl_device_id::max_const_buffer_size() const {
|
||||
device::max_const_buffer_size() const {
|
||||
return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
|
||||
PIPE_SHADER_CAP_MAX_CONSTS) * 16;
|
||||
}
|
||||
|
||||
cl_uint
|
||||
_cl_device_id::max_const_buffers() const {
|
||||
device::max_const_buffers() const {
|
||||
return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
|
||||
PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
|
||||
}
|
||||
|
||||
size_t
|
||||
_cl_device_id::max_threads_per_block() const {
|
||||
device::max_threads_per_block() const {
|
||||
return get_compute_param<uint64_t>(
|
||||
pipe, PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK)[0];
|
||||
}
|
||||
|
||||
cl_ulong
|
||||
_cl_device_id::max_mem_alloc_size() const {
|
||||
device::max_mem_alloc_size() const {
|
||||
return get_compute_param<uint64_t>(pipe,
|
||||
PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE)[0];
|
||||
}
|
||||
|
||||
std::vector<size_t>
|
||||
_cl_device_id::max_block_size() const {
|
||||
device::max_block_size() const {
|
||||
auto v = get_compute_param<uint64_t>(pipe, PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
|
||||
return { v.begin(), v.end() };
|
||||
}
|
||||
|
||||
std::string
|
||||
_cl_device_id::device_name() const {
|
||||
device::device_name() const {
|
||||
return pipe->get_name(pipe);
|
||||
}
|
||||
|
||||
std::string
|
||||
_cl_device_id::vendor_name() const {
|
||||
device::vendor_name() const {
|
||||
return pipe->get_vendor(pipe);
|
||||
}
|
||||
|
||||
enum pipe_shader_ir
|
||||
_cl_device_id::ir_format() const {
|
||||
return (enum pipe_shader_ir) pipe->get_shader_param(pipe,
|
||||
PIPE_SHADER_COMPUTE,
|
||||
PIPE_SHADER_CAP_PREFERRED_IR);
|
||||
device::ir_format() const {
|
||||
return (enum pipe_shader_ir) pipe->get_shader_param(
|
||||
pipe, PIPE_SHADER_COMPUTE, PIPE_SHADER_CAP_PREFERRED_IR);
|
||||
}
|
||||
|
||||
std::string
|
||||
_cl_device_id::ir_target() const {
|
||||
std::vector<char> target = get_compute_param<char>(pipe,
|
||||
PIPE_COMPUTE_CAP_IR_TARGET);
|
||||
device::ir_target() const {
|
||||
std::vector<char> target = get_compute_param<char>(
|
||||
pipe, PIPE_COMPUTE_CAP_IR_TARGET);
|
||||
return { target.data() };
|
||||
}
|
||||
|
||||
enum pipe_endian
|
||||
_cl_device_id::endianness() const {
|
||||
device::endianness() const {
|
||||
return (enum pipe_endian)pipe->get_param(pipe, PIPE_CAP_ENDIANNESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,54 +31,53 @@
|
|||
#include "pipe-loader/pipe_loader.h"
|
||||
|
||||
namespace clover {
|
||||
typedef struct _cl_device_id device;
|
||||
struct platform;
|
||||
class platform;
|
||||
class root_resource;
|
||||
class hard_event;
|
||||
|
||||
class device : public _cl_device_id {
|
||||
public:
|
||||
device(clover::platform &platform, pipe_loader_device *ldev);
|
||||
device(device &&dev);
|
||||
device(const device &dev) = delete;
|
||||
~device();
|
||||
|
||||
device &operator=(device dev);
|
||||
|
||||
cl_device_type type() const;
|
||||
cl_uint vendor_id() const;
|
||||
size_t max_images_read() const;
|
||||
size_t max_images_write() const;
|
||||
cl_uint max_image_levels_2d() const;
|
||||
cl_uint max_image_levels_3d() const;
|
||||
cl_uint max_samplers() const;
|
||||
cl_ulong max_mem_global() const;
|
||||
cl_ulong max_mem_local() const;
|
||||
cl_ulong max_mem_input() const;
|
||||
cl_ulong max_const_buffer_size() const;
|
||||
cl_uint max_const_buffers() const;
|
||||
size_t max_threads_per_block() const;
|
||||
cl_ulong max_mem_alloc_size() const;
|
||||
|
||||
std::vector<size_t> max_block_size() const;
|
||||
std::string device_name() const;
|
||||
std::string vendor_name() const;
|
||||
enum pipe_shader_ir ir_format() const;
|
||||
std::string ir_target() const;
|
||||
enum pipe_endian endianness() const;
|
||||
|
||||
friend struct ::_cl_command_queue;
|
||||
friend class root_resource;
|
||||
friend class hard_event;
|
||||
friend std::set<cl_image_format>
|
||||
supported_formats(cl_context, cl_mem_object_type);
|
||||
|
||||
clover::platform &platform;
|
||||
|
||||
private:
|
||||
pipe_screen *pipe;
|
||||
pipe_loader_device *ldev;
|
||||
};
|
||||
}
|
||||
|
||||
struct _cl_device_id {
|
||||
public:
|
||||
_cl_device_id(clover::platform &platform, pipe_loader_device *ldev);
|
||||
_cl_device_id(_cl_device_id &&dev);
|
||||
_cl_device_id(const _cl_device_id &dev) = delete;
|
||||
~_cl_device_id();
|
||||
|
||||
_cl_device_id &operator=(_cl_device_id dev);
|
||||
|
||||
cl_device_type type() const;
|
||||
cl_uint vendor_id() const;
|
||||
size_t max_images_read() const;
|
||||
size_t max_images_write() const;
|
||||
cl_uint max_image_levels_2d() const;
|
||||
cl_uint max_image_levels_3d() const;
|
||||
cl_uint max_samplers() const;
|
||||
cl_ulong max_mem_global() const;
|
||||
cl_ulong max_mem_local() const;
|
||||
cl_ulong max_mem_input() const;
|
||||
cl_ulong max_const_buffer_size() const;
|
||||
cl_uint max_const_buffers() const;
|
||||
size_t max_threads_per_block() const;
|
||||
cl_ulong max_mem_alloc_size() const;
|
||||
|
||||
std::vector<size_t> max_block_size() const;
|
||||
std::string device_name() const;
|
||||
std::string vendor_name() const;
|
||||
enum pipe_shader_ir ir_format() const;
|
||||
std::string ir_target() const;
|
||||
enum pipe_endian endianness() const;
|
||||
|
||||
friend struct _cl_command_queue;
|
||||
friend class clover::root_resource;
|
||||
friend class clover::hard_event;
|
||||
friend std::set<cl_image_format>
|
||||
clover::supported_formats(cl_context, cl_mem_object_type);
|
||||
|
||||
clover::platform &platform;
|
||||
|
||||
private:
|
||||
pipe_screen *pipe;
|
||||
pipe_loader_device *ldev;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
namespace clover {
|
||||
typedef struct _cl_command_queue command_queue;
|
||||
typedef struct _cl_context context;
|
||||
typedef struct _cl_device_id device;
|
||||
class device;
|
||||
typedef struct _cl_event event;
|
||||
class hard_event;
|
||||
class soft_event;
|
||||
|
|
|
|||
|
|
@ -179,6 +179,9 @@ namespace clover {
|
|||
}
|
||||
}
|
||||
|
||||
struct _cl_device_id :
|
||||
public clover::descriptor<clover::device, _cl_device_id> {};
|
||||
|
||||
struct _cl_platform_id :
|
||||
public clover::descriptor<clover::platform, _cl_platform_id> {};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue