diff --git a/cmake/ADIOSFunctions.cmake b/cmake/ADIOSFunctions.cmake index 6e5332cc59..bcf38e6aae 100644 --- a/cmake/ADIOSFunctions.cmake +++ b/cmake/ADIOSFunctions.cmake @@ -99,10 +99,12 @@ function(GenerateADIOSHeaderConfig) ") if(ADIOS2_HAVE_${OPT}) set(ADIOS2_HAVE_${OPT_UPPER} 1) + string(APPEND ADIOS2_CONFIG_FEATURE_LIST "\"${OPT_UPPER}\",") else() set(ADIOS2_HAVE_${OPT_UPPER}) endif() endforeach() + string(APPEND ADIOS2_CONFIG_FEATURE_LIST "nullptr") configure_file( ${ADIOS2_SOURCE_DIR}/source/adios2/common/ADIOSConfig.h.in diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index f7f6643bf7..8db95b9d3c 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -18,6 +18,7 @@ add_library(adios2_core core/VariableBase.cpp core/Span.cpp core/Span.tcc core/Group.cpp core/Group.tcc + core/Info.cpp #operator operator/callback/Signature1.cpp @@ -398,6 +399,11 @@ install(FILES common/ADIOSMacros.h common/ADIOSTypes.h common/ADIOSTypes.inl install(DIRECTORY core/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2/core COMPONENT adios2_core-development FILES_MATCHING PATTERN "*.h" + PATTERN "Info.h" EXCLUDE +) + +install(FILES core/Info.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT adios2_core-development ) install(DIRECTORY engine/ diff --git a/source/adios2/common/ADIOSConfig.h.in b/source/adios2/common/ADIOSConfig.h.in index 2fef35756b..ae0bccbb59 100644 --- a/source/adios2/common/ADIOSConfig.h.in +++ b/source/adios2/common/ADIOSConfig.h.in @@ -31,6 +31,8 @@ @ADIOS2_CONFIG_DEFINES@ +#define ADIOS2_FEATURE_LIST @ADIOS2_CONFIG_FEATURE_LIST@ + /* Everything between here and the note above is programatically generated */ #ifndef ADIOS2_USE_MPI diff --git a/source/adios2/core/Info.cpp b/source/adios2/core/Info.cpp new file mode 100644 index 0000000000..f6fab45756 --- /dev/null +++ b/source/adios2/core/Info.cpp @@ -0,0 +1,113 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Info.h + * + * Created on: June 22, 2023 + * Author: Norbert Podhorszki pnorbert@ornl.gov + */ + +#include "Info.h" +#include "adios2/common/ADIOSConfig.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +const int adios2_version_major = ADIOS2_VERSION_MAJOR; +const int adios2_version_minor = ADIOS2_VERSION_MINOR; +const int adios2_version_patch = ADIOS2_VERSION_PATCH; +const char adios2_version_str[] = ADIOS2_VERSION_STR; + +static const char *const engines[] = {"BP3", + "BP4", +#ifdef ADIOS2_HAVE_BP5 + "BP5", +#endif +#ifdef ADIOS2_HAVE_HDF5 + "HDF5", +#endif +#ifdef ADIOS2_HAVE_SST + "SST", +#endif +#ifdef ADIOS2_HAVE_MPI + "SSC", +#endif +#ifdef ADIOS2_HAVE_DataMan + "DataMan", +#endif +#ifdef ADIOS2_HAVE_DataSpaces + "DataSpaces", +#endif + "Inline", +#ifdef ADIOS2_HAVE_DAOS + "DAOS", +#endif +#ifdef ADIOS2_HAVE_MHS + "MHS", +#endif +#ifdef ADIOS2_HAVE_CATALYST + "ParaViewADIOSInSituEngine", +#endif + "Null", + "Skeleton", + nullptr}; + +void adios2_available_engines(size_t *nentries, const char *const **list) +{ + *nentries = (sizeof(engines) / sizeof(const char *)) - 1; + *list = engines; +} + +static const char *const operators[] = { +#ifdef ADIOS2_HAVE_BZIP2 + "BZip2", +#endif +#ifdef ADIOS2_HAVE_BLOSC2 + "Blosc", +#endif +#ifdef ADIOS2_HAVE_MGARD + "MGARD", + "MGARDPlus", +#endif +#ifdef ADIOS2_HAVE_SZ + "SZ", +#endif +#ifdef ADIOS2_HAVE_ZFP + "ZFP", +#endif +#ifdef ADIOS2_HAVE_PNG + "PNG", +#endif +#ifdef ADIOS2_HAVE_SIRIUS + "Sirius", +#endif +#ifdef ADIOS2_HAVE_LIBPRESSIO + "libpressio", +#ifdef ADIOS2_HAVE_SODIUM + "Sodium plugin", +#endif +#endif + nullptr}; + +void adios2_available_operators(size_t *nentries, const char *const **list) +{ + *nentries = (sizeof(operators) / sizeof(const char *)) - 1; + *list = operators; +} + +const char *adios2_feature_list[] = {ADIOS2_FEATURE_LIST}; + +void adios2_available_features(size_t *nentries, const char *const **list) +{ + *nentries = (sizeof(adios2_feature_list) / sizeof(const char *)) - 1; + *list = adios2_feature_list; +} + +#ifdef __cplusplus +} // end extern C +#endif diff --git a/source/adios2/core/Info.h b/source/adios2/core/Info.h new file mode 100644 index 0000000000..657cea1a0e --- /dev/null +++ b/source/adios2/core/Info.h @@ -0,0 +1,38 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Info.h + * + * Created on: June 22, 2023 + * Author: Norbert Podhorszki pnorbert@ornl.gov + */ + +#ifndef ADIOS2_INFO_H_ +#define ADIOS2_INFO_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern const int adios2_version_major; +extern const int adios2_version_minor; +extern const int adios2_version_patch; +extern const char adios2_version_str[]; + +/** Return the list of available Engines in the installed adios2 library */ +void adios2_available_engines(size_t *nentries, const char *const **list); + +/** Return the list of available Engines in the installed adios2 library */ +void adios2_available_operators(size_t *nentries, const char *const **list); + +/** Return the list of available features in the installed adios2 library */ +void adios2_available_features(size_t *nentries, const char *const **list); + +#ifdef __cplusplus +} // end extern C +#endif + +#endif /* ADIOS2_INFO_H_ */ diff --git a/source/utils/CMakeLists.txt b/source/utils/CMakeLists.txt index 227c176754..37153406c0 100644 --- a/source/utils/CMakeLists.txt +++ b/source/utils/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(bpls ./bpls/bpls.cpp) target_link_libraries(bpls PUBLIC adios2_core adios2sys PRIVATE adios2::thirdparty::pugixml $<$:shlwapi>) -target_include_directories(bpls PRIVATE ${PROJECT_BINARY_DIR}) +target_include_directories(bpls PRIVATE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/bindings/C) set_property(TARGET bpls PROPERTY OUTPUT_NAME bpls${ADIOS2_EXECUTABLE_SUFFIX}) install(TARGETS bpls EXPORT adios2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_tools-runtime diff --git a/source/utils/bpls/bpls.cpp b/source/utils/bpls/bpls.cpp index 553db18321..714b14f1ff 100644 --- a/source/utils/bpls/bpls.cpp +++ b/source/utils/bpls/bpls.cpp @@ -250,6 +250,48 @@ void print_bpls_version() } printf("Target OS: %s\n", ADIOS_INFO_SYSTEM); printf("Target Arch: %s\n", ADIOS_INFO_ARCH); + + size_t nengines; + const char *const *list_engines; + adios2_available_engines(&nengines, &list_engines); + printf("Available engines = %zu:", nengines); + for (size_t i = 0; i < nengines; ++i) + { + printf(" %s", list_engines[i]); + if (i < nengines - 1) + { + printf(","); + } + } + printf("\n"); + + size_t noperators; + const char *const *list_operators; + adios2_available_operators(&noperators, &list_operators); + printf("Available operators = %zu:", noperators); + for (size_t i = 0; i < noperators; ++i) + { + printf(" %s", list_operators[i]); + if (i < noperators - 1) + { + printf(","); + } + } + printf("\n"); + + size_t nfeatures; + const char *const *list_features; + adios2_available_features(&nfeatures, &list_features); + printf("Available features = %zu:", nfeatures); + for (size_t i = 0; i < nfeatures; ++i) + { + printf(" %s", list_features[i]); + if (i < nfeatures - 1) + { + printf(","); + } + } + printf("\n"); } } diff --git a/source/utils/bpls/bpls.h b/source/utils/bpls/bpls.h index 42a8d7363d..7ddec2e10a 100644 --- a/source/utils/bpls/bpls.h +++ b/source/utils/bpls/bpls.h @@ -14,6 +14,8 @@ #include "adios2/core/Variable.h" #include "adios2/helper/adiosFunctions.h" +#include "adios2/core/Info.h" + #include namespace adios2 diff --git a/testing/adios2/interface/CMakeLists.txt b/testing/adios2/interface/CMakeLists.txt index 050be805b9..25d7ccbf8b 100644 --- a/testing/adios2/interface/CMakeLists.txt +++ b/testing/adios2/interface/CMakeLists.txt @@ -29,3 +29,4 @@ gtest_add_tests_helper(Selection MPI_NONE ADIOS Interface. .BP3 gtest_add_tests_helper(Selection MPI_NONE ADIOS Interface. .BPfile WORKING_DIRECTORY ${BPfile_DIR} EXTRA_ARGS "BPfile") gtest_add_tests_helper(NoMpi MPI_NONE ADIOS Interface. "") +gtest_add_tests_helper(Info MPI_NONE ADIOS Interface. "") diff --git a/testing/adios2/interface/TestADIOSInfo.cpp b/testing/adios2/interface/TestADIOSInfo.cpp new file mode 100644 index 0000000000..b719537ab3 --- /dev/null +++ b/testing/adios2/interface/TestADIOSInfo.cpp @@ -0,0 +1,41 @@ +#include +#include + +TEST(ADIOSInterface, info_available_features) +{ + size_t nfeatures = 0; + const char *const *list_features = nullptr; + adios2_available_features(&nfeatures, &list_features); + + EXPECT_GE(nfeatures, 0); + EXPECT_NE(list_features, nullptr); + EXPECT_EQ(list_features[nfeatures], nullptr); +} + +TEST(ADIOSInterface, info_available_engines) +{ + size_t nengines = 0; + const char *const *list_engines = nullptr; + adios2_available_engines(&nengines, &list_engines); + + EXPECT_GE(nengines, 1); + EXPECT_NE(list_engines, nullptr); + EXPECT_EQ(list_engines[nengines], nullptr); +} + +TEST(ADIOSInterface, info_available_operators) +{ + size_t noperators = 0; + const char *const *list_operators = nullptr; + adios2_available_operators(&noperators, &list_operators); + + EXPECT_GE(noperators, 0); + EXPECT_NE(list_operators, nullptr); + EXPECT_EQ(list_operators[noperators], nullptr); +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}