Hi,
first of all i dont know this is the right forum, pardon me.
i have some confusion in const memory in opencl. As far as i know, my current hardware supports 64k of const memory which i understood as one cannot allocate >64K const memory for a kernel, and the kernel may fail if one tries to allocate more than that. So just to test that point i created a stand alone application (linux/opencl) to test that.
clGetDeviceInfo with CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE returned 65536 bytes
later i created two read only buffer as
cl_mem buffer1 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, max_buffer,NULL,NULL); // max_buffer = 65536
cl_mem buffer2 = clCreateBuffer(ctx, CL_MEM_READ_ONLY, max_buffer,NULL,NULL);
...
..
//set it as kernel args
err |= clSetKernelArg(kernel, 4, sizeof(cl_mem), &buffer1);
err |= clSetKernelArg(kernel, 5, sizeof(cl_mem), &buffer2);
...
// write some thing into the buffers
clEnqueueWriteBuffer(cmdQ, buffer1, CL_TRUE, 0, max_buffer, buffer, 0, NULL, NULL);
// buffer is a char* array with max_buffer size and filled with 1
clEnqueueWriteBuffer(cmdQ, buffer2, CL_TRUE, 0, max_buffer, buffer, 0, NULL, NULL);
..
//execute kernel
kernel code accepts these params as __constant char* buffers and adds the two and writes to an output buffer.
my questions are
- How does the kernel accept two 64K buffer as const ?, does this overflow to global ? the opencl doc says that 64K is the max buffer size, which is not equal to max const memory size
- Is there any method by which we can make sure that the memory is indeed const.
- or am i missing something/doing wrong