mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2024-12-21 23: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);
|
||||
|
||||
inline randomx_argon2_impl* selectArgonImpl(randomx_flags flags) {
|
||||
if ((flags & RANDOMX_FLAG_ARGON2) == 0) {
|
||||
return &randomx_argon2_fill_segment_ref;
|
||||
if (flags & RANDOMX_FLAG_ARGON2_AVX2) {
|
||||
return randomx_argon2_impl_avx2();
|
||||
}
|
||||
randomx_argon2_impl* impl = nullptr;
|
||||
if ((flags & RANDOMX_FLAG_ARGON2) == RANDOMX_FLAG_ARGON2_SSSE3) {
|
||||
impl = randomx_argon2_impl_ssse3();
|
||||
if (flags & RANDOMX_FLAG_ARGON2_SSSE3) {
|
||||
return randomx_argon2_impl_ssse3();
|
||||
}
|
||||
if ((flags & RANDOMX_FLAG_ARGON2) == RANDOMX_FLAG_ARGON2_AVX2) {
|
||||
impl = randomx_argon2_impl_avx2();
|
||||
}
|
||||
if (impl != nullptr) {
|
||||
return impl;
|
||||
}
|
||||
throw std::runtime_error("Unsupported Argon2 implementation");
|
||||
return &randomx_argon2_fill_segment_ref;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ extern "C" {
|
||||
if (randomx_argon2_impl_avx2() != nullptr && cpu.hasAvx2()) {
|
||||
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;
|
||||
}
|
||||
return flags;
|
||||
@ -56,10 +56,14 @@ extern "C" {
|
||||
|
||||
randomx_cache *randomx_alloc_cache(randomx_flags flags) {
|
||||
randomx_cache *cache = nullptr;
|
||||
auto impl = randomx::selectArgonImpl(flags);
|
||||
if (impl == nullptr) {
|
||||
return cache;
|
||||
}
|
||||
|
||||
try {
|
||||
cache = new randomx_cache();
|
||||
cache->argonImpl = randomx::selectArgonImpl(flags);
|
||||
cache->argonImpl = impl;
|
||||
switch (flags & (RANDOMX_FLAG_JIT | RANDOMX_FLAG_LARGE_PAGES)) {
|
||||
case RANDOMX_FLAG_DEFAULT:
|
||||
cache->dealloc = &randomx::deallocCache<randomx::DefaultAllocator>;
|
||||
|
@ -203,13 +203,15 @@ int main(int argc, char** argv) {
|
||||
flags |= RANDOMX_FLAG_SECURE;
|
||||
}
|
||||
|
||||
if (flags & RANDOMX_FLAG_ARGON2_SSSE3) {
|
||||
std::cout << " - Argon2 implementation: SSSE3" << std::endl;
|
||||
}
|
||||
|
||||
if (flags & RANDOMX_FLAG_ARGON2_AVX2) {
|
||||
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) {
|
||||
std::cout << " - full memory mode (2080 MiB)" << std::endl;
|
||||
@ -253,7 +255,9 @@ int main(int argc, char** argv) {
|
||||
std::cout << " ..." << std::endl;
|
||||
|
||||
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) {
|
||||
throw std::runtime_error("JIT compilation is not supported on this platform. Try without --jit");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user