Skip to content

Commit

Permalink
HDF5: Silence a variety of CI warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuck Atkins committed Feb 25, 2022
1 parent 1d8c456 commit 7aa92e8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions examples/hello/hdf5Reader/helloHDF5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(int argc, char *argv[])
const std::map<std::string, adios2::Params> variables =
h5IO.AvailableVariables();

for (const auto variablePair : variables)
for (const auto &variablePair : variables)
{
std::cout << "Name: " << variablePair.first;
std::cout << std::endl;
Expand Down Expand Up @@ -132,7 +132,7 @@ int main(int argc, char *argv[])
const std::map<std::string, adios2::Params> attributes =
h5IO.AvailableAttributes();

for (const auto attrPair : attributes)
for (const auto &attrPair : attributes)
{
std::cout << "AttrName: " << attrPair.first;
std::cout << std::endl;
Expand Down
17 changes: 11 additions & 6 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
add_subdirectory(adios2)
add_subdirectory(utils)

# HDF5 VOL requires a matching adios configuration
if(ADIOS2_HAVE_HDF5 AND HDF5_VERSION VERSION_GREATER_EQUAL 1.11 AND
(NOT HDF5_IS_PARALLEL OR (HDF5_IS_PARALLEL AND ADIOS2_USE_MPI)))
set(ADIOS2_HAVE_HDF5_VOL ON CACHE INTERNAL "" FORCE)
add_subdirectory(h5vol)
# HDF5 VOL requires 1.13+
if(ADIOS2_HAVE_HDF5)
if(HDF5_VERSION VERSION_LESS 1.13)
set(ADIOS2_HAVE_HDF5_VOL OFF CACHE INTERNAL "")
else()
set(ADIOS2_HAVE_HDF5_VOL ON CACHE INTERNAL "")
endif()
else()
set(ADIOS2_HAVE_HDF5_VOL OFF CACHE INTERNAL "" FORCE)
set(ADIOS2_HAVE_HDF5_VOL OFF CACHE INTERNAL "")
endif()
if(ADIOS2_HAVE_HDF5_VOL)
add_subdirectory(h5vol)
endif()
8 changes: 6 additions & 2 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,18 @@ if(ADIOS2_HAVE_HDF5)
set(adios2_hdf5_objs adios2_hdf5)
if(HDF5_IS_PARALLEL)
list(APPEND adios2_hdf5_objs adios2_hdf5_mpi)
set_property(SOURCE core/IOMPI.cpp APPEND PROPERTY COMPILE_DEFINITIONS ADIOS2_HAVE_HDF5_PARALLEL)
set_property(SOURCE core/IOMPI.cpp APPEND PROPERTY
COMPILE_DEFINITIONS ADIOS2_HAVE_HDF5_PARALLEL
)
add_library(adios2_hdf5_mpi OBJECT
toolkit/interop/hdf5/HDF5CommonMPI.cpp
)
target_compile_definitions(adios2_hdf5_mpi PRIVATE ADIOS2_USE_MPI)
target_link_libraries(adios2_core_mpi PRIVATE adios2_hdf5_mpi)
set_property(TARGET adios2_hdf5_mpi PROPERTY EXPORT_NAME hdf5_mpi)
set_property(TARGET adios2_hdf5_mpi PROPERTY OUTPUT_NAME adios2${ADIOS2_LIBRARY_SUFFIX}_hdf5_mpi)
set_property(TARGET adios2_hdf5_mpi PROPERTY
OUTPUT_NAME adios2${ADIOS2_LIBRARY_SUFFIX}_hdf5_mpi
)
endif()

foreach(lib IN LISTS adios2_hdf5_objs)
Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/interop/hdf5/HDF5Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace
HDF5Common::MPI_API const *GetHDF5Common_MPI_API()
{
std::lock_guard<std::mutex> guard(HDF5Common_MPI_API_Mutex);
(void)guard; // Workaround to silence compiler warning about unused variable
return HDF5Common_MPI_API;
}

Expand Down
26 changes: 9 additions & 17 deletions source/h5vol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

if(CMAKE_C_COMPILER_ID MATCHES "^(GNU)$")
# Silence a noisy warning in our log functions as the behavior is
# intentional
string(APPEND CMAKE_C_FLAGS " -Wno-format-zero-length")
endif()

add_library(adios2_h5vol
H5VolReadWrite.c
H5Vol.c
Expand All @@ -19,27 +25,13 @@ target_link_libraries(adios2_h5vol PRIVATE
${HDF5_C_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
)

message(STATUS "HDF5_VERSION=${HDF5_VERSION}")
if (HDF5_VERSION)
if (HDF5_VERSION VERSION_LESS "1.13")
message(FATAL_ERROR "HDF5 version 1.13+ is required")
endif()
if(ADIOS2_USE_MPI)
target_link_libraries(adios2_h5vol PRIVATE adios2::c_mpi MPI::MPI_C)
else()
message(WARNING "Version of HDF5 is unknown, but version 1.13+ is required.")
endif()

if(NOT HDF5_IS_PARALLEL)
target_link_libraries(adios2_h5vol PRIVATE adios2::c)
elseif(HDF5_IS_PARALLEL AND ADIOS2_HAVE_MPI)
target_link_libraries(adios2_h5vol PRIVATE adios2::c_mpi MPI::MPI_C)
else() # HDF5_IS_PARALLEL AND NOT ADIOS2_HAVE_MPI
message(FATAL_ERROR "Invalid configuration: HDF5_IS_PARALLEL AND NOT ADIOS2_HAVE_MPI")
endif()

install(FILES H5Vol_def.h H5VolError.h H5Vol.h H5VolReadWrite.h H5VolUtil.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2/h5vol
COMPONENT adios2_h5vol
)
# VOL install should only contain the .so and no headers
install(TARGETS adios2_h5vol
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
4 changes: 2 additions & 2 deletions source/utils/adios_iotest/hdf5Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void hdf5Stream::Write(CommandWrite *cmdW, Config &cfg,
double maxWriteTime, minWriteTime;
MPI_Barrier(comm);
timeStart = MPI_Wtime();
for (const auto ov : cmdW->variables)
for (const auto &ov : cmdW->variables)
{
putHDF5Array(ov, step);
}
Expand Down Expand Up @@ -394,7 +394,7 @@ adios2::StepStatus hdf5Stream::Read(CommandRead *cmdR, Config &cfg,
}
void hdf5Stream::Close()
{
for (const auto it : varmap)
for (const auto &it : varmap)
{
auto &vi = it.second;
H5Dclose(vi.dataset);
Expand Down

0 comments on commit 7aa92e8

Please sign in to comment.