Skip to content

Commit

Permalink
Merge pull request #23 from ecmwf/feature/daos_handle
Browse files Browse the repository at this point in the history
DAOS backend
  • Loading branch information
simondsmart authored May 21, 2024
2 parents fcc2c0f + 823be84 commit 29420df
Show file tree
Hide file tree
Showing 111 changed files with 11,799 additions and 199 deletions.
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,45 @@ ecbuild_add_option( FEATURE FDB_REMOTE
DEFAULT ON
DESCRIPTION "Support for FDB remote access" )

find_package(UUID QUIET)

find_package(DAOS QUIET)

set(_default_dummy_daos ON)
if(DAOS_FOUND)
set(_default_dummy_daos OFF)
endif()

ecbuild_add_option( FEATURE DUMMY_DAOS
DEFAULT ${_default_dummy_daos}
CONDITION UUID_FOUND
DESCRIPTION "Use dummy DAOS library emulating DAOS with a file system" )

if(HAVE_DUMMY_DAOS)
set(DAOS_LIBRARIES dummy_daos)
set(DAOS_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/dummy_daos)
set(DAOS_FOUND TRUE)
set(DAOS_TESTS_LIBRARIES dummy_daos_tests)
set(DAOS_TESTS_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/dummy_daos)
set(DAOS_TESTS_FOUND TRUE)
endif()

ecbuild_add_option( FEATURE DAOSFDB
CONDITION DAOS_FOUND AND UUID_FOUND
DEFAULT ON
DESCRIPTION "DAOS support for FDB Store" )

ecbuild_add_option( FEATURE DAOS_ADMIN
DEFAULT OFF
CONDITION HAVE_DAOSFDB AND DAOS_TESTS_FOUND
DESCRIPTION "Add features for DAOS pool management. Removes need to manually create a pool for DAOS unit tests" )

# DAOS_TESTS is a daos admin library, usually not present
if(NOT HAVE_DAOS_ADMIN)
set( DAOS_TESTS_LIBRARIES "" )
set( DAOS_TESTS_INCLUDE_DIRS "" )
endif()

ecbuild_add_option( FEATURE EXPERIMENTAL
DEFAULT OFF
DESCRIPTION "Experimental features" )
Expand Down
164 changes: 164 additions & 0 deletions cmake/FindDAOS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Copyright 2022 European Centre for Medium-Range Weather Forecasts (ECMWF)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

include(FindPackageHandleStandardArgs)

# daos

find_path(DAOS_INCLUDE_DIR
NAMES daos.h
HINTS
${DAOS_ROOT}
${DAOS_DIR}
${DAOS_PATH}
ENV DAOS_ROOT
ENV DAOS_DIR
ENV DAOS_PATH
PATH_SUFFIXES include
)

find_library(DAOS_LIBRARY
NAMES daos
HINTS
${DAOS_ROOT}
${DAOS_DIR}
${DAOS_PATH}
ENV DAOS_ROOT
ENV DAOS_DIR
ENV DAOS_PATH
PATH_SUFFIXES lib lib64
)

# daos_common

find_library(DAOS_COMMON_LIBRARY
NAMES daos_common
HINTS
${DAOS_ROOT}
${DAOS_DIR}
${DAOS_PATH}
ENV DAOS_ROOT
ENV DAOS_DIR
ENV DAOS_PATH
PATH_SUFFIXES lib lib64
)

# gurt

find_library(GURT_LIBRARY
NAMES gurt
HINTS
${DAOS_ROOT}
${DAOS_DIR}
${DAOS_PATH}
ENV DAOS_ROOT
ENV DAOS_DIR
ENV DAOS_PATH
PATH_SUFFIXES lib lib64
)

# daos tests

# if not using dummy DAOS, then the daos_tests lib should be installed
# from daos RPMs into the corresponding system directories. However its
# headers (daos/tests_lib.h) are not provided in any of the RPMs and
# need to be copied from source. tests_lib.h could be copied into standard
# system directories together with other DAOS headers, but the tests_lib.h
# file includes many other DAOS headers not provided by RPMs and other
# external library headers, e.g. boost, and are required when compiling a
# program which includes tests_lib.h (e.g. fdb5's DAOS backend with
# DAOS_ADMIN enabled for unit testing). To avoid having to install all
# these headers, tests_lib.h can be copied in a user directory and modified
# to only declare the necessary functions (pool create and destroy) and
# remove most of the includes. All this explains why a DAOS_TESTS_INCLUDE_ROOT
# environment variable is used here to find tests_lib.h rather than DAOS_ROOT.

find_path(DAOS_TESTS_INCLUDE_DIR
NAMES daos/tests_lib.h
HINTS
${DAOS_TESTS_INCLUDE_ROOT}
${DAOS_TESTS_DIR}
${DAOS_TESTS_PATH}
ENV DAOS_TESTS_INCLUDE_ROOT
ENV DAOS_TESTS_DIR
ENV DAOS_TESTS_PATH
PATH_SUFFIXES include
)

