To create a opencl application the fist step is to get platforms by using
clGetPlatformIDs
I have a problem with the platforms that return from function ;the function return that i have 2 platforms but when i check them i found that i have one platform but it’s duplicated !!
source code
struct PLATFORM
{
cl_platform_id _Platforms ;
map <cl_platform_info , char*> _Platforms_info ;
};
cl_int error ;
cl_uint temp_num_platforms ;
error = clGetPlatformIDs (NULL , NULL , &temp_num_platforms );
if ( error != CL_SUCCESS )
{
/* create error and debug function*/
cout << " error detect platforms " << endl << endl ;
}
else
{
cout << " we detect " << temp_num_platforms << " platforms " << endl << endl ;
_Platforms = std::unique_ptr < PLATFORM [] > ( new PLATFORM [temp_num_platforms] ) ;
for ( unsigned int num_platforms = 1 ; num_platforms <= temp_num_platforms ; num_platforms++ )
{
// get platforms
error = clGetPlatformIDs (num_platforms ,&_Platforms[num_platforms-1]._Platforms , NULL );
if ( error != CL_SUCCESS || _Platforms[num_platforms-1]._Platforms == NULL )
{
cout << " error get platform " << num_platforms - 1 << endl << endl;
}
else
{
cout << " OK ! we detect "<< num_platforms << " platform " << endl << endl ;
}
}
}
if ( _Platforms[0]._Platforms == _Platforms[1]._Platforms )
{
cout << " we have two platforms" << endl << endl ;
}
You haven’t said much about your installation platform. My guess is that you have installed multiple versions of the OpenCL SDK from some vendor. That, or you’ve hit a bug. Try the program below, which prints out the vendor, name, and version of all the platforms reported on your system. It might help you understand your problem better.
If you see two identical vendor-name-versions strings, then it’s a bug. File it with your OpenCL vendor, and they’ll thank you!