是否能够使用RB5的GPU运行OpenCL?

weixin_32298029 2024-11-01 15:56:24

是否能够使用RB5的GPU运行OpenCL?

...全文
754 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38498942 2024-11-07
  • 打赏
  • 举报
回复

在RB5.LU上使用“clinfo”命令可能无法显示正确的结果。
我写了一个演示,它表明该设备是可检测的。

img

我以下是源代码,你可以在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;
}

2,851

社区成员

发帖
与我相关
我的任务
社区描述
本论坛以AI、WoS 、XR、IoT、Auto、生成式AI等核心板块组成,为开发者提供便捷及高效的学习和交流平台。 高通开发者专区主页:https://qualcomm.csdn.net/
人工智能物联网机器学习 技术论坛(原bbs) 北京·东城区
社区管理员
  • csdnsqst0050
  • chipseeker
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