AstroBWT 20-50% speedup

Skips hashes with large stage 2 size. Added configurable `astrobwt-max-size` parameter, default value is 550, min 400, max 1200, optimal value ranges from 500 to 600 depending on CPU.

- Intel CPUs get 20-25% speedup
- 1st- and 2nd-gen Ryzens get 30% speedup
- 3rd-gen Ryzens get up to 50% speedup
This commit is contained in:
SChernykh 2020-03-05 12:20:21 +01:00
parent c80ef54b60
commit eeadea53e2
11 changed files with 63 additions and 10 deletions

View file

@ -28,6 +28,7 @@
#include "backend/cpu/Cpu.h"
#include "base/io/json/Json.h"
#include "rapidjson/document.h"
#include <algorithm>
namespace xmrig {
@ -48,6 +49,11 @@ static const char *kAsm = "asm";
static const char *kArgon2Impl = "argon2-impl";
#endif
#ifdef XMRIG_ALGO_ASTROBWT
static const char* kAstroBWTMaxSize = "astrobwt-max-size";
#endif
extern template class Threads<CpuThreads>;
}
@ -85,6 +91,10 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
obj.AddMember(StringRef(kArgon2Impl), m_argon2Impl.toJSON(), allocator);
# endif
# ifdef XMRIG_ALGO_ASTROBWT
obj.AddMember(StringRef(kAstroBWTMaxSize), m_astrobwtMaxSize, allocator);
# endif
m_threads.toJSON(obj, doc);
return obj;
@ -136,6 +146,16 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
m_argon2Impl = Json::getString(value, kArgon2Impl);
# endif
# ifdef XMRIG_ALGO_ASTROBWT
const auto& obj = Json::getValue(value, kAstroBWTMaxSize);
if (obj.IsNull() || !obj.IsInt()) {
m_shouldSave = true;
}
else {
m_astrobwtMaxSize = std::min(std::max(obj.GetInt(), 400), 1200);
}
# endif
m_threads.read(value);
generate();
@ -167,7 +187,7 @@ void xmrig::CpuConfig::generate()
count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit);
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, m_limit);
m_shouldSave = count > 0;
m_shouldSave |= count > 0;
}