From 8abf11f88df62dd525f30be4d60537f28b3f4a88 Mon Sep 17 00:00:00 2001 From: Ana Gainaru Date: Thu, 20 Jun 2024 12:38:05 -0400 Subject: [PATCH] Merge pull request #4207 from anagainaru/hide-symbols Limit the exposed symbols related to derived variables (cherry picked from commit c29702297015fac5cd48f0b29a436eb66c832b05) --- source/adios2/CMakeLists.txt | 3 +- source/adios2/core/VariableDerived.h | 2 - source/adios2/toolkit/derived/DerivedData.h | 18 ++++++ source/adios2/toolkit/derived/ExprHelper.h | 63 -------------------- source/adios2/toolkit/derived/Expression.cpp | 47 ++++++++++++++- source/adios2/toolkit/derived/Expression.h | 19 +++++- source/adios2/toolkit/derived/Function.cpp | 7 +-- source/adios2/toolkit/derived/Function.h | 26 +------- source/adios2/toolkit/derived/Function.tcc | 1 + 9 files changed, 85 insertions(+), 101 deletions(-) create mode 100644 source/adios2/toolkit/derived/DerivedData.h delete mode 100644 source/adios2/toolkit/derived/ExprHelper.h diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index ff1645b4bb..5bc3f9c121 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -133,8 +133,7 @@ if (ADIOS2_HAVE_Derived_Variable) target_sources(adios2_core PRIVATE core/VariableDerived.cpp toolkit/derived/Expression.cpp - toolkit/derived/Function.cpp toolkit/derived/Function.tcc - toolkit/derived/ExprHelper.h) + toolkit/derived/Function.cpp toolkit/derived/Function.tcc) set_target_properties(adios2_core PROPERTIES INCLUDE_DIRECTORIES "$;$") find_package(BISON "3.8.2") diff --git a/source/adios2/core/VariableDerived.h b/source/adios2/core/VariableDerived.h index cc7bf8cbf2..f0185f45c2 100644 --- a/source/adios2/core/VariableDerived.h +++ b/source/adios2/core/VariableDerived.h @@ -1,9 +1,7 @@ #ifndef ADIOS2_CORE_VARIABLE_DERIVED_H_ #define ADIOS2_CORE_VARIABLE_DERIVED_H_ -#include "adios2/common/ADIOSTypes.h" #include "adios2/core/VariableBase.h" -#include "adios2/helper/adiosType.h" #include "adios2/toolkit/derived/Expression.h" namespace adios2 diff --git a/source/adios2/toolkit/derived/DerivedData.h b/source/adios2/toolkit/derived/DerivedData.h new file mode 100644 index 0000000000..30365ebd05 --- /dev/null +++ b/source/adios2/toolkit/derived/DerivedData.h @@ -0,0 +1,18 @@ +#ifndef ADIOS2_DERIVED_Data_H_ +#define ADIOS2_DERIVED_Data_H_ + +#include "adios2/common/ADIOSTypes.h" + +namespace adios2 +{ +namespace derived +{ +struct DerivedData +{ + void *Data; + Dims Start; + Dims Count; +}; +} +} +#endif diff --git a/source/adios2/toolkit/derived/ExprHelper.h b/source/adios2/toolkit/derived/ExprHelper.h deleted file mode 100644 index 38672cfec4..0000000000 --- a/source/adios2/toolkit/derived/ExprHelper.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef ADIOS2_DERIVED_PARSER_EXPHELPER_H_ -#define ADIOS2_DERIVED_PARSER_EXPHELPER_H_ - -#include -#include -#include -#include - -namespace adios2 -{ -namespace detail -{ - -enum ExpressionOperator -{ - OP_NULL, - OP_ALIAS, /* Parser-use only */ - OP_PATH, /* Parser-use only */ - OP_NUM, /* Parser-use only */ - OP_INDEX, - OP_ADD, - OP_SQRT, - OP_POW, - OP_MAGN, - OP_CURL -}; - -struct OperatorProperty -{ - std::string name; - bool is_associative; -}; - -const std::map op_property = { - {ExpressionOperator::OP_NULL, {"NULL", false}}, - {ExpressionOperator::OP_ALIAS, {"ALIAS", false}}, /* Parser-use only */ - {ExpressionOperator::OP_PATH, {"PATH", false}}, /* Parser-use only */ - {ExpressionOperator::OP_NUM, {"NUM", false}}, /* Parser-use only */ - {ExpressionOperator::OP_INDEX, {"INDEX", false}}, - {ExpressionOperator::OP_ADD, {"ADD", true}}, - {ExpressionOperator::OP_SQRT, {"SQRT", false}}, - {ExpressionOperator::OP_POW, {"POW", false}}, - {ExpressionOperator::OP_CURL, {"CURL", false}}, - {ExpressionOperator::OP_MAGN, {"MAGNITUDE", false}}}; - -const std::map string_to_op = { - {"ALIAS", ExpressionOperator::OP_ALIAS}, /* Parser-use only */ - {"PATH", ExpressionOperator::OP_PATH}, /* Parser-use only */ - {"NUM", ExpressionOperator::OP_NUM}, /* Parser-use only */ - {"INDEX", ExpressionOperator::OP_INDEX}, {"+", ExpressionOperator::OP_ADD}, - {"add", ExpressionOperator::OP_ADD}, {"ADD", ExpressionOperator::OP_ADD}, - {"SQRT", ExpressionOperator::OP_SQRT}, {"sqrt", ExpressionOperator::OP_SQRT}, - {"POW", ExpressionOperator::OP_POW}, {"^", ExpressionOperator::OP_POW}, - {"CURL", ExpressionOperator::OP_CURL}, {"curl", ExpressionOperator::OP_CURL}, - {"MAGNITUDE", ExpressionOperator::OP_MAGN}, {"magnitude", ExpressionOperator::OP_MAGN}}; - -inline std::string get_op_name(ExpressionOperator op) { return op_property.at(op).name; } - -inline ExpressionOperator get_op(std::string op) { return string_to_op.at(op); } - -} -} -#endif diff --git a/source/adios2/toolkit/derived/Expression.cpp b/source/adios2/toolkit/derived/Expression.cpp index 81db7ccd15..89fa8083ac 100644 --- a/source/adios2/toolkit/derived/Expression.cpp +++ b/source/adios2/toolkit/derived/Expression.cpp @@ -2,14 +2,49 @@ #define ADIOS2_DERIVED_Expression_CPP_ #include "Expression.h" +#include "Function.h" +#include "adios2/helper/adiosLog.h" #include "parser/ASTDriver.h" namespace adios2 { namespace detail { +struct OperatorProperty +{ + std::string name; + bool is_associative; +}; + +const std::map op_property = { + {ExpressionOperator::OP_NULL, {"NULL", false}}, + {ExpressionOperator::OP_ALIAS, {"ALIAS", false}}, /* Parser-use only */ + {ExpressionOperator::OP_PATH, {"PATH", false}}, /* Parser-use only */ + {ExpressionOperator::OP_NUM, {"NUM", false}}, /* Parser-use only */ + {ExpressionOperator::OP_INDEX, {"INDEX", false}}, + {ExpressionOperator::OP_ADD, {"ADD", true}}, + {ExpressionOperator::OP_SQRT, {"SQRT", false}}, + {ExpressionOperator::OP_POW, {"POW", false}}, + {ExpressionOperator::OP_CURL, {"CURL", false}}, + {ExpressionOperator::OP_MAGN, {"MAGNITUDE", false}}}; + +const std::map string_to_op = { + {"ALIAS", ExpressionOperator::OP_ALIAS}, /* Parser-use only */ + {"PATH", ExpressionOperator::OP_PATH}, /* Parser-use only */ + {"NUM", ExpressionOperator::OP_NUM}, /* Parser-use only */ + {"INDEX", ExpressionOperator::OP_INDEX}, {"+", ExpressionOperator::OP_ADD}, + {"add", ExpressionOperator::OP_ADD}, {"ADD", ExpressionOperator::OP_ADD}, + {"SQRT", ExpressionOperator::OP_SQRT}, {"sqrt", ExpressionOperator::OP_SQRT}, + {"POW", ExpressionOperator::OP_POW}, {"^", ExpressionOperator::OP_POW}, + {"CURL", ExpressionOperator::OP_CURL}, {"curl", ExpressionOperator::OP_CURL}, + {"MAGNITUDE", ExpressionOperator::OP_MAGN}, {"magnitude", ExpressionOperator::OP_MAGN}}; + +inline std::string get_op_name(ExpressionOperator op) { return op_property.at(op).name; } + +inline ExpressionOperator get_op(std::string op) { return string_to_op.at(op); } + // helper function -adios2::detail::ExpressionOperator convert_op(std::string opname) +ExpressionOperator convert_op(std::string opname) { adios2::detail::ExpressionOperator op; try @@ -77,6 +112,16 @@ adios2::derived::ExpressionTree ASTNode_to_ExpressionTree(adios2::detail::ASTNod namespace derived { +struct OperatorFunctions +{ + std::function, DataType)> ComputeFct; + std::function)> DimsFct; +}; + +std::map OpFunctions = { + {adios2::detail::ExpressionOperator::OP_ADD, {AddFunc, SameDimsFunc}}, + {adios2::detail::ExpressionOperator::OP_CURL, {Curl3DFunc, CurlDimsFunc}}, + {adios2::detail::ExpressionOperator::OP_MAGN, {MagnitudeFunc, SameDimsFunc}}}; Expression::Expression(std::string string_exp) : m_Shape({0}), m_Start({0}), m_Count({0}), ExprString(string_exp) diff --git a/source/adios2/toolkit/derived/Expression.h b/source/adios2/toolkit/derived/Expression.h index 2b6f8912a3..41118c631f 100644 --- a/source/adios2/toolkit/derived/Expression.h +++ b/source/adios2/toolkit/derived/Expression.h @@ -1,13 +1,28 @@ #ifndef ADIOS2_DERIVED_Expression_H_ #define ADIOS2_DERIVED_Expression_H_ -#include "Function.h" -#include "adios2/common/ADIOSTypes.h" +#include "DerivedData.h" #include #include namespace adios2 { +namespace detail +{ +enum ExpressionOperator +{ + OP_NULL, + OP_ALIAS, /* Parser-use only */ + OP_PATH, /* Parser-use only */ + OP_NUM, /* Parser-use only */ + OP_INDEX, + OP_ADD, + OP_SQRT, + OP_POW, + OP_MAGN, + OP_CURL +}; +} namespace derived { diff --git a/source/adios2/toolkit/derived/Function.cpp b/source/adios2/toolkit/derived/Function.cpp index 7cb032f750..f6bc056543 100644 --- a/source/adios2/toolkit/derived/Function.cpp +++ b/source/adios2/toolkit/derived/Function.cpp @@ -3,8 +3,8 @@ #include "Function.h" #include "Function.tcc" -#include "adios2/common/ADIOSMacros.h" #include "adios2/helper/adiosFunctions.h" +#include "adios2/helper/adiosLog.h" #include #include @@ -12,11 +12,6 @@ namespace adios2 { namespace derived { -std::map OpFunctions = { - {adios2::detail::ExpressionOperator::OP_ADD, {AddFunc, SameDimsFunc}}, - {adios2::detail::ExpressionOperator::OP_CURL, {Curl3DFunc, CurlDimsFunc}}, - {adios2::detail::ExpressionOperator::OP_MAGN, {MagnitudeFunc, SameDimsFunc}}}; - DerivedData AddFunc(std::vector inputData, DataType type) { PERFSTUBS_SCOPED_TIMER("derived::Function::AddFunc"); diff --git a/source/adios2/toolkit/derived/Function.h b/source/adios2/toolkit/derived/Function.h index 7554916851..b72270ac46 100644 --- a/source/adios2/toolkit/derived/Function.h +++ b/source/adios2/toolkit/derived/Function.h @@ -1,29 +1,12 @@ #ifndef ADIOS2_DERIVED_Function_H_ #define ADIOS2_DERIVED_Function_H_ -#include "ExprHelper.h" -#include "adios2/common/ADIOSTypes.h" -#include "adios2/helper/adiosLog.h" -#include +#include "DerivedData.h" namespace adios2 { namespace derived { - -struct DerivedData -{ - void *Data; - Dims Start; - Dims Count; -}; - -struct OperatorFunctions -{ - std::function, DataType)> ComputeFct; - std::function)> DimsFct; -}; - DerivedData AddFunc(std::vector input, DataType type); DerivedData MagnitudeFunc(std::vector input, DataType type); DerivedData Curl3DFunc(std::vector input, DataType type); @@ -33,13 +16,6 @@ T linear_interp(T *data, size_t index, size_t count, size_t stride = 1); Dims SameDimsFunc(std::vector input); Dims CurlDimsFunc(std::vector input); - -extern std::map OpFunctions; - -template -T *ApplyOneToOne(std::vector inputData, size_t dataSize, - std::function compFct); - } } #endif diff --git a/source/adios2/toolkit/derived/Function.tcc b/source/adios2/toolkit/derived/Function.tcc index 077ad1e933..e93dc2c909 100644 --- a/source/adios2/toolkit/derived/Function.tcc +++ b/source/adios2/toolkit/derived/Function.tcc @@ -2,6 +2,7 @@ #define ADIOS2_DERIVED_Function_TCC_ #include "Function.h" +#include "adios2/helper/adiosLog.h" #include #include #include