mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-21 06:38:56 +00:00
Fixed Debug build in Visual Studio
This commit is contained in:
parent
6dba0635f1
commit
50bdaba526
11 changed files with 44 additions and 51 deletions
|
@ -92,24 +92,15 @@ namespace randomx {
|
||||||
|
|
||||||
argon2_ctx_mem(&context, Argon2_d, cache->memory, RandomX_CurrentConfig.ArgonMemory * 1024);
|
argon2_ctx_mem(&context, Argon2_d, cache->memory, RandomX_CurrentConfig.ArgonMemory * 1024);
|
||||||
|
|
||||||
cache->reciprocalCache.clear();
|
|
||||||
randomx::Blake2Generator gen(key, keySize);
|
randomx::Blake2Generator gen(key, keySize);
|
||||||
for (uint32_t i = 0; i < RandomX_CurrentConfig.CacheAccesses; ++i) {
|
for (uint32_t i = 0; i < RandomX_CurrentConfig.CacheAccesses; ++i) {
|
||||||
randomx::generateSuperscalar(cache->programs[i], gen);
|
randomx::generateSuperscalar(cache->programs[i], gen);
|
||||||
for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) {
|
|
||||||
auto& instr = cache->programs[i](j);
|
|
||||||
if ((SuperscalarInstructionType)instr.opcode == SuperscalarInstructionType::IMUL_RCP) {
|
|
||||||
auto rcp = randomx_reciprocal(instr.getImm32());
|
|
||||||
instr.setImm32(cache->reciprocalCache.size());
|
|
||||||
cache->reciprocalCache.push_back(rcp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCacheCompile(randomx_cache* cache, const void* key, size_t keySize) {
|
void initCacheCompile(randomx_cache* cache, const void* key, size_t keySize) {
|
||||||
initCache(cache, key, keySize);
|
initCache(cache, key, keySize);
|
||||||
cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache);
|
cache->jit->generateSuperscalarHash(cache->programs);
|
||||||
cache->jit->generateDatasetInitCode();
|
cache->jit->generateDatasetInitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +135,7 @@ namespace randomx {
|
||||||
rx_prefetch_nta(mixBlock);
|
rx_prefetch_nta(mixBlock);
|
||||||
SuperscalarProgram& prog = cache->programs[i];
|
SuperscalarProgram& prog = cache->programs[i];
|
||||||
|
|
||||||
executeSuperscalar(rl, prog, &cache->reciprocalCache);
|
executeSuperscalar(rl, prog);
|
||||||
|
|
||||||
for (unsigned q = 0; q < 8; ++q)
|
for (unsigned q = 0; q < 8; ++q)
|
||||||
rl[q] ^= load64_native(mixBlock + 8 * q);
|
rl[q] ^= load64_native(mixBlock + 8 * q);
|
||||||
|
|
|
@ -47,7 +47,6 @@ struct randomx_cache {
|
||||||
randomx::CacheInitializeFunc* initialize;
|
randomx::CacheInitializeFunc* initialize;
|
||||||
randomx::DatasetInitFunc* datasetInit;
|
randomx::DatasetInitFunc* datasetInit;
|
||||||
randomx::SuperscalarProgram programs[RANDOMX_CACHE_MAX_ACCESSES];
|
randomx::SuperscalarProgram programs[RANDOMX_CACHE_MAX_ACCESSES];
|
||||||
std::vector<uint64_t> reciprocalCache;
|
|
||||||
|
|
||||||
bool isInitialized() {
|
bool isInitialized() {
|
||||||
return programs[0].getSize() != 0;
|
return programs[0].getSize() != 0;
|
||||||
|
|
|
@ -230,7 +230,7 @@ void JitCompilerA64::generateProgramLight(Program& program, ProgramConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector<uint64_t> &reciprocalCache)
|
void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N])
|
||||||
{
|
{
|
||||||
uint32_t codePos = CodeSize;
|
uint32_t codePos = CodeSize;
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N], s
|
||||||
{
|
{
|
||||||
const Instruction& instr = prog(j);
|
const Instruction& instr = prog(j);
|
||||||
if (static_cast<SuperscalarInstructionType>(instr.opcode) == randomx::SuperscalarInstructionType::IMUL_RCP)
|
if (static_cast<SuperscalarInstructionType>(instr.opcode) == randomx::SuperscalarInstructionType::IMUL_RCP)
|
||||||
emit64(reciprocalCache[instr.getImm32()], code, codePos);
|
emit64(randomx_reciprocal(instr.getImm32()), code, codePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump over literal pool
|
// Jump over literal pool
|
||||||
|
@ -345,7 +345,7 @@ void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N], s
|
||||||
clear_code_cache(reinterpret_cast<char*>(code + CodeSize), reinterpret_cast<char*>(code + codePos));
|
clear_code_cache(reinterpret_cast<char*>(code + CodeSize), reinterpret_cast<char*>(code + codePos));
|
||||||
}
|
}
|
||||||
|
|
||||||
template void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[RANDOMX_CACHE_MAX_ACCESSES], std::vector<uint64_t> &reciprocalCache);
|
template void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[RANDOMX_CACHE_MAX_ACCESSES]);
|
||||||
|
|
||||||
DatasetInitFunc* JitCompilerA64::getDatasetInitFunc()
|
DatasetInitFunc* JitCompilerA64::getDatasetInitFunc()
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace randomx {
|
namespace randomx {
|
||||||
|
|
||||||
class Program;
|
class Program;
|
||||||
class ProgramConfiguration;
|
struct ProgramConfiguration;
|
||||||
class SuperscalarProgram;
|
class SuperscalarProgram;
|
||||||
class Instruction;
|
class Instruction;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace randomx {
|
||||||
void generateProgramLight(Program&, ProgramConfiguration&, uint32_t);
|
void generateProgramLight(Program&, ProgramConfiguration&, uint32_t);
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector<uint64_t> &);
|
void generateSuperscalarHash(SuperscalarProgram(&programs)[N]);
|
||||||
|
|
||||||
void generateDatasetInitCode() {}
|
void generateDatasetInitCode() {}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace randomx {
|
||||||
|
|
||||||
}
|
}
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector<uint64_t> &) {
|
void generateSuperscalarHash(SuperscalarProgram(&programs)[N]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
void generateDatasetInitCode() {
|
void generateDatasetInitCode() {
|
||||||
|
|
|
@ -96,24 +96,30 @@ namespace randomx {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define codePrefetchScratchpad ((uint8_t*)&randomx_prefetch_scratchpad)
|
# if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
#define codePrefetchScratchpadEnd ((uint8_t*)&randomx_prefetch_scratchpad_end)
|
#define ADDR(x) ((((uint8_t*)&x)[0] == 0xE9) ? (((uint8_t*)&x) + *(const int32_t*)(((uint8_t*)&x) + 1) + 5) : ((uint8_t*)&x))
|
||||||
#define codePrologue ((uint8_t*)&randomx_program_prologue)
|
# else
|
||||||
#define codeLoopBegin ((uint8_t*)&randomx_program_loop_begin)
|
#define ADDR(x) ((uint8_t*)&x)
|
||||||
#define codeLoopLoad ((uint8_t*)&randomx_program_loop_load)
|
# endif
|
||||||
#define codeLoopLoadXOP ((uint8_t*)&randomx_program_loop_load_xop)
|
|
||||||
#define codeProgamStart ((uint8_t*)&randomx_program_start)
|
#define codePrefetchScratchpad ADDR(randomx_prefetch_scratchpad)
|
||||||
#define codeReadDatasetLightSshInit ((uint8_t*)&randomx_program_read_dataset_sshash_init)
|
#define codePrefetchScratchpadEnd ADDR(randomx_prefetch_scratchpad_end)
|
||||||
#define codeReadDatasetLightSshFin ((uint8_t*)&randomx_program_read_dataset_sshash_fin)
|
#define codePrologue ADDR(randomx_program_prologue)
|
||||||
#define codeDatasetInit ((uint8_t*)&randomx_dataset_init)
|
#define codeLoopBegin ADDR(randomx_program_loop_begin)
|
||||||
#define codeLoopStore ((uint8_t*)&randomx_program_loop_store)
|
#define codeLoopLoad ADDR(randomx_program_loop_load)
|
||||||
#define codeLoopEnd ((uint8_t*)&randomx_program_loop_end)
|
#define codeLoopLoadXOP ADDR(randomx_program_loop_load_xop)
|
||||||
#define codeEpilogue ((uint8_t*)&randomx_program_epilogue)
|
#define codeProgamStart ADDR(randomx_program_start)
|
||||||
#define codeProgramEnd ((uint8_t*)&randomx_program_end)
|
#define codeReadDatasetLightSshInit ADDR(randomx_program_read_dataset_sshash_init)
|
||||||
#define codeShhLoad ((uint8_t*)&randomx_sshash_load)
|
#define codeReadDatasetLightSshFin ADDR(randomx_program_read_dataset_sshash_fin)
|
||||||
#define codeShhPrefetch ((uint8_t*)&randomx_sshash_prefetch)
|
#define codeDatasetInit ADDR(randomx_dataset_init)
|
||||||
#define codeShhEnd ((uint8_t*)&randomx_sshash_end)
|
#define codeLoopStore ADDR(randomx_program_loop_store)
|
||||||
#define codeShhInit ((uint8_t*)&randomx_sshash_init)
|
#define codeLoopEnd ADDR(randomx_program_loop_end)
|
||||||
|
#define codeEpilogue ADDR(randomx_program_epilogue)
|
||||||
|
#define codeProgramEnd ADDR(randomx_program_end)
|
||||||
|
#define codeShhLoad ADDR(randomx_sshash_load)
|
||||||
|
#define codeShhPrefetch ADDR(randomx_sshash_prefetch)
|
||||||
|
#define codeShhEnd ADDR(randomx_sshash_end)
|
||||||
|
#define codeShhInit ADDR(randomx_sshash_init)
|
||||||
|
|
||||||
#define prefetchScratchpadSize (codePrefetchScratchpadEnd - codePrefetchScratchpad)
|
#define prefetchScratchpadSize (codePrefetchScratchpadEnd - codePrefetchScratchpad)
|
||||||
#define prologueSize (codeLoopBegin - codePrologue)
|
#define prologueSize (codeLoopBegin - codePrologue)
|
||||||
|
@ -264,14 +270,14 @@ namespace randomx {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void JitCompilerX86::generateSuperscalarHash(SuperscalarProgram(&programs)[N], std::vector<uint64_t> &reciprocalCache) {
|
void JitCompilerX86::generateSuperscalarHash(SuperscalarProgram(&programs)[N]) {
|
||||||
memcpy(code + superScalarHashOffset, codeShhInit, codeSshInitSize);
|
memcpy(code + superScalarHashOffset, codeShhInit, codeSshInitSize);
|
||||||
codePos = superScalarHashOffset + codeSshInitSize;
|
codePos = superScalarHashOffset + codeSshInitSize;
|
||||||
for (unsigned j = 0; j < RandomX_CurrentConfig.CacheAccesses; ++j) {
|
for (unsigned j = 0; j < RandomX_CurrentConfig.CacheAccesses; ++j) {
|
||||||
SuperscalarProgram& prog = programs[j];
|
SuperscalarProgram& prog = programs[j];
|
||||||
for (unsigned i = 0; i < prog.getSize(); ++i) {
|
for (unsigned i = 0; i < prog.getSize(); ++i) {
|
||||||
Instruction& instr = prog(i);
|
Instruction& instr = prog(i);
|
||||||
generateSuperscalarCode(instr, reciprocalCache);
|
generateSuperscalarCode(instr);
|
||||||
}
|
}
|
||||||
emit(codeShhLoad, codeSshLoadSize, code, codePos);
|
emit(codeShhLoad, codeSshLoadSize, code, codePos);
|
||||||
if (j < RandomX_CurrentConfig.CacheAccesses - 1) {
|
if (j < RandomX_CurrentConfig.CacheAccesses - 1) {
|
||||||
|
@ -284,7 +290,7 @@ namespace randomx {
|
||||||
}
|
}
|
||||||
|
|
||||||
template
|
template
|
||||||
void JitCompilerX86::generateSuperscalarHash(SuperscalarProgram(&programs)[RANDOMX_CACHE_MAX_ACCESSES], std::vector<uint64_t> &reciprocalCache);
|
void JitCompilerX86::generateSuperscalarHash(SuperscalarProgram(&programs)[RANDOMX_CACHE_MAX_ACCESSES]);
|
||||||
|
|
||||||
void JitCompilerX86::generateDatasetInitCode() {
|
void JitCompilerX86::generateDatasetInitCode() {
|
||||||
memcpy(code, codeDatasetInit, datasetInitSize);
|
memcpy(code, codeDatasetInit, datasetInitSize);
|
||||||
|
@ -366,7 +372,7 @@ namespace randomx {
|
||||||
emit32(epilogueOffset - codePos - 4, code, codePos);
|
emit32(epilogueOffset - codePos - 4, code, codePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JitCompilerX86::generateSuperscalarCode(Instruction& instr, std::vector<uint64_t> &reciprocalCache) {
|
void JitCompilerX86::generateSuperscalarCode(Instruction& instr) {
|
||||||
static constexpr uint8_t REX_SUB_RR[] = { 0x4d, 0x2b };
|
static constexpr uint8_t REX_SUB_RR[] = { 0x4d, 0x2b };
|
||||||
static constexpr uint8_t REX_MOV_RR64[] = { 0x49, 0x8b };
|
static constexpr uint8_t REX_MOV_RR64[] = { 0x49, 0x8b };
|
||||||
static constexpr uint8_t REX_MOV_R64R[] = { 0x4c, 0x8b };
|
static constexpr uint8_t REX_MOV_R64R[] = { 0x4c, 0x8b };
|
||||||
|
@ -452,7 +458,7 @@ namespace randomx {
|
||||||
break;
|
break;
|
||||||
case randomx::SuperscalarInstructionType::IMUL_RCP:
|
case randomx::SuperscalarInstructionType::IMUL_RCP:
|
||||||
emit(MOV_RAX_I, code, codePos);
|
emit(MOV_RAX_I, code, codePos);
|
||||||
emit64(reciprocalCache[instr.getImm32()], code, codePos);
|
emit64(randomx_reciprocal_fast(instr.getImm32()), code, codePos);
|
||||||
emit(REX_IMUL_RM, code, codePos);
|
emit(REX_IMUL_RM, code, codePos);
|
||||||
emitByte(0xc0 + 8 * instr.dst, code, codePos);
|
emitByte(0xc0 + 8 * instr.dst, code, codePos);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace randomx {
|
||||||
void generateProgram(Program&, ProgramConfiguration&, uint32_t);
|
void generateProgram(Program&, ProgramConfiguration&, uint32_t);
|
||||||
void generateProgramLight(Program&, ProgramConfiguration&, uint32_t);
|
void generateProgramLight(Program&, ProgramConfiguration&, uint32_t);
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
void generateSuperscalarHash(SuperscalarProgram (&programs)[N], std::vector<uint64_t> &);
|
void generateSuperscalarHash(SuperscalarProgram (&programs)[N]);
|
||||||
void generateDatasetInitCode();
|
void generateDatasetInitCode();
|
||||||
ProgramFunc* getProgramFunc() {
|
ProgramFunc* getProgramFunc() {
|
||||||
return (ProgramFunc*)code;
|
return (ProgramFunc*)code;
|
||||||
|
@ -92,7 +92,7 @@ namespace randomx {
|
||||||
static void genAddressImm(const Instruction&, uint8_t* code, uint32_t& codePos);
|
static void genAddressImm(const Instruction&, uint8_t* code, uint32_t& codePos);
|
||||||
static void genSIB(int scale, int index, int base, uint8_t* code, uint32_t& codePos);
|
static void genSIB(int scale, int index, int base, uint8_t* code, uint32_t& codePos);
|
||||||
|
|
||||||
void generateSuperscalarCode(Instruction &, std::vector<uint64_t> &);
|
void generateSuperscalarCode(Instruction &);
|
||||||
|
|
||||||
static void emitByte(uint8_t val, uint8_t* code, uint32_t& codePos) {
|
static void emitByte(uint8_t val, uint8_t* code, uint32_t& codePos) {
|
||||||
code[codePos] = val;
|
code[codePos] = val;
|
||||||
|
|
|
@ -847,7 +847,7 @@ namespace randomx {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void executeSuperscalar(int_reg_t(&r)[8], SuperscalarProgram& prog, std::vector<uint64_t> *reciprocals) {
|
void executeSuperscalar(int_reg_t(&r)[8], SuperscalarProgram& prog) {
|
||||||
for (unsigned j = 0; j < prog.getSize(); ++j) {
|
for (unsigned j = 0; j < prog.getSize(); ++j) {
|
||||||
Instruction& instr = prog(j);
|
Instruction& instr = prog(j);
|
||||||
switch ((SuperscalarInstructionType)instr.opcode)
|
switch ((SuperscalarInstructionType)instr.opcode)
|
||||||
|
@ -884,9 +884,6 @@ namespace randomx {
|
||||||
r[instr.dst] = smulh(r[instr.dst], r[instr.src]);
|
r[instr.dst] = smulh(r[instr.dst], r[instr.src]);
|
||||||
break;
|
break;
|
||||||
case SuperscalarInstructionType::IMUL_RCP:
|
case SuperscalarInstructionType::IMUL_RCP:
|
||||||
if (reciprocals != nullptr)
|
|
||||||
r[instr.dst] *= (*reciprocals)[instr.getImm32()];
|
|
||||||
else
|
|
||||||
r[instr.dst] *= randomx_reciprocal(instr.getImm32());
|
r[instr.dst] *= randomx_reciprocal(instr.getImm32());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -56,5 +56,5 @@ namespace randomx {
|
||||||
};
|
};
|
||||||
|
|
||||||
void generateSuperscalar(SuperscalarProgram& prog, Blake2Generator& gen);
|
void generateSuperscalar(SuperscalarProgram& prog, Blake2Generator& gen);
|
||||||
void executeSuperscalar(uint64_t(&r)[8], SuperscalarProgram& prog, std::vector<uint64_t> *reciprocals = nullptr);
|
void executeSuperscalar(uint64_t(&r)[8], SuperscalarProgram& prog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace randomx {
|
||||||
void CompiledLightVm<softAes>::setCache(randomx_cache* cache) {
|
void CompiledLightVm<softAes>::setCache(randomx_cache* cache) {
|
||||||
cachePtr = cache;
|
cachePtr = cache;
|
||||||
mem.memory = cache->memory;
|
mem.memory = cache->memory;
|
||||||
compiler.generateSuperscalarHash(cache->programs, cache->reciprocalCache);
|
compiler.generateSuperscalarHash(cache->programs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int softAes>
|
template<int softAes>
|
||||||
|
|
|
@ -117,7 +117,7 @@ static HANDLE wrmsr_install_driver()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = dir.end(); it != dir.begin(); --it) {
|
for (auto it = dir.end() - 1; it != dir.begin(); --it) {
|
||||||
if ((*it == L'\\') || (*it == L'/')) {
|
if ((*it == L'\\') || (*it == L'/')) {
|
||||||
++it;
|
++it;
|
||||||
*it = L'\0';
|
*it = L'\0';
|
||||||
|
|
Loading…
Reference in a new issue