Added selection for optimized Argon2 implementation.

This commit is contained in:
XMRig 2019-08-17 01:42:03 +07:00
parent 1c00721de3
commit 3022f19eda
12 changed files with 258 additions and 77 deletions

View file

@ -43,6 +43,11 @@
#include "rapidjson/document.h"
#ifdef XMRIG_ALGO_ARGON2
# include "crypto/argon2/Impl.h"
#endif
namespace xmrig {
@ -192,8 +197,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
}

View file

@ -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;
@ -132,6 +141,10 @@ 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();
}

View file

@ -55,6 +55,7 @@ public:
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; }
@ -70,6 +71,7 @@ private:
bool m_hugePages = true;
bool m_shouldSave = false;
int m_priority = -1;
String m_argon2Impl;
Threads<CpuThreads> m_threads;
};