I've all ready done that I've called the method once to retrieve the param_value_size_ret and then a second time to retrieve the version after looking up the size. It says the length of the data I requested is zero.
Then post the actual code snippet you used for that. Your previous post was
not doing that. In fact, your erroneous call to clGetPlatformInfo() would have generated an OpenCL error -30 (CL_INVALID_VALUE) had you checked for the return/error code of the method call and
that is the reason why the OpenCL function aborted with an error and left you with an untouched 0 in the size buffer.
Please, again, read the documentation
https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clGetPlatformInfo.html:
Errors:
...
- CL_INVALID_VALUE if param_name is not one of the supported values or if size in bytes specified by param_value_size is less than size of return type and param_value is not a NULL value.
For once, here is one correct way of doing it:
static void assertNoError(int ret) {
if (ret != CL_SUCCESS) throw new AssertionError("OpenCL error: " + ret);
}
...
IntBuffer ib = BufferUtils.createIntBuffer(1);
assertNoError(clGetPlatformIDs(null, ib));
int numPlatforms = ib.get(0);
PointerBuffer pb = BufferUtils.createPointerBuffer(numPlatforms);
assertNoError(clGetPlatformIDs(pb, ib));
PointerBuffer size = BufferUtils.createPointerBuffer(1);
for (int i = 0; i < numPlatforms; i++) {
assertNoError(clGetPlatformInfo(pb.get(i), CL_PLATFORM_VERSION, (ByteBuffer) null, size));
int length = (int) size.get(0);
ByteBuffer bb = BufferUtils.createByteBuffer(length);
assertNoError(clGetPlatformInfo(pb.get(i), CL_PLATFORM_VERSION, bb, size));
String version = MemoryUtil.memASCII(bb, length - 1);
System.out.println(version);
}
Example output on a Quadro K2000M with driver version 377.35:
OpenCL 1.2 CUDA 8.0.0