Parallel HDF5 not detected with HDF5 2.x and CMake older than 4.3

Aperta Adatta ai principianti
#4,213 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cmake
Ambito
build-system

Direzione di ricerca

La correzione va apportata in CMakeLists.txt, vicino al find_package(HDF5 ...) esistente: confronta HDF5_PROVIDES_PARALLEL con il segnale precedente HDF5_IS_PARALLEL e imposta di conseguenza il flag per il parallelismo. Riproduci prima il problema con CMake 3.26.5 o 4.2.3 e HDF5 parallelo 2.2.0, quindi controlla che build/CMakeFiles/libopenmc_objects.dir/flags.make contenga -DPHDF5 e che l'output di configurazione includa Using parallel HDF5. Il controllo MPI di scrittura/lettura del payload con 3 rank è il criterio di completamento; decidi anche se l'errore di configurazione per HDF5 parallelo senza MPI è intenzionale.

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

Descrizione

Bug Description

With HDF5 2.x and CMake older than 4.3, OpenMC does not detect a parallel HDF5 installation. Configuration succeeds with no warning, but -- Using parallel HDF5 is not printed and PHDF5 is not defined, so OpenMC writes through the master rank instead of using collective I/O.

FindHDF5.cmake in older CMake sets HDF5_IS_PARALLEL from HDF5_ENABLE_PARALLEL. HDF5 2.x config packages set HDF5_PROVIDES_PARALLEL instead. CMake fixed this in 4.3 (Kitware/CMake@27e558dfa5), but OpenMC allows CMake 3.22 and later, so older versions still hit it.

Results from configuring develop (e43e165) against a parallel HDF5 2.2.0 (h5pcc -showconfig reports Parallel HDF5: ON):

CMake CMakeLists.txt Using parallel HDF5 -DPHDF5
3.26.5 unchanged no no
4.2.3 unchanged no no
4.3.2 unchanged yes yes
3.26.5 fallback below yes yes

Possible fallback, placed after find_package(HDF5 ...):

if(HDF5_PROVIDES_PARALLEL)
  set(HDF5_IS_PARALLEL TRUE)
endif()

Passing -DHDF5_ENABLE_PARALLEL=ON also works around it on 3.26.5.

I also tested the fallback on the same commit with CMake 3.26.5. Where the table says "3 ranks ok", I did a full build and a small MPI program wrote a source bank with write_h5_source_point and read all 300 sites back on each of 3 ranks.

HDF5 OPENMC_USE_MPI Unchanged With fallback
2.2.0 parallel ON not detected detected, 3 ranks ok
2.2.0 serial ON not detected not detected, 3 ranks ok
2.2.0 serial OFF not run not detected, configure only
1.14.6 parallel ON detected detected, 3 ranks ok
1.14.6 parallel OFF "MPI was not enabled" error same error
2.2.0 parallel OFF not detected, builds "MPI was not enabled" error

The last row is a behavior change: parallel HDF5 2.x without MPI builds today and would stop at configure with the fallback. That matches how HDF5 1.14 already behaves, but it could affect anyone relying on that combination.

I have not run the OpenMC test suite with any of these, or tested with MPICH.

This came up through Cardinal, where code that assumed collective I/O started failing on a file lock (neams-th-coe/cardinal#1499). A fix for that is open on the Cardinal side, and OpenMC's own writes still work without PHDF5. The problem here is that parallel I/O is silently turned off.

Steps to Reproduce

In idaholab/moose-dev:2026.10.19, which has CMake 3.26.5 and a parallel HDF5 2.2.0 in /opt/petsc:

export HDF5_ROOT=/opt/petsc
git clone --depth 1 https://github.com/openmc-dev/openmc.git
cmake -S openmc -B build -DCMAKE_BUILD_TYPE=Release -DOPENMC_USE_MPI=ON \
  -DOPENMC_BUILD_TESTS=off -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx
grep -c -- '-DPHDF5' build/CMakeFiles/libopenmc_objects.dir/flags.make

The output has Found HDF5: hdf5-shared (found version "2.2.0") but no Using parallel HDF5, and the grep prints 0.

Environment

  • OS: Rocky Linux container idaholab/moose-dev:2026.10.19, run under Docker on Windows
  • OpenMC: develop at e43e165, built from source
  • HDF5: 2.2.0 parallel built by PETSc; 2.2.0 serial and 1.14.6 parallel built from source with CMake
  • MPI: OpenMPI (mpicc/mpicxx)
  • CMake: 3.26.5 from the container, plus official 4.2.3 and 4.3.2 binaries
  • Nuclear data: not used
Lingua principale
Python
Stelle
1.1k
Fork
683
Merge medio
3g 10h
PR unite (30g)
17

Preparare l'ambiente

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 openmc-dev/openmc

Tutte le issue di openmc-dev/openmc

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.