[BUG]: Different compilers give different results from `normal_distribution`.
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 487
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 296
Description
### Is this a duplicate?
- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Type of Bug
Silent Failure
### Component
Thrust
### Describe the bug
`thrust::normal_distribution` returns different results when compiled with g++ and nvcc. As shown in the following snippets, the random engine returns consistent results, but the normal distribution doesn't.
### How to Reproduce
``` c++
#include
#include
int main () {
thrust::minstd_rand rng;
rng.seed(0);
std::cout << "rng:" << rng() << std::endl;
thrust::normal_distribution dist{0.0f, 1.5f};
std::cout << dist(rng) << std::endl;
}
```
The nvcc command I used, please modify it for a different include path:
```
nvcc -forward-unknown-to-host-compiler -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -isystem /home/jiamingy/.anaconda/envs/xgboost_dev_125/targets/x86_64-linux/include -g -std=c++17 -arch=native -Xcompiler=-fPIC -Xcompiler=-fvisibility=hidden --expt-extended-lambda --expt-relaxed-constexpr --default-stream per-thread -x cu ./main.cc -o main_cu
```
Result
```
$ ./main_cu
rng:48271
-2.05799
```
Similarly, for the g++ command:
```
g++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -fstack-protector-strong -O2 -ffunction-sections -isystem /home/jiamingy/.anaconda/envs/xgboost_dev_125/include -I/home/jiamingy/.anaconda/envs/xgboost_dev_125/targets/x86_64-linux/include -fvisibility=hidden ./main.cc -o main_cc
```
Result
```
$ ./main_cc
rng:48271
1.75083
```
I'm using ctk12.5 from conda, the thrust is packaged with it, from `-H` output:
```
/home/jiamingy/.anaconda/envs/xgboost_dev_125/targets/x86_64-linux/include/thrust/random/detail/normal_distribution.inl
```
### Expected behavior
They should produce the same result.
### Reproduction link
_No response_
### Operating System
Ubuntu 22.04
### nvidia-smi output
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03 Driver Version: 560.35.03 CUDA Version: 12.6 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 4070 ... Off | 00000000:01:00.0 On | N/A |
| 0% 44C P8 14W / 285W | 561MiB / 16376MiB | 11% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA GeForce RTX 4070 ... Off | 00000000:03:00.0 Off | N/A |
| 0% 45C P8 8W / 285W | 10MiB / 16376MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
### NVCC version
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Jun__6_02:18:23_PDT_2024
Cuda compilation tools, release 12.5, V12.5.82
Build cuda_12.5.r12.5/compiler.34385749_0
Contributor guide
Assessment
This issue has not been assessed yet.