Query regarding OpenCL function clEnqueueReadBuffer

Hello everyone,

I am using one single kernel and I have to perform computation on both the CPU and GPU simultaneously. Then, I am copying the result onto one variable but the initial value comes from the CPU and the rest values come from the GPU. But, I am getting errors while copying data back from the GPU.

Could someone point out the mistake that I have done?

It is very urgent.


int splittingPoint = (nrows * 1)/DIM_LOCAL_WORK_GROUP_Y;
size_t readoffsetCPU;
size_t readoffsetGPU;
size_t readsizeCPU;
size_t readsizeGPU;
readoffsetCPU = 0;
readoffsetGPU = sizeof(DATA_TYPE) * ((size_t)ceil(splittingPoint) * DIM_LOCAL_WORK_GROUP_Y) * ncols;
readsizeCPU = readoffsetGPU;
readsizeGPU = sizeof(DATA_TYPE) * ((size_t)ceil(((float)nrows) / ((float)DIM_LOCAL_WORK_GROUP_Y) - splittingPoint) * DIM_LOCAL_WORK_GROUP_Y) * ncols;

errcode = clEnqueueReadBuffer(clCPUCommandQue, ptrout_mem_objCPU, CL_TRUE, readoffsetCPU, readsizeCPU, ptrout, 0, NULL, NULL);
if(errcode != CL_SUCCESS) printf("##Error in reading CPU mem

errcode = clEnqueueReadBuffer(clGPUCommandQue, ptrout_mem_objGPU, CL_TRUE, readoffsetGPU, readsizeGPU, ptrout + ((splittingPoint) * DIM_LOCAL_WORK_GROUP_Y) * ncols, 0, NULL, NULL);
if(errcode != CL_SUCCESS) printf("##Error in reading GPU mem

I am trying to copy the data on the memory location pointed by the ‘ptrout’ pointer.