Пример #1
0
cl_int
clRetainMemObject(cl_mem memobj)
{
    if (!memobj->isA(Coal::Object::T_MemObject))
        return CL_INVALID_MEM_OBJECT;

    memobj->reference();

    return CL_SUCCESS;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
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;
}
Пример #5
0
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
0
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);
}