Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc 14 C++ headers have unresolved incompatibilities with HIP #856

Closed
BenWibking opened this issue Jan 21, 2025 · 1 comment · Fixed by #857
Closed

gcc 14 C++ headers have unresolved incompatibilities with HIP #856

BenWibking opened this issue Jan 21, 2025 · 1 comment · Fixed by #857
Labels
AMDGPU affects AMD GPUs compiler bug caused by a bug in a compiler, not in the code itself

Comments

@BenWibking
Copy link
Collaborator

BenWibking commented Jan 21, 2025

Describe the bug
There are lots of changes in the GCC 14 C++ headers that break HIP builds. These are usually debugging functions in math functions, but there are some other examples, such as in operator* for std::optional objects. Since the debugging functions are host-only, whenever one of these function is called from device code, the compiler aborts with an error.

To Reproduce
Steps to reproduce the behavior:

  1. Use std::clamp or operator* for an std::optional object in device code and compile for AMDGPU on a system that bundles GCC 14 as the system compiler.
  2. See error below.
2025-01-21T00:28:55.8893422Z /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/optional:482:2: error: reference to __host__ function '__glibcxx_assert_fail' in __host__ __device__ function
2025-01-21T00:28:55.8894500Z   482 |         __glibcxx_assert(this->_M_is_engaged());
2025-01-21T00:28:55.8895148Z       |         ^
2025-01-21T00:28:55.8895962Z /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14/bits/c++config.h:612:7: note: expanded from macro '__glibcxx_assert'
2025-01-21T00:28:55.8897145Z   612 |         std::__glibcxx_assert_fail();                                   \
2025-01-21T00:28:55.8897673Z       |              ^
2025-01-21T00:28:55.8898316Z /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/optional:968:22: note: called by 'operator*'
2025-01-21T00:28:55.8899038Z   968 |       { return this->_M_get(); }
2025-01-21T00:28:55.8899565Z       |                      ^
2025-01-21T00:28:55.8900235Z /home/runner/work/quokka/quokka/src/hydro/EOS.hpp:327:27: note: called by 'ComputePressure'
2025-01-21T00:28:55.8901001Z   327 |                 const auto &massArray = *massScalars;
2025-01-21T00:28:55.8901445Z       |                                         ^
@BenWibking BenWibking added AMDGPU affects AMD GPUs compiler bug caused by a bug in a compiler, not in the code itself labels Jan 21, 2025
@BenWibking
Copy link
Collaborator Author

std::clamp can be trivially replaced with amrex::math::Clamp, but fixing the operator* issue for std::optional appears tricky.

@dosubot dosubot bot added the bug: wrong answer/failure/crash Something isn't working label Jan 21, 2025
@BenWibking BenWibking removed the bug: wrong answer/failure/crash Something isn't working label Jan 21, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 21, 2025
)

### Description
Temporarily workaround incompatibilities between the C++ standard
library headers shipped with GCC 14 and HIP by switching to using the
C++ standard library headers shipped with Clang (an independent
implementation).

This may not be viable in production, since (in principle) any
third-party libraries that use C++ should be complied against the same
C++ standard library in order to ensure compatibility, but it will at
least allow the CI to pass again and unblock several PRs. Currently, the
only C++ library dependency that is not built simultaneously alongside
Quokka is ADIOS2, which is optional.

### Related issues
Fixes #856.

### Checklist
_Before this pull request can be reviewed, all of these tasks should be
completed. Denote completed tasks with an `x` inside the square brackets
`[ ]` in the Markdown source below:_
- [x] I have added a description (see above).
- [x] I have added a link to any related issues (if applicable; see
above).
- [x] I have read the [Contributing
Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md).
- [ ] I have added tests for any new physics that this PR adds to the
code.
- [ ] *(For quokka-astro org members)* I have manually triggered the GPU
tests with the magic comment `/azp run`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AMDGPU affects AMD GPUs compiler bug caused by a bug in a compiler, not in the code itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant