Merge pull request #2715 from SChernykh/dev

Benchmark support for GhostRider (offline only)
This commit is contained in:
xmrig 2021-11-24 22:05:44 +07:00 committed by GitHub
commit 0dcafeb571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 8 deletions

View file

@ -87,6 +87,7 @@ public:
SpendSecretKey = 1055, SpendSecretKey = 1055,
DaemonZMQPortKey = 1056, DaemonZMQPortKey = 1056,
HugePagesJitKey = 1057, HugePagesJitKey = 1057,
RotationKey = 1058,
// xmrig common // xmrig common
CPUPriorityKey = 1021, CPUPriorityKey = 1021,

View file

@ -48,6 +48,39 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
std::vector<char> blob(112 * 2 + 1, '0'); std::vector<char> blob(112 * 2 + 1, '0');
blob.back() = '\0'; blob.back() = '\0';
# ifdef XMRIG_ALGO_GHOSTRIDER
if (m_benchmark->algorithm() == Algorithm::GHOSTRIDER_RTM) {
const uint32_t r = benchmark->rotation() % 20;
static constexpr uint32_t indices[20][3] = {
{ 0, 1, 2 },
{ 0, 1, 3 },
{ 0, 1, 4 },
{ 0, 1, 5 },
{ 0, 2, 3 },
{ 0, 2, 4 },
{ 0, 2, 5 },
{ 0, 3, 4 },
{ 0, 3, 5 },
{ 0, 4, 5 },
{ 1, 2, 3 },
{ 1, 2, 4 },
{ 1, 2, 5 },
{ 1, 3, 4 },
{ 1, 3, 5 },
{ 1, 4, 5 },
{ 2, 3, 4 },
{ 2, 3, 5 },
{ 2, 4, 5 },
{ 3, 4, 5 },
};
blob[ 8] = '0' + indices[r][1];
blob[ 9] = '0' + indices[r][0];
blob[11] = '0' + indices[r][2];
}
# endif
m_job.setAlgorithm(m_benchmark->algorithm()); m_job.setAlgorithm(m_benchmark->algorithm());
m_job.setBlob(blob.data()); m_job.setBlob(blob.data());
m_job.setDiff(std::numeric_limits<uint64_t>::max()); m_job.setDiff(std::numeric_limits<uint64_t>::max());
@ -60,7 +93,7 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
BenchState::init(this, m_benchmark->size()); BenchState::init(this, m_benchmark->size());
# ifdef XMRIG_FEATURE_HTTP # ifdef XMRIG_FEATURE_HTTP
if (m_benchmark->isSubmit()) { if (m_benchmark->isSubmit() && (m_benchmark->algorithm().family() == Algorithm::RANDOM_X)) {
m_mode = ONLINE_BENCH; m_mode = ONLINE_BENCH;
m_token = m_benchmark->token(); m_token = m_benchmark->token();

View file

@ -39,6 +39,7 @@ const char *BenchConfig::kHash = "hash";
const char *BenchConfig::kId = "id"; const char *BenchConfig::kId = "id";
const char *BenchConfig::kSeed = "seed"; const char *BenchConfig::kSeed = "seed";
const char *BenchConfig::kSize = "size"; const char *BenchConfig::kSize = "size";
const char *BenchConfig::kRotation = "rotation";
const char *BenchConfig::kSubmit = "submit"; const char *BenchConfig::kSubmit = "submit";
const char *BenchConfig::kToken = "token"; const char *BenchConfig::kToken = "token";
const char *BenchConfig::kUser = "user"; const char *BenchConfig::kUser = "user";
@ -53,7 +54,7 @@ const char *BenchConfig::kApiHost = "127.0.0.1";
} // namespace xmrig } // namespace xmrig
xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object, bool dmi) : xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object, bool dmi, uint32_t rotation) :
m_algorithm(Json::getString(object, kAlgo)), m_algorithm(Json::getString(object, kAlgo)),
m_dmi(dmi), m_dmi(dmi),
m_submit(Json::getBool(object, kSubmit)), m_submit(Json::getBool(object, kSubmit)),
@ -61,9 +62,15 @@ xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson
m_seed(Json::getString(object, kSeed)), m_seed(Json::getString(object, kSeed)),
m_token(Json::getString(object, kToken)), m_token(Json::getString(object, kToken)),
m_user(Json::getString(object, kUser)), m_user(Json::getString(object, kUser)),
m_size(size) m_size(size),
m_rotation(rotation)
{ {
if (!m_algorithm.isValid() || m_algorithm.family() != Algorithm::RANDOM_X) { auto f = m_algorithm.family();
if (!m_algorithm.isValid() || (f != Algorithm::RANDOM_X
# ifdef XMRIG_ALGO_GHOSTRIDER
&& f != Algorithm::GHOSTRIDER
# endif
)) {
m_algorithm = Algorithm::RX_0; m_algorithm = Algorithm::RX_0;
} }
@ -83,11 +90,14 @@ xmrig::BenchConfig *xmrig::BenchConfig::create(const rapidjson::Value &object, b
const uint32_t size = getSize(Json::getString(object, kSize)); const uint32_t size = getSize(Json::getString(object, kSize));
const String id = Json::getString(object, kVerify); const String id = Json::getString(object, kVerify);
const char* rotation_str = Json::getString(object, kRotation);
const uint32_t rotation = rotation_str ? strtoul(rotation_str, nullptr, 10) : 0;
if (size == 0 && id.isEmpty()) { if (size == 0 && id.isEmpty()) {
return nullptr; return nullptr;
} }
return new BenchConfig(size, id, object, dmi); return new BenchConfig(size, id, object, dmi, rotation);
} }

View file

@ -37,6 +37,7 @@ public:
static const char *kId; static const char *kId;
static const char *kSeed; static const char *kSeed;
static const char *kSize; static const char *kSize;
static const char* kRotation;
static const char *kSubmit; static const char *kSubmit;
static const char *kToken; static const char *kToken;
static const char *kUser; static const char *kUser;
@ -50,7 +51,7 @@ public:
static constexpr const uint16_t kApiPort = 18805; static constexpr const uint16_t kApiPort = 18805;
# endif # endif
BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object, bool dmi); BenchConfig(uint32_t size, const String &id, const rapidjson::Value &object, bool dmi, uint32_t rotation);
static BenchConfig *create(const rapidjson::Value &object, bool dmi); static BenchConfig *create(const rapidjson::Value &object, bool dmi);
@ -63,6 +64,7 @@ public:
inline const String &user() const { return m_user; } inline const String &user() const { return m_user; }
inline uint32_t size() const { return m_size; } inline uint32_t size() const { return m_size; }
inline uint64_t hash() const { return m_hash; } inline uint64_t hash() const { return m_hash; }
inline uint32_t rotation() const { return m_rotation; }
rapidjson::Value toJSON(rapidjson::Document &doc) const; rapidjson::Value toJSON(rapidjson::Document &doc) const;
@ -77,6 +79,7 @@ private:
String m_token; String m_token;
String m_user; String m_user;
uint32_t m_size; uint32_t m_size;
uint32_t m_rotation;
uint64_t m_hash = 0; uint64_t m_hash = 0;
}; };

