Skip to content

Commit

Permalink
Merge pull request #225 from fireice-uk/topic-bug-squashing
Browse files Browse the repository at this point in the history
Topic bug squashing
  • Loading branch information
psychocrypt authored Jul 19, 2017
2 parents e1ce614 + 06402d7 commit 5452906
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion autoAdjustHwloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class autoAdjust
cores.reserve(16);
findChildrenByType(obj, HWLOC_OBJ_CORE, [&cores](hwloc_obj_t found) { cores.emplace_back(found); } );

size_t cacheHashes = (cacheSize + hashSize/2u - 1) / hashSize;
size_t cacheHashes = (cacheSize + hashSize/2) / hashSize;

//Firstly allocate PU 0 of every CORE, then PU 1 etc.
size_t pu_id = 0;
Expand Down
28 changes: 15 additions & 13 deletions minethd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void telemetry::push_perf_value(size_t iThd, uint64_t iHashCount, uint64_t iTime
iBucketTop[iThd] = (iTop + 1) & iBucketMask;
}

minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefetch, int affinity)
minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefetch, int64_t affinity)
{
oWork = pWork;
bQuit = 0;
Expand Down Expand Up @@ -307,15 +307,6 @@ std::vector<minethd*>* minethd::thread_starter(miner_work& pWork)
jconf::inst()->GetThreadConfig(i, cfg);

minethd* thd = new minethd(pWork, i, cfg.bDoubleMode, cfg.bNoPrefetch, cfg.iCpuAff);

if(cfg.iCpuAff >= 0)
{
#if defined(__APPLE__)
printer::inst()->print_msg(L1, "WARNING on MacOS thread affinity is only advisory.");
#endif
thd_setaffinity(thd->oWorkThd.native_handle(), cfg.iCpuAff);
}

pvThreads->push_back(thd);

if(cfg.iCpuAff >= 0)
Expand Down Expand Up @@ -370,11 +361,22 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch)
return func_table[digit.to_ulong()];
}

void minethd::work_main()
void minethd::pin_thd_affinity()
{
// pin memory to NUMA node
bindMemoryToNUMANode(affinity);

#if defined(__APPLE__)
printer::inst()->print_msg(L1, "WARNING on MacOS thread affinity is only advisory.");
#endif
thd_setaffinity(oWorkThd.native_handle(), affinity);
}

void minethd::work_main()
{
if(affinity >= 0) //-1 means no affinity
pin_thd_affinity();

cn_hash_fun hash_fun;
cryptonight_ctx* ctx;
uint64_t iCount = 0;
Expand Down Expand Up @@ -462,8 +464,8 @@ minethd::cn_hash_fun_dbl minethd::func_dbl_selector(bool bHaveAes, bool bNoPrefe

void minethd::double_work_main()
{
// pin memory to NUMA node
bindMemoryToNUMANode(affinity);
if(affinity >= 0) //-1 means no affinity
pin_thd_affinity();

cn_hash_fun_dbl hash_fun;
cryptonight_ctx* ctx0;
Expand Down
7 changes: 4 additions & 3 deletions minethd.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ class minethd
std::atomic<uint64_t> iHashCount;
std::atomic<uint64_t> iTimestamp;

int affinity;

private:
typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx*);
typedef void (*cn_hash_fun_dbl)(const void*, size_t, void*, cryptonight_ctx* __restrict, cryptonight_ctx* __restrict);

minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefetch, int affinity);
minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefetch, int64_t affinity);

// We use the top 10 bits of the nonce for thread and resume
// This allows us to resume up to 128 threads 4 times before
Expand Down Expand Up @@ -131,8 +129,11 @@ class minethd
static miner_work oGlobalWork;
miner_work oWork;

void pin_thd_affinity();

std::thread oWorkThd;
uint8_t iThreadNo;
int64_t affinity;

bool bQuit;
bool bNoPrefetch;
Expand Down

0 comments on commit 5452906

Please sign in to comment.