Skip to content

Commit

Permalink
Guard against non-MPI installs
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 25, 2024
1 parent 8f6397c commit 2f42208
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/IO/HDF5/HDF5IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2938,16 +2938,21 @@ HDF5IOHandlerImpl::getFile(Writable *writable)
return std::make_optional(std::move(res));
}

#define OPENPMD_HAVE_HDF5_INDEPENDENT_STORES openPMD_HAVE_MPI

std::future<void> HDF5IOHandlerImpl::flush(internal::ParsedFlushParams &params)
{
#if OPENPMD_HAVE_HDF5_INDEPENDENT_STORES
std::optional<H5FD_mpio_xfer_t> old_value;
#endif
if (params.backendConfig.json().contains("hdf5"))
{
auto hdf5_config = params.backendConfig["hdf5"];

if (hdf5_config.json().contains("independent_stores"))
{
auto independent_stores_json = hdf5_config["independent_stores"];
#if OPENPMD_HAVE_HDF5_INDEPENDENT_STORES
if (!independent_stores_json.json().is_boolean())
{
throw error::BackendConfigSchema(
Expand All @@ -2970,6 +2975,12 @@ std::future<void> HDF5IOHandlerImpl::flush(internal::ParsedFlushParams &params)
status >= 0,
"[HDF5] Internal error: Failed to set the local data "
"transfer mode before flushing.");
#else
std::cerr << "[Warning] HDF5 backend option "
"`hdf5.independent_stores` was specified, but "
"HDF5 has no MPI support. Will ignore."
<< std::endl;
#endif
}

if (auto shadow = hdf5_config.invertShadow(); shadow.size() > 0)
Expand All @@ -2993,6 +3004,7 @@ std::future<void> HDF5IOHandlerImpl::flush(internal::ParsedFlushParams &params)
}
auto res = AbstractIOHandlerImpl::flush();

#if OPENPMD_HAVE_HDF5_INDEPENDENT_STORES
if (old_value.has_value())
{
herr_t status = H5Pset_dxpl_mpio(m_datasetTransferProperty, *old_value);
Expand All @@ -3001,6 +3013,7 @@ std::future<void> HDF5IOHandlerImpl::flush(internal::ParsedFlushParams &params)
"[HDF5] Internal error: Failed to reset the global data "
"transfer mode after flushing.");
}
#endif

return res;
}
Expand Down
2 changes: 1 addition & 1 deletion test/ParallelIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ TEST_CASE("hipace_like_write", "[parallel]")
}
#endif

#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9
#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9 && openPMD_HAVE_MPI
TEST_CASE("independent_write_with_collective_flush", "[parallel]")
{
Series write(
Expand Down

0 comments on commit 2f42208

Please sign in to comment.