start fixing compile errors... (NOT FINISHED)

This commit is contained in:
Christian Zimmermann 2018-01-13 18:07:52 +01:00
parent 9d7ab24d8c
commit 740004d160
8 changed files with 143 additions and 118 deletions

View file

@ -83,21 +83,31 @@ namespace MultiArrayTools
class AssignmentExpr class AssignmentExpr
{ {
private:
AssignmentExpr() = default;
//AssignmentExpr(const AssignmentExpr& in) = default;
//AssignmentExpr& operator=(const AssignmentExpr& in) = default;
OperationMaster* mMPtr;
const OpClass* mSecPtr;
public: public:
static size_t layer() { return 0; } static size_t layer() { return 0; }
static const size_t LAYER = 0;
static const size_t SIZE = OpClass::SIZE;
typedef decltype(mSecPtr->rootSteps()) ETuple;
AssignmentExpr(OperationMaster* mPtr, const OpClass* secPtr); AssignmentExpr(OperationMaster* mPtr, const OpClass* secPtr);
AssignmentExpr(AssignmentExpr&& in) = default; AssignmentExpr(AssignmentExpr&& in) = default;
AssignmentExpr& operator=(AssignmentExpr&& in) = default; //AssignmentExpr& operator=(const AssignmentExpr&& in) = default;
inline void operator()(size_t start = 0); inline void operator()(size_t start = 0);
inline void operator()(size_t start, const ETuple& last);
private: ETuple rootSteps(std::intptr_t iPtrNum = 0);
AssignmentExpr() = default;
OperationMaster* mMPtr;
const OpClass* mSecPtr;
}; };
typedef T value_type; typedef T value_type;
@ -147,6 +157,7 @@ namespace MultiArrayTools
typedef Block<T> bType; typedef Block<T> bType;
static size_t rootNum() { return 1; } static size_t rootNum() { return 1; }
static const size_t SIZE = 1;
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma, ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices); const std::shared_ptr<typename Ranges::IndexType>&... indices);
@ -183,6 +194,7 @@ namespace MultiArrayTools
typedef MBlock<T> bType; typedef MBlock<T> bType;
static size_t rootNum() { return 1; } static size_t rootNum() { return 1; }
static const size_t SIZE = 1;
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma, OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices); const std::shared_ptr<typename Ranges::IndexType>&... indices);
@ -223,6 +235,34 @@ namespace MultiArrayTools
{ {
return typename Op1::rootNum() + sumRootNum<Op2,Ops...>(); return typename Op1::rootNum() + sumRootNum<Op2,Ops...>();
} }
template <size_t N>
struct RootSumN
{
template <class Op1, class... Ops>
struct rs
{
static const size_t SIZE = Op1::SIZE + RootSumN<N-1>::template rs<Ops...>::SIZE;
};
};
template <>
struct RootSumN<0>
{
template <class Op1>
struct rs
{
static const size_t SIZE = Op1::SIZE;
};
};
template <class... Ops>
struct RootSum
{
static const size_t SIZE = RootSumN<sizeof...(Ops)-1>::template rs<Ops...>::SIZE;
};
template <typename T, class OpFunction, class... Ops> template <typename T, class OpFunction, class... Ops>
class Operation : public OperationTemplate<T,Operation<T,OpFunction,Ops...> > class Operation : public OperationTemplate<T,Operation<T,OpFunction,Ops...> >
@ -236,6 +276,7 @@ namespace MultiArrayTools
typedef BlockResult<T> bType; typedef BlockResult<T> bType;
static size_t rootNum() { return sumRootNum<Ops...>(); } static size_t rootNum() { return sumRootNum<Ops...>(); }
static const size_t SIZE = RootSum<Ops...>::SIZE;
private: private:
std::tuple<Ops const&...> mOps; std::tuple<Ops const&...> mOps;
@ -264,7 +305,8 @@ namespace MultiArrayTools
typedef BlockResult<T> bType; typedef BlockResult<T> bType;
static size_t rootNum() { return typename Op::rootNum(); } static size_t rootNum() { return typename Op::rootNum(); }
static const size_t SIZE = Op::SIZE;
private: private:
const Op& mOp; const Op& mOp;
@ -437,18 +479,11 @@ namespace MultiArrayTools
template <typename T, class OpClass, class... Ranges> template <typename T, class OpClass, class... Ranges>
void OperationMaster<T,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum) void OperationMaster<T,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
{ {
#define XX_USE_NEW_LOOP_ROUTINE_XX
#ifdef XX_USE_NEW_LOOP_ROUTINE_XX #ifdef XX_USE_NEW_LOOP_ROUTINE_XX
// === N E W === // === N E W ===
static const size_t TDIM = IndexType::totalDim()
typedef std::array<std::intptr_t,TDIM> IAT;
typedef decltype(mSecond.rootSteps()) RootStepType;
AssignmentExpr ae(this, &mSecond); AssignmentExpr ae(this, &mSecond);
const auto loop = mIndex->ifor(ae);
IAT siar = mIndex->getSIndexTuple();
std::array<RootStepType,TDIM> ee;
PackNum<TDIM-1>::mkExt(ee, siar, mSecond);
auto loop = mIndex->ifor(ee, ae);
loop(); loop();
#else #else
// === O L D === // === O L D ===

View file

@ -89,9 +89,9 @@ namespace MultiArrayTools
std::string id(); std::string id();
void print(size_t offset); void print(size_t offset);
template <class Ext, class Exprs> template <class Exprs>
auto ifor(const Ext& ext, Exprs&& exs) const auto ifor(Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs)); -> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs));
}; };
@ -372,11 +372,11 @@ namespace MultiArrayTools
} }
template <class... Indices> template <class... Indices>
template <class Ext, class Exprs> template <class Exprs>
auto ContainerIndex<Indices...>::ifor(const Ext& ext, Exprs&& exs) const auto ContainerIndex<Indices...>::ifor(Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs)) -> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs))
{ {
return RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs); return RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs);
} }

View file

@ -74,9 +74,9 @@ namespace MultiArrayTools
void print(size_t offset = 0) const { THIS().print(offset); } void print(size_t offset = 0) const { THIS().print(offset); }
// CHECK / IMPLEMENT !!!!!! // CHECK / IMPLEMENT !!!!!!
template <class Expr, typename... Args> template <class Expr>
auto ifor(const Args&... args) const -> decltype(THIS().template ifor<Expr>(args...)) auto ifor(const Expr&& ex) const -> decltype(THIS().template ifor<Expr>(ex))
{ return THIS().template ifor<Expr>(args...); } { return THIS().template ifor<Expr>(ex); }
private: private:

View file

@ -105,9 +105,9 @@ namespace MultiArrayTools
std::string id(); std::string id();
void print(size_t offset); void print(size_t offset);
template <class Ext, class Exprs> template <class Exprs>
auto ifor(const Ext& ext, Exprs&& exs) const auto ifor(Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs)); -> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs));
}; };
/************************* /*************************
@ -416,11 +416,11 @@ namespace MultiArrayTools
} }
template <class... Indices> template <class... Indices>
template <class Ext, class Exprs> template <class Exprs>
auto MultiIndex<Indices...>::ifor(const Ext& ext, Exprs&& exs) const auto MultiIndex<Indices...>::ifor(Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs)) -> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs))
{ {
return RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs); return RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs);
} }
/************************* /*************************

View file

@ -14,13 +14,13 @@ namespace MultiArrayHelper
template <class Index1> template <class Index1>
size_t mkTotalDim() size_t mkTotalDim()
{ {
return typename Index1::totalDim(); return Index1::totalDim();
} }
template <class Index1, class Index2, class... Indices> template <class Index1, class Index2, class... Indices>
size_t mkTotalDim() size_t mkTotalDim()
{ {
return typename Index1::totalDim() * mkTotalDim<Index2,Indices...>(); return Index1::totalDim() * mkTotalDim<Index2,Indices...>();
} }
@ -233,13 +233,13 @@ namespace MultiArrayHelper
RPackNum<N-1>::buildInfoVec(out, ip, bs); RPackNum<N-1>::buildInfoVec(out, ip, bs);
} }
template <class IndexPack, class Ext, class Exprs> template <class IndexPack, class Exprs>
static auto mkFor(const IndexPack& ipack, const Ext& ext, Exprs&& exs) static auto mkFor(const IndexPack& ipack, Exprs&& exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N>(ipack) -> decltype(std::get<std::tuple_size<IndexPack>::value-N>(ipack)
->ifor(ext, RPackNum<N-1>::mkFor(ipack, ext, exs) ) ) ->ifor( RPackNum<N-1>::mkFor(ipack, exs) ) )
{ {
return std::get<std::tuple_size<IndexPack>::value-N>(ipack) return std::get<std::tuple_size<IndexPack>::value-N>(ipack)
->ifor( ext, RPackNum<N-1>::mkFor(ipack, ext, exs) ); ->ifor( RPackNum<N-1>::mkFor(ipack, exs) );
} }
}; };
@ -405,12 +405,12 @@ namespace MultiArrayHelper
out.emplace_back(*std::get<POS>(ip), std::get<POS>(bs)); out.emplace_back(*std::get<POS>(ip), std::get<POS>(bs));
} }
template <class IndexPack, class Ext, class Exprs> template <class IndexPack, class Exprs>
static auto mkFor(const IndexPack& ipack, const Ext& ext, Exprs&& exs) static auto mkFor(const IndexPack& ipack, Exprs&& exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack, ext) -> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->ifor(ext, exs) ) ->ifor(exs) )
{ {
return std::get<std::tuple_size<IndexPack>::value-1>(ipack)->ifor(ext, exs); return std::get<std::tuple_size<IndexPack>::value-1>(ipack)->ifor(exs);
} }
}; };

View file

@ -65,9 +65,9 @@ namespace MultiArrayTools
std::string id(); std::string id();
void print(size_t offset); void print(size_t offset);
template <class Expr, size_t DIM, class... Ops> template <class Expr>
auto ifor(const std::array<std::tuple<to_size_t<Ops>...>,DIM>& ee, Expr&& ex) const auto ifor(Expr&& ex) const
-> For<SingleIndex<U,TYPE>,Expr,Ops...>; -> For<SingleIndex<U,TYPE>,Expr>;
}; };
template <typename U, SpaceType TYPE> template <typename U, SpaceType TYPE>
@ -249,12 +249,12 @@ namespace MultiArrayTools
} }
template <typename U, SpaceType TYPE> template <typename U, SpaceType TYPE>
template <class Expr, size_t DIM, class... Ops> template <class Expr>
auto SingleIndex<U,TYPE>::ifor(const std::array<std::tuple<to_size_t<Ops>...>,DIM>& ee, Expr&& ex) const auto SingleIndex<U,TYPE>::ifor(Expr&& ex) const
-> For<SingleIndex<U,TYPE>,Expr,Ops...> -> For<SingleIndex<U,TYPE>,Expr>
{ {
static const size_t layer = typename Expr::layer(); //static const size_t LAYER = typename Expr::LAYER;
return For<SingleIndex<U,TYPE>,Expr,Ops...>( this, ex, std::get<layer>( ee ) ); return For<SingleIndex<U,TYPE>,Expr>(this, ex);
} }

View file

@ -16,22 +16,20 @@ namespace MultiArrayHelper
template <size_t N> template <size_t N>
struct XFPackNum struct XFPackNum
{ {
template <class IndexClass, class ExtTuple, class LastTuple, typename... Args> template <class ETuple, typename... Args>
static auto mkPos(const IndexClass& ind, const ExtTuple& et, const LastTuple& lt, const Args&... args) static ETuple mkPos(size_t pos, const ETuple& et, const ETuple& lt, const Args&... args)
-> decltype(XFPackNum<N-1>::mkPos(et, lt, 0ul, args...))
{ {
return XFPackNum<N-1>::mkPos(et, lt, std::get<N>(lt) + ind.pos() * std::get<N>(et), args...); return std::move( XFPackNum<N-1>::mkPos(pos, et, lt, std::get<N>(lt) + pos * std::get<N>(et), args...) );
} }
}; };
template <> template <>
struct XFPackNum<0> struct XFPackNum<0>
{ {
template <class IndexClass, class ExtTuple, class LastTuple, typename... Args> template <class ETuple, typename... Args>
static auto mkPos(const IndexClass& ind, const ExtTuple& et, const LastTuple& lt, const Args&... args) static ETuple mkPos(size_t pos, const ETuple& et, const ETuple& lt, const Args&... args)
-> std::tuple<size_t,to_size_t<Args>...>
{ {
return std::tuple<size_t,to_size_t<Args>...>(std::get<0>(lt) + ind.pos() * std::get<0>(et), args...); return ETuple(std::get<0>(lt) + pos * std::get<0>(et), args...);
} }
}; };

View file

@ -10,40 +10,41 @@
namespace MultiArrayHelper namespace MultiArrayHelper
{ {
template <class IndexClass, class Expr, class... Ops> template <class IndexClass, class Expr>
class For class For
{ {
private:
For() = default;
//For(const For& in) = default;
//For& operator=(const For& in) = default;
const IndexClass* mIndPtr;
Expr mExpr;
decltype(mExpr.rootSteps()) mExt;
public: public:
static size_t layer() { return typename Expr::layer() + 1; } static size_t layer() { return Expr::layer() + 1; }
static const size_t LAYER = Expr::LAYER + 1;
static const size_t SIZE = std::remove_reference<Expr>::type::SIZE;
typedef decltype(mExpr.rootSteps()) ETuple;
For(For&& in) = default; For(For&& in) = default;
For& operator=(For&& in) = default; For& operator=(For&& in) = default;
template <typename... Args>
For(const std::shared_ptr<IndexClass>& indPtr, For(const std::shared_ptr<IndexClass>& indPtr,
std::tuple<to_size_t<Ops>...>&& ext, const Args&... args); Expr&& expr);
For(const std::shared_ptr<IndexClass>& indPtr, For(const IndexClass* indPtr,
Expr&& expr, std::tuple<to_size_t<Ops>...>&& ext); Expr&& expr);
template <typename... Args>
For(IndexClass* indPtr,
std::tuple<to_size_t<Ops>...>&& ext, const Args&... args);
For(IndexClass* indPtr,
Expr&& expr, std::tuple<to_size_t<Ops>...>&& ext);
inline void operator()(size_t mlast, const std::tuple<to_size_t<Ops>...>& last) const; inline void operator()(size_t mlast, const ETuple& last) const;
inline void operator()(size_t mlast = 0) const; inline void operator()(size_t mlast = 0) const;
private: ETuple rootSteps(std::intptr_t iPtrNum = 0) const;
For() = default;
IndexClass* mIndPtr;
const Expr mExpr;
const std::tuple<to_size_t<Ops>...> mExt;
}; };
template <size_t N> template <size_t N>
@ -62,58 +63,49 @@ namespace MultiArrayHelper
namespace MultiArrayHelper namespace MultiArrayHelper
{ {
template <class IndexClass, class Expr, class... Ops> template <class IndexClass, class Expr>
template <typename... Args> For<IndexClass,Expr>::For(const std::shared_ptr<IndexClass>& indPtr,
For<IndexClass,Expr,Ops...>::For(const std::shared_ptr<IndexClass>& indPtr, Expr&& expr) :
std::tuple<to_size_t<Ops>...>&& ext, mIndPtr(indPtr.get()), mExpr(expr), mExt(expr.rootSteps( static_cast<std::intptr_t>( mIndPtr.get() ))) {}
const Args&... args) :
mIndPtr(indPtr.get()), mExpr(args...), mExt(ext) {}
template <class IndexClass, class Expr, class... Ops> template <class IndexClass, class Expr>
For<IndexClass,Expr,Ops...>::For(const std::shared_ptr<IndexClass>& indPtr, For<IndexClass,Expr>::For(const IndexClass* indPtr,
Expr&& expr, std::tuple<to_size_t<Ops>...>&& ext) : Expr&& expr) :
mIndPtr(indPtr.get()), mExpr(expr), mExt(ext) {} mIndPtr(indPtr), mExpr(expr), mExt(expr.rootSteps( static_cast<std::intptr_t>( mIndPtr ) )) {}
template <class IndexClass, class Expr, class... Ops>
template <typename... Args>
For<IndexClass,Expr,Ops...>::For(IndexClass* indPtr,
std::tuple<to_size_t<Ops>...>&& ext,
const Args&... args) :
mIndPtr(indPtr), mExpr(args...), mExt(ext) {}
template <class IndexClass, class Expr, class... Ops> template <class IndexClass, class Expr>
For<IndexClass,Expr,Ops...>::For(IndexClass* indPtr, inline void For<IndexClass,Expr>::operator()(size_t mlast,
Expr&& expr, std::tuple<to_size_t<Ops>...>&& ext) : const ETuple& last) const
mIndPtr(indPtr), mExpr(expr), mExt(ext) {}
template <class IndexClass, class Expr, class... Ops>
inline void For<IndexClass,Expr,Ops...>::operator()(size_t mlast,
const std::tuple<to_size_t<Ops>...>& last) const
{ {
static const size_t opNum = sizeof...(Ops);
auto& ind = *mIndPtr; auto& ind = *mIndPtr;
const size_t max = exceptMax<For<IndexClass,Expr,Ops...>::layer()>( ind.max() ); // blocking const size_t max = ind.max(); // blocking
for(ind = 0; ind.pos() != max; ++ind){ for(size_t pos = ind.pos(); pos != max; ++pos){
const size_t mnpos = mlast * max + ind.pos(); const size_t mnpos = mlast * max + pos;
const std::tuple<to_size_t<Ops>...> npos = std::move( XFPackNum<opNum-1>::mkPos(ind, mExt, last) ); const ETuple npos = std::move( XFPackNum<SIZE-1>::mkPos(pos, mExt, last) );
mExpr(mnpos, npos); mExpr(mnpos, npos);
} }
} }
template <class IndexClass, class Expr, class... Ops> template <class IndexClass, class Expr>
inline void For<IndexClass,Expr,Ops...>::operator()(size_t mlast) const inline void For<IndexClass,Expr>::operator()(size_t mlast) const
{ {
static const size_t opNum = sizeof...(Ops); const ETuple last;
std::tuple<to_size_t<Ops>...> last(to_size_t<Ops>(0)...);
auto& ind = *mIndPtr; auto& ind = *mIndPtr;
const size_t max = exceptMax<For<IndexClass,Expr,Ops...>::layer()>( ind.max() ); // blocking const size_t max = ind.max(); // blocking
for(ind = 0; ind.pos() != max; ++ind){ for(size_t pos = ind.pos(); pos != max; ++pos){
const size_t mnpos = mlast * max + ind.pos(); const size_t mnpos = mlast * max + pos;
const std::tuple<to_size_t<Ops>...> npos = std::move( XFPackNum<opNum-1>::mkPos(ind, mExt, last) ); const ETuple npos = std::move( XFPackNum<SIZE-1>::mkPos(pos, mExt, last) );
mExpr(mnpos, npos); mExpr(mnpos, npos);
} }
} }
template <class IndexClass, class Expr>
typename For<IndexClass,Expr>::ETuple For<IndexClass,Expr>::rootSteps(std::intptr_t iPtrNum) const
{
return mExpr.rootSteps(iPtrNum);
}
} // namespace MultiArrayHelper } // namespace MultiArrayHelper
#endif #endif