Skip to content

Commit

Permalink
Merge pull request ornladios#4207 from anagainaru/hide-symbols
Browse files Browse the repository at this point in the history
Limit the exposed symbols related to derived variables
  • Loading branch information
anagainaru authored Jun 20, 2024
2 parents aa56a4e + 20d8023 commit c297022
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 104 deletions.
3 changes: 1 addition & 2 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<BUILD_INTERFACE:${ADIOS2_SOURCE_DIR}/source/adios2/toolkit/derived/parser>;$<BUILD_INTERFACE:${ADIOS2_BINARY_DIR}/source/adios2>")
find_package(BISON "3.8.2")
Expand Down
2 changes: 0 additions & 2 deletions source/adios2/core/VariableDerived.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 18 additions & 0 deletions source/adios2/toolkit/derived/DerivedData.h
Original file line number Diff line number Diff line change
@@ -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
63 changes: 0 additions & 63 deletions source/adios2/toolkit/derived/ExprHelper.h

This file was deleted.

47 changes: 46 additions & 1 deletion source/adios2/toolkit/derived/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExpressionOperator, OperatorProperty> 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<std::string, ExpressionOperator> 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
Expand Down Expand Up @@ -77,6 +112,16 @@ adios2::derived::ExpressionTree ASTNode_to_ExpressionTree(adios2::detail::ASTNod

namespace derived
{
struct OperatorFunctions
{
std::function<DerivedData(std::vector<DerivedData>, DataType)> ComputeFct;
std::function<Dims(std::vector<Dims>)> DimsFct;
};

std::map<adios2::detail::ExpressionOperator, OperatorFunctions> 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)
Expand Down
19 changes: 17 additions & 2 deletions source/adios2/toolkit/derived/Expression.h
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <unordered_map>

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
{
Expand Down
7 changes: 1 addition & 6 deletions source/adios2/toolkit/derived/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@

#include "Function.h"
#include "Function.tcc"
#include "adios2/common/ADIOSMacros.h"
#include "adios2/helper/adiosFunctions.h"
#include "adios2/helper/adiosLog.h"
#include <adios2-perfstubs-interface.h>
#include <cmath>

namespace adios2
{
namespace derived
{
std::map<adios2::detail::ExpressionOperator, OperatorFunctions> 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<DerivedData> inputData, DataType type)
{
PERFSTUBS_SCOPED_TIMER("derived::Function::AddFunc");
Expand Down
29 changes: 1 addition & 28 deletions source/adios2/toolkit/derived/Function.h
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
#ifndef ADIOS2_DERIVED_Function_H_
#define ADIOS2_DERIVED_Function_H_

#include "ExprHelper.h"
#include "adios2/common/ADIOSTypes.h"
#include "adios2/helper/adiosLog.h"
#include <functional>
#include "DerivedData.h"

namespace adios2
{
namespace derived
{

struct DerivedData
{
void *Data;
Dims Start;
Dims Count;
};

struct OperatorFunctions
{
std::function<DerivedData(std::vector<DerivedData>, DataType)> ComputeFct;
std::function<Dims(std::vector<Dims>)> DimsFct;
};

DerivedData AddFunc(std::vector<DerivedData> input, DataType type);
DerivedData MagnitudeFunc(std::vector<DerivedData> input, DataType type);
DerivedData Curl3DFunc(std::vector<DerivedData> input, DataType type);

Dims SameDimsFunc(std::vector<Dims> input);
Dims CurlDimsFunc(std::vector<Dims> input);

extern std::map<adios2::detail::ExpressionOperator, OperatorFunctions> OpFunctions;

template <class T>
T *ApplyOneToOne(std::vector<DerivedData> inputData, size_t dataSize,
std::function<T(T, T)> compFct);

template <class T>
T *ApplyCurl(const T *input1, const T *input2, const T *input3, const size_t dims[3]);

}
}
#endif
1 change: 1 addition & 0 deletions source/adios2/toolkit/derived/Function.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define ADIOS2_DERIVED_Function_TCC_

#include "Function.h"
#include "adios2/helper/adiosLog.h"
#include <algorithm>
#include <cstring>
#include <iostream>
Expand Down

0 comments on commit c297022

Please sign in to comment.