Skip to content

Commit

Permalink
Do not expose symbols that are only used internally by the derived logic
Browse files Browse the repository at this point in the history
  • Loading branch information
anagainaru committed Jun 15, 2024
1 parent 8cd2d94 commit 07d9c0a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 76 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
63 changes: 0 additions & 63 deletions source/adios2/toolkit/derived/ExprHelper.h

This file was deleted.

40 changes: 39 additions & 1 deletion source/adios2/toolkit/derived/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,48 @@
#define ADIOS2_DERIVED_Expression_CPP_

#include "Expression.h"
#include "Function.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 +111,10 @@ adios2::derived::ExpressionTree ASTNode_to_ExpressionTree(adios2::detail::ASTNod

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

Expression::Expression(std::string string_exp)
: m_Shape({0}), m_Start({0}), m_Count({0}), ExprString(string_exp)
Expand Down
18 changes: 16 additions & 2 deletions source/adios2/toolkit/derived/Expression.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
#ifndef ADIOS2_DERIVED_Expression_H_
#define ADIOS2_DERIVED_Expression_H_

#include "Function.h"
#include "adios2/common/ADIOSTypes.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
5 changes: 0 additions & 5 deletions source/adios2/toolkit/derived/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ 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
3 changes: 0 additions & 3 deletions source/adios2/toolkit/derived/Function.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#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>
Expand Down Expand Up @@ -31,8 +30,6 @@ 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);
Expand Down

0 comments on commit 07d9c0a

Please sign in to comment.