NVIDIA / NVIDIA/cccl

thrust::uniform_int_distribution<uint64_t> exclusively produces multiples of 4096

Open
#758 3 comments 0 reactions 1 assignee Assigned to @gonidelis View on GitHub
thrust
Dominant language
C++
Stars
2.5k
Forks
487
Avg merge
2d 7h
Merged PRs (30d)
296

Description

The thrust::uniform_int_distribution uses uniform_real_distribution under the hood.
However, for 64 bit numbers this means the lower 12 bits are always 0.

For example:
```
int main( int argc, char** argv )
{
thrust::uniform_int_distribution dist;
// thrust::default_random_engine engine{ 0 };
// thrust::taus88 engine{ 0xdeadbeef };
thrust::ranlux48 engine{ 0 };
for( uint64_t i = 0; i < 1e4; i++ )
std::cout << std::hex << dist( engine ) << std::endl;
}
```

will produce 0s in the lower bits for all the thrust random number generators.

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.