Permalink
Browse files

Elektra: Core: rand: fix to high ELEKTRARANDMAX right

  • Loading branch information...
Kurt Micheli
Kurt Micheli committed Dec 9, 2017
1 parent 04fcfb2 commit 0e1738a26dab9559baaaf156054d70207638f01c
Showing with 5 additions and 5 deletions.
  1. +2 −2 benchmarks/opmphm.c
  2. +2 −2 scripts/generate-seeds
  3. +1 −1 src/libs/elektra/rand.c
View
@@ -722,7 +722,7 @@ static void benchmarkMappingOpt (void)
*
* This benchmark counts the opmphmMapping (...) invocations until success, for each KeySet size and all seeds.
* First the KeySets are build, for every KeySet size (n). Then the benchmarking for every KeySet size (n) takes place,
* the seeds start at 1 and go to 2147483647 = ELEKTRARANDMAX = (2^31)-1.
* the seeds start at 1 and go to ELEKTRARANDMAX - 1 = 2147483646.
* At the end the results are written out in the following format:
*
* trials;n_%lucr_%luc_%f;... (each n is unique)
@@ -745,7 +745,7 @@ static void benchmarkMappingAllSeeds (void)
// seeds limits
const int32_t startSeed = 1;
const int32_t endSeed = 2147483647; // = ELEKTRARANDMAX;
const int32_t endSeed = ELEKTRARANDMAX - 1; // = ELEKTRARANDMAX;
const size_t maxMappings = 10; // the maximum trials for one opmphmMapping (...) invocation series.
View
@@ -5,11 +5,11 @@
# @date 08.11.2017
# @tags benchmark, generator
# generates seeds distributed uniformly from 1 to 2147483647 = ELEKTRARANDMAX
# generates seeds distributed uniformly from 1 to 2147483646 = ELEKTRARANDMAX - 1
if [ ! "$1" ] || [ ! "$2" ]
then
echo "Usage: $0 <numberOfSeeds> <outfile>"
fi
R --slave --no-save <<< "options(scipen=999);cat(round(runif($1,1,2147483647)), sep=\"\n\")" > "$2"
R --slave --no-save <<< "options(scipen=999);cat(round(runif($1,1,2147483646)), sep=\"\n\")" > "$2"
View
@@ -32,7 +32,7 @@ void elektraRand (int32_t * seed)
{
ELEKTRA_ASSERT (seed, "seed is NULL");
ELEKTRA_ASSERT (*seed, "seed is 0");
ELEKTRA_ASSERT (*seed <= ELEKTRARANDMAX, "seed is equal or bigger than ELEKTRARANDMAX");
ELEKTRA_ASSERT (*seed < ELEKTRARANDMAX, "seed is equal or bigger than ELEKTRARANDMAX");
uint32_t lo, hi;
lo = 16807 * (int32_t) (*seed & 0xFFFF);
hi = 16807 * (int32_t) ((uint32_t)*seed >> 16);

0 comments on commit 0e1738a

Please sign in to comment.