summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend/nvidia
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-10-26 23:09:14 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-10-26 23:09:14 +0200
commitb685c90fc2d9d76017565d84a73b92a64ca4843c (patch)
treeb4cdf2191c4e11f00af708569cacacc36223dddc /xmrstak/backend/nvidia
parent712f7b7bdb02d05aaffc5f70817aeb1edd17a2b3 (diff)
downloadxmr-stak-b685c90fc2d9d76017565d84a73b92a64ca4843c.zip
xmr-stak-b685c90fc2d9d76017565d84a73b92a64ca4843c.tar.gz
thread affinity for non cpu backends
This is a follow up of #43 and use the some mechanism to set the thread affinity for non cpu backends correct. - use cpu affinity workflow for nvidia and amd - cpu: move messages of thread spawning before thread creation
Diffstat (limited to 'xmrstak/backend/nvidia')
-rw-r--r--xmrstak/backend/nvidia/minethd.cpp27
-rw-r--r--xmrstak/backend/nvidia/minethd.hpp4
2 files changed, 24 insertions, 7 deletions
diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp
index 7549c86..b9ad549 100644
--- a/xmrstak/backend/nvidia/minethd.cpp
+++ b/xmrstak/backend/nvidia/minethd.cpp
@@ -31,6 +31,7 @@
#include "xmrstak/misc/executor.hpp"
#include "xmrstak/jconf.hpp"
#include "xmrstak/misc/environment.hpp"
+#include "xmrstak/backend/cpu/hwlocMemory.hpp"
#include <assert.h>
#include <cmath>
@@ -73,8 +74,16 @@ minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg)
ctx.device_threads = (int)cfg.threads;
ctx.device_bfactor = (int)cfg.bfactor;
ctx.device_bsleep = (int)cfg.bsleep;
+ this->affinity = cfg.cpu_aff;
+
+ std::future<void> order_guard = order_fix.get_future();
oWorkThd = std::thread(&minethd::work_main, this);
+
+ order_guard.wait();
+
+ if(!cpu::minethd::thd_setaffinity(oWorkThd.native_handle(), affinity))
+ printer::inst()->print_msg(L1, "WARNING setting affinity failed.");
}
@@ -147,22 +156,21 @@ std::vector<iBackend*>* minethd::thread_starter(uint32_t threadOffset, miner_wor
for (i = 0; i < n; i++)
{
jconf::inst()->GetGPUThreadConfig(i, cfg);
- minethd* thd = new minethd(pWork, i + threadOffset, cfg);
if(cfg.cpu_aff >= 0)
{
#if defined(__APPLE__)
printer::inst()->print_msg(L1, "WARNING on MacOS thread affinity is only advisory.");
#endif
- cpu::minethd::thd_setaffinity(thd->oWorkThd.native_handle(), cfg.cpu_aff);
- }
+ printer::inst()->print_msg(L1, "Starting NVIDIA GPU thread %d, affinity: %d.", i, (int)cfg.cpu_aff);
+ }
+ else
+ printer::inst()->print_msg(L1, "Starting NVIDIA GPU thread %d, no affinity.", i);
+
+ minethd* thd = new minethd(pWork, i + threadOffset, cfg);
pvThreads->push_back(thd);
- if(cfg.cpu_aff >= 0)
- printer::inst()->print_msg(L1, "Starting GPU thread, affinity: %d.", (int)cfg.cpu_aff);
- else
- printer::inst()->print_msg(L1, "Starting GPU thread, no affinity.");
}
return pvThreads;
@@ -191,6 +199,11 @@ void minethd::consume_work()
void minethd::work_main()
{
+ if(affinity >= 0) //-1 means no affinity
+ bindMemoryToNUMANode(affinity);
+
+ order_fix.set_value();
+
uint64_t iCount = 0;
cryptonight_ctx* cpu_ctx;
cpu_ctx = cpu::minethd::minethd_alloc_ctx();
diff --git a/xmrstak/backend/nvidia/minethd.hpp b/xmrstak/backend/nvidia/minethd.hpp
index 657ee6a..d1fce40 100644
--- a/xmrstak/backend/nvidia/minethd.hpp
+++ b/xmrstak/backend/nvidia/minethd.hpp
@@ -12,6 +12,7 @@
#include <thread>
#include <atomic>
#include <vector>
+#include <future>
namespace xmrstak
@@ -43,7 +44,10 @@ private:
static miner_work oGlobalWork;
miner_work oWork;
+ std::promise<void> order_fix;
+
std::thread oWorkThd;
+ int64_t affinity;
nvid_ctx ctx;
OpenPOWER on IntegriCloud