Skip to content

Commit

Permalink
Merge pull request #433 from HDFGroup/chogan/fix_hdf5_cmake
Browse files Browse the repository at this point in the history
Fix several build-related issues
  • Loading branch information
ChristopherHogan committed Jul 14, 2022
2 parents c862339 + 071fa7a commit 48fc897
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 70 deletions.
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,37 @@ if(HERMES_BUILD_BUFFER_POOL_VISUALIZER)
endif()
endif()

# HDF5
if(HERMES_ENABLE_VFD)
set(HERMES_REQUIRED_HDF5_VERSION 1.13.0)
set(HERMES_REQUIRED_HDF5_COMPONENTS C)
find_package(HDF5 ${HERMES_REQUIRED_HDF5_VERSION} CONFIG NAMES hdf5
COMPONENTS ${HERMES_REQUIRED_HDF5_COMPONENTS} shared)
if(HDF5_FOUND)
message(STATUS "found HDF5 ${HDF5_VERSION} at ${HDF5_INCLUDE_DIR}")
set(HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES}
${HDF5_INCLUDE_DIR})
set(HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES}
${HDF5_C_SHARED_LIBRARY})
else()
# Allow for HDF5 autotools builds
find_package(HDF5 ${HERMES_REQUIRED_HDF5_VERSION} MODULE REQUIRED
COMPONENTS ${HERMES_REQUIRED_HDF5_COMPONENTS})
if(HDF5_FOUND)
set(HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES}
${HDF5_INCLUDE_DIRS})
set(HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES}
${HDF5_LIBRARIES})
else()
message(FATAL_ERROR "Could not find HDF5, please set HDF5_DIR (1.13.0) or HDF5_ROOT (1.13.1).")
endif()
endif()
endif()

#-----------------------------------------------------------------------------
# Coverage
#-----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion adapter/test/vfd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ target_link_libraries(hermes_vfd_test
glog::glog
stdc++fs
${HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES}
${HDF5_HERMES_VFD_EXT_PKG_DEPENDENCIES}
)

if(HERMES_USE_ADDRESS_SANITIZER)
Expand Down
41 changes: 0 additions & 41 deletions adapter/vfd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,6 @@ if(NOT HDF5_HERMES_VFD_EXPORTED_TARGETS)
set(HDF5_HERMES_VFD_EXPORTED_TARGETS "${HDF5_HERMES_VFD_PACKAGE}-targets")
endif()

#------------------------------------------------------------------------------
# External dependencies
#------------------------------------------------------------------------------
#HDF5

set(HERMES_REQUIRED_HDF5_COMPONENTS C)

find_package(HDF5 1.13.0 NO_MODULE NAMES hdf5 COMPONENTS ${HERMES_REQUIRED_HDF5_COMPONENTS} shared)
if(HDF5_FOUND)
set(HDF5_C_SHARED_LIBRARY hdf5-shared)
# if(NOT TARGET ${HDF5_C_SHARED_LIBRARY})
# message(FATAL_ERROR "Could not find hdf5 shared target, please make "
#"sure that HDF5 has ben compiled with shared libraries enabled.")
# endif()
set(HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES}
${HDF5_INCLUDE_DIR}
)
set(HDF5_HERMES_VFD_EXT_PKG_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_PKG_DEPENDENCIES}
${HDF5_C_SHARED_LIBRARY}
)
else()
# Allow for HDF5 autotools builds
find_package(HDF5 1.13.0 MODULE REQUIRED COMPONENTS ${HERMES_REQUIRED_HDF5_COMPONENTS})
if(HDF5_FOUND)
set(HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_INCLUDE_DEPENDENCIES}
${HDF5_INCLUDE_DIRS}
)
set(HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES
${HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES}
${HDF5_LIBRARIES}
)
else()
message(FATAL_ERROR "Could not find HDF5, please check HDF5_DIR.")
endif()
endif()

