【问题标题】:How do you make SYCL "default_selector" select an Intel GPU rather than an NVIDIA GPU?如何让 SYCL“default_selector”选择 Intel GPU 而不是 NVIDIA GPU?
【发布时间】:2019-11-27 00:41:06
【问题描述】:

我目前正在使用 SYCL 对图像应用非锐化蒙版的项目。我的机器里面有一个 NVIDIA 和一个 Intel GPU。我从以下代码开始:

default_selector deviceSelector;
queue myQueue(deviceSelector);

问题在于代码行“default_selector deviceSelector;”自动抓取我机器内的 NVIDIA GPU,这会破坏后面的所有代码,因为 SYCL 不适用于 NVIDIA。

因此我的问题是 - 我如何强制“default_selector deviceSelector;”获取我的 Intel GPU 而不是 NVIDIA GPU?也许我可以这样说:

if (device.has_extension(cl::sycl::string_class("Intel"))) 
   if (device.get_info<info::device::device_type>() == info::device_type::gpu)
       then select this GPU;//pseudo code 

从而使代码跳过NVIDIA GPU并保证选择我的Intel GPU。

【问题讨论】:

    标签: gpu sycl


    【解决方案1】:

    您正在检查扩展程序是否包含一个名为“Intel”的条目,但它不会。扩展是设备支持的东西,比如 SPIR-V 你可以通过在命令行调用 clinfo 来查看支持的扩展。要选择 Intel GPU,您需要检查设备制造商以选择正确的。

    所以在自定义设备选择的示例代码https://github.com/codeplaysoftware/computecpp-sdk/blob/master/samples/custom-device-selector.cpp#L46

    你只需要像

    这样的东西
    if (device.get_info<info::device::name>() == "Name of device") {
            return 100;
          }
    

    你可以打印出

    的值
    device.get_info<info::device::name>
    

    获取要检查的值。

    【讨论】:

      猜你喜欢
      • 2019-10-23
      • 1970-01-01
      • 2017-06-16
      • 2018-07-21
      • 2021-04-07
      • 2014-08-03
      • 2015-01-10
      • 1970-01-01
      • 2019-06-15
      相关资源
      最近更新 更多