timchist

CL_INVALID_PLATFORM in clGetPlatformInfo

Discussion created by timchist on Nov 16, 2010
Latest reply on Dec 1, 2010 by timchist

I have ATI 5850 and NVIDIA GTX 470 installed in one computer. I use Windows 7 64 bit, but compile a 32-bit application.

Sometimes when I try to find an AMD Open CL platform, error -32 (CL_INVALID_PLATFORM) is returned from clGetPlatformInfo.

So clGetPlatformIDs says that 2 platform present and successfully returns the list of IDs of these platforms. Then I do a loop for the platforms. Platform 0 on my system is NVIDIA, so I get its name without errors. But then when I call clGetPlatformInfo for the second platform ID (which is supposed to be AMD), I get CL_INVALID_PLATFORM.

What makes it difficult to debug that the error is not always reproduced. In most cases the program just works normally, but some builds have this error.

cl_uint numPlatforms; err = clGetPlatformIDs(0, NULL, &numPlatforms); cl_platform_id* platforms = new cl_platform_id[numPlatforms]; err = clGetPlatformIDs(numPlatforms, platforms, &numPlatforms); if(err == CL_SUCCESS) { cl_platform_id amdPlatform = NULL; for(cl_uint i = 0; i < numPlatforms; i++) { char pbuf[100]; err = clGetPlatformInfo(platforms[i], CL_PLATFORM_VENDOR, sizeof(pbuf), pbuf, NULL); if(err != CL_SUCCESS) break; if(strcmp(pbuf, "Advanced Micro Devices, Inc.") == 0) { amdPlatform = platforms[i]; break; } } if(!amdPlatform) { err = CL_DEVICE_NOT_FOUND; } else { cl_uint devCount; err = clGetDeviceIDs(amdPlatform, CL_DEVICE_TYPE_GPU, 0, NULL, &devCount); if(devCount == 0) { err = CL_DEVICE_NOT_FOUND; } } if(err == CL_DEVICE_NOT_FOUND && Log!=NULL) strcat(Log, "Failed to find ATI GPU Device." PLZ_INSTALL_ATI_DRIVER); } else { if(Log!=NULL) strcat(Log, "Failed to initialize OpenCL driver." PLZ_INSTALL_ATI_DRIVER); }

Outcomes