Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding Adios2 io support #113

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bob_input(Kokkos_PREFIX "" PATH "Path to Kokkos install")
bob_option(Omega_h_USE_CUDA_AWARE_MPI "Assume MPI is CUDA-aware, make use of that" OFF)
bob_option(Omega_h_USE_SimModSuite "Enable reading Simmetrix MeshSim meshes" OFF)
bob_option(Omega_h_USE_SimDiscrete "Enable reading and creating Simmetrix Discrete models" OFF)
bob_option(Omega_h_USE_ADIOS2 "Enable ADIOS2" OFF)
bob_input(Omega_h_VALGRIND "" STRING "Valgrind plus arguments for testing")
bob_option(Omega_h_EXAMPLES "Compile examples" OFF)

Expand Down Expand Up @@ -163,6 +164,7 @@ set(Omega_h_KEY_BOOLS
Omega_h_USE_SEACASExodus
Omega_h_USE_SimModSuite
Omega_h_USE_SimDiscrete
Omega_h_USE_ADIOS2
Omega_h_USE_DOLFIN
Omega_h_USE_dwarf
Omega_h_CHECK_BOUNDS
Expand Down
104 changes: 104 additions & 0 deletions cmake/FindADIOS2.cmake
seegyoung marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# - Try to find ADIOS2
seegyoung marked this conversation as resolved.
Show resolved Hide resolved
# Once done this will define
# ADIOS2_FOUND - System has ADIOS2
# ADIOS2_INCLUDE_DIR - The ADIOS2 include directories
# ADIOS2_LIBS - The libraries needed to use ADIOS2
# ADIOS2_<library>_FOUND - System has <library>
# ADIOS2_MAJOR_VERSION - the leading integer of the version string
# ADIOS2_MINOR_VERSION - the date code from the version string
#
# Based on input variables:
# ADIOS2_LIB_DIR
# ADIOS2_INCLUDE_DIR
# And environment variable:
# CMAKE_PREFIX_PATH
#
# This implementation assumes an adios2 install has the following structure
# VERSION/
# include/*.h
# lib64/*.a

macro(adios2LibCheck libs isRequired)
foreach(lib ${libs})
unset(adios2lib CACHE)
find_library(adios2lib "${lib}" PATHS ${ADIOS2_LIB_DIR})
if(adios2lib MATCHES "^adios2lib-NOTFOUND$")
if(${isRequired})
message(FATAL_ERROR "adios2 library ${lib} not found in ${ADIOS2_LIB_DIR}")
else()
message("adios2 library ${lib} not found in ${ADIOS2_LIB_DIR}")
endif()
else()
set("ADIOS2_${lib}_FOUND" TRUE CACHE INTERNAL "ADIOS2 library present")
set(ADIOS2_LIBS ${ADIOS2_LIBS} ${adios2lib})
endif()
endforeach()
endmacro(adios2LibCheck)

find_path(ADIOS2_INCLUDE_DIR
NAMES adios2_c.h adios2.h
PATHS ${ADIOS2_INCLUDE_DIR})
if(NOT EXISTS "${ADIOS2_INCLUDE_DIR}")
message(FATAL_ERROR "adios2 include dir not found")
endif()

string(REGEX REPLACE
"/include$" ""
ADIOS2_INSTALL_DIR
"${ADIOS2_INCLUDE_DIR}")

string(REGEX MATCH
"[0-9]+[.][0-9]+-[0-9]+"
ADIOS2_VERSION
"${ADIOS2_INCLUDE_DIR}")

#VERSION_LESS and VERSION_GREATER need '.' delimited version strings.
string(REGEX REPLACE
"([0-9]+[.][0-9]+)-([0-9]+)"
"\\1.\\2" ADIOS2_DOT_VERSION
"${ADIOS2_VERSION}")
string(REGEX REPLACE
"([0-9]+)[.]([0-9]+)-([0-9]+)"
"\\1" ADIOS2_MAJOR_VERSION
"${ADIOS2_VERSION}")
string(REGEX REPLACE
"([0-9]+)[.]([0-9]+)-([0-9]+)"
"\\3" ADIOS2_MINOR_VERSION
"${ADIOS2_VERSION}")

set(MIN_VALID_ADIOS2_VERSION 2.10.0)
set(MAX_VALID_ADIOS2_VERSION 2.10.10)
#if( ${SKIP_ADIOS2_VERSION_CHECK} )
# message(STATUS "Skipping ADIOS2 version check."
# " This may result in undefined behavior")
#elseif( (ADIOS2_DOT_VERSION VERSION_LESS MIN_VALID_ADIOS2_VERSION) OR
# (ADIOS2_DOT_VERSION VERSION_GREATER MAX_VALID_ADIOS2_VERSION) )
# MESSAGE(FATAL_ERROR
# "invalid ADIOS2 version: ${ADIOS2_DOT_VERSION}, \
# valid versions are ${MIN_VALID_ADIOS2_VERSION} to ${MAX_VALID_ADIOS2_VERSION}")
#endif()
message(STATUS "Building with ADIOS2 ${ADIOS2_DOT_VERSION}")

set(ADIOS2_LIBS "")

if (Omega_h_USE_MPI)
set(ADIOS2_LIB_NAMES
adios2_core_mpi
adios2_cxx11_mpi
)
else()
set(ADIOS2_LIB_NAMES
adios2_core
adios2_cxx11
)
endif()

adios2LibCheck("${ADIOS2_LIB_NAMES}" TRUE)

# handle the QUIETLY and REQUIRED arguments and set ADIOS2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(ADIOS2 DEFAULT_MSG
ADIOS2_LIBS ADIOS2_INCLUDE_DIR
)

