+static SIMDExecInstr intSIMDInstr = SIMD_AUTO;
+
+void SetSIMDInstr(SIMDExecInstr instr) {
+ intSIMDInstr = instr;
+
+ crack_states_bitsliced_function_p = &crack_states_bitsliced_dispatch;
+ bitslice_test_nonces_function_p = &bitslice_test_nonces_dispatch;
+}
+
+SIMDExecInstr GetSIMDInstr() {
+ SIMDExecInstr instr = SIMD_NONE;
+
+#if defined (__i386__) || defined (__x86_64__)
+ #if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
+ #if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
+ if (__builtin_cpu_supports("avx512f")) instr = SIMD_AVX512;
+ else if (__builtin_cpu_supports("avx2")) instr = SIMD_AVX2;
+ #else
+ if (__builtin_cpu_supports("avx2")) instr = SIMD_AVX2;
+ #endif
+ else if (__builtin_cpu_supports("avx")) instr = SIMD_AVX;
+ else if (__builtin_cpu_supports("sse2")) instr = SIMD_SSE2;
+ else if (__builtin_cpu_supports("mmx")) instr = SIMD_MMX;
+ else
+ #endif
+#endif
+ instr = SIMD_NONE;
+
+ return instr;
+}
+
+SIMDExecInstr GetSIMDInstrAuto() {
+ SIMDExecInstr instr = intSIMDInstr;
+ if (instr == SIMD_AUTO)
+ return GetSIMDInstr();
+
+ return instr;
+}
+