Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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
4 changes: 2 additions & 2 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
hunter_config(CURL VERSION ${HUNTER_CURL_VERSION} CMAKE_ARGS HTTP_ONLY=ON CMAKE_USE_OPENSSL=ON CMAKE_USE_LIBSSH2=OFF CURL_CA_PATH=none)
hunter_config(Boost VERSION 1.70.0-p0)
hunter_config(Boost VERSION ${HUNTER_Boost_VERSION})

hunter_config(ethash VERSION 1.0.0
URL https://github.com/RavenCommunity/cpp-kawpow/archive/1.1.0.tar.gz
SHA1 fff78f555a43900b6726c131305a71be769ef769
)
)
33 changes: 29 additions & 4 deletions libethash-cl/CLMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,42 @@ 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)(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 << setfill('0') << setw(2) << hex << (unsigned int)(t[21]) << ":" << setw(2)
<< (unsigned int)(t[22]) << "." << (unsigned int)(t[23]);
s << "AMD:" << pIdx << "." << dIdx;
uniqueId = s.str();
}
}
Expand Down
5 changes: 5 additions & 0 deletions libethash-cl/CLMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define CL_HPP_TARGET_OPENCL_VERSION 120
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#include "CL/cl2.hpp"
#include <CL/cl_ext.h>
#pragma GCC diagnostic pop

// macOS OpenCL fix:
Expand All @@ -37,6 +38,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