find_library(DAOS_TESTS_LIBRARY
NAMES daos_tests
HINTS
${DAOS_ROOT}
${DAOS_DIR}
${DAOS_PATH}
ENV DAOS_ROOT
ENV DAOS_DIR
ENV DAOS_PATH
PATH_SUFFIXES lib lib64
)

find_package_handle_standard_args(
DAOS
DEFAULT_MSG
DAOS_LIBRARY
DAOS_INCLUDE_DIR
DAOS_COMMON_LIBRARY
GURT_LIBRARY )

mark_as_advanced(DAOS_INCLUDE_DIR DAOS_LIBRARY DAOS_COMMON_LIBRARY GURT_LIBRARY)

if(DAOS_FOUND)
add_library(daos UNKNOWN IMPORTED GLOBAL)
set_target_properties(daos PROPERTIES
IMPORTED_LOCATION ${DAOS_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${DAOS_INCLUDE_DIR}
)
add_library(daos_common UNKNOWN IMPORTED GLOBAL)
set_target_properties(daos_common PROPERTIES
IMPORTED_LOCATION ${DAOS_COMMON_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${DAOS_INCLUDE_DIR}
)
add_library(gurt UNKNOWN IMPORTED GLOBAL)
set_target_properties(gurt PROPERTIES
IMPORTED_LOCATION ${GURT_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${DAOS_INCLUDE_DIR}
)
set(DAOS_INCLUDE_DIRS ${DAOS_INCLUDE_DIR})
list(APPEND DAOS_LIBRARIES daos daos_common gurt)
endif()

find_package_handle_standard_args(
DAOS_TESTS
DEFAULT_MSG
DAOS_TESTS_LIBRARY
DAOS_TESTS_INCLUDE_DIR )

mark_as_advanced(DAOS_TESTS_INCLUDE_DIR DAOS_TESTS_LIBRARY)

if(DAOS_TESTS_FOUND)
add_library(daos_tests UNKNOWN IMPORTED GLOBAL)
set_target_properties(daos_tests PROPERTIES
IMPORTED_LOCATION ${DAOS_TESTS_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES "${DAOS_TESTS_INCLUDE_DIR};${DAOS_INCLUDE_DIR}"
)
list(APPEND DAOS_TESTS_INCLUDE_DIRS
${DAOS_TESTS_INCLUDE_DIR}
${DAOS_INCLUDE_DIR}
)
set(DAOS_TESTS_LIBRARIES daos_tests)
endif()
60 changes: 60 additions & 0 deletions cmake/FindUUID.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2022 European Centre for Medium-Range Weather Forecasts (ECMWF)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

include(FindPackageHandleStandardArgs)

# uuid

find_path(UUID_INCLUDE_DIR
NAMES uuid/uuid.h
HINTS
${UUID_ROOT}
${UUID_DIR}
${UUID_PATH}
ENV UUID_ROOT
ENV UUID_DIR
ENV UUID_PATH
PATH_SUFFIXES include include/uuid
NO_DEFAULT_PATH
)

find_library(UUID_LIBRARY
NAMES uuid
HINTS
${UUID_ROOT}
${UUID_DIR}
${UUID_PATH}
ENV UUID_ROOT
ENV UUID_DIR
ENV UUID_PATH
PATH_SUFFIXES lib lib64
)

find_package_handle_standard_args(UUID DEFAULT_MSG UUID_LIBRARY UUID_INCLUDE_DIR)

mark_as_advanced(UUID_INCLUDE_DIR UUID_LIBRARY)

if(UUID_FOUND)
add_library(uuid UNKNOWN IMPORTED GLOBAL)
set_target_properties(uuid PROPERTIES
IMPORTED_LOCATION ${UUID_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${UUID_INCLUDE_DIR}
)
set(UUID_INCLUDE_DIRS ${UUID_INCLUDE_DIR})
set(UUID_LIBRARIES uuid)
endif()
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ ecbuild_find_project_files()

add_subdirectory( fdb5 )

if (HAVE_DUMMY_DAOS)
add_subdirectory(dummy_daos)
endif()

############################################################################################
# following directories are not packaged
# currently this is developer only, hence not distributed
Expand Down
45 changes: 45 additions & 0 deletions src/dummy_daos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ecbuild_add_library(

TARGET dummy_daos

INSTALL_HEADERS_LIST
daos.h

HEADER_DESTINATION ${INSTALL_INCLUDE_DIR}

SOURCES
daos.h
daos.cc
dummy_daos.h
dummy_daos.cc

PUBLIC_LIBS
eckit
uuid

)

if(HAVE_DAOS_ADMIN)

ecbuild_add_library(

TARGET dummy_daos_tests

INSTALL_HEADERS LISTED

HEADER_DESTINATION ${INSTALL_INCLUDE_DIR}

SOURCES
daos/tests_lib.h
daos/tests_lib.cc

PRIVATE_INCLUDES
${PROJECT_SOURCE_DIR}/../daos.h
${PROJECT_SOURCE_DIR}/../dummy_daos.h

PRIVATE_LIBS
dummy_daos

)

endif()
Loading

0 comments on commit 29420df

Please sign in to comment.