Added "msr" field for CPU backend.

This commit is contained in:
XMRig
2020-10-25 16:36:37 +07:00
parent 03cd56ed73
commit 4914fefb1f
5 changed files with 38 additions and 16 deletions

View File

@ -430,6 +430,7 @@ rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
out.AddMember("profile", profileName().toJSON(), allocator);
out.AddMember("hw-aes", cpu.isHwAES(), allocator);
out.AddMember("priority", cpu.priority(), allocator);
out.AddMember("msr", Rx::isMSR(), allocator);
# ifdef XMRIG_FEATURE_ASM
const Assembly assembly = Cpu::assembly(cpu.assembly());

View File

@ -42,6 +42,7 @@ class RxPrivate;
static bool osInitialized = false;
static bool msrInitialized = false;
static bool msrEnabled = false;
static RxPrivate *d_ptr = nullptr;
@ -93,7 +94,8 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
if (seed.algorithm().family() != Algorithm::RANDOM_X) {
if (msrInitialized) {
msrDestroy();
msrInitialized = false;
msrInitialized = false;
msrEnabled = false;
}
return true;
@ -107,8 +109,8 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
}
if (!msrInitialized) {
msrInit(config, cpu.threads().get(seed.algorithm()).data());
msrInitialized = true;
msrEnabled = msrInit(config, cpu.threads().get(seed.algorithm()).data());
msrInitialized = true;
}
if (!osInitialized) {
@ -132,9 +134,15 @@ bool xmrig::Rx::isReady(const T &seed)
}
#ifndef XMRIG_FEATURE_MSR
void xmrig::Rx::msrInit(const RxConfig &, const std::vector<CpuThread> &)
#ifdef XMRIG_FEATURE_MSR
bool xmrig::Rx::isMSR()
{
return msrEnabled;
}
#else
bool xmrig::Rx::msrInit(const RxConfig &, const std::vector<CpuThread> &)
{
return false;
}

View File

@ -63,8 +63,14 @@ public:
static void setMainLoopBounds(const std::pair<const void*, const void*>& bounds);
# endif
# ifdef XMRIG_FEATURE_MSR
static bool isMSR();
# else
static constexpr bool isMSR() { return false; }
# endif
private:
static void msrInit(const RxConfig &config, const std::vector<CpuThread>& threads);
static bool msrInit(const RxConfig &config, const std::vector<CpuThread>& threads);
static void msrDestroy();
static void setupMainLoopExceptionFrame();
};

View File

@ -272,21 +272,25 @@ void Rx::setMainLoopBounds(const std::pair<const void*, const void*>& bounds)
} // namespace xmrig
void xmrig::Rx::msrInit(const RxConfig &config, const std::vector<CpuThread>& threads)
bool xmrig::Rx::msrInit(const RxConfig &config, const std::vector<CpuThread> &threads)
{
const auto &preset = config.msrPreset();
if (preset.empty()) {
return;
return false;
}
const uint64_t ts = Chrono::steadyMSecs();
if (wrmsr(preset, threads, config.cacheQoS(), config.rdmsr())) {
LOG_NOTICE(CLEAR "%s" GREEN_BOLD_S "register values for \"%s\" preset has been set successfully" BLACK_BOLD(" (%" PRIu64 " ms)"), tag, config.msrPresetName(), Chrono::steadyMSecs() - ts);
return true;
}
else {
LOG_ERR(CLEAR "%s" RED_BOLD_S "FAILED TO APPLY MSR MOD, HASHRATE WILL BE LOW", tag);
}
LOG_ERR(CLEAR "%s" RED_BOLD_S "FAILED TO APPLY MSR MOD, HASHRATE WILL BE LOW", tag);
return false;
}

View File

@ -395,21 +395,24 @@ void Rx::setMainLoopBounds(const std::pair<const void*, const void*>& bounds)
} // namespace xmrig
void xmrig::Rx::msrInit(const RxConfig &config, const std::vector<CpuThread>& threads)
bool xmrig::Rx::msrInit(const RxConfig &config, const std::vector<CpuThread>& threads)
{
const auto &preset = config.msrPreset();
if (preset.empty()) {
return;
return false;
}
const uint64_t ts = Chrono::steadyMSecs();
if (wrmsr(preset, threads, config.cacheQoS(), config.rdmsr())) {
LOG_NOTICE(CLEAR "%s" GREEN_BOLD_S "register values for \"%s\" preset has been set successfully" BLACK_BOLD(" (%" PRIu64 " ms)"), tag, config.msrPresetName(), Chrono::steadyMSecs() - ts);
return true;
}
else {
LOG_ERR(CLEAR "%s" RED_BOLD_S "FAILED TO APPLY MSR MOD, HASHRATE WILL BE LOW", tag);
}
LOG_ERR(CLEAR "%s" RED_BOLD_S "FAILED TO APPLY MSR MOD, HASHRATE WILL BE LOW", tag);
return false;
}