View file

@ -269,6 +269,7 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
case IConfig::BenchSeedKey: /* --seed */ case IConfig::BenchSeedKey: /* --seed */
case IConfig::BenchHashKey: /* --hash */ case IConfig::BenchHashKey: /* --hash */
case IConfig::UserKey: /* --user */ case IConfig::UserKey: /* --user */
case IConfig::RotationKey: /* --rotation */
return transformBenchmark(doc, key, arg); return transformBenchmark(doc, key, arg);
# endif # endif
@ -358,6 +359,9 @@ void xmrig::ConfigTransform::transformBenchmark(rapidjson::Document &doc, int ke
case IConfig::UserKey: /* --user */ case IConfig::UserKey: /* --user */
return set(doc, BenchConfig::kBenchmark, BenchConfig::kUser, arg); return set(doc, BenchConfig::kBenchmark, BenchConfig::kUser, arg);
case IConfig::RotationKey: /* --rotation */
return set(doc, BenchConfig::kBenchmark, BenchConfig::kRotation, arg);
default: default:
break; break;
} }

View file

@ -71,6 +71,7 @@ static const option options[] = {
{ "hugepage-size", 1, nullptr, IConfig::HugePageSizeKey }, { "hugepage-size", 1, nullptr, IConfig::HugePageSizeKey },
{ "huge-pages-jit", 0, nullptr, IConfig::HugePagesJitKey }, { "huge-pages-jit", 0, nullptr, IConfig::HugePagesJitKey },
{ "hugepages-jit", 0, nullptr, IConfig::HugePagesJitKey }, { "hugepages-jit", 0, nullptr, IConfig::HugePagesJitKey },
{ "rotation", 1, nullptr, IConfig::RotationKey },
{ "pass", 1, nullptr, IConfig::PasswordKey }, { "pass", 1, nullptr, IConfig::PasswordKey },
{ "print-time", 1, nullptr, IConfig::PrintTimeKey }, { "print-time", 1, nullptr, IConfig::PrintTimeKey },
{ "retries", 1, nullptr, IConfig::RetriesKey }, { "retries", 1, nullptr, IConfig::RetriesKey },