From 41182081f4f9c863222c9fd2645868de8abbbfe6 Mon Sep 17 00:00:00 2001 From: tooomm Date: Sun, 17 May 2026 14:15:46 +0200 Subject: [PATCH] Update SFMT to v1.5.4 --- .../libcockatrice/rng/sfmt/SFMT.c | 4 +++- .../libcockatrice/rng/sfmt/SFMT.h | 21 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.c b/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.c index b4ac9308b..fde6367a0 100644 --- a/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.c +++ b/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.c @@ -60,7 +60,9 @@ inline static void swap(w128_t *array, int size); */ static const w128_t sse2_param_mask = {{SFMT_MSK1, SFMT_MSK2, SFMT_MSK3, SFMT_MSK4}}; - #if defined(_MSC_VER) + #if defined(__AVX2__) && (SFMT_SL1 >= 16) && !(SFMT_N & 1) && !(SFMT_POS1 & 1) + #include "SFMT-avx256.h" + #elif defined(_MSC_VER) #include "SFMT-sse2-msc.h" #else #include "SFMT-sse2.h" diff --git a/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.h b/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.h index 79e012d63..34d9e746f 100644 --- a/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.h +++ b/libcockatrice_rng/libcockatrice/rng/sfmt/SFMT.h @@ -88,8 +88,13 @@ union W128_T { uint64_t u64[2]; uint32x4_t si; }; +//#elif defined(HAVE_SSE2) #elif defined(HAVE_SSE2) - #include + #if defined(__AVX2__) + #include + #else + #include + #endif /** 128-bit data structure */ union W128_T { @@ -112,8 +117,18 @@ typedef union W128_T w128_t; * SFMT internal state */ struct SFMT_T { +#if defined(__AVX2__) + union { + w128_t state[SFMT_N]; + __m256i state_ymm[SFMT_N/2]; + #if defined(__AVX512VL__) + __m512i state_zmm[SFMT_N/4]; + #endif + }; +#else /** the 128-bit internal state array */ w128_t state[SFMT_N]; +#endif /** index counter to the 32-bit internal state array */ int idx; }; @@ -249,9 +264,9 @@ inline static double sfmt_genrand_real3(sfmt_t * sfmt) } /** - * converts an unsigned 32-bit integer to double on [0,1) + * converts an unsigned 64-bit integer to double on [0,1) * with 53-bit resolution. - * @param v 32-bit unsigned integer + * @param v 64-bit unsigned integer * @return double on [0,1)-real-interval with 53-bit resolution. */ inline static double sfmt_to_res53(uint64_t v)