ubuntu intel OpenCL

1.配置OpenCL
1.下载https://software.intel.com/en-us/intel-opencl
2.安装过程中会自动检查缺少的库。

2.CMakelists

include_directories(/opt/intel/opencl-sdk/include/CL)
target_link_libraries(untitled1 /opt/intel/opencl-sdk/lib64/libOpenCL.so)

3.获取平台和设备信息

#include <iostream>
#include <opencl.h>
#include <time.h>
using namespace std;


void show_platfor_device()
{
    cl_platform_id *platform;
    cl_uint num_platform;
    cl_int error;

    error = clGetPlatformIDs(0, NULL, &num_platform);
    platform = (cl_platform_id *)malloc(sizeof(cl_platform_id) * num_platform);
    error = clGetPlatformIDs(num_platform, platform, NULL);
    for (int i = 0; i < num_platform; ++i) {
        size_t size_platform;
        error = clGetPlatformInfo(platform[i], CL_PLATFORM_NAME, 0, NULL, &size_platform);
        char *name;
        name = (char *)malloc(sizeof(char) * size_platform);
        error = clGetPlatformInfo(platform[i], CL_PLATFORM_NAME, size_platform, name, NULL);
        cout << "platform:" << name << endl;
        free(name);
        cl_device_id *device_id;
        cl_uint num_device;
        error = clGetDeviceIDs(platform[i], CL_DEVICE_TYPE_ALL, 0, NULL, &num_device);
        device_id = (cl_device_id *)malloc(sizeof(cl_device_id) * num_device);
        error = clGetDeviceIDs(platform[i], CL_DEVICE_TYPE_ALL, num_device, device_id, NULL);
        for (int j = 0; j < num_device; ++j) {
            size_t size_device;
            char *name_device;
            error = clGetDeviceInfo(device_id[j], CL_DEVICE_NAME,0, NULL, &size_device);
            name_device = (char *)malloc(sizeof(char) * size_device);
            error = clGetDeviceInfo(device_id[j], CL_DEVICE_NAME, size_device, name_device, NULL);
            cout << "device  " << j << ":" <<name_device << endl;
            free(name_device);
        }
    }
}



int main()
{
    show_platfor_device();
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值