summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend/cpu
diff options
context:
space:
mode:
authorfireice-uk <fireice-uk@users.noreply.github.com>2017-10-12 12:38:14 +0100
committerfireice-uk <fireice-uk@users.noreply.github.com>2017-10-12 12:38:14 +0100
commit73482f3065af13de1140308f65371d059df7decf (patch)
tree24eddb96df9e00c180eb670f5b2862df4e8ed82f /xmrstak/backend/cpu
parent329a6d9ad172b5c9c4296a5762b039abac1881cb (diff)
downloadxmr-stak-73482f3065af13de1140308f65371d059df7decf.zip
xmr-stak-73482f3065af13de1140308f65371d059df7decf.tar.gz
Affinity - fix B
Diffstat (limited to 'xmrstak/backend/cpu')
-rw-r--r--xmrstak/backend/cpu/minethd.cpp16
-rw-r--r--xmrstak/backend/cpu/minethd.hpp1
2 files changed, 9 insertions, 8 deletions
diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp
index 1f0f2b1..51091bf 100644
--- a/xmrstak/backend/cpu/minethd.cpp
+++ b/xmrstak/backend/cpu/minethd.cpp
@@ -106,6 +106,9 @@ minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefet
oWorkThd = std::thread(&minethd::double_work_main, this);
else
oWorkThd = std::thread(&minethd::work_main, this);
+
+ if(!thd_setaffinity(oWorkThd.native_handle(), affinity))
+ printer::inst()->print_msg(L1, "WARNING setting affinity failed.");
}
cryptonight_ctx* minethd::minethd_alloc_ctx()
@@ -258,7 +261,13 @@ std::vector<iBackend*> minethd::thread_starter(uint32_t threadOffset, miner_work
pvThreads.push_back(thd);
if(cfg.iCpuAff >= 0)
+ {
+#if defined(__APPLE__)
+ printer::inst()->print_msg(L1, "WARNING on MacOS thread affinity is only advisory.");
+#endif
+
printer::inst()->print_msg(L1, "Starting %s thread, affinity: %d.", cfg.bDoubleMode ? "double" : "single", (int)cfg.iCpuAff);
+ }
else
printer::inst()->print_msg(L1, "Starting %s thread, no affinity.", cfg.bDoubleMode ? "double" : "single");
}
@@ -296,15 +305,8 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch)
void minethd::pin_thd_affinity()
{
- //Lock is needed because we need to use oWorkThd
std::lock_guard<std::mutex> lock(work_thd_mtx);
-#if defined(__APPLE__)
- printer::inst()->print_msg(L1, "WARNING on MacOS thread affinity is only advisory.");
-#endif
- if(!thd_setaffinity(oWorkThd.native_handle(), affinity))
- printer::inst()->print_msg(L1, "WARNING setting affinity failed.");
-
// pin memory to NUMA node
bindMemoryToNUMANode(affinity);
}
diff --git a/xmrstak/backend/cpu/minethd.hpp b/xmrstak/backend/cpu/minethd.hpp
index 584fb0d..ad75d07 100644
--- a/xmrstak/backend/cpu/minethd.hpp
+++ b/xmrstak/backend/cpu/minethd.hpp
@@ -46,7 +46,6 @@ private:
miner_work oWork;
void pin_thd_affinity();
- // Held by the creating context to prevent a race cond with oWorkThd = std::thread(...)
std::mutex work_thd_mtx;
std::thread oWorkThd;
OpenPOWER on IntegriCloud