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 11 commits into
base: master
Choose a base branch
from
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't need this since find_package should directly work since adios2 provides a config file.

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# - Try to find ADIOS2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this file. It is not needed and will cause us issues in the future.

Copy link
Author

Choose a reason for hiding this comment

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

OK I will try to remove it although I don't know what the the alternative is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

adios2 creates a config file since it is built with CMake so, as long as you point omega_h to the correct path during the configure stage it should bring in everything it needs.

# 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/")
Comment on lines +179 to +180
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think if you get rid of the config files these should not be needed.

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}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't need this if we use the adios2 cmake targets

target_link_libraries(omega_h PUBLIC "${ADIOS2_LIBS}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

else()
message("set Omega_h_USE_MPI to use ADIOS2")
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