NVIDIA / NVIDIA/cccl

[BUG]: NaN implementation is different on host and device

Open
#5,555 3 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 bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Type of Bug

Something else

### Component

libcu++

### Describe the bug

When improving our fp constants implementation, I found out that `__builtin_nansf` produces different values in host and device code. Actually, each compiler uses different values for nans.

### How to Reproduce

https://godbolt.org/z/abT833rqz

These are the values of signaling NaN I got on my machine:
```cpp
# nvcc + gcc
H nan: 7fc00000
H nans: 7fa00000
D nan: 7fc00000
D nans: 7f800001

# clang-cuda
H nan: 7fc00000
H nans: 7fa00000
D nan: 7fc00000
D nans: 7fa00000

# nvc++ -cuda
H nan: 7fc00000
H nans: 7f800001
D nan: 7fc00000
D nans: 7f800001
```

### Expected behavior

I'm not sure yet.

### Reproduction link

https://godbolt.org/z/abT833rqz

### Operating System

_No response_

### nvidia-smi output

_No response_

### NVCC version

_No response_

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.