How to write/read a single float value(buffer) from OpenCL device
问题 There are lots of questions about how to read an array from the device, but I only wanna read a single float value from the device. Or it only can read an array from the device? I create a buffer for (float) sum like below. ocl.sum = clCreateBuffer(context, CL_MEM_READ_WRITE, 1, NULL, &err); Set the arg like this. clSetKernelArg(kernel, 0, sizeof(cl_men), &ocl.arr); clSetKernelArg(kernel, 1, sizeof(cl_float), &ocl.sum); In the kernel, I calculate the sum. kernel calculate(global arr, float