Skip to content

Releases: vxst/qrand

v1.0.0

21 Aug 13:34
Compare
Choose a tag to compare

This is the first release for qrand project.

It can be used as a drop-in replacement for STL random generator like:

#include <random>
#include <iostream>
#include "qrand.h"

int main(){
    std::uniform_int_distribution<int> dist(0, 100);
    std::uniform_real_distribution<double> distf(0.0, 1.0);
    qrand rng;
    for(int i = 0; i < 10; i++){
        std::cout << dist(rng) << " " << distf(rng) << std::endl;
    }
}

Or you can use the callable object as a drop in replacement for rand function:

#include <iostream>
#include "qrand.h"

int main(){
    qrand randq;
    for(int i = 0; i < 10; i++){
        std::cout << randq() << " " << randq() % 100 << std::endl;
    }
}

There is no static global state, so it's thread safe as long as it's thread local:

void some_thread_function(){
    static thread_local qrand randq;
    // call randq
}

Or in OpenMP

extern qrand randq;
#pragma omp threadprivate(randq)
qrand randq;

For the versioning, given a version number MAJOR.MINOR.PATCH,

  • "PATCH" is guaranteed to generate same sequence of random number with the same seed
  • "MINOR" may change the sequence with the same seed, but will put in release notes if it happens. It is guaranteed to keep the API unchanged
  • "MAJOR" may include the API change

It passes the BigCrush(and also SmallCrush, Crush) tests with the following results(with the default eps=1e-300, eps1=1e-15):

========= Summary results of SmallCrush =========

 Version:          TestU01 1.2.3
 Generator:        qrand
 Number of statistics:  15
 Total CPU time:   00:00:04.65

 All tests were passed


========= Summary results of Crush =========

 Version:          TestU01 1.2.3
 Generator:        qrand
 Number of statistics:  144
 Total CPU time:   00:18:43.85

 All tests were passed


========= Summary results of BigCrush =========

 Version:          TestU01 1.2.3
 Generator:        qrand
 Number of statistics:  160
 Total CPU time:   02:04:35.23

 All tests were passed

The reproducibility is tested on following platform:

Intel Xeon E5-2650         (Sandy Bridge EP, AES-NI+SSE)
Intel Xeon E5-2670 v2      (Ivy Bridge EP,   AES-NI+SSE)
Intel Xeon E5-2686 v4      (Broadwell EP,    AES-NI+AVX2)
Intel Xeon Platinum 8259CL (Cascade Lake,    AES-NI+AVX512F)
Intel Xeon Platinum 8375C  (Ice Lake,        VAES+AVX512F)

AMD EPYC 7571              (Zen/Naples,      AES-NI+AVX2)
AMD EPYC 7R32              (Zen2/Rome,       AES-NI+AVX2)
AMD EPYC 7R13              (Zen3/Milan,      VAES+AVX2)

Apple M1                   (Rosetta 2/GCC,   AES-NI+SSE)