Doing some experimentation with OpenCL this morning, and I noticed that clGetPlatformIDs crashes when num_entries is >= 6. For anything less than that, it works just fine; however, the OpenCL spec (1.0.48) doesn’t say anything about there being a limitation on this parameter…so it should be able to handle anything up to (unsigned int)(0xFFFFFFFF).
For me, on Win32XP, driver 195.62, I only get errors if I don’t allocate the memory to fit all the num_entries, even large numbers (tried 1000000) work as long as the memory is allocated.
Are you sure you have the memory allocated for “num_entries” platform ids?
The OpenCL spec doesn’t say what should happen to rest of the memory that is meant to be allocated for potential platforms, but that isn’t in the actual range of devices returned: {0…num_platforms-1}. It seems the NVidia driver chooses to zero out the rest of the memory {num_platforms…num_entries-1} too and this causes an AV if it isn’t actually allocated.
You can get the number of platforms that will be returned before actually returning the ids, and then allocate the memory by performing something similar to this:
Nope, it still crashes for me even if I allocate the memory. I’m using the OpenCL driver via .NET P/Invoke calls (in C#), but I don’t see why that would matter (I’ve been using CUDA that way for a long time now.)