Code syntaxis
Auto code style in some files and update VS project properties.
This commit is contained in:
parent
86f0d9d944
commit
e3407385ab
15 changed files with 300 additions and 228 deletions
116
src/Cpu.cpp
116
src/Cpu.cpp
|
@ -41,78 +41,90 @@ int Cpu::m_totalThreads = 0;
|
||||||
|
|
||||||
int Cpu::optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage)
|
int Cpu::optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage)
|
||||||
{
|
{
|
||||||
if (m_totalThreads == 1) {
|
if(m_totalThreads == 1)
|
||||||
return 1;
|
{
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int cache = 0;
|
int cache = 0;
|
||||||
if (m_l3_cache) {
|
if(m_l3_cache)
|
||||||
cache = m_l2_exclusive ? (m_l2_cache + m_l3_cache) : m_l3_cache;
|
{
|
||||||
}
|
cache = m_l2_exclusive ? (m_l2_cache + m_l3_cache) : m_l3_cache;
|
||||||
else {
|
}
|
||||||
cache = m_l2_cache;
|
else
|
||||||
}
|
{
|
||||||
|
cache = m_l2_cache;
|
||||||
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
const int size = (algo ? 1024 : 2048) * (doubleHash ? 2 : 1);
|
const int size = (algo ? 1024 : 2048) * (doubleHash ? 2 : 1);
|
||||||
|
|
||||||
if (cache) {
|
if(cache)
|
||||||
count = cache / size;
|
{
|
||||||
}
|
count = cache / size;
|
||||||
else {
|
}
|
||||||
count = m_totalThreads / 2;
|
else
|
||||||
}
|
{
|
||||||
|
count = m_totalThreads / 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (count > m_totalThreads) {
|
if(count > m_totalThreads)
|
||||||
count = m_totalThreads;
|
{
|
||||||
}
|
count = m_totalThreads;
|
||||||
|
}
|
||||||
|
|
||||||
if (((float) count / m_totalThreads * 100) > maxCpuUsage) {
|
if(((float) count / m_totalThreads * 100) > maxCpuUsage)
|
||||||
count = (int) ceil((float) m_totalThreads * (maxCpuUsage / 100.0));
|
{
|
||||||
}
|
count = (int) ceil((float) m_totalThreads * (maxCpuUsage / 100.0));
|
||||||
|
}
|
||||||
|
|
||||||
return count < 1 ? 1 : count;
|
return count < 1 ? 1 : count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cpu::initCommon()
|
void Cpu::initCommon()
|
||||||
{
|
{
|
||||||
struct cpu_raw_data_t raw = { 0 };
|
struct cpu_raw_data_t raw = { 0 };
|
||||||
struct cpu_id_t data = { 0 };
|
struct cpu_id_t data = { 0 };
|
||||||
|
|
||||||
cpuid_get_raw_data(&raw);
|
cpuid_get_raw_data(&raw);
|
||||||
cpu_identify(&raw, &data);
|
cpu_identify(&raw, &data);
|
||||||
|
|
||||||
strncpy(m_brand, data.brand_str, sizeof(m_brand) - 1);
|
strncpy(m_brand, data.brand_str, sizeof(m_brand) - 1);
|
||||||
|
|
||||||
m_totalThreads = data.total_logical_cpus;
|
m_totalThreads = data.total_logical_cpus;
|
||||||
m_sockets = m_totalThreads / data.num_logical_cpus;
|
m_sockets = m_totalThreads / data.num_logical_cpus;
|
||||||
|
|
||||||
if (m_sockets == 0) {
|
if(m_sockets == 0)
|
||||||
m_sockets = 1;
|
{
|
||||||
}
|
m_sockets = 1;
|
||||||
|
}
|
||||||
|
|
||||||
m_totalCores = data.num_cores * m_sockets;
|
m_totalCores = data.num_cores * m_sockets;
|
||||||
m_l3_cache = data.l3_cache > 0 ? data.l3_cache * m_sockets : 0;
|
m_l3_cache = data.l3_cache > 0 ? data.l3_cache * m_sockets : 0;
|
||||||
|
|
||||||
// Workaround for AMD CPUs https://github.com/anrieff/libcpuid/issues/97
|
// Workaround for AMD CPUs https://github.com/anrieff/libcpuid/issues/97
|
||||||
if (data.vendor == VENDOR_AMD && data.ext_family >= 0x15 && data.ext_family < 0x17) {
|
if(data.vendor == VENDOR_AMD && data.ext_family >= 0x15 && data.ext_family < 0x17)
|
||||||
m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets;
|
{
|
||||||
m_l2_exclusive = true;
|
m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets;
|
||||||
}
|
m_l2_exclusive = true;
|
||||||
else {
|
}
|
||||||
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0;
|
else
|
||||||
}
|
{
|
||||||
|
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0;
|
||||||
|
}
|
||||||
|
|
||||||
# if defined(__x86_64__) || defined(_M_AMD64)
|
# if defined(__x86_64__) || defined(_M_AMD64)
|
||||||
m_flags |= X86_64;
|
m_flags |= X86_64;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (data.flags[CPU_FEATURE_AES]) {
|
if(data.flags[CPU_FEATURE_AES])
|
||||||
m_flags |= AES;
|
{
|
||||||
}
|
m_flags |= AES;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.flags[CPU_FEATURE_BMI2]) {
|
if(data.flags[CPU_FEATURE_BMI2])
|
||||||
m_flags |= BMI2;
|
{
|
||||||
}
|
m_flags |= BMI2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
75
src/Cpu.h
75
src/Cpu.h
|
@ -31,36 +31,61 @@
|
||||||
class Cpu
|
class Cpu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Flags {
|
enum Flags
|
||||||
X86_64 = 1,
|
{
|
||||||
AES = 2,
|
X86_64 = 1,
|
||||||
BMI2 = 4
|
AES = 2,
|
||||||
};
|
BMI2 = 4
|
||||||
|
};
|
||||||
|
|
||||||
static int optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage);
|
static int optimalThreadsCount(int algo, bool doubleHash, int maxCpuUsage);
|
||||||
static void init();
|
static void init();
|
||||||
static void setAffinity(int id, uint64_t mask);
|
static void setAffinity(int id, uint64_t mask);
|
||||||
|
|
||||||
static inline bool hasAES() { return (m_flags & AES) != 0; }
|
static inline bool hasAES()
|
||||||
static inline bool isX64() { return (m_flags & X86_64) != 0; }
|
{
|
||||||
static inline const char *brand() { return m_brand; }
|
return (m_flags & AES) != 0;
|
||||||
static inline int cores() { return m_totalCores; }
|
}
|
||||||
static inline int l2() { return m_l2_cache; }
|
static inline bool isX64()
|
||||||
static inline int l3() { return m_l3_cache; }
|
{
|
||||||
static inline int sockets() { return m_sockets; }
|
return (m_flags & X86_64) != 0;
|
||||||
static inline int threads() { return m_totalThreads; }
|
}
|
||||||
|
static inline const char* brand()
|
||||||
|
{
|
||||||
|
return m_brand;
|
||||||
|
}
|
||||||
|
static inline int cores()
|
||||||
|
{
|
||||||
|
return m_totalCores;
|
||||||
|
}
|
||||||
|
static inline int l2()
|
||||||
|
{
|
||||||
|
return m_l2_cache;
|
||||||
|
}
|
||||||
|
static inline int l3()
|
||||||
|
{
|
||||||
|
return m_l3_cache;
|
||||||
|
}
|
||||||
|
static inline int sockets()
|
||||||
|
{
|
||||||
|
return m_sockets;
|
||||||
|
}
|
||||||
|
static inline int threads()
|
||||||
|
{
|
||||||
|
return m_totalThreads;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void initCommon();
|
static void initCommon();
|
||||||
|
|
||||||
static bool m_l2_exclusive;
|
static bool m_l2_exclusive;
|
||||||
static char m_brand[64];
|
static char m_brand[64];
|
||||||
static int m_flags;
|
static int m_flags;
|
||||||
static int m_l2_cache;
|
static int m_l2_cache;
|
||||||
static int m_l3_cache;
|
static int m_l3_cache;
|
||||||
static int m_sockets;
|
static int m_sockets;
|
||||||
static int m_totalCores;
|
static int m_totalCores;
|
||||||
static int m_totalThreads;
|
static int m_totalThreads;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,27 +56,30 @@ void Cpu::init()
|
||||||
|
|
||||||
void Cpu::setAffinity(int id, uint64_t mask)
|
void Cpu::setAffinity(int id, uint64_t mask)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
cpu_set_t set;
|
cpu_set_t set;
|
||||||
CPU_ZERO(&set);
|
CPU_ZERO(&set);
|
||||||
|
|
||||||
for (int i = 0; i < m_totalThreads; i++) {
|
for(int i = 0; i < m_totalThreads; i++)
|
||||||
if (mask & (1UL << i)) {
|
{
|
||||||
CPU_SET(i, &set);
|
if(mask & (1UL << i))
|
||||||
}
|
{
|
||||||
|
CPU_SET(i, &set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == -1) {
|
if(id == -1)
|
||||||
# ifndef __FreeBSD__
|
{
|
||||||
sched_setaffinity(0, sizeof(&set), &set);
|
# ifndef __FreeBSD__
|
||||||
# endif
|
sched_setaffinity(0, sizeof(&set), &set);
|
||||||
} else {
|
# endif
|
||||||
# ifndef __ANDROID__
|
}
|
||||||
pthread_setaffinity_np(pthread_self(), sizeof(&set), &set);
|
else
|
||||||
# else
|
{
|
||||||
sched_setaffinity(gettid(), sizeof(&set), &set);
|
# ifndef __ANDROID__
|
||||||
# endif
|
pthread_setaffinity_np(pthread_self(), sizeof(&set), &set);
|
||||||
|
# else
|
||||||
|
sched_setaffinity(gettid(), sizeof(&set), &set);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -31,22 +31,24 @@
|
||||||
void Cpu::init()
|
void Cpu::init()
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_NO_LIBCPUID
|
# ifdef XMRIG_NO_LIBCPUID
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
|
|
||||||
m_totalThreads = sysinfo.dwNumberOfProcessors;
|
m_totalThreads = sysinfo.dwNumberOfProcessors;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
initCommon();
|
initCommon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Cpu::setAffinity(int id, uint64_t mask)
|
void Cpu::setAffinity(int id, uint64_t mask)
|
||||||
{
|
{
|
||||||
if (id == -1) {
|
if(id == -1)
|
||||||
SetProcessAffinityMask(GetCurrentProcess(), mask);
|
{
|
||||||
}
|
SetProcessAffinityMask(GetCurrentProcess(), mask);
|
||||||
else {
|
}
|
||||||
SetThreadAffinityMask(GetCurrentThread(), mask);
|
else
|
||||||
}
|
{
|
||||||
|
SetThreadAffinityMask(GetCurrentThread(), mask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
54
src/Mem.cpp
54
src/Mem.cpp
|
@ -35,53 +35,57 @@ int Mem::m_algo = 0;
|
||||||
int Mem::m_flags = 0;
|
int Mem::m_flags = 0;
|
||||||
int Mem::m_threads = 0;
|
int Mem::m_threads = 0;
|
||||||
size_t Mem::m_offset = 0;
|
size_t Mem::m_offset = 0;
|
||||||
uint8_t *Mem::m_memory = nullptr;
|
uint8_t* Mem::m_memory = nullptr;
|
||||||
|
|
||||||
|
|
||||||
cryptonight_ctx *Mem::create(int threadId)
|
cryptonight_ctx* Mem::create(int threadId)
|
||||||
{
|
{
|
||||||
# ifndef XMRIG_NO_AEON
|
# ifndef XMRIG_NO_AEON
|
||||||
if (m_algo == Options::ALGO_CRYPTONIGHT_LITE) {
|
if(m_algo == Options::ALGO_CRYPTONIGHT_LITE)
|
||||||
return createLite(threadId);
|
{
|
||||||
}
|
return createLite(threadId);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
cryptonight_ctx *ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
cryptonight_ctx* ctx = reinterpret_cast<cryptonight_ctx*>(&m_memory[MEMORY - sizeof(cryptonight_ctx) *
|
||||||
|
(threadId + 1)]);
|
||||||
|
|
||||||
const int ratio = m_doubleHash ? 2 : 1;
|
const int ratio = m_doubleHash ? 2 : 1;
|
||||||
ctx->memory = &m_memory[MEMORY * (threadId * ratio + 1)];
|
ctx->memory = &m_memory[MEMORY * (threadId * ratio + 1)];
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *Mem::calloc(size_t num, size_t size)
|
void* Mem::calloc(size_t num, size_t size)
|
||||||
{
|
{
|
||||||
void *mem = &m_memory[m_offset];
|
void* mem = &m_memory[m_offset];
|
||||||
m_offset += (num * size);
|
m_offset += (num * size);
|
||||||
|
|
||||||
memset(mem, 0, num * size);
|
memset(mem, 0, num * size);
|
||||||
|
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef XMRIG_NO_AEON
|
#ifndef XMRIG_NO_AEON
|
||||||
cryptonight_ctx *Mem::createLite(int threadId) {
|
cryptonight_ctx* Mem::createLite(int threadId)
|
||||||
cryptonight_ctx *ctx;
|
{
|
||||||
|
cryptonight_ctx* ctx;
|
||||||
|
|
||||||
if (!m_doubleHash) {
|
if(!m_doubleHash)
|
||||||
const size_t offset = MEMORY * (threadId + 1);
|
{
|
||||||
|
const size_t offset = MEMORY * (threadId + 1);
|
||||||
|
|
||||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[offset + MEMORY_LITE]);
|
ctx = reinterpret_cast<cryptonight_ctx*>(&m_memory[offset + MEMORY_LITE]);
|
||||||
ctx->memory = &m_memory[offset];
|
ctx->memory = &m_memory[offset];
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = reinterpret_cast<cryptonight_ctx *>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
ctx = reinterpret_cast<cryptonight_ctx*>(&m_memory[MEMORY - sizeof(cryptonight_ctx) * (threadId + 1)]);
|
||||||
ctx->memory = &m_memory[MEMORY * (threadId + 1)];
|
ctx->memory = &m_memory[MEMORY * (threadId + 1)];
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,10 +91,17 @@ const uint8_t saes_sbox[256] = saes_data(saes_h0);
|
||||||
|
|
||||||
static inline __m128i soft_aesenc(__m128i in, __m128i key)
|
static inline __m128i soft_aesenc(__m128i in, __m128i key)
|
||||||
{
|
{
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
const uint32_t x0 = in.m128i_u32[0];
|
||||||
|
const uint32_t x1 = in.m128i_u32[1];
|
||||||
|
const uint32_t x2 = in.m128i_u32[2];
|
||||||
|
const uint32_t x3 = in.m128i_u32[3];
|
||||||
|
#else
|
||||||
const uint32_t x0 = _mm_cvtsi128_si32(in);
|
const uint32_t x0 = _mm_cvtsi128_si32(in);
|
||||||
const uint32_t x1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55));
|
const uint32_t x1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55));
|
||||||
const uint32_t x2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA));
|
const uint32_t x2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA));
|
||||||
const uint32_t x3 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF));
|
const uint32_t x3 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF));
|
||||||
|
#endif
|
||||||
|
|
||||||
__m128i out = _mm_set_epi32(
|
__m128i out = _mm_set_epi32(
|
||||||
(saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^
|
(saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^
|
||||||
|
|
|
@ -32,9 +32,9 @@ class JobResult;
|
||||||
class IJobResultListener
|
class IJobResultListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IJobResultListener() {}
|
virtual ~IJobResultListener() {}
|
||||||
|
|
||||||
virtual void onJobResult(const JobResult &result) = 0;
|
virtual void onJobResult(const JobResult & result) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
class IWorker
|
class IWorker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IWorker() {}
|
virtual ~IWorker() {}
|
||||||
|
|
||||||
virtual uint64_t hashCount() const = 0;
|
virtual uint64_t hashCount() const = 0;
|
||||||
virtual uint64_t timestamp() const = 0;
|
virtual uint64_t timestamp() const = 0;
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,46 +35,47 @@
|
||||||
class JobResult
|
class JobResult
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline JobResult() : poolId(0), diff(0), nonce(0) {}
|
inline JobResult() : poolId(0), diff(0), nonce(0) {}
|
||||||
inline JobResult(int poolId, const JobId &jobId, uint32_t nonce, const uint8_t *result, uint32_t diff) :
|
inline JobResult(int poolId, const JobId & jobId, uint32_t nonce, const uint8_t* result, uint32_t diff) :
|
||||||
poolId(poolId),
|
poolId(poolId),
|
||||||
jobId(jobId),
|
jobId(jobId),
|
||||||
diff(diff),
|
diff(diff),
|
||||||
nonce(nonce)
|
nonce(nonce)
|
||||||
{
|
{
|
||||||
memcpy(this->result, result, sizeof(this->result));
|
memcpy(this->result, result, sizeof(this->result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline JobResult(const Job &job) : poolId(0), diff(0), nonce(0)
|
inline JobResult(const Job & job) : poolId(0), diff(0), nonce(0)
|
||||||
{
|
{
|
||||||
jobId = job.id();
|
jobId = job.id();
|
||||||
poolId = job.poolId();
|
poolId = job.poolId();
|
||||||
diff = job.diff();
|
diff = job.diff();
|
||||||
nonce = *job.nonce();
|
nonce = *job.nonce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline JobResult &operator=(const Job &job) {
|
inline JobResult & operator=(const Job & job)
|
||||||
jobId = job.id();
|
{
|
||||||
poolId = job.poolId();
|
jobId = job.id();
|
||||||
diff = job.diff();
|
poolId = job.poolId();
|
||||||
|
diff = job.diff();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline uint64_t actualDiff() const
|
inline uint64_t actualDiff() const
|
||||||
{
|
{
|
||||||
return Job::toDiff(reinterpret_cast<const uint64_t*>(result)[3]);
|
return Job::toDiff(reinterpret_cast<const uint64_t*>(result)[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int poolId;
|
int poolId;
|
||||||
JobId jobId;
|
JobId jobId;
|
||||||
uint32_t diff;
|
uint32_t diff;
|
||||||
uint32_t nonce;
|
uint32_t nonce;
|
||||||
uint8_t result[32];
|
uint8_t result[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __JOBRESULT_H__ */
|
#endif /* __JOBRESULT_H__ */
|
||||||
|
|
|
@ -31,18 +31,18 @@
|
||||||
class SubmitResult
|
class SubmitResult
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline SubmitResult() : seq(0), diff(0), actualDiff(0), elapsed(0), start(0) {}
|
inline SubmitResult() : seq(0), diff(0), actualDiff(0), elapsed(0), start(0) {}
|
||||||
SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff);
|
SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff);
|
||||||
|
|
||||||
void done();
|
void done();
|
||||||
|
|
||||||
int64_t seq;
|
int64_t seq;
|
||||||
uint32_t diff;
|
uint32_t diff;
|
||||||
uint64_t actualDiff;
|
uint64_t actualDiff;
|
||||||
uint64_t elapsed;
|
uint64_t elapsed;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t start;
|
uint64_t start;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __SUBMITRESULT_H__ */
|
#endif /* __SUBMITRESULT_H__ */
|
||||||
|
|
|
@ -37,21 +37,21 @@ class Handle;
|
||||||
class DoubleWorker : public Worker
|
class DoubleWorker : public Worker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DoubleWorker(Handle *handle);
|
DoubleWorker(Handle* handle);
|
||||||
~DoubleWorker();
|
~DoubleWorker();
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool resume(const Job &job);
|
bool resume(const Job & job);
|
||||||
void consumeJob();
|
void consumeJob();
|
||||||
void save(const Job &job);
|
void save(const Job & job);
|
||||||
|
|
||||||
class State;
|
class State;
|
||||||
|
|
||||||
uint8_t m_hash[64];
|
uint8_t m_hash[64];
|
||||||
State *m_state;
|
State* m_state;
|
||||||
State *m_pausedState;
|
State* m_pausedState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,24 +35,42 @@ class IWorker;
|
||||||
class Handle
|
class Handle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Handle(int threadId, int threads, int64_t affinity, int priority);
|
Handle(int threadId, int threads, int64_t affinity, int priority);
|
||||||
void join();
|
void join();
|
||||||
void start(void (*callback) (void *));
|
void start(void (*callback)(void*));
|
||||||
|
|
||||||
inline int priority() const { return m_priority; }
|
inline int priority() const
|
||||||
inline int threadId() const { return m_threadId; }
|
{
|
||||||
inline int threads() const { return m_threads; }
|
return m_priority;
|
||||||
inline int64_t affinity() const { return m_affinity; }
|
}
|
||||||
inline IWorker *worker() const { return m_worker; }
|
inline int threadId() const
|
||||||
inline void setWorker(IWorker *worker) { m_worker = worker; }
|
{
|
||||||
|
return m_threadId;
|
||||||
|
}
|
||||||
|
inline int threads() const
|
||||||
|
{
|
||||||
|
return m_threads;
|
||||||
|
}
|
||||||
|
inline int64_t affinity() const
|
||||||
|
{
|
||||||
|
return m_affinity;
|
||||||
|
}
|
||||||
|
inline IWorker* worker() const
|
||||||
|
{
|
||||||
|
return m_worker;
|
||||||
|
}
|
||||||
|
inline void setWorker(IWorker* worker)
|
||||||
|
{
|
||||||
|
m_worker = worker;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_priority;
|
int m_priority;
|
||||||
int m_threadId;
|
int m_threadId;
|
||||||
int m_threads;
|
int m_threads;
|
||||||
int64_t m_affinity;
|
int64_t m_affinity;
|
||||||
IWorker *m_worker;
|
IWorker* m_worker;
|
||||||
uv_thread_t m_thread;
|
uv_thread_t m_thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,18 +36,18 @@ class Handle;
|
||||||
class SingleWorker : public Worker
|
class SingleWorker : public Worker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SingleWorker(Handle *handle);
|
SingleWorker(Handle* handle);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool resume(const Job &job);
|
bool resume(const Job & job);
|
||||||
void consumeJob();
|
void consumeJob();
|
||||||
void save(const Job &job);
|
void save(const Job & job);
|
||||||
|
|
||||||
Job m_job;
|
Job m_job;
|
||||||
Job m_paused;
|
Job m_paused;
|
||||||
JobResult m_result;
|
JobResult m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,8 @@
|
||||||
<GenerateMapFile>true</GenerateMapFile>
|
<GenerateMapFile>true</GenerateMapFile>
|
||||||
<AssemblyDebug>true</AssemblyDebug>
|
<AssemblyDebug>true</AssemblyDebug>
|
||||||
<ProgramDatabaseFile>$(ProjectName)$(Platform)d.pdb</ProgramDatabaseFile>
|
<ProgramDatabaseFile>$(ProjectName)$(Platform)d.pdb</ProgramDatabaseFile>
|
||||||
<LinkStatus>true</LinkStatus>
|
|
||||||
<MapExports>true</MapExports>
|
<MapExports>true</MapExports>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='vc-release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='vc-release|x64'">
|
||||||
|
@ -328,7 +328,7 @@
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\libuv-1.x\Release\$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\libuv-1.x\Release\$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>libuv.lib;advapi32.lib;iphlpapi.lib;psapi.lib;shell32.lib;user32.lib;userenv.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libuv.lib;advapi32.lib;iphlpapi.lib;psapi.lib;shell32.lib;user32.lib;userenv.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<IgnoreSpecificDefaultLibraries>LIBCMTD;LIBCMT</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>LIBCMTD;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||||
<LinkStatus>true</LinkStatus>
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='vc-debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='vc-debug|Win32'">
|
||||||
|
@ -342,12 +342,12 @@
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\libuv-1.x\Release\$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\libuv-1.x\Release\$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<IgnoreSpecificDefaultLibraries>LIBCMTD;LIBCMT</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>LIBCMTD;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||||
<AdditionalDependencies>libuv.lib;advapi32.lib;iphlpapi.lib;psapi.lib;shell32.lib;user32.lib;userenv.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libuv.lib;advapi32.lib;iphlpapi.lib;psapi.lib;shell32.lib;user32.lib;userenv.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<LinkStatus>true</LinkStatus>
|
|
||||||
<ProgramDatabaseFile>$(ProjectName)$(Platform)d.pdb</ProgramDatabaseFile>
|
<ProgramDatabaseFile>$(ProjectName)$(Platform)d.pdb</ProgramDatabaseFile>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<GenerateMapFile>true</GenerateMapFile>
|
<GenerateMapFile>true</GenerateMapFile>
|
||||||
<MapExports>true</MapExports>
|
<MapExports>true</MapExports>
|
||||||
<AssemblyDebug>true</AssemblyDebug>
|
<AssemblyDebug>true</AssemblyDebug>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='vc-release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='vc-release|Win32'">
|
||||||
|
@ -367,7 +367,7 @@
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\libuv-1.x\Release\$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\libuv-1.x\Release\$(Platform)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>libuv.lib;advapi32.lib;iphlpapi.lib;psapi.lib;shell32.lib;user32.lib;userenv.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libuv.lib;advapi32.lib;iphlpapi.lib;psapi.lib;shell32.lib;user32.lib;userenv.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<IgnoreSpecificDefaultLibraries>LIBCMTD;LIBCMT</IgnoreSpecificDefaultLibraries>
|
<IgnoreSpecificDefaultLibraries>LIBCMTD;LIBCMT</IgnoreSpecificDefaultLibraries>
|
||||||
<LinkStatus>true</LinkStatus>
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -519,24 +519,6 @@
|
||||||
<ClInclude Include="..\src\net\strategies\SinglePoolStrategy.h">
|
<ClInclude Include="..\src\net\strategies\SinglePoolStrategy.h">
|
||||||
<Filter>Archivos de encabezado\net\strategies</Filter>
|
<Filter>Archivos de encabezado\net\strategies</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\workers\DoubleWorker.h">
|
|
||||||
<Filter>Archivos de encabezado\workers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\workers\Handle.h">
|
|
||||||
<Filter>Archivos de encabezado\workers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\workers\Hashrate.h">
|
|
||||||
<Filter>Archivos de encabezado\workers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\workers\SingleWorker.h">
|
|
||||||
<Filter>Archivos de encabezado\workers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\workers\Worker.h">
|
|
||||||
<Filter>Archivos de encabezado\workers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\workers\Workers.h">
|
|
||||||
<Filter>Archivos de encabezado\workers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\src\3rdparty\libcpuid\amd_code_t.h">
|
<ClInclude Include="..\src\3rdparty\libcpuid\amd_code_t.h">
|
||||||
<Filter>Archivos de encabezado\3rdparty\libcpuid</Filter>
|
<Filter>Archivos de encabezado\3rdparty\libcpuid</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -570,6 +552,24 @@
|
||||||
<ClInclude Include="..\src\3rdparty\libcpuid\recog_amd.h">
|
<ClInclude Include="..\src\3rdparty\libcpuid\recog_amd.h">
|
||||||
<Filter>Archivos de encabezado\3rdparty\libcpuid</Filter>
|
<Filter>Archivos de encabezado\3rdparty\libcpuid</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\workers\Workers.h">
|
||||||
|
<Filter>Archivos de encabezado\workers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\workers\DoubleWorker.h">
|
||||||
|
<Filter>Archivos de encabezado\workers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\workers\Handle.h">
|
||||||
|
<Filter>Archivos de encabezado\workers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\workers\Hashrate.h">
|
||||||
|
<Filter>Archivos de encabezado\workers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\workers\SingleWorker.h">
|
||||||
|
<Filter>Archivos de encabezado\workers</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\workers\Worker.h">
|
||||||
|
<Filter>Archivos de encabezado\workers</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<MASM Include="..\src\3rdparty\libcpuid\masm-x64.asm">
|
<MASM Include="..\src\3rdparty\libcpuid\masm-x64.asm">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue