2018-12-11 20:00:30 +00:00
|
|
|
/*
|
2019-05-18 12:21:47 +00:00
|
|
|
Copyright (c) 2018-2019, tevador <tevador@gmail.com>
|
2018-12-11 20:00:30 +00:00
|
|
|
|
2019-05-18 12:21:47 +00:00
|
|
|
All rights reserved.
|
2018-12-11 20:00:30 +00:00
|
|
|
|
2019-05-18 12:21:47 +00:00
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the copyright holder nor the
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior written permission.
|
2018-12-11 20:00:30 +00:00
|
|
|
|
2019-05-18 12:21:47 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2018-12-11 20:00:30 +00:00
|
|
|
*/
|
2019-04-20 09:08:01 +00:00
|
|
|
|
2018-12-11 20:00:30 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <exception>
|
|
|
|
#include <string>
|
2019-04-20 09:08:01 +00:00
|
|
|
#include <vector>
|
2018-12-19 20:54:44 +00:00
|
|
|
#include <thread>
|
|
|
|
#include <atomic>
|
2019-04-20 22:20:21 +00:00
|
|
|
#include "stopwatch.hpp"
|
|
|
|
#include "utility.hpp"
|
|
|
|
#include "../randomx.h"
|
|
|
|
#include "../blake2/endian.h"
|
2019-06-22 15:42:26 +00:00
|
|
|
#include "../common.hpp"
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#include <VersionHelpers.h>
|
|
|
|
#endif
|
2019-06-22 21:11:24 +00:00
|
|
|
#include "affinity.hpp"
|
2018-12-11 20:00:30 +00:00
|
|
|
|
2019-04-20 09:08:01 +00:00
|
|
|
const uint8_t blockTemplate_[] = {
|
2019-02-11 17:57:42 +00:00
|
|
|
0x07, 0x07, 0xf7, 0xa4, 0xf0, 0xd6, 0x05, 0xb3, 0x03, 0x26, 0x08, 0x16, 0xba, 0x3f, 0x10, 0x90, 0x2e, 0x1a, 0x14,
|
|
|
|
0x5a, 0xc5, 0xfa, 0xd3, 0xaa, 0x3a, 0xf6, 0xea, 0x44, 0xc1, 0x18, 0x69, 0xdc, 0x4f, 0x85, 0x3f, 0x00, 0x2b, 0x2e,
|
|
|
|
0xea, 0x00, 0x00, 0x00, 0x00, 0x77, 0xb2, 0x06, 0xa0, 0x2c, 0xa5, 0xb1, 0xd4, 0xce, 0x6b, 0xbf, 0xdf, 0x0a, 0xca,
|
|
|
|
0xc3, 0x8b, 0xde, 0xd3, 0x4d, 0x2d, 0xcd, 0xee, 0xf9, 0x5c, 0xd2, 0x0c, 0xef, 0xc1, 0x2f, 0x61, 0xd5, 0x61, 0x09
|
|
|
|
};
|
|
|
|
|
2018-12-19 20:54:44 +00:00
|
|
|
class AtomicHash {
|
|
|
|
public:
|
|
|
|
AtomicHash() {
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
hash[i].store(0);
|
|
|
|
}
|
|
|
|
void xorWith(uint64_t update[4]) {
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
hash[i].fetch_xor(update[i]);
|
|
|
|
}
|
|
|
|
void print(std::ostream& os) {
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
print(hash[i], os);
|
|
|
|
os << std::endl;
|
|
|
|
}
|
|
|
|
private:
|
2019-02-15 09:41:02 +00:00
|
|
|
static void print(std::atomic<uint64_t>& hash, std::ostream& os) {
|
2018-12-19 20:54:44 +00:00
|
|
|
auto h = hash.load();
|
|
|
|
outputHex(std::cout, (char*)&h, sizeof(h));
|
|
|
|
}
|
|
|
|
std::atomic<uint64_t> hash[4];
|
|
|
|
};
|
2018-12-11 20:00:30 +00:00
|
|
|
|
2018-12-23 17:02:17 +00:00
|
|
|
void printUsage(const char* executable) {
|
|
|
|
std::cout << "Usage: " << executable << " [OPTIONS]" << std::endl;
|
|
|
|
std::cout << "Supported options:" << std::endl;
|
2019-02-11 17:57:42 +00:00
|
|
|
std::cout << " --help shows this message" << std::endl;
|
2019-05-15 21:13:22 +00:00
|
|
|
std::cout << " --mine mining mode: 2080 MiB" << std::endl;
|
2019-03-28 15:40:53 +00:00
|
|
|
std::cout << " --verify verification mode: 256 MiB" << std::endl;
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << " --jit x86-64 JIT compiled mode (default: interpreter)" << std::endl;
|
2019-08-25 11:47:40 +00:00
|
|
|
std::cout << " --secure W^X policy for JIT pages (default: off)" << std::endl;
|
2019-08-30 07:53:22 +00:00
|
|
|
std::cout << " --largePages use large pages (default: small pages)" << std::endl;
|
|
|
|
std::cout << " --softAes use software AES (default: hardware AES)" << std::endl;
|
2019-02-11 17:57:42 +00:00
|
|
|
std::cout << " --threads T use T threads (default: 1)" << std::endl;
|
2019-06-13 03:18:38 +00:00
|
|
|
std::cout << " --affinity A thread affinity bitmask (default: 0)" << std::endl;
|
2019-02-19 21:47:45 +00:00
|
|
|
std::cout << " --init Q initialize dataset with Q threads (default: 1)" << std::endl;
|
2019-02-11 17:57:42 +00:00
|
|
|
std::cout << " --nonces N run N nonces (default: 1000)" << std::endl;
|
2019-04-22 13:13:41 +00:00
|
|
|
std::cout << " --seed S seed for cache initialization (default: 0)" << std::endl;
|
2019-01-24 18:29:59 +00:00
|
|
|
}
|
|
|
|
|
2019-06-22 15:42:26 +00:00
|
|
|
struct MemoryException : public std::exception {
|
|
|
|
};
|
|
|
|
struct CacheAllocException : public MemoryException {
|
|
|
|
const char * what() const throw () {
|
|
|
|
return "Cache allocation failed";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct DatasetAllocException : public MemoryException {
|
|
|
|
const char * what() const throw () {
|
|
|
|
return "Dataset allocation failed";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-13 03:18:38 +00:00
|
|
|
void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result, uint32_t noncesCount, int thread, int cpuid=-1) {
|
|
|
|
if (cpuid >= 0) {
|
|
|
|
int rc = set_thread_affinity(cpuid);
|
|
|
|
if (rc) {
|
|
|
|
std::cerr << "Failed to set thread affinity for thread " << thread << " (error=" << rc << ")" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2019-04-20 22:20:21 +00:00
|
|
|
uint64_t hash[RANDOMX_HASH_SIZE / sizeof(uint64_t)];
|
2019-04-20 09:08:01 +00:00
|
|
|
uint8_t blockTemplate[sizeof(blockTemplate_)];
|
|
|
|
memcpy(blockTemplate, blockTemplate_, sizeof(blockTemplate));
|
2019-02-25 08:31:35 +00:00
|
|
|
void* noncePtr = blockTemplate + 39;
|
|
|
|
auto nonce = atomicNonce.fetch_add(1);
|
2018-12-13 22:11:55 +00:00
|
|
|
|
2018-12-19 20:54:44 +00:00
|
|
|
while (nonce < noncesCount) {
|
2019-02-25 08:31:35 +00:00
|
|
|
store32(noncePtr, nonce);
|
2019-04-20 09:08:01 +00:00
|
|
|
randomx_calculate_hash(vm, blockTemplate, sizeof(blockTemplate), &hash);
|
2018-12-19 20:54:44 +00:00
|
|
|
result.xorWith(hash);
|
|
|
|
nonce = atomicNonce.fetch_add(1);
|
2018-12-13 22:11:55 +00:00
|
|
|
}
|
2018-12-19 20:54:44 +00:00
|
|
|
}
|
2018-12-13 22:11:55 +00:00
|
|
|
|
2018-12-19 20:54:44 +00:00
|
|
|
int main(int argc, char** argv) {
|
2019-08-25 11:47:40 +00:00
|
|
|
bool softAes, miningMode, verificationMode, help, largePages, jit, secure;
|
2019-04-20 22:20:21 +00:00
|
|
|
int noncesCount, threadCount, initThreadCount;
|
2019-06-13 03:18:38 +00:00
|
|
|
uint64_t threadAffinity;
|
2019-04-24 16:37:58 +00:00
|
|
|
int32_t seedValue;
|
|
|
|
char seed[4];
|
2018-12-23 17:02:17 +00:00
|
|
|
|
2018-12-19 20:54:44 +00:00
|
|
|
readOption("--softAes", argc, argv, softAes);
|
2019-02-11 17:57:42 +00:00
|
|
|
readOption("--mine", argc, argv, miningMode);
|
2019-02-19 21:47:45 +00:00
|
|
|
readOption("--verify", argc, argv, verificationMode);
|
2018-12-19 20:54:44 +00:00
|
|
|
readIntOption("--threads", argc, argv, threadCount, 1);
|
2019-06-13 03:18:38 +00:00
|
|
|
readUInt64Option("--affinity", argc, argv, threadAffinity, 0);
|
2019-04-20 22:20:21 +00:00
|
|
|
readIntOption("--nonces", argc, argv, noncesCount, 1000);
|
2019-02-19 21:47:45 +00:00
|
|
|
readIntOption("--init", argc, argv, initThreadCount, 1);
|
2019-04-24 16:37:58 +00:00
|
|
|
readIntOption("--seed", argc, argv, seedValue, 0);
|
2019-01-04 18:44:15 +00:00
|
|
|
readOption("--largePages", argc, argv, largePages);
|
2019-08-30 07:53:22 +00:00
|
|
|
if (!largePages) {
|
|
|
|
readOption("--largepages", argc, argv, largePages);
|
|
|
|
}
|
2019-03-21 19:44:59 +00:00
|
|
|
readOption("--jit", argc, argv, jit);
|
2019-02-19 21:47:45 +00:00
|
|
|
readOption("--help", argc, argv, help);
|
2019-08-25 11:47:40 +00:00
|
|
|
readOption("--secure", argc, argv, secure);
|
2018-12-21 20:09:55 +00:00
|
|
|
|
2019-04-24 16:37:58 +00:00
|
|
|
store32(&seed, seedValue);
|
|
|
|
|
2019-09-22 20:18:28 +00:00
|
|
|
std::cout << "RandomX benchmark v1.1.1" << std::endl;
|
2019-01-24 18:29:59 +00:00
|
|
|
|
2019-02-19 21:47:45 +00:00
|
|
|
if (help || (!miningMode && !verificationMode)) {
|
|
|
|
printUsage(argv[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-25 08:31:35 +00:00
|
|
|
std::atomic<uint32_t> atomicNonce(0);
|
2018-12-19 20:54:44 +00:00
|
|
|
AtomicHash result;
|
2019-04-20 09:08:01 +00:00
|
|
|
std::vector<randomx_vm*> vms;
|
2018-12-19 20:54:44 +00:00
|
|
|
std::vector<std::thread> threads;
|
2019-04-20 09:08:01 +00:00
|
|
|
randomx_dataset* dataset;
|
|
|
|
randomx_cache* cache;
|
|
|
|
randomx_flags flags = RANDOMX_FLAG_DEFAULT;
|
2018-12-13 22:11:55 +00:00
|
|
|
|
2019-04-20 09:08:01 +00:00
|
|
|
if (miningMode) {
|
|
|
|
flags = (randomx_flags)(flags | RANDOMX_FLAG_FULL_MEM);
|
2019-05-01 12:40:13 +00:00
|
|
|
std::cout << " - full memory mode (2080 MiB)" << std::endl;
|
2019-04-20 22:20:21 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::cout << " - light memory mode (256 MiB)" << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (jit) {
|
|
|
|
flags = (randomx_flags)(flags | RANDOMX_FLAG_JIT);
|
2019-08-25 11:47:40 +00:00
|
|
|
std::cout << " - JIT compiled mode ";
|
|
|
|
if (secure) {
|
|
|
|
flags = (randomx_flags)(flags | RANDOMX_FLAG_SECURE);
|
|
|
|
std::cout << "(secure)";
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << " - interpreted mode" << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (softAes) {
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << " - software AES mode" << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
flags = (randomx_flags)(flags | RANDOMX_FLAG_HARD_AES);
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << " - hardware AES mode" << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (largePages) {
|
|
|
|
flags = (randomx_flags)(flags | RANDOMX_FLAG_LARGE_PAGES);
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << " - large pages mode" << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << " - small pages mode" << std::endl;
|
2019-04-20 09:08:01 +00:00
|
|
|
}
|
2019-02-11 17:57:42 +00:00
|
|
|
|
2019-06-13 03:18:38 +00:00
|
|
|
if (threadAffinity) {
|
|
|
|
std::cout << " - thread affinity (" << mask_to_string(threadAffinity) << ")" << std::endl;
|
|
|
|
}
|
|
|
|
|
2019-02-19 21:47:45 +00:00
|
|
|
std::cout << "Initializing";
|
2019-04-20 22:20:21 +00:00
|
|
|
if (miningMode)
|
2019-02-19 21:47:45 +00:00
|
|
|
std::cout << " (" << initThreadCount << " thread" << (initThreadCount > 1 ? "s)" : ")");
|
|
|
|
std::cout << " ..." << std::endl;
|
|
|
|
|
2018-12-11 20:00:30 +00:00
|
|
|
try {
|
2019-06-22 15:42:26 +00:00
|
|
|
if (jit && !RANDOMX_HAVE_COMPILER) {
|
2019-06-28 08:37:41 +00:00
|
|
|
throw std::runtime_error("JIT compilation is not supported on this platform. Try without --jit");
|
|
|
|
}
|
|
|
|
if (!jit && RANDOMX_HAVE_COMPILER) {
|
|
|
|
std::cout << "WARNING: You are using the interpreter mode. Use --jit for optimal performance." << std::endl;
|
2019-06-22 15:42:26 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 20:54:44 +00:00
|
|
|
Stopwatch sw(true);
|
2019-04-20 09:08:01 +00:00
|
|
|
cache = randomx_alloc_cache(flags);
|
2019-04-20 22:20:21 +00:00
|
|
|
if (cache == nullptr) {
|
2019-06-22 15:42:26 +00:00
|
|
|
throw CacheAllocException();
|
2019-04-20 22:20:21 +00:00
|
|
|
}
|
2019-04-22 13:13:41 +00:00
|
|
|
randomx_init_cache(cache, &seed, sizeof(seed));
|
2019-04-20 09:08:01 +00:00
|
|
|
if (miningMode) {
|
|
|
|
dataset = randomx_alloc_dataset(flags);
|
2019-04-20 22:20:21 +00:00
|
|
|
if (dataset == nullptr) {
|
2019-06-22 15:42:26 +00:00
|
|
|
throw DatasetAllocException();
|
2019-04-20 22:20:21 +00:00
|
|
|
}
|
2019-04-23 20:27:23 +00:00
|
|
|
uint32_t datasetItemCount = randomx_dataset_item_count();
|
2019-04-20 09:08:01 +00:00
|
|
|
if (initThreadCount > 1) {
|
2019-04-23 20:27:23 +00:00
|
|
|
auto perThread = datasetItemCount / initThreadCount;
|
|
|
|
auto remainder = datasetItemCount % initThreadCount;
|
2019-04-22 13:13:41 +00:00
|
|
|
uint32_t startItem = 0;
|
2019-04-20 09:08:01 +00:00
|
|
|
for (int i = 0; i < initThreadCount; ++i) {
|
|
|
|
auto count = perThread + (i == initThreadCount - 1 ? remainder : 0);
|
2019-04-22 13:13:41 +00:00
|
|
|
threads.push_back(std::thread(&randomx_init_dataset, dataset, cache, startItem, count));
|
|
|
|
startItem += count;
|
2019-04-13 19:29:51 +00:00
|
|
|
}
|
2019-04-20 09:08:01 +00:00
|
|
|
for (unsigned i = 0; i < threads.size(); ++i) {
|
|
|
|
threads[i].join();
|
2019-04-13 19:29:51 +00:00
|
|
|
}
|
2018-12-23 14:12:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-04-23 20:27:23 +00:00
|
|
|
randomx_init_dataset(dataset, cache, 0, datasetItemCount);
|
2018-12-19 20:54:44 +00:00
|
|
|
}
|
2019-04-20 09:08:01 +00:00
|
|
|
randomx_release_cache(cache);
|
2019-08-05 07:10:10 +00:00
|
|
|
cache = nullptr;
|
2018-12-19 20:54:44 +00:00
|
|
|
threads.clear();
|
|
|
|
}
|
2019-04-20 09:08:01 +00:00
|
|
|
std::cout << "Memory initialized in " << sw.getElapsed() << " s" << std::endl;
|
2019-02-19 21:47:45 +00:00
|
|
|
std::cout << "Initializing " << threadCount << " virtual machine(s) ..." << std::endl;
|
2018-12-19 20:54:44 +00:00
|
|
|
for (int i = 0; i < threadCount; ++i) {
|
2019-04-21 21:23:13 +00:00
|
|
|
randomx_vm *vm = randomx_create_vm(flags, cache, dataset);
|
|
|
|
if (vm == nullptr) {
|
2019-06-28 08:37:41 +00:00
|
|
|
if (!softAes) {
|
|
|
|
throw std::runtime_error("Cannot create VM with the selected options. Try using --softAes");
|
|
|
|
}
|
|
|
|
if (largePages) {
|
|
|
|
throw std::runtime_error("Cannot create VM with the selected options. Try without --largePages");
|
|
|
|
}
|
|
|
|
throw std::runtime_error("Cannot create VM");
|
2019-04-21 21:23:13 +00:00
|
|
|
}
|
2018-12-19 20:54:44 +00:00
|
|
|
vms.push_back(vm);
|
|
|
|
}
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << "Running benchmark (" << noncesCount << " nonces) ..." << std::endl;
|
2018-12-11 20:00:30 +00:00
|
|
|
sw.restart();
|
2018-12-23 14:12:54 +00:00
|
|
|
if (threadCount > 1) {
|
2019-02-09 18:32:53 +00:00
|
|
|
for (unsigned i = 0; i < vms.size(); ++i) {
|
2019-06-13 03:18:38 +00:00
|
|
|
int cpuid = -1;
|
|
|
|
if (threadAffinity)
|
|
|
|
cpuid = cpuid_from_mask(threadAffinity, i);
|
2019-02-13 21:46:32 +00:00
|
|
|
if (softAes)
|
2019-06-13 03:18:38 +00:00
|
|
|
threads.push_back(std::thread(&mine, vms[i], std::ref(atomicNonce), std::ref(result), noncesCount, i, cpuid));
|
2019-02-13 21:46:32 +00:00
|
|
|
else
|
2019-06-13 03:18:38 +00:00
|
|
|
threads.push_back(std::thread(&mine, vms[i], std::ref(atomicNonce), std::ref(result), noncesCount, i, cpuid));
|
2018-12-23 14:12:54 +00:00
|
|
|
}
|
2019-02-09 18:32:53 +00:00
|
|
|
for (unsigned i = 0; i < threads.size(); ++i) {
|
2018-12-23 14:12:54 +00:00
|
|
|
threads[i].join();
|
|
|
|
}
|
2018-12-19 20:54:44 +00:00
|
|
|
}
|
2018-12-23 14:12:54 +00:00
|
|
|
else {
|
2019-04-20 22:20:21 +00:00
|
|
|
mine(vms[0], std::ref(atomicNonce), std::ref(result), noncesCount, 0);
|
2018-12-11 20:00:30 +00:00
|
|
|
}
|
2019-04-28 10:44:28 +00:00
|
|
|
|
2018-12-13 22:11:55 +00:00
|
|
|
double elapsed = sw.getElapsed();
|
2019-04-28 10:44:28 +00:00
|
|
|
for (unsigned i = 0; i < vms.size(); ++i)
|
|
|
|
randomx_destroy_vm(vms[i]);
|
|
|
|
if (miningMode)
|
|
|
|
randomx_release_dataset(dataset);
|
|
|
|
else
|
|
|
|
randomx_release_cache(cache);
|
2018-12-19 11:38:10 +00:00
|
|
|
std::cout << "Calculated result: ";
|
2018-12-19 20:54:44 +00:00
|
|
|
result.print(std::cout);
|
2019-04-24 16:37:58 +00:00
|
|
|
if (noncesCount == 1000 && seedValue == 0)
|
2019-08-30 07:53:22 +00:00
|
|
|
std::cout << "Reference result: 10b649a3f15c7c7f88277812f2e74b337a0f20ce909af09199cccb960771cfa1" << std::endl;
|
2019-02-11 17:57:42 +00:00
|
|
|
if (!miningMode) {
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << "Performance: " << 1000 * elapsed / noncesCount << " ms per hash" << std::endl;
|
2019-01-14 23:01:11 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-04-20 22:20:21 +00:00
|
|
|
std::cout << "Performance: " << noncesCount / elapsed << " hashes per second" << std::endl;
|
2019-01-14 23:01:11 +00:00
|
|
|
}
|
2018-12-11 20:00:30 +00:00
|
|
|
}
|
2019-06-22 15:42:26 +00:00
|
|
|
catch (MemoryException& e) {
|
|
|
|
std::cout << "ERROR: " << e.what() << std::endl;
|
|
|
|
if (largePages) {
|
|
|
|
#ifdef _WIN32
|
|
|
|
std::cout << "To use large pages, please enable the \"Lock Pages in Memory\" policy and reboot." << std::endl;
|
|
|
|
if (!IsWindows8OrGreater()) {
|
|
|
|
std::cout << "Additionally, you have to run the benchmark from elevated command prompt." << std::endl;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
std::cout << "To use large pages, please run: sudo sysctl -w vm.nr_hugepages=1250" << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-12-11 20:00:30 +00:00
|
|
|
catch (std::exception& e) {
|
|
|
|
std::cout << "ERROR: " << e.what() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2019-04-20 22:20:21 +00:00
|
|
|
}
|