update sfmt to version 1.5.1 from 1.4.1 (#4124)

This commit is contained in:
ebbit1q 2020-10-02 18:13:12 +02:00 committed by GitHub
parent a5511190a3
commit e2251fe06b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 30 deletions

View file

@ -157,8 +157,8 @@ inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b,
^ y.u[3] ^ (d->u[3] << SFMT_SL1); ^ y.u[3] ^ (d->u[3] << SFMT_SL1);
} }
#endif #endif
#endif
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
#endif // SFMT_COMMON_H

View file

@ -46,8 +46,8 @@
*/ */
/** the parameter of shift right as one 128-bit register. /** the parameter of shift right as one 128-bit register.
* The 128-bit integer is shifted by (SFMT_SL2 * 8) bits. * The 128-bit integer is shifted by (SFMT_SR2 * 8) bits.
#define SFMT_SR21 1 #define SFMT_SR2 1
*/ */
/** A bitmask, used in the recursion. These parameters are introduced /** A bitmask, used in the recursion. These parameters are introduced

View file

@ -40,11 +40,6 @@ extern "C" {
#undef ONLY64 #undef ONLY64
#endif #endif
/**
* parameters used by sse2.
*/
static const w128_t sse2_param_mask = {{SFMT_MSK1, SFMT_MSK2,
SFMT_MSK3, SFMT_MSK4}};
/*---------------- /*----------------
STATIC FUNCTIONS STATIC FUNCTIONS
----------------*/ ----------------*/
@ -60,11 +55,18 @@ inline static void swap(w128_t *array, int size);
#if defined(HAVE_ALTIVEC) #if defined(HAVE_ALTIVEC)
#include "SFMT-alti.h" #include "SFMT-alti.h"
#elif defined(HAVE_SSE2) #elif defined(HAVE_SSE2)
/**
* parameters used by sse2.
*/
static const w128_t sse2_param_mask = {{SFMT_MSK1, SFMT_MSK2,
SFMT_MSK3, SFMT_MSK4}};
#if defined(_MSC_VER) #if defined(_MSC_VER)
#include "SFMT-sse2-msc.h" #include "SFMT-sse2-msc.h"
#else #else
#include "SFMT-sse2.h" #include "SFMT-sse2.h"
#endif #endif
#elif defined(HAVE_NEON)
#include "SFMT-neon.h"
#endif #endif
/** /**
@ -81,7 +83,7 @@ inline static int idxof(int i) {
} }
#endif #endif
#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2)) #if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2)) && (!defined(HAVE_NEON))
/** /**
* This function fills the user-specified array with pseudorandom * This function fills the user-specified array with pseudorandom
* integers. * integers.
@ -166,17 +168,19 @@ static uint32_t func2(uint32_t x) {
* @param sfmt SFMT internal state * @param sfmt SFMT internal state
*/ */
static void period_certification(sfmt_t * sfmt) { static void period_certification(sfmt_t * sfmt) {
int inner = 0; uint32_t inner = 0;
int i, j; int i, j;
uint32_t work; uint32_t work;
uint32_t *psfmt32 = &sfmt->state[0].u[0]; uint32_t *psfmt32 = &sfmt->state[0].u[0];
const uint32_t parity[4] = {SFMT_PARITY1, SFMT_PARITY2, const uint32_t parity[4] = {SFMT_PARITY1, SFMT_PARITY2,
SFMT_PARITY3, SFMT_PARITY4}; SFMT_PARITY3, SFMT_PARITY4};
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++) {
inner ^= psfmt32[idxof(i)] & parity[i]; inner ^= psfmt32[idxof(i)] & parity[i];
for (i = 16; i > 0; i >>= 1) }
for (i = 16; i > 0; i >>= 1) {
inner ^= inner >> i; inner ^= inner >> i;
}
inner &= 1; inner &= 1;
/* check OK */ /* check OK */
if (inner == 1) { if (inner == 1) {
@ -232,7 +236,7 @@ int sfmt_get_min_array_size64(sfmt_t * sfmt) {
return SFMT_N64; return SFMT_N64;
} }
#if !defined(HAVE_SSE2) && !defined(HAVE_ALTIVEC) #if !defined(HAVE_SSE2) && !defined(HAVE_ALTIVEC) && !defined(HAVE_NEON)
/** /**
* This function fills the internal state array with pseudorandom * This function fills the internal state array with pseudorandom
* integers. * integers.

View file

@ -79,6 +79,15 @@ union W128_T {
uint32_t u[4]; uint32_t u[4];
uint64_t u64[2]; uint64_t u64[2];
}; };
#elif defined(HAVE_NEON)
#include <arm_neon.h>
/** 128-bit data structure */
union W128_T {
uint32_t u[4];
uint64_t u64[2];
uint32x4_t si;
};
#elif defined(HAVE_SSE2) #elif defined(HAVE_SSE2)
#include <emmintrin.h> #include <emmintrin.h>
@ -247,7 +256,7 @@ inline static double sfmt_genrand_real3(sfmt_t * sfmt)
*/ */
inline static double sfmt_to_res53(uint64_t v) inline static double sfmt_to_res53(uint64_t v)
{ {
return v * (1.0/18446744073709551616.0); return (v >> 11) * (1.0/9007199254740992.0);
} }
/** /**