2,851
社区成员




在RB5.LU上使用“clinfo”命令可能无法显示正确的结果。
我写了一个演示,它表明该设备是可检测的。
我以下是源代码,你可以在RB5.LU2.0中构建它。
请在您当地的ENV上试用。
#include <stdio.h>
#include <stdlib.h>
#include <CL/cl.h>
#define MAX_PLATFORMS 5
#define MAX_DEVICES 10
int main() {
cl_platform_id platforms[MAX_PLATFORMS];
cl_uint num_platforms;
cl_device_id devices[MAX_DEVICES];
cl_uint num_devices;
cl_int err;
// 获取平台数量
err = clGetPlatformIDs(MAX_PLATFORMS, platforms, &num_platforms);
if (err != CL_SUCCESS) {
printf("Error getting platform IDs\n");
return EXIT_FAILURE;
}
printf("Found %u OpenCL platforms\n", num_platforms);
// 遍历每个平台
for (cl_uint i = 0; i < num_platforms; i++) {
// 获取设备数量
err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, MAX_DEVICES, devices, &num_devices);
if (err != CL_SUCCESS) {
printf("Error getting device IDs for platform %u\n", i);
continue;
}
printf("Platform %u has %u devices:\n", i, num_devices);
// 遍历每个设备
for (cl_uint j = 0; j < num_devices; j++) {
char device_name[1024];
// 获取设备名称
err = clGetDeviceInfo(devices[j], CL_DEVICE_NAME, sizeof(device_name), device_name, NULL);
if (err != CL_SUCCESS) {
printf("Error getting device name for device %u on platform %u\n", j, i);
continue;
}
printf(" Device %u: %s\n", j, device_name);
}
}
return EXIT_SUCCESS;
}