系统软件层

该程序使用 SYCL 获取设备信息,并提取设备的名称、最大计算单元数和全局内存大小等信息,并将这些信息打印到控制台。

示例代码:

#include <CL/sycl.hpp>
#include <iostream>

int main() {
    try {
        // sycl::default_selector_v
        sycl::default_selector selector; 
        sycl::queue queue(selector);

        // device
        sycl::device device = queue.get_device();

        std::cout << "Device Name: " << device.get_info<sycl::info::device::name>() << std::endl;
        std::cout << "Device Vendor: " << device.get_info<sycl::info::device::vendor>() << std::endl;
        std::cout << "Max Compute Units: " << device.get_info<sycl::info::device::max_compute_units>() << std::endl;
        std::cout << "Global Memory Size: " << device.get_info<sycl::info::device::global_mem_size>() / (1024 * 1024) << " MB" << std::endl;
    } catch (const sycl::exception& e) {
        std::cerr << "SYCL exception caught: " << e.what() << std::endl;
        return 1;
    }

    return 0;
}

结果:

Device Name: NVIDIA GeForce RTX 2080 Ti
Device Vendor: NVIDIA Corporation
Max Compute Units: 68
Global Memory Size: 11002 MB