mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2025-01-03 05:38:54 +00:00
Select AVX2 if both AVX2 and SSSE3 flags are set
This commit is contained in:
parent
ebbe7696c7
commit
fc892fc5c0
@ -83,19 +83,12 @@ namespace randomx {
|
|||||||
void initDataset(randomx_cache* cache, uint8_t* dataset, uint32_t startBlock, uint32_t endBlock);
|
void initDataset(randomx_cache* cache, uint8_t* dataset, uint32_t startBlock, uint32_t endBlock);
|
||||||
|
|
||||||
inline randomx_argon2_impl* selectArgonImpl(randomx_flags flags) {
|
inline randomx_argon2_impl* selectArgonImpl(randomx_flags flags) {
|
||||||
if ((flags & RANDOMX_FLAG_ARGON2) == 0) {
|
if (flags & RANDOMX_FLAG_ARGON2_AVX2) {
|
||||||
return &randomx_argon2_fill_segment_ref;
|
return randomx_argon2_impl_avx2();
|
||||||
}
|
}
|
||||||
randomx_argon2_impl* impl = nullptr;
|
if (flags & RANDOMX_FLAG_ARGON2_SSSE3) {
|
||||||
if ((flags & RANDOMX_FLAG_ARGON2) == RANDOMX_FLAG_ARGON2_SSSE3) {
|
return randomx_argon2_impl_ssse3();
|
||||||
impl = randomx_argon2_impl_ssse3();
|
|
||||||
}
|
}
|
||||||
if ((flags & RANDOMX_FLAG_ARGON2) == RANDOMX_FLAG_ARGON2_AVX2) {
|
return &randomx_argon2_fill_segment_ref;
|
||||||
impl = randomx_argon2_impl_avx2();
|
|
||||||
}
|
|
||||||
if (impl != nullptr) {
|
|
||||||
return impl;
|
|
||||||
}
|
|
||||||
throw std::runtime_error("Unsupported Argon2 implementation");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ extern "C" {
|
|||||||
if (randomx_argon2_impl_avx2() != nullptr && cpu.hasAvx2()) {
|
if (randomx_argon2_impl_avx2() != nullptr && cpu.hasAvx2()) {
|
||||||
flags |= RANDOMX_FLAG_ARGON2_AVX2;
|
flags |= RANDOMX_FLAG_ARGON2_AVX2;
|
||||||
}
|
}
|
||||||
else if (randomx_argon2_impl_ssse3() != nullptr && cpu.hasSsse3()) {
|
if (randomx_argon2_impl_ssse3() != nullptr && cpu.hasSsse3()) {
|
||||||
flags |= RANDOMX_FLAG_ARGON2_SSSE3;
|
flags |= RANDOMX_FLAG_ARGON2_SSSE3;
|
||||||
}
|
}
|
||||||
return flags;
|
return flags;
|
||||||
@ -56,10 +56,14 @@ extern "C" {
|
|||||||
|
|
||||||
randomx_cache *randomx_alloc_cache(randomx_flags flags) {
|
randomx_cache *randomx_alloc_cache(randomx_flags flags) {
|
||||||
randomx_cache *cache = nullptr;
|
randomx_cache *cache = nullptr;
|
||||||
|
auto impl = randomx::selectArgonImpl(flags);
|
||||||
|
if (impl == nullptr) {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cache = new randomx_cache();
|
cache = new randomx_cache();
|
||||||
cache->argonImpl = randomx::selectArgonImpl(flags);
|
cache->argonImpl = impl;
|
||||||
switch (flags & (RANDOMX_FLAG_JIT | RANDOMX_FLAG_LARGE_PAGES)) {
|
switch (flags & (RANDOMX_FLAG_JIT | RANDOMX_FLAG_LARGE_PAGES)) {
|
||||||
case RANDOMX_FLAG_DEFAULT:
|
case RANDOMX_FLAG_DEFAULT:
|
||||||
cache->dealloc = &randomx::deallocCache<randomx::DefaultAllocator>;
|
cache->dealloc = &randomx::deallocCache<randomx::DefaultAllocator>;
|
||||||
|
@ -203,13 +203,15 @@ int main(int argc, char** argv) {
|
|||||||
flags |= RANDOMX_FLAG_SECURE;
|
flags |= RANDOMX_FLAG_SECURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & RANDOMX_FLAG_ARGON2_SSSE3) {
|
|
||||||
std::cout << " - Argon2 implementation: SSSE3" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & RANDOMX_FLAG_ARGON2_AVX2) {
|
if (flags & RANDOMX_FLAG_ARGON2_AVX2) {
|
||||||
std::cout << " - Argon2 implementation: AVX2" << std::endl;
|
std::cout << " - Argon2 implementation: AVX2" << std::endl;
|
||||||
}
|
}
|
||||||
|
else if (flags & RANDOMX_FLAG_ARGON2_SSSE3) {
|
||||||
|
std::cout << " - Argon2 implementation: SSSE3" << std::endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << " - Argon2 implementation: reference" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & RANDOMX_FLAG_FULL_MEM) {
|
if (flags & RANDOMX_FLAG_FULL_MEM) {
|
||||||
std::cout << " - full memory mode (2080 MiB)" << std::endl;
|
std::cout << " - full memory mode (2080 MiB)" << std::endl;
|
||||||
@ -253,7 +255,9 @@ int main(int argc, char** argv) {
|
|||||||
std::cout << " ..." << std::endl;
|
std::cout << " ..." << std::endl;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
randomx::selectArgonImpl(flags); //just to check if flags are valid
|
if (nullptr == randomx::selectArgonImpl(flags)) {
|
||||||
|
throw std::runtime_error("Unsupported Argon2 implementation");
|
||||||
|
}
|
||||||
if ((flags & RANDOMX_FLAG_JIT) && !RANDOMX_HAVE_COMPILER) {
|
if ((flags & RANDOMX_FLAG_JIT) && !RANDOMX_HAVE_COMPILER) {
|
||||||
throw std::runtime_error("JIT compilation is not supported on this platform. Try without --jit");
|
throw std::runtime_error("JIT compilation is not supported on this platform. Try without --jit");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user