Using clCreateSubBuffer

淺唱寂寞╮ 提交于 2019-12-06 15:51:52

问题


I am trying to use create a subBuffer to read in a chunk of the buffer created from a 1-D vector. This is the code I am using:

d_treeArray = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_uint)*total,NULL,&err);
cl_buffer_region region;
region.origin = 0; // This works
//region.origin = 4; // This doesnt work
region.size = 10*sizeof(cl_uint);
d_subtreeArray = clCreateSubBuffer(d_treeArray,CL_MEM_READ_WRITE,CL_BUFFER_CREATE_TYPE_REGION, &region, &err);
if(err != CL_SUCCESS) {
      std::cout << "Cannot set buffers" << std::endl;
      exit(1);
}

Now when I give the region.origin as anything other than 0, I am getting -13 error (CL_INVALID_VALUE) which according to the help, means the region origin and size is out of bounds of the buffer. What might be the reason for this?


回答1:


I believe the error code -13 is for CL_MISALIGNED_SUB_BUFFER_OFFSET. Make sure the offset is aligned to the device's' CL_DEVICE_MEM_BASE_ADDR_ALIGN. The value is usually between 1024 and 4096.



来源:https://stackoverflow.com/questions/17575032/using-clcreatesubbuffer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!