diff --git a/src/Mem.cpp b/src/Mem.cpp index 2efaac8a..bb2da646 100644 --- a/src/Mem.cpp +++ b/src/Mem.cpp @@ -50,7 +50,7 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) allocate(info, m_enabled); for (size_t i = 0; i < count; ++i) { - cryptonight_ctx *c = static_cast(_mm_malloc(sizeof(cryptonight_ctx), 16)); + cryptonight_ctx *c = static_cast(_mm_malloc(sizeof(cryptonight_ctx), 4096)); c->memory = info.memory + (i * cn_select_memory(algorithm)); ctx[i] = c; diff --git a/src/Mem_unix.cpp b/src/Mem_unix.cpp index 550033c4..229a0d46 100644 --- a/src/Mem_unix.cpp +++ b/src/Mem_unix.cpp @@ -45,7 +45,7 @@ void Mem::allocate(MemInfo &info, bool enabled) info.hugePages = 0; if (!enabled) { - info.memory = static_cast(_mm_malloc(info.size, 16)); + info.memory = static_cast(_mm_malloc(info.size, 4096)); return; } diff --git a/src/Mem_win.cpp b/src/Mem_win.cpp index d0b698f6..9a81b039 100644 --- a/src/Mem_win.cpp +++ b/src/Mem_win.cpp @@ -157,7 +157,7 @@ void Mem::allocate(MemInfo &info, bool enabled) info.hugePages = 0; if (!enabled) { - info.memory = static_cast(_mm_malloc(info.size, 16)); + info.memory = static_cast(_mm_malloc(info.size, 4096)); return; } diff --git a/src/crypto/CryptoNight_arm.h b/src/crypto/CryptoNight_arm.h index d9677d06..101a1f58 100644 --- a/src/crypto/CryptoNight_arm.h +++ b/src/crypto/CryptoNight_arm.h @@ -455,7 +455,7 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output) template -inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx *__restrict__ ctx) +inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx) { constexpr size_t MASK = xmrig::cn_select_mask(); constexpr size_t ITERATIONS = xmrig::cn_select_iter(); @@ -466,14 +466,14 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si return; } - keccak(input, (int) size, ctx->state0, 200); + keccak(input, (int) size, ctx[0]->state, 200); VARIANT1_INIT(0); - cn_explode_scratchpad((__m128i*) ctx->state0, (__m128i*) ctx->memory); + cn_explode_scratchpad((__m128i*) ctx[0]->state, (__m128i*) ctx[0]->memory); - const uint8_t* l0 = ctx->memory; - uint64_t* h0 = reinterpret_cast(ctx->state0); + const uint8_t* l0 = ctx[0]->memory; + uint64_t* h0 = reinterpret_cast(ctx[0]->state); uint64_t al0 = h0[0] ^ h0[4]; uint64_t ah0 = h0[1] ^ h0[5]; @@ -526,15 +526,15 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si } } - cn_implode_scratchpad((__m128i*) ctx->memory, (__m128i*) ctx->state0); + cn_implode_scratchpad((__m128i*) ctx[0]->memory, (__m128i*) ctx[0]->state); keccakf(h0, 24); - extra_hashes[ctx->state0[0] & 3](ctx->state0, 200, output); + extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); } template -inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx) +inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx) { constexpr size_t MASK = xmrig::cn_select_mask(); constexpr size_t ITERATIONS = xmrig::cn_select_iter(); @@ -545,16 +545,16 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si return; } - keccak(input, (int) size, ctx->state0, 200); - keccak(input + size, (int) size, ctx->state1, 200); + keccak(input, (int) size, ctx[0]->state, 200); + keccak(input + size, (int) size, ctx[1]->state, 200); VARIANT1_INIT(0); VARIANT1_INIT(1); - const uint8_t* l0 = ctx->memory; - const uint8_t* l1 = ctx->memory + MEM; - uint64_t* h0 = reinterpret_cast(ctx->state0); - uint64_t* h1 = reinterpret_cast(ctx->state1); + const uint8_t* l0 = ctx[0]->memory; + const uint8_t* l1 = ctx[1]->memory; + uint64_t* h0 = reinterpret_cast(ctx[0]->state); + uint64_t* h1 = reinterpret_cast(ctx[1]->state); cn_explode_scratchpad((__m128i*) h0, (__m128i*) l0); cn_explode_scratchpad((__m128i*) h1, (__m128i*) l1); @@ -655,25 +655,25 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si keccakf(h0, 24); keccakf(h1, 24); - extra_hashes[ctx->state0[0] & 3](ctx->state0, 200, output); - extra_hashes[ctx->state1[0] & 3](ctx->state1, 200, output + 32); + extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); + extra_hashes[ctx[1]->state[0] & 3](ctx[1]->state, 200, output + 32); } template -inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx) +inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx) { } template -inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx) +inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx) { } template -inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx *__restrict__ ctx) +inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx) { } diff --git a/src/crypto/CryptoNight_monero.h b/src/crypto/CryptoNight_monero.h index a34f3ba8..ea1622ab 100644 --- a/src/crypto/CryptoNight_monero.h +++ b/src/crypto/CryptoNight_monero.h @@ -39,7 +39,7 @@ uint64_t tweak1_2_##part = 0; \ if (VARIANT > 0) { \ volatile const uint64_t a = *reinterpret_cast(input + 35 + part * size); \ - volatile const uint64_t b = *(reinterpret_cast(ctx->state##part) + 24); \ + volatile const uint64_t b = *(reinterpret_cast(ctx[part]->state) + 24); \ tweak1_2_##part = a ^ b; \ } #endif