This commit is contained in:
Christian Zimmermann 2020-08-28 13:46:12 +02:00
parent 7afd193d09
commit cb6a6ccdb3
4 changed files with 59 additions and 24 deletions

View file

@ -46,20 +46,21 @@ namespace MultiArrayTools
const std::shared_ptr<typename Ranges::IndexType>&... inds) const std::shared_ptr<typename Ranges::IndexType>&... inds)
: mOp(op), : mOp(op),
mMa(std::make_shared<MultiArray<T,Ranges...>>(mkArray<T>(inds->range()...))), mMa(std::make_shared<MultiArray<T,Ranges...>>(mkArray<T>(inds->range()...))),
mProto((*mMa)(inds...)) mProto(OperationRoot<T,Ranges...>(*mMa,inds...)),
{ mL(std::make_tuple(mProto.mOp,mOp), std::make_tuple(inds...),
/*
auto ll = mkILoop(std::make_tuple(mProto.mOp,mOp), std::make_tuple(inds...),
std::make_tuple(mMa), std::make_tuple(mProto.mOp.assign( mOp )), std::make_tuple(mMa), std::make_tuple(mProto.mOp.assign( mOp )),
std::array<size_t,1>({0}), std::array<size_t,1>({0})); std::array<size_t,1>({0}), std::array<size_t,1>({0}))
*/ {
VCHECK(reinterpret_cast<std::intptr_t>(mProto.mOp.data()));
VCHECK(reinterpret_cast<std::intptr_t>(mMa->data()));
} }
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
OpH<OperationRoot<T,Ranges...>> DynamicOuterOp<T,Operation,Ranges...>::get(const DExtT& pos) const OpH<OperationRoot<T,Ranges...>> DynamicOuterOp<T,Operation,Ranges...>::get(const DExtT& pos) const
{ {
mOp.get(pos.expl<ET>()); CHECK;
//mL(); //mOp.get(pos.expl<ET>());
//mL(0,pos.expl<ET>());
// execute assignment... care about threads!!! // execute assignment... care about threads!!!
return mProto.mOp; // empty return mProto.mOp; // empty
} }
@ -68,6 +69,7 @@ namespace MultiArrayTools
DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>& DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>&
DynamicOuterOp<T,Operation,Ranges...>::set(const DExtT& pos) DynamicOuterOp<T,Operation,Ranges...>::set(const DExtT& pos)
{ {
CHECK;
mOp.set(pos.expl<ET>()); mOp.set(pos.expl<ET>());
return *this; return *this;
} }
@ -75,18 +77,21 @@ namespace MultiArrayTools
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
DExtT DynamicOuterOp<T,Operation,Ranges...>::rootSteps(std::intptr_t iPtrNum) const DExtT DynamicOuterOp<T,Operation,Ranges...>::rootSteps(std::intptr_t iPtrNum) const
{ {
return DExtT(mkDExt(mkExtT(mOp.rootSteps(iPtrNum))),None(0)); CHECK;
return DExtT(mkDExt(mkExtT(mL.rootSteps(iPtrNum))),None(0));
} }
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
DynamicExpression DynamicOuterOp<T,Operation,Ranges...>::loop(const DynamicExpression& exp) const DynamicExpression DynamicOuterOp<T,Operation,Ranges...>::loop(const DynamicExpression& exp) const
{ {
return mOp.loop(exp); CHECK;
return mOp.loop(exp); // ???!!
} }
template <typename T, class Operation, class... Ranges> template <typename T, class Operation, class... Ranges>
const OpH<OperationRoot<T,Ranges...>>* DynamicOuterOp<T,Operation,Ranges...>::data() const const OpH<OperationRoot<T,Ranges...>>* DynamicOuterOp<T,Operation,Ranges...>::data() const
{ {
CHECK;
return &mProto; return &mProto;
} }
@ -94,6 +99,7 @@ namespace MultiArrayTools
std::shared_ptr<DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>> std::shared_ptr<DynamicOperationBase<OpH<OperationRoot<T,Ranges...>>>>
DynamicOuterOp<T,Operation,Ranges...>::deepCopy() const DynamicOuterOp<T,Operation,Ranges...>::deepCopy() const
{ {
CHECK;
return std::make_shared<DynamicOuterOp<T,Operation,Ranges...>>(*this); return std::make_shared<DynamicOuterOp<T,Operation,Ranges...>>(*this);
} }

View file

@ -73,16 +73,16 @@ namespace MultiArrayTools
//OperationRoot<T,Ranges...> mProto; //OperationRoot<T,Ranges...> mProto;
std::shared_ptr<MultiArray<T,Ranges...>> mMa; std::shared_ptr<MultiArray<T,Ranges...>> mMa;
OpH<OperationRoot<T,Ranges...>> mProto; OpH<OperationRoot<T,Ranges...>> mProto;
/*
typedef ILoop<std::tuple<OperationRoot<T,Ranges...>,Operation>, typedef ILoop<std::tuple<OperationRoot<T,Ranges...>,Operation>,
std::tuple<std::shared_ptr<typename Ranges::IndexType>...>, std::tuple<std::shared_ptr<typename Ranges::IndexType>...>,
std::tuple<std::shared_ptr<MultiArray<T,Ranges...>>>, std::tuple<std::shared_ptr<MultiArray<T,Ranges...>>>,
std::tuple<decltype(mProto.mOp.assign( mOp ))>> LoopT; std::tuple<decltype(mProto.mOp.assign( mOp ))>> LoopT;
LoopT mL; mutable LoopT mL;
*/
public: public:
typedef decltype(mOp.rootSteps()) ET; typedef decltype(mL.rootSteps()) ET;
//typedef decltype(std::declval<Operation>().rootSteps()) ET; //typedef decltype(std::declval<Operation>().rootSteps()) ET;
DynamicOuterOp() = default; DynamicOuterOp() = default;

View file

@ -7,6 +7,7 @@
#include <tuple> #include <tuple>
#include <array> #include <array>
#include <omp.h> #include <omp.h>
#include "xfor.h"
namespace MultiArrayHelper namespace MultiArrayHelper
{ {
@ -98,7 +99,7 @@ namespace MultiArrayHelper
}; };
template <class OpTp, class IndTp, class VarTp, class LTp> template <class OpTp, class IndTp, class VarTp, class LTp>
class ILoop class ILoop : public ExpressionBase
{ {
private: private:
static constexpr size_t LTpSize = std::tuple_size<LTp>::value; static constexpr size_t LTpSize = std::tuple_size<LTp>::value;
@ -143,6 +144,28 @@ namespace MultiArrayHelper
{ {
return mVarTp; return mVarTp;
} }
virtual void operator()(size_t mlast, DExt last) override final
{
operator()(mlast, std::dynamic_pointer_cast<ExtT<ExtType>>(last)->ext());
}
virtual void operator()(size_t mlast = 0) override final
{
ExtType last = rootSteps();
last.zero();
operator()(mlast, last);
}
virtual DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final
{
return std::make_shared<ExtT<ExtType>>(rootSteps(iPtrNum));
}
virtual DExt dExtension() const override final
{
return nullptr; //!!
}
}; };
template <size_t N> template <size_t N>

View file

@ -125,24 +125,30 @@ namespace
auto resx2 = res1; auto resx2 = res1;
auto resx3 = res1; auto resx3 = res1;
auto resx4 = res1; auto resx4 = res1;
//auto xx = std::make_shared<decltype(resx4)>(resx4); auto xx = std::make_shared<decltype(resx4)>(resx4);
res1(i1,di4) = ma1(i1,di1) * ma2(i1,di2); res1(i1,di4) = ma1(i1,di1) * ma2(i1,di2);
resx1(i1,di4) = mkDynOp(ma1(i1,di1)) * mkDynOp(ma2(i1,di2)); resx1(i1,di4) = mkDynOp(ma1(i1,di1)) * mkDynOp(ma2(i1,di2));
resx2(i1,di4) = mkDynOp(ma1(i1,di1) * ma2(i1,di2)); resx2(i1,di4) = mkDynOp(ma1(i1,di1) * ma2(i1,di2));
resx3(i1,di4) = mkDynOp(mkDynOp(ma1(i1,di1)) * mkDynOp(ma2(i1,di2))); resx3(i1,di4) = mkDynOp(mkDynOp(ma1(i1,di1)) * mkDynOp(ma2(i1,di2)));
auto op1 = mkDynOutOp(ma1(i1,di1) * ma2(i1,di2), ci4); auto op1 = mkDynOutOp(ma1(i1,di1) * ma2(i1,di2), ci4);
/**auto opr = resx4(i1,di4); auto op1x = ma1(i1,di1) * ma2(i1,di2);
auto loop = mkILoop(std::make_tuple(opr,op1), std::make_tuple(ci4), auto opr = resx4(i1,di4);
std::make_tuple(xx), std::make_tuple(opr.assign( op1.data()->mOp )),
auto loop = mkILoop(std::make_tuple(opr,op1,op1.data()->mOp), std::make_tuple(ci4),
std::make_tuple(xx), std::make_tuple(opr.assign( op1.data()->mOp, ci4 )),
//std::make_tuple(), std::make_tuple(),
std::array<size_t,1>({1}), std::array<size_t,1>({0}));
/*
auto loop = mkILoop(std::make_tuple(opr,op1x), std::make_tuple(ci4),
std::make_tuple(xx), std::make_tuple(opr.assign( op1x, ci4 )),
//std::make_tuple(), std::make_tuple(), //std::make_tuple(), std::make_tuple(),
std::array<size_t,1>({1}), std::array<size_t,1>({0})); std::array<size_t,1>({1}), std::array<size_t,1>({0}));
*/ */
//std::array<size_t,0>(), std::array<size_t,0>());
//!!!!
//mi->ifor(1, loop)(); //mi->ifor(1, loop)();
mi->ifor(1, loop)();
//mi->ifor(1, opr.assign( op1.data()->mOp ))();
auto i2_1 = imap.at("i2_1"); auto i2_1 = imap.at("i2_1");
auto i2_2 = imap.at("i2_2"); auto i2_2 = imap.at("i2_2");
auto i3_1 = imap.at("i3_1"); auto i3_1 = imap.at("i3_1");