mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-17 05:41:41 +02:00
Affinity - fix C
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user