rurban / dieharder

A fixed version of Robert G. Brown's "dieharder" tests for random number generators.
Other
10 stars 4 forks source link

Test PRVHASH 3.3 #13

Closed avaneev closed 1 year ago

avaneev commented 3 years ago

Could you test minimal PRVHASH PRNG with your DieHarder setting? https://github.com/avaneev/prvhash

#include "prvhash_core.h"
#include <stdio.h>

int main()
{
    uint64_t Seed = 0;
    uint64_t lcg = 0;
    uint64_t Hash = 0;

    uint64_t v = 0;
    uint64_t i;

    for( i = 0; i < ( 1ULL << 27 ); i++ )
    {
        v = prvhash_core64( &Seed, &lcg, &Hash );
    }

    printf( "%llu\n", v );
}

Another arrangement (I call it "Fused PRNG") worth testing, because it's fast (0.41cycles/byte) without SIMD: here, v, v2, v3 (24 bytes combined) are a single continuous PRNG output per round, it's structurally similar to SIMD and can be potentially ported to AVX-512.

#include "prvhash_core.h"
#include <stdio.h>

int main()
{
    uint64_t Seed = 0;
    uint64_t lcg = 0;
    uint64_t Hash = 0;
    uint64_t Seed2 = 0;
    uint64_t lcg2 = 0;
    uint64_t Hash2 = 0;
    uint64_t Seed3 = 0;
    uint64_t lcg3 = 0;
    uint64_t Hash3 = 0;
    uint64_t Hash4 = 0;

    uint64_t v = 0;
    uint64_t v2 = 0;
    uint64_t v3 = 0;

    uint64_t i;

    for( i = 0; i < ( 1ULL << 27 ); i++ )
    {
        v = prvhash_core64( &Seed, &lcg, &Hash );
        v2 = prvhash_core64( &Seed2, &lcg2, &Hash2 );
        v3 = prvhash_core64( &Seed3, &lcg3, &Hash3 );

        uint64_t t = Hash;
        Hash = Hash2;
        Hash2 = Hash3;
        Hash3 = Hash4;
        Hash4 = t;
    }

    printf( "%llu %llu %llu\n", v, v2, v3 );
}