Merge remote-tracking branch 'upstream/dev' into dev

dev
SChernykh 5 years ago
commit 93afb248bf

@ -72,7 +72,7 @@ namespace randomx {
asmCode << "xor " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; asmCode << "xor " << regR[instr.dst] << ", " << regR[instr.src] << std::endl;
break; break;
case SuperscalarInstructionType::IADD_RS: case SuperscalarInstructionType::IADD_RS:
asmCode << "lea " << regR[instr.dst] << ", [" << regR[instr.dst] << "+" << regR[instr.src] << "*" << (1 << (instr.getModMem())) << "]" << std::endl; asmCode << "lea " << regR[instr.dst] << ", [" << regR[instr.dst] << "+" << regR[instr.src] << "*" << (1 << (instr.getModShift())) << "]" << std::endl;
break; break;
case SuperscalarInstructionType::IMUL_R: case SuperscalarInstructionType::IMUL_R:
asmCode << "imul " << regR[instr.dst] << ", " << regR[instr.src] << std::endl; asmCode << "imul " << regR[instr.dst] << ", " << regR[instr.src] << std::endl;
@ -181,7 +181,7 @@ namespace randomx {
asmCode << regR[instr.dst] << " ^= " << regR[instr.src] << ";" << std::endl; asmCode << regR[instr.dst] << " ^= " << regR[instr.src] << ";" << std::endl;
break; break;
case SuperscalarInstructionType::IADD_RS: case SuperscalarInstructionType::IADD_RS:
asmCode << regR[instr.dst] << " += " << regR[instr.src] << "*" << (1 << (instr.getModMem())) << ";" << std::endl; asmCode << regR[instr.dst] << " += " << regR[instr.src] << "*" << (1 << (instr.getModShift())) << ";" << std::endl;
break; break;
case SuperscalarInstructionType::IMUL_R: case SuperscalarInstructionType::IMUL_R:
asmCode << regR[instr.dst] << " *= " << regR[instr.src] << ";" << std::endl; asmCode << regR[instr.dst] << " *= " << regR[instr.src] << ";" << std::endl;

@ -47,15 +47,15 @@ static_assert(ARGON2_BLOCK_SIZE == randomx::ArgonBlockSize, "Unpexpected value o
namespace randomx { namespace randomx {
void initCache(randomx_cache* cache, const void* seed, size_t seedSize) { void initCache(randomx_cache* cache, const void* key, size_t keySize) {
uint32_t memory_blocks, segment_length; uint32_t memory_blocks, segment_length;
argon2_instance_t instance; argon2_instance_t instance;
argon2_context context; argon2_context context;
context.out = nullptr; context.out = nullptr;
context.outlen = 0; context.outlen = 0;
context.pwd = CONST_CAST(uint8_t *)seed; context.pwd = CONST_CAST(uint8_t *)key;
context.pwdlen = (uint32_t)seedSize; context.pwdlen = (uint32_t)keySize;
context.salt = CONST_CAST(uint8_t *)RANDOMX_ARGON_SALT; context.salt = CONST_CAST(uint8_t *)RANDOMX_ARGON_SALT;
context.saltlen = (uint32_t)randomx::ArgonSaltSize; context.saltlen = (uint32_t)randomx::ArgonSaltSize;
context.secret = NULL; context.secret = NULL;
@ -100,7 +100,7 @@ namespace randomx {
fill_memory_blocks(&instance); fill_memory_blocks(&instance);
cache->reciprocalCache.clear(); cache->reciprocalCache.clear();
randomx::Blake2Generator gen(seed, seedSize); randomx::Blake2Generator gen(key, keySize);
for (int i = 0; i < RANDOMX_CACHE_ACCESSES; ++i) { for (int i = 0; i < RANDOMX_CACHE_ACCESSES; ++i) {
randomx::generateSuperscalar(cache->programs[i], gen); randomx::generateSuperscalar(cache->programs[i], gen);
for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) { for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) {
@ -114,8 +114,8 @@ namespace randomx {
} }
} }
void initCacheCompile(randomx_cache* cache, const void* seed, size_t seedSize) { void initCacheCompile(randomx_cache* cache, const void* key, size_t keySize) {
initCache(cache, seed, seedSize); initCache(cache, key, keySize);
cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache); cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache);
cache->jit->generateDatasetInitCode(); cache->jit->generateDatasetInitCode();
} }

@ -352,7 +352,7 @@ namespace randomx {
case randomx::SuperscalarInstructionType::IADD_RS: case randomx::SuperscalarInstructionType::IADD_RS:
emit(REX_LEA); emit(REX_LEA);
emitByte(0x04 + 8 * instr.dst); emitByte(0x04 + 8 * instr.dst);
genSIB(instr.getModMem(), instr.src, instr.dst); genSIB(instr.getModShift(), instr.src, instr.dst);
break; break;
case randomx::SuperscalarInstructionType::IMUL_R: case randomx::SuperscalarInstructionType::IMUL_R:
emit(REX_IMUL_RR); emit(REX_IMUL_RR);

@ -76,8 +76,8 @@ extern "C" {
return cache; return cache;
} }
void randomx_init_cache(randomx_cache *cache, const void *seed, size_t seedSize) { void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize) {
cache->initialize(cache, seed, seedSize); cache->initialize(cache, key, keySize);
} }
void randomx_release_cache(randomx_cache* cache) { void randomx_release_cache(randomx_cache* cache) {

@ -56,13 +56,13 @@ extern "C" {
randomx_cache *randomx_alloc_cache(randomx_flags flags); randomx_cache *randomx_alloc_cache(randomx_flags flags);
/** /**
* Initializes the cache memory and SuperscalarHash using the provided seed value. * Initializes the cache memory and SuperscalarHash using the provided key value.
* *
* @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL. * @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL.
* @param seed is a pointer to memory which contains the seed value. Must not be NULL. * @param key is a pointer to memory which contains the key value. Must not be NULL.
* @param seedSize is the number of bytes of the seed. * @param keySize is the number of bytes of the key.
*/ */
void randomx_init_cache(randomx_cache *cache, const void *seed, size_t seedSize); void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize);
/** /**
* Releases all memory occupied by the randomx_cache structure. * Releases all memory occupied by the randomx_cache structure.
@ -146,7 +146,7 @@ randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx
/** /**
* Reinitializes a virtual machine with a new Cache. This function should be called anytime * Reinitializes a virtual machine with a new Cache. This function should be called anytime
* the Cache is reinitialized with a new seed. * the Cache is reinitialized with a new key.
* *
* @param machine is a pointer to a randomx_vm structure that was initialized * @param machine is a pointer to a randomx_vm structure that was initialized
* without RANDOMX_FLAG_FULL_MEM. Must not be NULL. * without RANDOMX_FLAG_FULL_MEM. Must not be NULL.

@ -849,7 +849,7 @@ namespace randomx {
r[instr.dst] ^= r[instr.src]; r[instr.dst] ^= r[instr.src];
break; break;
case randomx::SuperscalarInstructionType::IADD_RS: case randomx::SuperscalarInstructionType::IADD_RS:
r[instr.dst] += r[instr.src] << instr.getModMem(); r[instr.dst] += r[instr.src] << instr.getModShift();
break; break;
case randomx::SuperscalarInstructionType::IMUL_R: case randomx::SuperscalarInstructionType::IMUL_R:
r[instr.dst] *= r[instr.src]; r[instr.dst] *= r[instr.src];

@ -126,7 +126,7 @@ int main(int argc, char** argv) {
if (miningMode) { if (miningMode) {
flags = (randomx_flags)(flags | RANDOMX_FLAG_FULL_MEM); flags = (randomx_flags)(flags | RANDOMX_FLAG_FULL_MEM);
std::cout << " - full memory mode (2 GiB)" << std::endl; std::cout << " - full memory mode (2080 MiB)" << std::endl;
} }
else { else {
std::cout << " - light memory mode (256 MiB)" << std::endl; std::cout << " - light memory mode (256 MiB)" << std::endl;
@ -229,7 +229,7 @@ int main(int argc, char** argv) {
std::cout << "Calculated result: "; std::cout << "Calculated result: ";
result.print(std::cout); result.print(std::cout);
if (noncesCount == 1000 && seedValue == 0) if (noncesCount == 1000 && seedValue == 0)
std::cout << "Reference result: 6d95d8d07fa3a80771f33d1b20452b61ab2d0bf21058b5e586fad38bf3e1e0ca" << std::endl; std::cout << "Reference result: a15448785857f9a78703eb5da235dfe73d0d5fc4c8effaebe73869904f5af47d" << std::endl;
if (!miningMode) { if (!miningMode) {
std::cout << "Performance: " << 1000 * elapsed / noncesCount << " ms per hash" << std::endl; std::cout << "Performance: " << 1000 * elapsed / noncesCount << " ms per hash" << std::endl;
} }

@ -23,7 +23,6 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
#include <sstream> #include <sstream>
#include <cmath> #include <cmath>
#include <cfloat> #include <cfloat>
#include <climits>
#include "vm_interpreted.hpp" #include "vm_interpreted.hpp"
#include "dataset.hpp" #include "dataset.hpp"
#include "intrin_portable.h" #include "intrin_portable.h"

Loading…
Cancel
Save