From 4fc2c52865bb9649b3b75a98b4b1f2524d47f9fe Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 31 Aug 2020 17:28:00 +0200 Subject: [PATCH] revert to a80e927 --- src/include/high_level_operation.h | 150 ----------------------------- src/include/multi_array_header.h | 1 - src/include/xfor/xfor.h | 3 +- src/tests/op4_unit_test.cc | 21 +--- 4 files changed, 6 insertions(+), 169 deletions(-) delete mode 100644 src/include/high_level_operation.h diff --git a/src/include/high_level_operation.h b/src/include/high_level_operation.h deleted file mode 100644 index 0bad1b8..0000000 --- a/src/include/high_level_operation.h +++ /dev/null @@ -1,150 +0,0 @@ - -#ifndef __high_level_operation_h__ -#define __high_level_operation_h__ - -#include "base_def.h" -#include "dynamic_operation.h" -#include "multi_array_operation.h" - -namespace MultiArrayTools -{ - - template - class HLOBuilderBase - { - protected: - //typedef typename DOp::value_type IOp; - DOp mDOp; - typedef decltype(mDOp.data()->mOp) IOpP; - IOpP mIOpP; - typedef std::shared_ptr> HLOBP; - HLOBP mPrev; - public: - - HLOBuilderBase(const HLOBP& prev) : mPrev(prev) {} - - virtual void create(const std::shared_ptr&... inds) = 0; - - virtual std::shared_ptr> - operator*(const std::shared_ptr>& in) const = 0; - - const IOpP& get() const - { - return mIOpP; - } - - const DOp& dget() const - { - return mDOp; - } - - const HLOBP& prev() const - { - return mPrev; - } - - void appendPrev(const HLOBP& prev) - { - if(mPrev){ - mPrev->append(prev); - } - else { - mPrev = prev; - } - } - - template - DynamicExpression mkGetExpr(const Expr& expr) const - { - if(not mPrev){ - return DynamicExpression( mkGetExpr(mDOp, expr) ); - } - else { - return DynamicExpression( mkGetExpr(mDOp, mPrev->mkGetExpr(expr) ) ); - } - } - }; - - - template - class HLOBuilder : public HLOBuilderBase - { - private: - typedef HLOBuilderBase B; - typedef typename B::HLOBP HLOBP; - CF mCF; - public: - - HLOBuilder(const HLOBP& prev, - const CF& cf) : B(prev), mCF(cf) {} - - HLOBuilder(const CF& cf) : B(nullptr), mCF(cf) {} - - virtual void create(const std::shared_ptr&... inds) override final - { - B::mPrev->create(inds...); - auto op = mCF(); - B::mDOp = mkDynOutOp(op, inds...); - B::mIOpP = B::mDOp.data()->mOp; - } - - virtual std::shared_ptr - operator*(const std::shared_ptr>& in) const override final - { - HLOBP xprev = B::mPrev; - xprev->appendPrev(in->prev()); - xprev->append(in); - xprev->appendPrev(std::make_shared>(*this)); - return std::make_sharedmkDOp().data()->mOp),Indices...>> - (xprev, [&in,this]() { this->create(); return *B::mIOpP*in->mkDOp().data()->mOp; }); - } - }; - - - template - class HLOBuilderRoot : public HLOBuilderBase - { - private: - typedef HLOBuilderBase B; - typedef typename B::HLOBP HLOBP; - Op mOp; - public: - - HLOBuilderRoot(const Op& op) : B(nullptr), mOp(op) {} - - virtual void create(const std::shared_ptr&... inds) override final - { - //B::mPrev->create(inds...); - //mOp = mCF(); - //B::mDOp = mkDynOutOp(op, inds...); - //B::mIOpP = B::mDOp.data()->mOp; - } - - virtual std::shared_ptr - operator*(const std::shared_ptr>& in) const override final - { - HLOBP xprev = in->prev(); - xprev->append(in); - //xprev->appendPrev(in.prev()); - //xprev->appendPrev(std::make_shared>(*this)); - return std::make_sharedmkDOp().data()->mOp),Indices...>> - (xprev, [&in,this]() { this->create(); return mOp*in->mkDOp().data()->mOp; }); - } - }; - - template - std::shared_ptr> - mkHLOBuilder( const CF& cf, const std::shared_ptr&... inds) - { - return std::make_shared>(cf); - } - - template - std::shared_ptr> - mkHLOBuilderRoot( const Op& op, const std::shared_ptr&... inds ) - { - return std::make_shared>(op); - } -} - -#endif diff --git a/src/include/multi_array_header.h b/src/include/multi_array_header.h index 6b62fbb..95ffbc5 100644 --- a/src/include/multi_array_header.h +++ b/src/include/multi_array_header.h @@ -13,7 +13,6 @@ #include "map_range.h" #include "dynamic_operation.h" //#include "expressions.h" -#include "high_level_operation.h" #include "multi_array_header.cc.h" diff --git a/src/include/xfor/xfor.h b/src/include/xfor/xfor.h index 31e94e5..1bffc0f 100644 --- a/src/include/xfor/xfor.h +++ b/src/include/xfor/xfor.h @@ -457,8 +457,7 @@ namespace MultiArrayHelper std::shared_ptr mNext; public: - - typedef DExtT ExtType; + static constexpr size_t LAYER = 0; static constexpr size_t SIZE = 0; diff --git a/src/tests/op4_unit_test.cc b/src/tests/op4_unit_test.cc index 418388b..253fedf 100644 --- a/src/tests/op4_unit_test.cc +++ b/src/tests/op4_unit_test.cc @@ -306,29 +306,18 @@ namespace auto op1 = ma2(i1,di2); auto op3 = ma1(i1,di1); auto opr = resx4(i1,di4); - typedef decltype(mkDynOutOp(exp(op1), ic_1, ic_2)) DOp; auto loop = mkPILoop ( [&op1,&op3,&opr,&xx,&ic_1,&ic_2,this](){ - //auto dop1 = mkDynOutOp(exp(op1), ic_1, ic_2); - //auto op2 = *dop1.data()->mOp; - //auto dop2 = mkDynOutOp(op3 * op2, ic_1, ic_2); - auto dop2 = (*mkHLOBuilderRoot( op3, ic_1, ic_2 )) * mkHLOBuilder([&op1,this]() { return exp(op1); }, ic_1, ic_2); - dop2->create(ic_1,ic_2); - const OperationRoot& yy = *dop2->get(); - return dop2->mkGetExpr - (mkILoop(std::make_tuple(dop2->dget()), std::make_tuple(ic_1, ic_2), - std::make_tuple(xx), - std::make_tuple(opr.assign( yy , mkMIndex(ic_1, ic_2) )), - std::array({1}), std::array({0}))); - /* + auto dop1 = mkDynOutOp(exp(op1), ic_1, ic_2); + auto op2 = *dop1.data()->mOp; + auto dop2 = mkDynOutOp(op3 * op2, ic_1, ic_2); return mkGetExpr (dop1,mkGetExpr (dop2,mkILoop(std::make_tuple(*dop2.data()->mOp), std::make_tuple(ic_1, ic_2), std::make_tuple(xx), std::make_tuple(opr.assign( *dop2.data()->mOp, mkMIndex(ic_1, ic_2) )), - std::array({1}), std::array({0})))); - */ - } ); + std::array({1}), std::array({0})))); } ); + mi->pifor(1,loop)(); auto i2_1 = imap.at("i2_1");