我无法识别不同的gpus。这是我的代码,据我所知,它应该返回不同的总线/设备/功能号,但是我对所有gpus都是一样的。任何帮助将不胜感激。
int main()
{
cl_platform_id* platformIDs = nullptr;
cl_uint platformCount = 0;
clGetPlatformIDs(0, nullptr, &platformCount);
platformIDs = new cl_platform_id[platformCount];
clGetPlatformIDs(platformCount, platformIDs, nullptr);
for (cl_uint i = 0; i < platformCount; i++)
{
cl_uint deviceCount;
clGetDeviceIDs(platformIDs[i], CL_DEVICE_TYPE_GPU, 0, nullptr, &deviceCount);
cl_device_id* deviceIDs = new cl_device_id[deviceCount];
clGetDeviceIDs(platformIDs[i], CL_DEVICE_TYPE_GPU, deviceCount, deviceIDs, nullptr);
for (cl_uint j = 0; j < deviceCount; j++)
{
cl_device_topology_amd amdtopo;
cl_int clret = clGetDeviceInfo(deviceIDs[j], CL_DEVICE_TOPOLOGY_AMD, sizeof(amdtopo), &amdtopo, nullptr);
std::cout << "platform=" << i << "; device=" << j << "; ";
if (clret == CL_SUCCESS)
{
if (amdtopo.raw.type == CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD)
{
std::cout <<
"bus=" << (int)amdtopo.pcie.bus <<
"; device=" << (int)amdtopo.pcie.device <<
"; function=" << (int)amdtopo.pcie.function <<
";";
}
else
{
std::cout << "not amd";
}
}
else
{
std::cout << "error";
}
std::cout << "\n";
}
}
}
这是我在12 amd gpus的机器上得到的输出:
C:\Users\x>gpuid.exe
platform=0; device=0; error
platform=1; device=0; bus=0; device=0; function=1;
platform=1; device=1; bus=0; device=0; function=1;
platform=1; device=2; bus=0; device=0; function=1;
platform=1; device=3; bus=0; device=0; function=1;
platform=1; device=4; bus=0; device=0; function=1;
platform=1; device=5; bus=0; device=0; function=1;
platform=1; device=6; bus=0; device=0; function=1;
platform=1; device=7; bus=0; device=0; function=1;
platform=1; device=8; bus=0; device=0; function=1;
platform=1; device=9; bus=0; device=0; function=1;
platform=1; device=10; bus=0; device=0; function=1;
platform=1; device=11; bus=0; device=0; function=1;