mark_as_advanced(ADIOS2_INCLUDE_DIR ADIOS2_LIBS)
34 changes: 34 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ if(Omega_h_USE_SimModSuite)
"${CMAKE_CURRENT_BINARY_DIR}/Omega_h_simConfig.h")
endif()

message(STATUS "Omega_h_USE_ADIOS2: ${Omega_h_USE_ADIOS2}")
if(Omega_h_USE_ADIOS2)
list(APPEND Omega_h_SOURCES Omega_h_adios2.cpp)
#Is there a better way? I assume CMAKE_MODULE_PATH was purposely not set in
# the top level CMakeLists.txt
set(OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
seegyoung marked this conversation as resolved.
Show resolved Hide resolved
find_package(ADIOS2 MODULE REQUIRED)
set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH})
endif()

if(Omega_h_USE_SEACASExodus)
set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_exodus.cpp)
endif()
Expand Down Expand Up @@ -226,6 +237,16 @@ if(Omega_h_USE_SimModSuite)
target_link_libraries(omega_h PUBLIC "${SIMMODSUITE_LIBS}")
endif()

if(Omega_h_USE_ADIOS2)
set(ADIOS_REQUIRED_VERSION 2.10)
if (Omega_h_USE_MPI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DADIOS2_USE_MPI")
target_include_directories(omega_h PUBLIC "${ADIOS2_INCLUDE_DIR}")
seegyoung marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(omega_h PUBLIC "${ADIOS2_LIBS}")
seegyoung marked this conversation as resolved.
Show resolved Hide resolved
else()
message("set Omega_h_USE_MPI to use ADIOS2")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
message("set Omega_h_USE_MPI to use ADIOS2")
message(FATAL_ERROR, "set Omega_h_USE_MPI to use ADIOS2")

The cmake configure should fail if a dependency is missing:
https://cmake.org/cmake/help/latest/command/message.html#general-messages

If the current implementation of the adios2 interface doesn't support GPU execution there should also be a conditional for that. Something like the following should work:

if(Omega_h_USE_Kokkos)
  foreach(backend IN LISTS "CUDA" "HIP" "SYCL")
    if (backend IN_LIST Kokkos_DEVICES)
      message(FATAL_ERROR, "Omega_h_USE_ADIOS2 does not support GPU backends")
    endif()
  endforeach()
endif()

endif()
endif()

bob_link_dependency(omega_h PUBLIC SEACASExodus)

Expand Down Expand Up @@ -629,6 +650,15 @@ if(BUILD_TESTING)
else()
test_func(describe_serial 1 ./describe ${CMAKE_SOURCE_DIR}/meshes/box_3d.osh)
endif()

if (Omega_h_USE_ADIOS2)
osh_add_util(bp2osh)
osh_add_util(osh2bp)
osh_add_exe(adios2_io)
test_basefunc(adios2_io 1 ./adios2_io
${CMAKE_SOURCE_DIR}/meshes/unitbox_cutTriCube_1k.osh
output.bp)
endif()
endif()

bob_config_header("${CMAKE_CURRENT_BINARY_DIR}/Omega_h_config.h")
Expand Down Expand Up @@ -744,6 +774,10 @@ else()
list(APPEND Omega_h_HEADERS Omega_h_array_default.hpp)
endif()

if(Omega_h_USE_ADIOS2)
list(APPEND Omega_h_HEADERS Omega_h_adios2.hpp)
endif()

install(FILES ${Omega_h_HEADERS} DESTINATION include)

if (Omega_h_USE_pybind11)
Expand Down
Loading