识别 AMD GPU
Identifying amd gpus
我无法区分不同的 GPU。这是我的代码,据我所知,它应该 return 不同的 bus/device/function 数字,但是我对所有 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 GPU 的机器上获得的输出:
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;
事实证明,最近的 amd 驱动程序存在错误:
https://community.amd.com/thread/224200
我无法区分不同的 GPU。这是我的代码,据我所知,它应该 return 不同的 bus/device/function 数字,但是我对所有 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 GPU 的机器上获得的输出:
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;
事实证明,最近的 amd 驱动程序存在错误: https://community.amd.com/thread/224200