summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-11-16 12:12:40 +0100
committerGitHub <noreply@github.com>2017-11-16 12:12:40 +0100
commit1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a (patch)
treebbebd1f9969dbd09283fba5cb3ef9fc170dc0400 /xmrstak/backend
parent2c3a3484757f242cf20b8e2ca2d89cfe01f64888 (diff)
parent41eb0ad64e6d003368ccf8f3212f190a829aae10 (diff)
downloadxmr-stak-1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a.zip
xmr-stak-1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a.tar.gz
Merge pull request #115 from fireice-uk/topic-net-ext
Network extensions
Diffstat (limited to 'xmrstak/backend')
-rw-r--r--xmrstak/backend/amd/minethd.cpp2
-rw-r--r--xmrstak/backend/cpu/minethd.cpp8
-rw-r--r--xmrstak/backend/iBackend.hpp27
-rw-r--r--xmrstak/backend/nvidia/minethd.cpp2
4 files changed, 25 insertions, 14 deletions
diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp
index 94fc088..de0b6e8 100644
--- a/xmrstak/backend/amd/minethd.cpp
+++ b/xmrstak/backend/amd/minethd.cpp
@@ -241,7 +241,7 @@ void minethd::work_main()
hash_fun(bWorkBlob, oWork.iWorkSize, bResult, cpu_ctx);
if ( (*((uint64_t*)(bResult + 24))) < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, results[i], bResult), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, results[i], bResult, iThreadNo), oWork.iPoolId));
else
executor::inst()->push_event(ex_event("AMD Invalid Result", oWork.iPoolId));
}
diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp
index 8183adf..03071c4 100644
--- a/xmrstak/backend/cpu/minethd.cpp
+++ b/xmrstak/backend/cpu/minethd.cpp
@@ -358,7 +358,8 @@ void minethd::work_main()
piHashVal = (uint64_t*)(result.bResult + 24);
piNonce = (uint32_t*)(oWork.bWorkBlob + 39);
globalStates::inst().inst().iConsumeCnt++;
-
+ result.iThreadId = iThreadNo;
+
while (bQuit == 0)
{
if (oWork.bStall)
@@ -542,17 +543,16 @@ void minethd::double_work_main()
globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, nonce_chunk);
}
-
*piNonce0 = ++iNonce;
*piNonce1 = ++iNonce;
hash_fun(bDoubleWorkBlob, oWork.iWorkSize, bDoubleHashOut, ctx0, ctx1);
if (*piHashVal0 < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce-1, bDoubleHashOut), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce-1, bDoubleHashOut, iThreadNo), oWork.iPoolId));
if (*piHashVal1 < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce, bDoubleHashOut + 32), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce, bDoubleHashOut + 32, iThreadNo), oWork.iPoolId));
std::this_thread::yield();
}
diff --git a/xmrstak/backend/iBackend.hpp b/xmrstak/backend/iBackend.hpp
index dbfbc99..3d2115a 100644
--- a/xmrstak/backend/iBackend.hpp
+++ b/xmrstak/backend/iBackend.hpp
@@ -8,22 +8,33 @@
#include <vector>
#include <string>
+template <typename T, std::size_t N>
+constexpr std::size_t countof(T const (&)[N]) noexcept
+{
+ return N;
+}
+
namespace xmrstak
{
struct iBackend
{
- enum BackendType : uint32_t { UNKNOWN = 0, CPU = 1u, AMD = 2u, NVIDIA = 3u };
+ enum BackendType : uint32_t { UNKNOWN = 0u, CPU = 1u, AMD = 2u, NVIDIA = 3u };
- static std::string getName(const BackendType type)
+ static const char* getName(const BackendType type)
{
- std::vector<std::string> backendNames = {
- "UNKNOWN",
- "CPU",
- "AMD",
- "NVIDIA"
+ const char* backendNames[] = {
+ "unknown",
+ "cpu",
+ "amd",
+ "nvidia"
};
- return backendNames[static_cast<uint32_t>(type)];
+
+ uint32_t i = static_cast<uint32_t>(type);
+ if(i >= countof(backendNames))
+ i = 0;
+
+ return backendNames[i];
}
std::atomic<uint64_t> iHashCount;
diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp
index 4d9efd2..9dbd83e 100644
--- a/xmrstak/backend/nvidia/minethd.cpp
+++ b/xmrstak/backend/nvidia/minethd.cpp
@@ -283,7 +283,7 @@ void minethd::work_main()
hash_fun(bWorkBlob, oWork.iWorkSize, bResult, cpu_ctx);
if ( (*((uint64_t*)(bResult + 24))) < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, foundNonce[i], bResult), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, foundNonce[i], bResult, iThreadNo), oWork.iPoolId));
else
executor::inst()->push_event(ex_event("NVIDIA Invalid Result", oWork.iPoolId));
}
OpenPOWER on IntegriCloud