NVIDIA / NVIDIA/cccl

[FEA]: Implement new random number generators

Open
#5,679 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Area

Thrust

### Is your feature request related to a problem? Please describe.

Thrust currently implements the following random number generators:

[thrust::random::minstd_rand](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1ga1c89beeeb2681026be374c4e0d6609f3.html)
[thrust::random::ranlux24_base](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1ga44ec779aead9b140b3fb332ea4c349bc.html)
[thrust::random::ranlux48](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1ga67a4f4c57c6d60aea077a947285cb7c5.html)
[thrust::random::default_random_engine](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1ga8450c92f9d27a16992ca377f7d8dc75c.html)
[thrust::random::ranlux24](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1gaacaf3beafd00b7087532c98d9062778a.html)
[thrust::random::taus88](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1gac781a23cdf5b0cdb48ec3fbe7cb4318c.html)
[thrust::random::ranlux48_base](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1gaeb4bf97731c920bdf7cc80d2c2321f2f.html)
[thrust::random::minstd_rand0](https://nvidia.github.io/cccl/thrust/api/group__predefined__random_1gaf8dffb2a8bfaaa20d5c916d74c07dc98.html)

These leave a little to be desired in either performance (either generation or advancing) or robustness in comparison to some recent developments in the field.

### Describe the solution you'd like

I propose adding:
https://en.cppreference.com/w/cpp/numeric/random/philox_engine.html
https://en.wikipedia.org/wiki/Permuted_congruential_generator (PCG64 as used in numpy).

Furthermore, I think documentation could be improved in the following areas:
- Example code of how generators are expected to be used in a parallel environment (e.g. generate/for_each).
- Documentation of complexity of `discard` method for generators. This is critical for evaluating the performance of generators in parallel launches.
- Documentation of the relative 'strength' of each generator on standardised benchmarks to help users make a selection. I suspect the current default random generator minstd would not hold up here and thus we could guide users to a stronger generator for more sensitive applications (e.g. Monte Carlo).

### Describe alternatives you've considered

_No response_

### Additional context

Related issues https://github.com/NVIDIA/cccl/issues/758, https://github.com/NVIDIA/cccl/issues/2510, @djns99

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.