Skip to content

Commit

Permalink
Use SplitMix64 for seeding test cases
Browse files Browse the repository at this point in the history
Close #581.
  • Loading branch information
Cuda-Chen committed Oct 6, 2023
1 parent 8371b36 commit 6578a55
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions tests/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,40 @@ static inline double bankersRounding(double val)
return ret;
}

static float ranf(void)
/*static float ranf(void)
{
uint32_t ir = rand() & 0x7FFF;
return (float) ir * (1.0f / 32768.0f);
uint32_t ir = rand() & 0xFFFF;
return (float) ir * (1.0f / 65536.0f);
}*/

/* Written in 2015 by Sebastiano Vigna ([email protected])
*
* To the extent possible under law, the author has dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty.
*
* See <http://creativecommons.org/publicdomain/zero/1.0/>. */

/* This is a fixed-increment version of Java 8's SplittableRandom generator
* See http://dx.doi.org/10.1145/2714064.2660195 and
* http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html
*
* It is a very fast generator passing BigCrush, and it can be useful
* if for some reason you absolutely want 64 bits of state. */
static uint64_t x;
const double TWOPOWER64 = pow(2, 64);

static double next()
{
uint64_t z = (x += 0x9e3779b97f4a7c15);
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
return z ^ (z >> 31);
}

static float ranf()
{
return next() / TWOPOWER64;
}

static float ranf(float low, float high)
Expand Down Expand Up @@ -4059,6 +4089,11 @@ result_t test_mm_cmplt_sd(const SSE2NEONTestImpl &impl, uint32_t iter)
__m128d b = load_m128d(_b);
__m128d c = _mm_cmplt_sd(a, b);

/*double res[2];
memcpy(res, &c, sizeof(res));
printf("a: %lf %lf \nb: %lf %lf \nc: %lf %lf \nd0: %" PRId64 " d1: %" PRId64
"\n===\n", _a[0], _a[1], _b[0], _b[1], res[0], res[1], d0, d1);*/

return validateDouble(c, *(double *) &d0, *(double *) &d1);
}

Expand Down

0 comments on commit 6578a55

Please sign in to comment.