Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Fix lack of uniqueId on AMD GPU OpenCL without AMD extensions #2333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hunter_config(CURL VERSION ${HUNTER_CURL_VERSION} CMAKE_ARGS HTTP_ONLY=ON CMAKE_USE_OPENSSL=OFF CMAKE_USE_LIBSSH2=OFF CURL_CA_PATH=none)
hunter_config(Boost VERSION 1.66.0)
hunter_config(Boost VERSION ${HUNTER_Boost_VERSION})
34 changes: 30 additions & 4 deletions libethash-cl/CLMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,19 +509,45 @@ void CLMiner::enumDevices(std::map<string, DeviceDescriptor>& _DevicesCollection
<< (unsigned int)(slot_id >> 3) << "." << (unsigned int)(slot_id & 0x7);
uniqueId = s.str();
}
else
{
/* No Nvidia extensions */
std::ostringstream s;
s << "Nvidia:" << pIdx << "." << dIdx;
uniqueId = s.str();
}
}
else if (clDeviceType == DeviceTypeEnum::Gpu &&
(platformType == ClPlatformTypeEnum::Amd ||
platformType == ClPlatformTypeEnum::Clover))
{
cl_char t[24];
if (clGetDeviceInfo(device.get(), 0x4037, sizeof(t), &t, NULL) == CL_SUCCESS)
struct amd_topo {
cl_char padding[21];
cl_char bus;
cl_char device;
cl_char function;
} amd_topo;

if (clGetDeviceInfo(device.get(), CL_DEVICE_TOPOLOGY_AMD,
sizeof(amd_topo), &amd_topo, NULL)
== CL_SUCCESS)
{
std::ostringstream s;
s << setfill('0') << setw(2) << hex << (unsigned int)(t[21]) << ":" << setw(2)
<< (unsigned int)(t[22]) << "." << (unsigned int)(t[23]);
s << setfill('0') << setw(2) << hex
<< (unsigned int)(amd_topo.bus)
<< ":" << setw(2)
<< (unsigned int)(amd_topo.device)
<< "."
<< (unsigned int)(amd_topo.function);
uniqueId = s.str();
}
else
{
/* No AMD extensions */
std::ostringstream s;
s << "AMD:" << pIdx << "." << dIdx;
uniqueId = s.str();
}
}
else if (clDeviceType == DeviceTypeEnum::Gpu && platformType == ClPlatformTypeEnum::Intel)
{
Expand Down
4 changes: 4 additions & 0 deletions libethash-cl/CLMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
#endif

#ifndef CL_DEVICE_TOPOLOGY_AMD
#define CL_DEVICE_TOPOLOGY_AMD 0x4037
#endif

namespace dev
{
namespace eth
Expand Down