在多GPU系统中,如何在给定PCI供应商,设备和总线ID的情况下将OpenCL设备与特定的GPU匹配? [英] How to match OpenCL devices with a specific GPU given PCI vendor, device and bus IDs in a multi-GPU system?

查看:185
本文介绍了在多GPU系统中,如何在给定PCI供应商,设备和总线ID的情况下将OpenCL设备与特定的GPU匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PCI ID标识的多GPU系统上,我希望能够将OpenCL设备与系统中的GPU匹配.

I would like to be able to match OpenCL devices with GPUs in the system on multi-GPU systems identified by PCI IDs.

例如,如果我有一个带有多个GPU(可能来自不同供应商)的系统,则可以通过枚举PCI总线来列出设备.这给了我PCI供应商,设备和总线ID.如果我根据某些选择标准选择这些(GPU)PCI设备之一进行OpenCL计算,该如何将其与OpenCL设备进行匹配?

For example, if I have a system with multiple GPUs, possibly from different vendors, I can list the devices by enumerating the PCI bus. This gives me PCI vendor, device and bus IDs. If I choose one of these (GPU) PCI devices to use for OpenCL computation based on some selection criteria, how do I match it to the OpenCL device?

我可以使用 clGetDeviceIDs()枚举OpenCL中的GPU设备,但是没有明显的方法可以将OpenCL设备与PCI设备进行匹配. OpenCL函数 clGetDeviceInfo()提供对PCI供应商ID和设备名称的访问,但不能访问PCI设备或总线ID.我可以尝试将PCI设备名称与OpenCL设备名称匹配,但是您可能有多个相同类型的设备,而且名称始终不一定相同.

I can enumerate GPU devices in OpenCL using clGetDeviceIDs() but there is no obvious way to match OpenCL devices to PCI devices. The OpenCL function clGetDeviceInfo() provides access to the PCI vendor ID and device name but not PCI device or bus IDs. I could try to match the PCI device name with the OpenCL device name but it's possible that you have more than one of the same type of device and the names are not always the same anyway.

为什么这是必要的?假设我知道程序X在GPU A上运行CUDA或其他功能.我想避免同时使用GPU A进行OpenCL操作,因此选择GPUB.然后,我需要确定哪个OpenCL设备是GPU A,哪个是GPU B. PCI ID似乎是识别GPU设备的唯一一致且跨平台的方式.

Why is this necessary? Say I know that program X is running CUDA or something else on GPU A. I want to avoid also using GPU A for an OpenCL operation so I choose GPU B. I then need to figure out which OpenCL device is GPU A and which is GPU B. PCI IDs seem to be the only consistent and cross platform way of identifying GPU devices.

顺便说一句,CUDA API确实提供了PCI,总线和插槽ID(CU_DEVICE_ATTRIBUTE_PCI_BUS_ID,CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID),但CUDA仅适用于NVidia设备.

BTW, the CUDA API does give you PCI, bus and slot IDs (CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID) but CUDA only works with NVidia devices.

理想情况下,我需要使用C或C ++的解决方案.

Ideally I need a solution using either C or C++.

推荐答案

做到这一点的方法是使用两个特定于供应商的扩展.对于AMD,您必须使用在Windows和Linux上均可使用的CL_DEVICE_TOPOLOGY_AMD,并且将返回PCIe总线ID,这对于GPU是唯一的.在NVIDIA上,在设备上查询CL_DEVICE_PCI_BUS_ID_NV.另请参阅: https://anteru.net/2014/08/01/2483/

The way to do it is to use two vendor-specific extensions. For AMD, you have to use CL_DEVICE_TOPOLOGY_AMD which works on Windows and Linux and will return the PCIe bus id, which is unique for a GPU. On NVIDIA, query the device for CL_DEVICE_PCI_BUS_ID_NV. See also: https://anteru.net/2014/08/01/2483/

这篇关于在多GPU系统中,如何在给定PCI供应商,设备和总线ID的情况下将OpenCL设备与特定的GPU匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