Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

HIP build fails for networks with no intermediate reactions with libstdc++ >= 13 (std::array<int, 0> in locate_intermediate_rate_index)

Chiusa Adatta ai principianti
#2,115 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
69/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

Inizia in networks/rhs.H, in corrispondenza di locate_intermediate_rate_index, dove la issue segnala un amrex::Array di dimensione zero e l’accesso che fallisce. Verifica come la funzione gestisce le reti senza reazioni intermedie, poi compila la rete di test triple_alpha_plus_cago usando il comando HIP make della issue con libstdc++ 13 o versione successiva. Il lavoro è completato quando la compilazione HIP riesce; la issue suggerisce di assegnare all’array almeno un elemento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug GPU

HIP builds of networks with no intermediate reactions (e.g. triple_alpha_plus_cago) fail to compile when the host C++ standard library is libstdc++ 13 or newer. libstdc++ 13 is the default on Ubuntu 24.04.

Error

On current development (60562512):

cd unit_test/test_react
make USE_HIP=TRUE AMD_ARCH=gfx90a NETWORK_DIR=triple_alpha_plus_cago
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/array:209:9: error: reference to __host__ function 'operator[]' in __host__ __device__ function
  209 |         return _M_elems[__n];
      |                ^
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/array:74:13: note: 'operator[]' declared here
   74 |        _Tp& operator[](size_t) const noexcept { __builtin_trap(); }
      |             ^
../../networks/rhs.H:142:28: note: called by 'locate_intermediate_rate_index'
  142 |                 if (indices[n-1] == data.additional_reaction_1) {

Environment: Ubuntu 24.04, ROCm 10.1 (hipcc: HIP 7.16, AMD clang 24.0.0git), libstdc++ 13.3 and 14.

Cause

locate_intermediate_rate_index in networks/rhs.H declares

amrex::Array<int, num_intermediate> indices = {};

which is a std::array<int, 0> when the network has no intermediate reactions. Starting with GCC 13, libstdc++ implements the zero-size std::array storage as an empty struct whose operator[] is a plain, non-constexpr host function that just traps. hipcc rejects any reference to it from a __host__ __device__ function, even inside a loop that never executes (n <= num_intermediate with num_intermediate == 0). libstdc++ 11 used a constexpr static helper there, so this compiled before.

CI doesn't catch it because .github/workflows/hip.yml only builds iso7 and URCA-simple, which both have intermediate reactions.

Minimal reproducer (no Microphysics)
// repro.cpp
#include <hip/hip_runtime.h>
#include <array>

__host__ __device__ constexpr int find_index (int x)
{
    constexpr int n_items = 0;
    std::array<int, n_items> a = {};
    for (int n = 1; n <= n_items; ++n) {
        if (a[n-1] == x) {
            return n;
        }
    }
    return -1;
}

__global__ void kernel (int* out) { *out = find_index(3); }
hipcc --offload-arch=gfx90a -std=c++20 --gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/11 -c repro.cpp   # compiles
hipcc --offload-arch=gfx90a -std=c++20 --gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/13 -c repro.cpp   # error above
hipcc --offload-arch=gfx90a -std=c++20 --gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/14 -c repro.cpp   # error above
Possible fix

Give the array at least one element, e.g. int indices[num_intermediate > 0 ? num_intermediate : 1] = {};. The loops only touch the first num_intermediate elements, so the results don't change.

This was found while porting triple_alpha_plus_cago to Loom, but it is a stock HIP build failure with no Loom code involved. CUDA builds against libstdc++ 13+ probably fail the same way, but that is untested.

Lingua principale
C++
Stelle
44
Fork
46
Merge medio
3g 7h
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AMReX-Astro/Microphysics

Tutte le issue di AMReX-Astro/Microphysics

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.