本文整理汇总了C++中OpenCLContext::attach_resource方法的典型用法代码示例。如果您正苦于以下问题:C++ OpenCLContext::attach_resource方法的具体用法?C++ OpenCLContext::attach_resource怎么用?C++ OpenCLContext::attach_resource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCLContext
的用法示例。
在下文中一共展示了OpenCLContext::attach_resource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
void OpenCLImage2D :: create(
OpenCLContext &ctx,
cl_mem_flags usage,
AlloArray *array
) {
destroy();
detach();
usage = OpenCLMemoryBuffer::check_memory_flags(usage, array->data.ptr);
bool at_least_2d = array->header.dimcount >= 2;
size_t width = array->header.dim[0];
size_t height = at_least_2d ? array->header.dim[1] : 1;
size_t rowstride = at_least_2d ? array->header.stride[1] : allo_array_size(array);
cl_image_format format = OpenCLImageFormat::format_from_array(array);
cl_int res = CL_SUCCESS;
cl_mem mem = clCreateImage2D(
ctx.get_context(),
usage,
&format,
width,
height,
rowstride,
array->data.ptr,
&res
);
if(opencl_error(res, "clCreateImage2D error creating buffer")) {
return;
}
mMem = mem;
ctx.attach_resource(this);
}
示例2: create
void OpenCLCommandQueue :: create(OpenCLContext &ctx, const OpenCLDevice &dev, bool ordered, bool profiling) {
destroy();
detach();
cl_command_queue_properties properties = 0;
if(profiling) {
properties |= CL_QUEUE_PROFILING_ENABLE;
}
if(! ordered) {
if(GET_FLAG(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, dev.get_queue_properties())) {
properties |= CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
}
else {
opencl_error(USER_OPENCL_ERROR, "Device doesn't support out of order execution ... disabling");
}
}
cl_int res = CL_SUCCESS;
cl_command_queue command_queue = clCreateCommandQueue(
ctx.get_context(),
dev.get_device(),
properties,
&res
);
if(opencl_error(res, "clCreateCommandQueue error creating command queue")) {
return;
}
mCommandQueue = command_queue;
ctx.attach_resource(this);
}
示例3: create
void OpenCLImage3D :: create(
OpenCLContext &ctx,
cl_mem_flags usage,
const cl_image_format *format,
size_t width,
size_t height,
size_t depth,
size_t rowstride,
size_t planestride,
void *ptr
) {
destroy();
detach();
usage = OpenCLMemoryBuffer::check_memory_flags(usage, ptr);
cl_int res = CL_SUCCESS;
cl_mem mem = clCreateImage3D(
ctx.get_context(),
usage,
format,
width,
height,
depth,
rowstride,
planestride,
ptr,
&res
);
if(opencl_error(res, "clCreateImage3D error creating buffer")) {
return;
}
mMem = mem;
ctx.attach_resource(this);
}