Here I have NVidia CUDA SDK & Intel OpenCL SDK installed in my machine. And here is code to enumerate all the devices in all the platforms.
vector< cl::Platform > platforms; try { cl::Platform::get( &platforms ); for( cl_uint n=0; n < platforms.size(); ++n ) { string platformName = platforms[n].getInfo< CL_PLATFORM_NAME >(); cout << "Platform : @ " << platformName.c_str() << endl; vector< cl::Device > devices, ctxDevices; platforms[n].getDevices( CL_DEVICE_TYPE_ALL, &devices ); cl::Context context( devices ); ctxDevices = context.getInfo< CL_CONTEXT_DEVICES >(); for( cl_uint i=0; i < ctxDevices.size(); ++i ) { string deviceName = ctxDevices[i].getInfo< CL_DEVICE_NAME >(); cout << "Device: @ " << deviceName.c_str() << endl; } } } catch( cl::Error e ) { cout << e.what() << ": Error Code " << e.err() << endl; }
Above code is linked with library OpenCL.lib come with NVidia CUDA SDK. It prints out below which enumerate all the OpenCL enabled devices incluing Intel OpenCL device.
Platform : @ NVIDIA CUDA Device: @ GeForce GT 640 Platform : @ Intel(R) OpenCL Device: @ Intel(R) Pentium(R) CPU G2120 @ 3.10GHz
This collaboration is based on the registery key \HKLM\SOFTWARE\Khronos\OpenCL\Vendors . Refer below. I guess OpenCL.lib must loadup all these dll and asks to communicate it's devices under control.
No comments:
Post a Comment