ikk*_*ikk 1 c linux parallel-processing cuda opencl
我有一个用 C 编写的代码(使用 opencl 规范)来列出所有可用的设备。我的电脑安装了 AMD FirePro 以及 Nvidia 的 Tesla 显卡。我首先安装了AMD-APP-SDK-v3.0-0.113.50-Beta-linux64.tar.bz2但它似乎不起作用,所以此后我安装了 OpenCL\xe2\x84\xa2 Runtime 15.1 for Intel\xc2 \xae Core\xe2\x84\xa2 和 Intel\xc2\xae Xeon\xc2\xae 处理器,适用于 Red Hat* 和 SLES* Linux* 操作系统(64 位),然后是OpenCL\xe2\x84\xa2 Code Builder。\n但是下面的代码只列出了CPU,并没有检测到2个显卡。\n
\n\nint main() {\nint i, j;\nchar* value;\nsize_t valueSize;\ncl_uint platformCount;\ncl_platform_id* platforms;\ncl_uint deviceCount;\ncl_device_id* devices;\ncl_uint maxComputeUnits;\ncl_device_type* dev_type;\n\n// get all platforms\nclGetPlatformIDs(2, NULL, &platformCount);\nplatforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);\nclGetPlatformIDs(platformCount, platforms, NULL);\n\nfor (i = 0; i < platformCount; i++) {\n\n // get all devices\n clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &deviceCount);\n devices = (cl_device_id*) malloc(sizeof(cl_device_id) * deviceCount);\n clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, deviceCount, devices, NULL);\n\n\n\nclGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, 0, NULL, &valueSize);\n value = (char*) malloc(valueSize);\n clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, valueSize, value, NULL);\n printf("\\n%d. Platform: %sn", j+1, value);\n free(value);\n\n // for each device print critical attributes\n for (j = 0; j < deviceCount; j++) {\n\n // print device name\n clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize);\n value = (char*) malloc(valueSize);\n clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL);\n printf("\\n%d.%d Device: %sn", j+1,1, value);\n free(value);\n\n // print hardware device version\n clGetDeviceInfo(devices[j], CL_DEVICE_TYPE, 0, NULL, &valueSize);\n dev_type = (cl_device_type*) malloc(valueSize);\n clGetDeviceInfo(devices[j], CL_DEVICE_TYPE, valueSize, dev_type, NULL);\n if(*dev_type==CL_DEVICE_TYPE_CPU)\n printf("\\nIts a CPU.");\n if(*dev_type==CL_DEVICE_TYPE_GPU)\n printf("\\nIts a GPU.");\n if(*dev_type==CL_DEVICE_TYPE_ACCELERATOR)\n printf("\\nIts a ACCELERATOR.");\n\n free(dev_type);\n\n // print software driver version\n clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, 0, NULL, &valueSize);\n value = (char*) malloc(valueSize);\n clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, valueSize, value, NULL);\n printf(" \\n%d.%d Software version: %sn", j+1, 2, value);\n free(value);\n\n\n // print parallel compute units\n clGetDeviceInfo(devices[j], CL_DEVICE_MAX_COMPUTE_UNITS,\n sizeof(maxComputeUnits), &maxComputeUnits, NULL);\n printf(" \\n%d.%d Parallel compute units: %dn\\n", j+1, 4, maxComputeUnits);\n\n }\n\n free(devices);\n\n}\n\nfree(platforms);\nreturn 0;}\nRun Code Online (Sandbox Code Playgroud)\n\n这是它返回的内容:
\n\ngcc -lOpenCL 1.c -o 1 && ./1\n1. Platform: AMD Accelerated Parallel Processingn\n1.1 Device: Intel(R) Xeon(R) CPU X5660 @ 2.80GHzn\nIts a CPU. \n1.2 Software version: 1642.5 (sse2)n \n1.4 Parallel compute units: 24n\nRun Code Online (Sandbox Code Playgroud)\n\n我需要安装任何其他驱动程序还是代码有问题?
\n