RandomX: added parameter for scratchpad prefetch mode

`scratchpad_prefetch_mode` can have 4 values:
0: off
1: use `prefetcht0` instruction (default, same as previous XMRig versions)
2: use `prefetchnta` instruction (faster on Coffee Lake and a few other CPUs)
3: use `mov` instruction
This commit is contained in:
SChernykh 2020-09-04 16:16:07 +02:00
parent a5b6383f7b
commit a84b45b1bb
7 changed files with 71 additions and 2 deletions

View file

@ -57,6 +57,8 @@ static const char *kCacheQoS = "cache_qos";
static const char *kNUMA = "numa";
#endif
static const char *kScratchpadPrefetchMode = "scratchpad_prefetch_mode";
static const std::array<const char *, RxConfig::ModeMax> modeNames = { "auto", "fast", "light" };
@ -118,6 +120,11 @@ bool xmrig::RxConfig::read(const rapidjson::Value &value)
}
# endif
const int mode = Json::getInt(value, kScratchpadPrefetchMode, static_cast<int>(m_scratchpadPrefetchMode));
if ((mode >= ScratchpadPrefetchOff) && (mode < ScratchpadPrefetchMax)) {
m_scratchpadPrefetchMode = static_cast<ScratchpadPrefetchMode>(mode);
}
return true;
}
@ -171,6 +178,8 @@ rapidjson::Value xmrig::RxConfig::toJSON(rapidjson::Document &doc) const
}
# endif
obj.AddMember(StringRef(kScratchpadPrefetchMode), static_cast<int>(m_scratchpadPrefetchMode), allocator);
return obj;
}