Affinity - fix C

This commit is contained in:
fireice-uk
2017-10-12 12:52:50 +01:00
parent 73482f3065
commit 8bbdd45b9e
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -101,12 +101,15 @@ minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefet
bNoPrefetch = no_prefetch;
this->affinity = affinity;
std::lock_guard<std::mutex> lock(work_thd_mtx);
std::future<void> order_guard = order_fix.get_future();
if(double_work)
oWorkThd = std::thread(&minethd::double_work_main, this);
else
oWorkThd = std::thread(&minethd::work_main, this);
order_guard.wait();
if(!thd_setaffinity(oWorkThd.native_handle(), affinity))
printer::inst()->print_msg(L1, "WARNING setting affinity failed.");
}
@@ -305,8 +308,6 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch)
void minethd::pin_thd_affinity()
{
std::lock_guard<std::mutex> lock(work_thd_mtx);
// pin memory to NUMA node
bindMemoryToNUMANode(affinity);
}
@@ -316,6 +317,8 @@ void minethd::work_main()
if(affinity >= 0) //-1 means no affinity
pin_thd_affinity();
order_fix.set_value();
cn_hash_fun hash_fun;
cryptonight_ctx* ctx;
uint64_t iCount = 0;
+2 -2
View File
@@ -8,7 +8,7 @@
#include <thread>
#include <vector>
#include <atomic>
#include <mutex>
#include <future>
namespace xmrstak
{
@@ -46,7 +46,7 @@ private:
miner_work oWork;
void pin_thd_affinity();
std::mutex work_thd_mtx;
std::promise<void> order_fix;
std::thread oWorkThd;
int64_t affinity;