C++ OpenCL 只找到 iGPU 但找不到 CPU

问题描述 投票:0回答:1

正如标题所示,OpenCL API 只检测我的 Intel iGPU,而不检测 CPU 本身。为什么有什么想法吗?我已经通过包管理器安装了 Intel-opencl-icd,但似乎不足以找到 CPU。

对于上下文,这是我到目前为止的代码。

#include <iostream>
#include <vector>

#include <CL/opencl.hpp>

int main(int argc, char const *argv[])
{
    std::vector<cl::Platform> platforms;
    cl::Platform::get(&platforms);

    std::cout << "Numbers of platforms : " << platforms.size() << std::endl;

    int platform_id = 0;
    int device_id = 0;

    for(cl::vector<cl::Platform>::iterator it = platforms.begin(); it != platforms.end(); ++it){
        cl::Platform platform(*it);

        std::cout << "Platform ID: " << platform_id++ << std::endl;  
        std::cout << "Platform Name: " << platform.getInfo<CL_PLATFORM_NAME>() << std::endl;  
        std::cout << "Platform Vendor: " << platform.getInfo<CL_PLATFORM_VENDOR>() << std::endl;  

        cl::vector<cl::Device> devices;  
        platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);  

        for(cl::vector<cl::Device>::iterator it2 = devices.begin(); it2 != devices.end(); ++it2){
            cl::Device device(*it2);

            std::cout << "\tDevice " << device_id++ << ": " << std::endl;
            std::cout << "\t\tDevice Name: " << device.getInfo<CL_DEVICE_NAME>() << std::endl;  
            std::cout << "\t\tDevice Type: " << device.getInfo<CL_DEVICE_TYPE>();
            std::cout << " (GPU: " << CL_DEVICE_TYPE_GPU << ", CPU: " << CL_DEVICE_TYPE_CPU << ")" << std::endl;  
            std::cout << "\t\tDevice Vendor: " << device.getInfo<CL_DEVICE_VENDOR>() << std::endl;
            std::cout << "\t\tDevice Max Compute Units: " << device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>() << std::endl;
            std::cout << "\t\tDevice Global Memory: " << device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>() << std::endl;
            std::cout << "\t\tDevice Max Clock Frequency: " << device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>() << std::endl;
            std::cout << "\t\tDevice Max Allocateable Memory: " << device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>() << std::endl;
            std::cout << "\t\tDevice Local Memory: " << device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>() << std::endl;
            std::cout << "\t\tDevice Available: " << device.getInfo< CL_DEVICE_AVAILABLE>() << std::endl;
        }  
        std::cout<< std::endl;
    } 

    return 0;
}

从技术上讲,无法在 CPU 内核上运行代码并不是什么大问题,但我想看看使用 CPU 内核和 GPU 内核之间的速度差异,因为我刚刚开始使用 OpenCL

谢谢

c++ opencl cpu intel
1个回答
1
投票

安装最新的Intel OpenCL CPU 运行时。这适用于 Intel 和 AMD CPU。对应的 GitHub 存储库位于here

注意:请勿在 Windows 上使用旧的 16.1 或 18.1 版本(Google 搜索的第一个结果)。这些不能正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.