Added "msr" field for CPU backend.
This commit is contained in:
parent
03cd56ed73
commit
4914fefb1f
5 changed files with 38 additions and 16 deletions
|
@ -430,6 +430,7 @@ rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
|
||||||
out.AddMember("profile", profileName().toJSON(), allocator);
|
out.AddMember("profile", profileName().toJSON(), allocator);
|
||||||
out.AddMember("hw-aes", cpu.isHwAES(), allocator);
|
out.AddMember("hw-aes", cpu.isHwAES(), allocator);
|
||||||
out.AddMember("priority", cpu.priority(), allocator);
|
out.AddMember("priority", cpu.priority(), allocator);
|
||||||
|
out.AddMember("msr", Rx::isMSR(), allocator);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# ifdef XMRIG_FEATURE_ASM
|
||||||
const Assembly assembly = Cpu::assembly(cpu.assembly());
|
const Assembly assembly = Cpu::assembly(cpu.assembly());
|
||||||
|
|
|
@ -42,6 +42,7 @@ class RxPrivate;
|
||||||
|
|
||||||
static bool osInitialized = false;
|
static bool osInitialized = false;
|
||||||
static bool msrInitialized = false;
|
static bool msrInitialized = false;
|
||||||
|
static bool msrEnabled = false;
|
||||||
static RxPrivate *d_ptr = nullptr;
|
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 (seed.algorithm().family() != Algorithm::RANDOM_X) {
|
||||||
if (msrInitialized) {
|
if (msrInitialized) {
|
||||||
msrDestroy();
|
msrDestroy();
|
||||||
msrInitialized = false;
|
msrInitialized = false;
|
||||||
|
msrEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,8 +109,8 @@ bool xmrig::Rx::init(const T &seed, const RxConfig &config, const CpuConfig &cpu
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msrInitialized) {
|
if (!msrInitialized) {
|
||||||
msrInit(config, cpu.threads().get(seed.algorithm()).data());
|
msrEnabled = msrInit(config, cpu.threads().get(seed.algorithm()).data());
|
||||||
msrInitialized = true;
|
msrInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!osInitialized) {
|
if (!osInitialized) {
|
||||||
|
@ -132,9 +134,15 @@ bool xmrig::Rx::isReady(const T &seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef XMRIG_FEATURE_MSR
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
void xmrig::Rx::msrInit(const RxConfig &, const std::vector<CpuThread> &)
|
bool xmrig::Rx::isMSR()
|
||||||
{
|
{
|
||||||
|
return msrEnabled;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
bool xmrig::Rx::msrInit(const RxConfig &, const std::vector<CpuThread> &)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,14 @@ public:
|
||||||
static void setMainLoopBounds(const std::pair<const void*, const void*>& bounds);
|
static void setMainLoopBounds(const std::pair<const void*, const void*>& bounds);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_MSR
|
||||||
|
static bool isMSR();
|
||||||
|
# else
|
||||||
|
static constexpr bool isMSR() { return false; }
|
||||||
|
# endif
|
||||||
|
|
||||||
private:
|
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 msrDestroy();
|
||||||
static void setupMainLoopExceptionFrame();
|
static void setupMainLoopExceptionFrame();
|
||||||
};
|
};
|
||||||
|
|
|
@ -272,21 +272,25 @@ void Rx::setMainLoopBounds(const std::pair<const void*, const void*>& bounds)
|
||||||
} // namespace xmrig
|
} // 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();
|
const auto &preset = config.msrPreset();
|
||||||
if (preset.empty()) {
|
if (preset.empty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
if (wrmsr(preset, threads, config.cacheQoS(), config.rdmsr())) {
|
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);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -395,21 +395,24 @@ void Rx::setMainLoopBounds(const std::pair<const void*, const void*>& bounds)
|
||||||
} // namespace xmrig
|
} // 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();
|
const auto &preset = config.msrPreset();
|
||||||
if (preset.empty()) {
|
if (preset.empty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t ts = Chrono::steadyMSecs();
|
const uint64_t ts = Chrono::steadyMSecs();
|
||||||
|
|
||||||
if (wrmsr(preset, threads, config.cacheQoS(), config.rdmsr())) {
|
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);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue