Merge branch 'dev' into feature-opencl
This commit is contained in:
commit
bd07f1d455
121 changed files with 5477 additions and 369 deletions
|
@ -66,7 +66,11 @@ size_t xmrig::Threads<T>::read(const rapidjson::Value &value)
|
|||
if (!threads.isEmpty()) {
|
||||
move(member.name.GetString(), std::move(threads));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &member : value.GetObject()) {
|
||||
if (member.value.IsArray() || member.value.IsObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
}
|
||||
|
||||
if (index() == 1 && job.index() == 0 && job == m_jobs[0]) {
|
||||
m_index = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,18 +166,7 @@ namespace xmrig {
|
|||
template<>
|
||||
xmrig::IWorker *xmrig::Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle)
|
||||
{
|
||||
const int intensity = handle->config().intensity;
|
||||
|
||||
# if defined(XMRIG_ALGO_RANDOMX) || defined(XMRIG_ALGO_CN_GPU)
|
||||
if (intensity > handle->config().algorithm.maxIntensity()) {
|
||||
LOG_WARN("CPU thread %zu warning: \"intensity %d not supported for %s algorithm\".", handle->index(), handle->config().intensity, handle->config().algorithm.shortName());
|
||||
|
||||
return new CpuWorker<1>(handle->index(), handle->config());
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
switch (intensity) {
|
||||
switch (handle->config().intensity) {
|
||||
case 1:
|
||||
return new CpuWorker<1>(handle->index(), handle->config());
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_ARGON2
|
||||
# include "crypto/argon2/Impl.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -210,8 +215,17 @@ const xmrig::String &xmrig::CpuBackend::type() const
|
|||
}
|
||||
|
||||
|
||||
void xmrig::CpuBackend::prepare(const Job &)
|
||||
void xmrig::CpuBackend::prepare(const Job &nextJob)
|
||||
{
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (nextJob.algorithm().family() == Algorithm::ARGON2 && argon2::Impl::select(d_ptr->controller->config()->cpu().argon2Impl())) {
|
||||
LOG_INFO("%s use " WHITE_BOLD("argon2") " implementation " CSI "1;%dm" "%s",
|
||||
tag,
|
||||
argon2::Impl::name() == "default" ? 33 : 32,
|
||||
argon2::Impl::name().data()
|
||||
);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -337,6 +351,10 @@ rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
|
|||
out.AddMember("asm", false, allocator);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
out.AddMember("argon2-impl", argon2::Impl::name().toJSON(), allocator);
|
||||
# endif
|
||||
|
||||
out.AddMember("hugepages", d_ptr->hugePages(2, doc), allocator);
|
||||
out.AddMember("memory", static_cast<uint64_t>(d_ptr->algo.isValid() ? (d_ptr->ways() * d_ptr->algo.l3()) : 0), allocator);
|
||||
|
||||
|
|
|
@ -62,6 +62,11 @@ static const char *kRx = "rx";
|
|||
static const char *kRxWOW = "rx/wow";
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_ARGON2
|
||||
static const char *kArgon2 = "argon2";
|
||||
static const char *kArgon2Impl = "argon2-impl";
|
||||
#endif
|
||||
|
||||
extern template class Threads<CpuThreads>;
|
||||
|
||||
}
|
||||
|
@ -94,6 +99,10 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
|
|||
obj.AddMember(StringRef(kAsm), m_assembly.toJSON(), allocator);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
obj.AddMember(StringRef(kArgon2Impl), m_argon2Impl.toJSON(), allocator);
|
||||
# endif
|
||||
|
||||
m_threads.toJSON(obj, doc);
|
||||
|
||||
return obj;
|
||||
|
@ -119,7 +128,7 @@ std::vector<xmrig::CpuLaunchData> xmrig::CpuConfig::get(const Miner *miner, cons
|
|||
}
|
||||
|
||||
|
||||
void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
||||
void xmrig::CpuConfig::read(const rapidjson::Value &value, uint32_t version)
|
||||
{
|
||||
if (value.IsObject()) {
|
||||
m_enabled = Json::getBool(value, kEnabled, m_enabled);
|
||||
|
@ -132,9 +141,17 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
|||
m_assembly = Json::getValue(value, kAsm);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
m_argon2Impl = Json::getString(value, kArgon2Impl);
|
||||
# endif
|
||||
|
||||
if (!m_threads.read(value)) {
|
||||
generate();
|
||||
}
|
||||
|
||||
if (version == 0) {
|
||||
generateArgon2();
|
||||
}
|
||||
}
|
||||
else if (value.IsBool() && value.IsFalse()) {
|
||||
m_enabled = false;
|
||||
|
@ -174,6 +191,16 @@ void xmrig::CpuConfig::generate()
|
|||
m_threads.move(kRx, cpu->threads(Algorithm::RX_0));
|
||||
m_threads.move(kRxWOW, cpu->threads(Algorithm::RX_WOW));
|
||||
# endif
|
||||
|
||||
generateArgon2();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::CpuConfig::generateArgon2()
|
||||
{
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
m_threads.move(kArgon2, Cpu::info()->threads(Algorithm::AR2_CHUKWA));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,17 +49,19 @@ public:
|
|||
bool isHwAES() const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
std::vector<CpuLaunchData> get(const Miner *miner, const Algorithm &algorithm) const;
|
||||
void read(const rapidjson::Value &value);
|
||||
void read(const rapidjson::Value &value, uint32_t version);
|
||||
|
||||
inline bool isEnabled() const { return m_enabled; }
|
||||
inline bool isHugePages() const { return m_hugePages; }
|
||||
inline bool isShouldSave() const { return m_shouldSave; }
|
||||
inline const Assembly &assembly() const { return m_assembly; }
|
||||
inline const String &argon2Impl() const { return m_argon2Impl; }
|
||||
inline const Threads<CpuThreads> &threads() const { return m_threads; }
|
||||
inline int priority() const { return m_priority; }
|
||||
|
||||
private:
|
||||
void generate();
|
||||
void generateArgon2();
|
||||
void setAesMode(const rapidjson::Value &aesMode);
|
||||
|
||||
inline void setPriority(int priority) { m_priority = (priority >= -1 && priority <= 5) ? priority : -1; }
|
||||
|
@ -70,6 +72,7 @@ private:
|
|||
bool m_hugePages = true;
|
||||
bool m_shouldSave = false;
|
||||
int m_priority = -1;
|
||||
String m_argon2Impl;
|
||||
Threads<CpuThreads> m_threads;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#include "backend/cpu/CpuLaunchData.h"
|
||||
#include "backend/cpu/CpuConfig.h"
|
||||
|
||||
|
@ -33,10 +36,10 @@ xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorit
|
|||
assembly(config.assembly()),
|
||||
hugePages(config.isHugePages()),
|
||||
hwAES(config.isHwAES()),
|
||||
intensity(thread.intensity()),
|
||||
priority(config.priority()),
|
||||
affinity(thread.affinity()),
|
||||
miner(miner)
|
||||
miner(miner),
|
||||
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity()))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,10 @@ public:
|
|||
const Assembly assembly;
|
||||
const bool hugePages;
|
||||
const bool hwAES;
|
||||
const int intensity;
|
||||
const int priority;
|
||||
const int64_t affinity;
|
||||
const Miner *miner;
|
||||
const uint32_t intensity;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@
|
|||
xmrig::CpuThread::CpuThread(const rapidjson::Value &value)
|
||||
{
|
||||
if (value.IsArray() && value.Size() >= 2) {
|
||||
m_intensity = value[0].GetInt();
|
||||
m_intensity = value[0].GetUint();
|
||||
m_affinity = value[1].GetInt();
|
||||
}
|
||||
else if (value.IsInt()) {
|
||||
m_intensity = -1;
|
||||
m_intensity = 0;
|
||||
m_affinity = value.GetInt();
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ xmrig::CpuThread::CpuThread(const rapidjson::Value &value)
|
|||
rapidjson::Value xmrig::CpuThread::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
if (m_intensity == -1) {
|
||||
if (m_intensity == 0) {
|
||||
return Value(m_affinity);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ class CpuThread
|
|||
{
|
||||
public:
|
||||
inline constexpr CpuThread() {}
|
||||
inline constexpr CpuThread(int64_t affinity, int intensity) : m_intensity(intensity), m_affinity(affinity) {}
|
||||
inline constexpr CpuThread(int64_t affinity, uint32_t intensity) : m_affinity(affinity), m_intensity(intensity) {}
|
||||
|
||||
CpuThread(const rapidjson::Value &value);
|
||||
|
||||
inline bool isEqual(const CpuThread &other) const { return other.m_affinity == m_affinity && other.m_intensity == m_intensity; }
|
||||
inline bool isValid() const { return m_intensity == -1 || (m_intensity >= 1 && m_intensity <= 5); }
|
||||
inline int intensity() const { return m_intensity == -1 ? 1 : m_intensity; }
|
||||
inline bool isValid() const { return m_intensity <= 5; }
|
||||
inline int64_t affinity() const { return m_affinity; }
|
||||
inline uint32_t intensity() const { return m_intensity == 0 ? 1 : m_intensity; }
|
||||
|
||||
inline bool operator!=(const CpuThread &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const CpuThread &other) const { return isEqual(other); }
|
||||
|
@ -51,8 +51,8 @@ public:
|
|||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
|
||||
private:
|
||||
int m_intensity = -1;
|
||||
int64_t m_affinity = -1;
|
||||
int64_t m_affinity = -1;
|
||||
uint32_t m_intensity = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ xmrig::CpuThreads::CpuThreads(const rapidjson::Value &value)
|
|||
}
|
||||
}
|
||||
else if (value.IsObject()) {
|
||||
int intensity = Json::getInt(value, kIntensity, 1);
|
||||
uint32_t intensity = Json::getUint(value, kIntensity, 1);
|
||||
const size_t threads = std::min<unsigned>(Json::getUint(value, kThreads), 1024);
|
||||
m_affinity = getAffinityMask(Json::getValue(value, kAffinity));
|
||||
m_format = ObjectFormat;
|
||||
|
@ -110,7 +110,7 @@ xmrig::CpuThreads::CpuThreads(const rapidjson::Value &value)
|
|||
}
|
||||
|
||||
|
||||
xmrig::CpuThreads::CpuThreads(size_t count, int intensity)
|
||||
xmrig::CpuThreads::CpuThreads(size_t count, uint32_t intensity)
|
||||
{
|
||||
m_data.reserve(count);
|
||||
|
||||
|
|
|
@ -42,13 +42,13 @@ public:
|
|||
inline CpuThreads(size_t count) : m_data(count) {}
|
||||
|
||||
CpuThreads(const rapidjson::Value &value);
|
||||
CpuThreads(size_t count, int intensity);
|
||||
CpuThreads(size_t count, uint32_t intensity);
|
||||
|
||||
inline bool isEmpty() const { return m_data.empty(); }
|
||||
inline const std::vector<CpuThread> &data() const { return m_data; }
|
||||
inline size_t count() const { return m_data.size(); }
|
||||
inline void add(CpuThread &&thread) { m_data.push_back(thread); }
|
||||
inline void add(int64_t affinity, int intensity) { add(CpuThread(affinity, intensity)); }
|
||||
inline void add(int64_t affinity, uint32_t intensity) { add(CpuThread(affinity, intensity)); }
|
||||
inline void reserve(size_t capacity) { m_data.reserve(capacity); }
|
||||
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
|
|
|
@ -156,6 +156,13 @@ bool xmrig::CpuWorker<N>::selfTest()
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (m_algorithm.family() == Algorithm::ARGON2) {
|
||||
return verify(Algorithm::AR2_CHUKWA, argon2_chukwa_test_out) &&
|
||||
verify(Algorithm::AR2_WRKZ, argon2_wrkz_test_out);
|
||||
}
|
||||
# endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm) co
|
|||
count = threads() / 2;
|
||||
}
|
||||
|
||||
int intensity = algorithm.maxIntensity() == 1 ? -1 : 1;
|
||||
uint32_t intensity = algorithm.maxIntensity() == 1 ? 0 : 1;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
if (algorithm == Algorithm::CN_PICO_0 && (count / cores()) >= 2) {
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
|
||||
#define VENDOR_ID (0)
|
||||
#define PROCESSOR_INFO (1)
|
||||
#define CACHE_TLB_DESCRIPTOR (2)
|
||||
#define EXTENDED_FEATURES (7)
|
||||
#define PROCESSOR_BRAND_STRING_1 (0x80000002)
|
||||
#define PROCESSOR_BRAND_STRING_2 (0x80000003)
|
||||
|
@ -222,5 +221,11 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm) const
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (algorithm.family() == Algorithm::ARGON2) {
|
||||
return count;
|
||||
}
|
||||
# endif
|
||||
|
||||
return CpuThreads(std::max<size_t>(count / 2, 1), 1);
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
|||
int L2_associativity = 0;
|
||||
size_t extra = 0;
|
||||
const size_t scratchpad = algorithm.l3();
|
||||
int intensity = algorithm.maxIntensity() == 1 ? -1 : 1;
|
||||
uint32_t intensity = algorithm.maxIntensity() == 1 ? 0 : 1;
|
||||
|
||||
if (cache->attr->cache.depth == 3) {
|
||||
for (size_t i = 0; i < cache->arity; ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue