We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
I'd like to add mine 5 cents here. In addition to “PRNG form” it is usually needed to provide a code, that initializes random generator. Such code can be found at pcg-random.org, and if being simplified will look like following: prng_state = 0; rand_pcg(); prng_state += seed; rand_pcg(); The uint seed is the value to initialize random number generator.
As is, the pcg_hash function fails PractRand (stdin32 -te 0 -tf 2 -tlmin 10) at 2^22 bytes. Replacing the "LCG part" with XQO primitive
uint32_t xqo_hash(uint32_t input)
{
uint32_t state = (input | 1u) ^ (input * input);
uint32_t word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
return (word >> 22u) ^ word;
}
raises that to 2^29 bytes (it nearly fails at 2^28). Not sure about BigCrush.
On x86, the perf seems to suffer slightly ( https://godbolt.org/z/fY9Mv... ), not sure about the GPUs.
Same as pcg_hash, it only requires 32-bit arithmetic (and only 32x32->32 multiplication).
The function is a permutation (same as pcg_hash), so it obviously fails the birthday test (which is a bug/feature depending on the requirements).
If you change rand_pcg to set "state" from the _new_ value of rng_state rather than the old, then you can initialize just by setting rand_pcg to the required seed (otherwise you need to run rand_pcg at least once to mix things up properly).
For more details on how pcg works so good, why hash functions beat PRNGs (sometimes even in their own field), and more goodies, I totally recommend this GDC talk on the topic https://www.youtube.com/wat...