#include <iostream> using namespace std; //OpenCL includes #include <CL/cl.h> int main(int argc, char **argv) { //platform details cl_uint devicecount=NULL; cl_uint NumPlatforms;
//获取支持opencl device数量,对应于GPU,或CPU个数 clGetPlatformIDs (0, NULL, &NumPlatforms); cl_platform_id* PlatformIDs; PlatformIDs = new cl_platform_id[NumPlatforms];
//获得各个device的id号 clGetPlatformIDs(NumPlatforms, PlatformIDs, NULL); cl_device_id cdDevice; clGetDeviceIDs(NULL, CL_DEVICE_TYPE_CPU, 1, &cdDevice, &devicecount); cout << NumPlatforms << endl; cout << PlatformIDs << endl; cout << cdDevice << endl; cout << devicecount << endl; return 0; }