set(HDF5_HERMES_VFD_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/H5FDhermes.h
${CMAKE_CURRENT_SOURCE_DIR}/H5FDhermes.c
Expand All @@ -85,9 +46,7 @@ target_include_directories(hdf5_hermes_vfd
target_link_libraries(hdf5_hermes_vfd
hermes_wrapper
MPI::MPI_C
${HDF5_HERMES_VFD_EXPORTED_LIBS}
${HDF5_HERMES_VFD_EXT_LIB_DEPENDENCIES}
${HDF5_HERMES_VFD_EXT_PKG_DEPENDENCIES}
)

set(HDF5_HERMES_VFD_EXPORTED_LIBS hdf5_hermes_vfd ${HDF5_HERMES_VFD_EXPORTED_LIBS} PARENT_SCOPE)
Expand Down
4 changes: 3 additions & 1 deletion adapter/vfd/H5FDhermes.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* and buffer datasets in Hermes buffering systems with
* multiple storage tiers.
*/
#define _GNU_SOURCE
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <stdio.h>
#include <string.h>
Expand Down
41 changes: 22 additions & 19 deletions ci/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,12 @@ MOCHI_REPO_DIR=${INSTALL_DIR}/mochi-spack-packages
THALLIUM_VERSION=0.10.0
GOTCHA_VERSION=develop
CATCH2_VERSION=2.13.3
SPACK_VERSION=0.17.2
HDF5_VERSION=1_13_0
SPACK_VERSION=0.18.0
HDF5_VERSION=1_13_1

echo "Installing dependencies at ${INSTALL_DIR}"
mkdir -p ${INSTALL_DIR}

# HDF5
# TODO: Use spack package once 1.13.0 is available in a release (currently
# only on the develop branch)
git clone https://github.com/HDFGroup/hdf5
pushd hdf5
git checkout hdf5-${HDF5_VERSION}
bash autogen.sh
mkdir -p build
pushd build
CXXFLAGS=-I"${INSTALL_DIR}/include" LDFLAGS="-L${INSTALL_DIR}/lib -Wl,-rpath,${INSTALL_DIR}/lib" \
../configure --prefix="${INSTALL_DIR}"
make -j 4 && make install
popd
popd

# Spack
git clone https://github.com/spack/spack ${SPACK_DIR}
pushd ${SPACK_DIR}
Expand Down Expand Up @@ -60,10 +45,28 @@ THALLIUM_SPEC="mochi-thallium@${THALLIUM_VERSION} ^mercury~boostsys"
CATCH2_SPEC="catch2@${CATCH2_VERSION}"
GLPK_SPEC="glpk"
GLOG_SPEC="glog"
HDF5_SPEC="hdf5@${HDF5_VERSION}"
ALL_SPECS="${THALLIUM_SPEC} ${CATCH2_SPEC} ${GLPK_SPEC} ${GLOG_SPEC} ${HDF5_SPEC}"

spack install ${THALLIUM_SPEC} ${CATCH2_SPEC} ${GLPK_SPEC} ${GLOG_SPEC}
spack install ${ALL_SPECS}
SPACK_STAGING_DIR=~/spack_staging
mkdir -p ${SPACK_STAGING_DIR}
spack view --verbose symlink ${SPACK_STAGING_DIR} ${THALLIUM_SPEC} ${CATCH2_SPEC} ${GLPK_SPEC} ${GLOG_SPEC}
spack view --verbose symlink ${SPACK_STAGING_DIR} ${ALL_SPECS}

cp -LRnv ${SPACK_STAGING_DIR}/* ${INSTALL_DIR}

# IOR
pushd ~
git clone https://github.com/ChristopherHogan/ior
pushd ior
git checkout chogan/hermes
./bootstrap
mkdir -p build
pushd build
CPPFLAGS=-I${INSTALL_DIR}/include \
LDFLAGS="-L${INSTALL_DIR}/lib -Wl,-rpath,${INSTALL_DIR}/lib" \
../configure --prefix=${INSTALL_DIR} --with-hdf5=yes
make -j 4 && make install
popd
popd
popd
6 changes: 4 additions & 2 deletions ci/install_hermes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pushd build
DEPENDENCY_PREFIX="${HOME}/${LOCAL}"
INSTALL_PREFIX="${HOME}/install"

# Need h5diff and ior on the PATH
export PATH="${DEPENDENCY_PREFIX}/bin:${PATH}"

export CXXFLAGS="${CXXFLAGS} -std=c++17 -Werror -Wall -Wextra"
cmake \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
Expand All @@ -37,7 +40,6 @@ cmake \
..

cmake --build . -- -j4
# Need h5diff on the PATH
PATH="${DEPENDENCY_PREFIX}/bin:${PATH}" ctest -VV
ctest -VV

popd
12 changes: 6 additions & 6 deletions ci/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ packages:
target: [x86_64]
mpich:
externals:
- spec: mpich@3.3
prefix: /opt/mpich-3.3-intel
- spec: mpich@3.3.2
prefix: /usr
buildable: False
cmake:
externals:
- spec: cmake@3.10.0
prefix: /usr/local/cmake-3.10.0
- spec: cmake@3.23.2
prefix: /usr/local
buildable: False
autoconf:
externals:
Expand All @@ -18,7 +18,7 @@ packages:
buildable: False
automake:
externals:
- spec: automake@1.15
- spec: automake@1.16
prefix: /usr
buildable: False
libtool:
Expand All @@ -28,7 +28,7 @@ packages:
buildable: False
m4:
externals:
- spec: m4@4.17
- spec: m4@1.4.18
prefix: /usr
buildable: False
pkg-config:
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ target_include_directories(hermes
target_link_libraries(hermes
PUBLIC ${GLPK_LIBRARIES}
PUBLIC thallium
PUBLIC glog::glog
PUBLIC "$<$<BOOL:${HERMES_INTERCEPT_IO}>:${GOTCHA_MODULE_LIBS}>"
PRIVATE $<$<BOOL:${HERMES_COMMUNICATION_MPI}>:MPI::MPI_CXX>
)
Expand Down

0 comments on commit 48fc897

Please sign in to comment.