|
|
|
@ -96,7 +96,7 @@ void printUsage(const char* executable) {
|
|
|
|
|
std::cout << " --avx2 use optimized Argon2 for AVX2 CPUs" << std::endl;
|
|
|
|
|
std::cout << " --auto select the best options for the current CPU" << std::endl;
|
|
|
|
|
std::cout << " --noBatch calculate hashes one by one (default: batch)" << std::endl;
|
|
|
|
|
std::cout << " --v2 calculate v2 hashes (default: v1)" << std::endl;
|
|
|
|
|
std::cout << " --commit calculate commitments instead of hashes (default: hashes)" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MemoryException : public std::exception {
|
|
|
|
@ -114,7 +114,7 @@ struct DatasetAllocException : public MemoryException {
|
|
|
|
|
|
|
|
|
|
using MineFunc = void(randomx_vm * vm, std::atomic<uint32_t> & atomicNonce, AtomicHash & result, uint32_t noncesCount, int thread, int cpuid);
|
|
|
|
|
|
|
|
|
|
template<bool batch, bool v2>
|
|
|
|
|
template<bool batch, bool commit>
|
|
|
|
|
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);
|
|
|
|
@ -139,8 +139,8 @@ void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result
|
|
|
|
|
}
|
|
|
|
|
store32(noncePtr, nonce);
|
|
|
|
|
(batch ? randomx_calculate_hash_next : randomx_calculate_hash)(vm, blockTemplate, sizeof(blockTemplate), &hash);
|
|
|
|
|
if (v2) {
|
|
|
|
|
randomx_calculate_hash_v2(blockTemplate, sizeof(blockTemplate), &hash, &hash);
|
|
|
|
|
if (commit) {
|
|
|
|
|
randomx_calculate_commitment(blockTemplate, sizeof(blockTemplate), &hash, &hash);
|
|
|
|
|
}
|
|
|
|
|
result.xorWith(hash);
|
|
|
|
|
if (!batch) {
|
|
|
|
@ -150,7 +150,7 @@ void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
bool softAes, miningMode, verificationMode, help, largePages, jit, secure, v2;
|
|
|
|
|
bool softAes, miningMode, verificationMode, help, largePages, jit, secure, commit;
|
|
|
|
|
bool ssse3, avx2, autoFlags, noBatch;
|
|
|
|
|
int noncesCount, threadCount, initThreadCount;
|
|
|
|
|
uint64_t threadAffinity;
|
|
|
|
@ -176,7 +176,7 @@ int main(int argc, char** argv) {
|
|
|
|
|
readOption("--avx2", argc, argv, avx2);
|
|
|
|
|
readOption("--auto", argc, argv, autoFlags);
|
|
|
|
|
readOption("--noBatch", argc, argv, noBatch);
|
|
|
|
|
readOption("--v2", argc, argv, v2);
|
|
|
|
|
readOption("--commit", argc, argv, commit);
|
|
|
|
|
|
|
|
|
|
store32(&seed, seedValue);
|
|
|
|
|
|
|
|
|
@ -285,8 +285,8 @@ int main(int argc, char** argv) {
|
|
|
|
|
MineFunc* func;
|
|
|
|
|
|
|
|
|
|
if (noBatch) {
|
|
|
|
|
if (v2) {
|
|
|
|
|
std::cout << " - v2 hashes" << std::endl;
|
|
|
|
|
if (commit) {
|
|
|
|
|
std::cout << " - hash commitments" << std::endl;
|
|
|
|
|
func = &mine<false, true>;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -294,9 +294,9 @@ int main(int argc, char** argv) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (v2) {
|
|
|
|
|
//TODO: support batch mode with v2
|
|
|
|
|
std::cout << " - v2 hashes" << std::endl;
|
|
|
|
|
if (commit) {
|
|
|
|
|
//TODO: support batch mode with commitments
|
|
|
|
|
std::cout << " - hash commitments" << std::endl;
|
|
|
|
|
func = &mine<false, true>;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -394,7 +394,7 @@ int main(int argc, char** argv) {
|
|
|
|
|
randomx_release_cache(cache);
|
|
|
|
|
std::cout << "Calculated result: ";
|
|
|
|
|
result.print(std::cout);
|
|
|
|
|
if (noncesCount == 1000 && seedValue == 0 && !v2)
|
|
|
|
|
if (noncesCount == 1000 && seedValue == 0 && !commit)
|
|
|
|
|
std::cout << "Reference result: 10b649a3f15c7c7f88277812f2e74b337a0f20ce909af09199cccb960771cfa1" << std::endl;
|
|
|
|
|
if (!miningMode) {
|
|
|
|
|
std::cout << "Performance: " << 1000 * elapsed / noncesCount << " ms per hash" << std::endl;
|
|
|
|
|