Skip to content

Commit

Permalink
Merge pull request #3676 from pnorbert/c_version2
Browse files Browse the repository at this point in the history
Version constants plus functions to retrieve list of ...
  • Loading branch information
vicentebolea authored Aug 2, 2023
2 parents 0a45dde + 6c4c723 commit 490bed5
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmake/ADIOSFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,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
Expand Down
6 changes: 6 additions & 0 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -404,6 +405,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/
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/common/ADIOSConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
113 changes: 113 additions & 0 deletions source/adios2/core/Info.cpp
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdlib.h>

#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
38 changes: 38 additions & 0 deletions source/adios2/core/Info.h
Original file line number Diff line number Diff line change
@@ -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 <stddef.h>

#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_ */
2 changes: 1 addition & 1 deletion source/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ add_executable(bpls ./bpls/bpls.cpp)
target_link_libraries(bpls
PUBLIC adios2_core adios2sys
PRIVATE adios2::thirdparty::pugixml $<$<PLATFORM_ID:Windows>: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
Expand Down
42 changes: 42 additions & 0 deletions source/utils/bpls/bpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,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");
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/utils/bpls/bpls.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "adios2/core/Variable.h"
#include "adios2/helper/adiosFunctions.h"

#include "adios2/core/Info.h"

#include <map>

namespace adios2
Expand Down
1 change: 1 addition & 0 deletions testing/adios2/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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. "")
41 changes: 41 additions & 0 deletions testing/adios2/interface/TestADIOSInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <adios2/core/Info.h>
#include <gtest/gtest.h>

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();
}

0 comments on commit 490bed5

Please sign in to comment.