本文整理汇总了C++中cl_mem类的典型用法代码示例。如果您正苦于以下问题:C++ cl_mem类的具体用法?C++ cl_mem怎么用?C++ cl_mem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cl_mem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_valid
bool is_valid(cl_mem m)
{
global_mutex.lock();
const bool r = valid_mems.count(m) != 0 && m->valid();
if (r)
m->lock();
global_mutex.unlock();
return r;
}
示例2: clRetainMemObjectFCL
cl_int clRetainMemObjectFCL (cl_mem memobj)
{
MSG(clRetainMemObjectFCL);
if (!FreeOCL::is_valid(memobj))
return CL_INVALID_MEM_OBJECT;
memobj->retain();
memobj->unlock();
return CL_SUCCESS;
}
示例3: clRetainMemObject
cl_int
clRetainMemObject(cl_mem memobj)
{
if (!memobj->isA(Coal::Object::T_MemObject))
return CL_INVALID_MEM_OBJECT;
memobj->reference();
return CL_SUCCESS;
}
示例4: clReleaseMemObject
cl_int
clReleaseMemObject(cl_mem memobj)
{
if (!memobj->isA(Coal::Object::T_MemObject))
return CL_INVALID_MEM_OBJECT;
if (memobj->dereference())
delete memobj;
return CL_SUCCESS;
}
示例5: clGetMemObjectInfo
cl_int
clGetMemObjectInfo(cl_mem memobj,
cl_mem_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
if (!memobj->isA(Coal::Object::T_MemObject))
return CL_INVALID_MEM_OBJECT;
return memobj->info(param_name, param_value_size, param_value,
param_value_size_ret);
}
示例6: clSetMemObjectDestructorCallback
cl_int
clSetMemObjectDestructorCallback(cl_mem memobj,
void (CL_CALLBACK *pfn_notify)(cl_mem memobj,
void *user_data),
void * user_data)
{
if (!memobj->isA(Coal::Object::T_MemObject))
return CL_INVALID_MEM_OBJECT;
memobj->setDestructorCallback(pfn_notify, user_data);
return CL_SUCCESS;
}
示例7: clRetainMemObject
PUBLIC cl_int
clRetainMemObject(cl_mem obj) {
if (!obj)
return CL_INVALID_MEM_OBJECT;
obj->retain();
return CL_SUCCESS;
}
示例8: clGetImageInfo
cl_int
clGetImageInfo(cl_mem image,
cl_image_info param_name,
size_t param_value_size,
void * param_value,
size_t * param_value_size_ret)
{
if (!image->isA(Coal::Object::T_MemObject) ||
(image->type() != Coal::MemObject::Image2D &&
image->type() != Coal::MemObject::Image3D))
return CL_INVALID_MEM_OBJECT;
Coal::Image2D *image2d = (Coal::Image2D *)image;
return image2d->imageInfo(param_name, param_value_size, param_value,
param_value_size_ret);
}
示例9: clReleaseMemObjectFCL
cl_int clReleaseMemObjectFCL (cl_mem memobj)
{
MSG(clReleaseMemObjectFCL);
if (!FreeOCL::is_valid(memobj))
return CL_INVALID_MEM_OBJECT;
memobj->release();
if (memobj->get_ref_count() == 0)
{
memobj->invalidate();
memobj->unlock();
delete memobj;
}
else
memobj->unlock();
return CL_SUCCESS;
}
示例10: clReleaseMemObject
PUBLIC cl_int
clReleaseMemObject(cl_mem obj) {
if (!obj)
return CL_INVALID_MEM_OBJECT;
if (obj->release())
delete obj;
return CL_SUCCESS;
}
示例11: clGetMemObjectInfo
PUBLIC cl_int
clGetMemObjectInfo(cl_mem obj, cl_mem_info param,
size_t size, void *buf, size_t *size_ret) {
if (!obj)
return CL_INVALID_MEM_OBJECT;
switch (param) {
case CL_MEM_TYPE:
return scalar_property<cl_mem_object_type>(buf, size, size_ret,
obj->type());
case CL_MEM_FLAGS:
return scalar_property<cl_mem_flags>(buf, size, size_ret, obj->flags());
case CL_MEM_SIZE:
return scalar_property<size_t>(buf, size, size_ret, obj->size());
case CL_MEM_HOST_PTR:
return scalar_property<void *>(buf, size, size_ret, obj->host_ptr());
case CL_MEM_MAP_COUNT:
return scalar_property<cl_uint>(buf, size, size_ret, 0);
case CL_MEM_REFERENCE_COUNT:
return scalar_property<cl_uint>(buf, size, size_ret, obj->ref_count());
case CL_MEM_CONTEXT:
return scalar_property<cl_context>(buf, size, size_ret, &obj->ctx);
case CL_MEM_ASSOCIATED_MEMOBJECT: {
sub_buffer *sub = dynamic_cast<sub_buffer *>(obj);
return scalar_property<cl_mem>(buf, size, size_ret,
(sub ? &sub->parent : NULL));
}
case CL_MEM_OFFSET: {
sub_buffer *sub = dynamic_cast<sub_buffer *>(obj);
return scalar_property<size_t>(buf, size, size_ret,
(sub ? sub->offset() : 0));
}
default:
return CL_INVALID_VALUE;
}
}
示例12: clCreateSubBuffer
cl_mem
clCreateSubBuffer(cl_mem buffer,
cl_mem_flags flags,
cl_buffer_create_type buffer_create_type,
const void * buffer_create_info,
cl_int * errcode_ret)
{
cl_int dummy_errcode;
if (!errcode_ret)
errcode_ret = &dummy_errcode;
if (!buffer->isA(Coal::Object::T_MemObject))
{
*errcode_ret = CL_INVALID_MEM_OBJECT;
return 0;
}
Coal::MemObject *memobject = (Coal::MemObject *)buffer;
cl_buffer_region *region = (cl_buffer_region *)buffer_create_info;
// NOTE: Is it right ? Couldn't we create SubBuffers of images ?
if (memobject->type() != Coal::MemObject::Buffer)
{
*errcode_ret = CL_INVALID_MEM_OBJECT;
return 0;
}
if (buffer_create_type != CL_BUFFER_CREATE_TYPE_REGION)
{
*errcode_ret = CL_INVALID_VALUE;
return 0;
}
if (!buffer_create_info)
{
*errcode_ret = CL_INVALID_VALUE;
return 0;
}
*errcode_ret = CL_SUCCESS;
Coal::SubBuffer *buf = new Coal::SubBuffer((Coal::Buffer *)buffer,
region->origin, region->size,
flags, errcode_ret);
if (*errcode_ret != CL_SUCCESS || (*errcode_ret = buf->init()) != CL_SUCCESS)
{
delete buf;
return 0;
}
return (cl_mem)buf;
}
示例13: clSetMemObjectDestructorCallback
PUBLIC cl_int
clSetMemObjectDestructorCallback(cl_mem obj,
void (CL_CALLBACK *pfn_notify)(cl_mem, void *),
void *user_data) {
if (!obj)
return CL_INVALID_MEM_OBJECT;
if (!pfn_notify)
return CL_INVALID_VALUE;
obj->destroy_notify([=]{ pfn_notify(obj, user_data); });
return CL_SUCCESS;
}
示例14: clEnqueueReadImage
cl_int
clEnqueueReadImage(cl_command_queue command_queue,
cl_mem image,
cl_bool blocking_read,
const size_t * origin,
const size_t * region,
size_t row_pitch,
size_t slice_pitch,
void * ptr,
cl_uint num_events_in_wait_list,
const cl_event * event_wait_list,
cl_event * event)
{
cl_int rs = CL_SUCCESS;
if (!command_queue->isA(Coal::Object::T_CommandQueue))
return CL_INVALID_COMMAND_QUEUE;
if (!image || (image->type() != Coal::MemObject::Image2D &&
image->type() != Coal::MemObject::Image3D))
return CL_INVALID_MEM_OBJECT;
Coal::ReadImageEvent *command = new Coal::ReadImageEvent(
(Coal::CommandQueue *)command_queue,
(Coal::Image2D *)image,
origin, region, row_pitch, slice_pitch, (void *)ptr,
num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs
);
if (rs != CL_SUCCESS)
{
delete command;
return rs;
}
return queueEvent(command_queue, command, event, blocking_read);
}
示例15: clEnqueueWriteBuffer
PUBLIC cl_int
clEnqueueWriteBuffer(cl_command_queue q, cl_mem obj, cl_bool blocking,
size_t offset, size_t size, const void *ptr,
cl_uint num_deps, const cl_event *deps,
cl_event *ev) try {
validate_base(q, num_deps, deps);
validate_obj(q, obj);
if (!ptr || offset > obj->size() || offset + size > obj->size())
throw error(CL_INVALID_VALUE);
hard_event *hev = new hard_event(
*q, CL_COMMAND_WRITE_BUFFER, { deps, deps + num_deps },
soft_copy_op(q,
obj, { offset }, { 1 },
ptr, { 0 }, { 1 },
{ size, 1, 1 }));
ret_object(ev, hev);
return CL_SUCCESS;
} catch (error &e) {
return e.get();
}