Added initial support for new style threads launch method.
This commit is contained in:
parent
dff59fabc2
commit
27f3008d79
32 changed files with 1429 additions and 505 deletions
|
@ -202,6 +202,9 @@ static void patchAsmVariants()
|
|||
#endif
|
||||
|
||||
|
||||
static const xmrig::CnHash cnHash;
|
||||
|
||||
|
||||
xmrig::CnHash::CnHash()
|
||||
{
|
||||
ADD_FN(Algorithm::CN_0);
|
||||
|
@ -252,18 +255,18 @@ xmrig::CnHash::CnHash()
|
|||
}
|
||||
|
||||
|
||||
xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly) const
|
||||
xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly)
|
||||
{
|
||||
if (!algorithm.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
cn_hash_fun fun = m_map[algorithm][av][assembly == Assembly::AUTO ? Cpu::info()->assembly() : assembly];
|
||||
cn_hash_fun fun = cnHash.m_map[algorithm][av][assembly == Assembly::AUTO ? Cpu::info()->assembly() : assembly];
|
||||
if (fun) {
|
||||
return fun;
|
||||
}
|
||||
# endif
|
||||
|
||||
return m_map[algorithm][av][Assembly::NONE];
|
||||
return cnHash.m_map[algorithm][av][Assembly::NONE];
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
CnHash();
|
||||
|
||||
cn_hash_fun fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly) const;
|
||||
static cn_hash_fun fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly);
|
||||
|
||||
private:
|
||||
cn_hash_fun m_map[Algorithm::MAX][AV_MAX][Assembly::MAX] = {};
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
std::atomic<uint64_t> Nonce::m_sequence;
|
||||
std::atomic<bool> Nonce::m_paused;
|
||||
std::atomic<uint64_t> Nonce::m_sequence[Nonce::MAX];
|
||||
uint32_t Nonce::m_nonces[2] = { 0, 0 };
|
||||
|
||||
|
||||
|
@ -45,7 +46,11 @@ static Nonce nonce;
|
|||
|
||||
xmrig::Nonce::Nonce()
|
||||
{
|
||||
m_sequence = 1;
|
||||
m_paused = true;
|
||||
|
||||
for (int i = 0; i < MAX; ++i) {
|
||||
m_sequence[i] = 1;
|
||||
}
|
||||
|
||||
uv_mutex_init(&mutex);
|
||||
}
|
||||
|
@ -77,7 +82,25 @@ void xmrig::Nonce::reset(uint8_t index)
|
|||
uv_mutex_lock(&mutex);
|
||||
|
||||
m_nonces[index] = 0;
|
||||
m_sequence++;
|
||||
touch();
|
||||
|
||||
uv_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Nonce::stop()
|
||||
{
|
||||
pause(false);
|
||||
|
||||
for (int i = 0; i < MAX; ++i) {
|
||||
m_sequence[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Nonce::touch()
|
||||
{
|
||||
for (int i = 0; i < MAX; ++i) {
|
||||
m_sequence[i]++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,19 +35,32 @@ namespace xmrig {
|
|||
class Nonce
|
||||
{
|
||||
public:
|
||||
enum Backend {
|
||||
CPU,
|
||||
OPENCL,
|
||||
CUDA,
|
||||
MAX
|
||||
};
|
||||
|
||||
|
||||
Nonce();
|
||||
|
||||
static inline bool isOutdated(uint64_t sequence) { return m_sequence.load(std::memory_order_relaxed) != sequence; }
|
||||
static inline uint64_t sequence() { return m_sequence.load(std::memory_order_relaxed); }
|
||||
static inline void stop() { m_sequence = 0; }
|
||||
static inline void touch() { m_sequence++; }
|
||||
static inline bool isOutdated(Backend backend, uint64_t sequence) { return m_sequence[backend].load(std::memory_order_relaxed) != sequence; }
|
||||
static inline bool isPaused() { return m_paused.load(std::memory_order_relaxed); }
|
||||
static inline uint64_t sequence(Backend backend) { return m_sequence[backend].load(std::memory_order_relaxed); }
|
||||
static inline void pause(bool paused) { m_paused = paused; }
|
||||
static inline void stop(Backend backend) { m_sequence[backend] = 0; }
|
||||
static inline void touch(Backend backend) { m_sequence[backend]++; }
|
||||
|
||||
static uint32_t next(uint8_t index, uint32_t nonce, uint32_t reserveCount, bool nicehash);
|
||||
static void reset(uint8_t index);
|
||||
static void stop();
|
||||
static void touch();
|
||||
|
||||
private:
|
||||
static std::atomic<bool> m_paused;
|
||||
static std::atomic<uint64_t> m_sequence[MAX];
|
||||
static uint32_t m_nonces[2];
|
||||
static std::atomic<uint64_t> m_sequence;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue