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

View file

@ -89,9 +89,9 @@ namespace MultiArrayTools
std::string id();
void print(size_t offset);
template <class Ext, class Exprs>
auto ifor(const Ext& ext, Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs));
template <class Exprs>
auto ifor(Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs));
};
@ -372,11 +372,11 @@ namespace MultiArrayTools
}
template <class... Indices>
template <class Ext, class Exprs>
auto ContainerIndex<Indices...>::ifor(const Ext& ext, Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs))
template <class Exprs>
auto ContainerIndex<Indices...>::ifor(Exprs&& exs) const
-> 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); }
// CHECK / IMPLEMENT !!!!!!
template <class Expr, typename... Args>
auto ifor(const Args&... args) const -> decltype(THIS().template ifor<Expr>(args...))
{ return THIS().template ifor<Expr>(args...); }
template <class Expr>
auto ifor(const Expr&& ex) const -> decltype(THIS().template ifor<Expr>(ex))
{ return THIS().template ifor<Expr>(ex); }
private:

View file

@ -105,9 +105,9 @@ namespace MultiArrayTools
std::string id();
void print(size_t offset);
template <class Ext, class Exprs>
auto ifor(const Ext& ext, Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs));
template <class Exprs>
auto ifor(Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, exs));
};
/*************************
@ -416,11 +416,11 @@ namespace MultiArrayTools
}
template <class... Indices>
template <class Ext, class Exprs>
auto MultiIndex<Indices...>::ifor(const Ext& ext, Exprs&& exs) const
-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(mIPack, ext, exs))
template <class Exprs>
auto MultiIndex<Indices...>::ifor(Exprs&& exs) const
-> 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>
size_t mkTotalDim()
{
return typename Index1::totalDim();
return Index1::totalDim();
}
template <class Index1, class Index2, class... Indices>
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);
}
template <class IndexPack, class Ext, class Exprs>
static auto mkFor(const IndexPack& ipack, const Ext& ext, Exprs&& exs)
template <class IndexPack, class Exprs>
static auto mkFor(const IndexPack& ipack, Exprs&& exs)
-> 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)
->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));
}
template <class IndexPack, class Ext, class Exprs>
static auto mkFor(const IndexPack& ipack, const Ext& ext, Exprs&& exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack, ext)
->ifor(ext, exs) )
template <class IndexPack, class Exprs>
static auto mkFor(const IndexPack& ipack, Exprs&& exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->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();
void print(size_t offset);
template <class Expr, size_t DIM, class... Ops>
auto ifor(const std::array<std::tuple<to_size_t<Ops>...>,DIM>& ee, Expr&& ex) const
-> For<SingleIndex<U,TYPE>,Expr,Ops...>;
template <class Expr>
auto ifor(Expr&& ex) const
-> For<SingleIndex<U,TYPE>,Expr>;
};
template <typename U, SpaceType TYPE>
@ -249,12 +249,12 @@ namespace MultiArrayTools
}
template <typename U, SpaceType TYPE>
template <class Expr, size_t DIM, class... Ops>
auto SingleIndex<U,TYPE>::ifor(const std::array<std::tuple<to_size_t<Ops>...>,DIM>& ee, Expr&& ex) const
-> For<SingleIndex<U,TYPE>,Expr,Ops...>
template <class Expr>
auto SingleIndex<U,TYPE>::ifor(Expr&& ex) const
-> For<SingleIndex<U,TYPE>,Expr>
{
static const size_t layer = typename Expr::layer();
return For<SingleIndex<U,TYPE>,Expr,Ops...>( this, ex, std::get<layer>( ee ) );
//static const size_t LAYER = typename Expr::LAYER;
return For<SingleIndex<U,TYPE>,Expr>(this, ex);
}

View file

@ -16,22 +16,20 @@ namespace MultiArrayHelper
template <size_t N>
struct XFPackNum
{
template <class IndexClass, class ExtTuple, class LastTuple, typename... Args>
static auto mkPos(const IndexClass& ind, const ExtTuple& et, const LastTuple& lt, const Args&... args)
-> decltype(XFPackNum<N-1>::mkPos(et, lt, 0ul, args...))
template <class ETuple, typename... Args>
static ETuple mkPos(size_t pos, const ETuple& et, const ETuple& lt, const Args&... 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 <>
struct XFPackNum<0>
{
template <class IndexClass, class ExtTuple, class LastTuple, typename... Args>
static auto mkPos(const IndexClass& ind, const ExtTuple& et, const LastTuple& lt, const Args&... args)
-> std::tuple<size_t,to_size_t<Args>...>
template <class ETuple, typename... Args>
static ETuple mkPos(size_t pos, const ETuple& et, const ETuple& lt, const Args&... 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
{
template <class IndexClass, class Expr, class... Ops>
template <class IndexClass, class Expr>
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:
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& operator=(For&& in) = default;
template <typename... Args>
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,
Expr&& expr, std::tuple<to_size_t<Ops>...>&& ext);
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);
For(const IndexClass* indPtr,
Expr&& expr);
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;
private:
For() = default;
IndexClass* mIndPtr;
const Expr mExpr;
const std::tuple<to_size_t<Ops>...> mExt;
ETuple rootSteps(std::intptr_t iPtrNum = 0) const;
};
template <size_t N>
@ -62,58 +63,49 @@ namespace MultiArrayHelper
namespace MultiArrayHelper
{
template <class IndexClass, class Expr, class... Ops>
template <typename... Args>
For<IndexClass,Expr,Ops...>::For(const std::shared_ptr<IndexClass>& indPtr,
std::tuple<to_size_t<Ops>...>&& ext,
const Args&... args) :
mIndPtr(indPtr.get()), mExpr(args...), mExt(ext) {}
template <class IndexClass, class Expr>
For<IndexClass,Expr>::For(const std::shared_ptr<IndexClass>& indPtr,
Expr&& expr) :
mIndPtr(indPtr.get()), mExpr(expr), mExt(expr.rootSteps( static_cast<std::intptr_t>( mIndPtr.get() ))) {}
template <class IndexClass, class Expr, class... Ops>
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(ext) {}
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>
For<IndexClass,Expr>::For(const IndexClass* indPtr,
Expr&& expr) :
mIndPtr(indPtr), mExpr(expr), mExt(expr.rootSteps( static_cast<std::intptr_t>( mIndPtr ) )) {}
template <class IndexClass, class Expr, class... Ops>
For<IndexClass,Expr,Ops...>::For(IndexClass* indPtr,
Expr&& expr, std::tuple<to_size_t<Ops>...>&& ext) :
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
template <class IndexClass, class Expr>
inline void For<IndexClass,Expr>::operator()(size_t mlast,
const ETuple& last) const
{
static const size_t opNum = sizeof...(Ops);
auto& ind = *mIndPtr;
const size_t max = exceptMax<For<IndexClass,Expr,Ops...>::layer()>( ind.max() ); // blocking
for(ind = 0; ind.pos() != max; ++ind){
const size_t mnpos = mlast * max + ind.pos();
const std::tuple<to_size_t<Ops>...> npos = std::move( XFPackNum<opNum-1>::mkPos(ind, mExt, last) );
const size_t max = ind.max(); // blocking
for(size_t pos = ind.pos(); pos != max; ++pos){
const size_t mnpos = mlast * max + pos;
const ETuple npos = std::move( XFPackNum<SIZE-1>::mkPos(pos, mExt, last) );
mExpr(mnpos, npos);
}
}
template <class IndexClass, class Expr, class... Ops>
inline void For<IndexClass,Expr,Ops...>::operator()(size_t mlast) const
template <class IndexClass, class Expr>
inline void For<IndexClass,Expr>::operator()(size_t mlast) const
{
static const size_t opNum = sizeof...(Ops);
std::tuple<to_size_t<Ops>...> last(to_size_t<Ops>(0)...);
const ETuple last;
auto& ind = *mIndPtr;
const size_t max = exceptMax<For<IndexClass,Expr,Ops...>::layer()>( ind.max() ); // blocking
for(ind = 0; ind.pos() != max; ++ind){
const size_t mnpos = mlast * max + ind.pos();
const std::tuple<to_size_t<Ops>...> npos = std::move( XFPackNum<opNum-1>::mkPos(ind, mExt, last) );
const size_t max = ind.max(); // blocking
for(size_t pos = ind.pos(); pos != max; ++pos){
const size_t mnpos = mlast * max + pos;
const ETuple npos = std::move( XFPackNum<SIZE-1>::mkPos(pos, mExt, last) );
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
#endif