rpacknum: replace mkfor

This commit is contained in:
Christian Zimmermann 2021-05-27 12:15:44 +02:00
parent 893b2360bc
commit 12c79b595f
7 changed files with 52 additions and 111 deletions

View file

@ -309,8 +309,9 @@ namespace MultiArrayTools
template <class Exprs>
auto GenMapIndex<OIType,Op,XSTYPE,Indices...>::ifor(size_t step, Exprs exs) const
{
return RPackNum<sizeof...(Indices)-1>::mkForh
(0, mIPack, mBlockSizes, OpExpr<Op,GenMapIndex<OIType,Op,XSTYPE,Indices...>,Exprs,XSTYPE>
return RangeHelper::mkFor<0>
(0, mIPack, mBlockSizes,
OpExpr<Op,GenMapIndex<OIType,Op,XSTYPE,Indices...>,Exprs,XSTYPE>
( range()->map(), this, step, exs ));
}

View file

@ -159,15 +159,12 @@ namespace MultiArrayTools
template <class Exprs>
auto ifor(size_t step, Exprs exs) const;
//-> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(step, mIPack, mBlockSizes, exs));
template <class Exprs>
auto iforh(size_t step, Exprs exs) const;
// -> decltype(RPackNum<sizeof...(Indices)-1>::mkForh(step, mIPack, mBlockSizes, exs));
template <class Exprs>
auto pifor(size_t step, Exprs exs) const;
// -> decltype(RPackNum<sizeof...(Indices)-1>::mkPFor(step, mIPack, mBlockSizes, exs));
std::intptr_t container() const;
ContainerIndex& format(const std::array<size_t,sizeof...(Indices)+1>& blocks);
@ -482,25 +479,22 @@ namespace MultiArrayTools
template <typename T, class... Indices>
template <class Exprs>
auto ContainerIndex<T,Indices...>::ifor(size_t step, Exprs exs) const
// -> decltype(RPackNum<sizeof...(Indices)-1>::mkFor(step, mIPack, mBlockSizes, exs))
{
return RPackNum<sizeof...(Indices)-1>::mkFor(step, mIPack, mBlockSizes, exs);
return RangeHelper::mkFor<0>(step, mIPack, mBlockSizes, exs);
}
template <typename T, class... Indices>
template <class Exprs>
auto ContainerIndex<T,Indices...>::iforh(size_t step, Exprs exs) const
// -> decltype(RPackNum<sizeof...(Indices)-1>::mkForh(step, mIPack, mBlockSizes, exs))
{
return RPackNum<sizeof...(Indices)-1>::mkForh(step, mIPack, mBlockSizes, exs);
return RangeHelper::mkForh<0>(step, mIPack, mBlockSizes, exs);
}
template <typename T, class... Indices>
template <class Exprs>
auto ContainerIndex<T,Indices...>::pifor(size_t step, Exprs exs) const
// -> decltype(RPackNum<sizeof...(Indices)-1>::mkPFor(step, mIPack, mBlockSizes, exs))
{
return RPackNum<sizeof...(Indices)-1>::mkPFor(step, mIPack, mBlockSizes, exs);
return RangeHelper::mkPFor<0>(step, mIPack, mBlockSizes, exs);
}
template <typename T, class... Indices>

View file

@ -473,21 +473,21 @@ namespace MultiArrayTools
template <class Exprs>
auto MultiIndex<Indices...>::ifor(size_t step, Exprs exs) const
{
return RPackNum<sizeof...(Indices)-1>::mkFor(step, mIPack, mBlockSizes, exs);
return RangeHelper::mkFor<0>(step, mIPack, mBlockSizes, exs);
}
template <class... Indices>
template <class Exprs>
auto MultiIndex<Indices...>::iforh(size_t step, Exprs exs) const
{
return RPackNum<sizeof...(Indices)-1>::mkForh(step, mIPack, mBlockSizes, exs);
return RangeHelper::mkForh<0>(step, mIPack, mBlockSizes, exs);
}
template <class... Indices>
template <class Exprs>
auto MultiIndex<Indices...>::pifor(size_t step, Exprs exs) const
{
return RPackNum<sizeof...(Indices)-1>::mkPFor(step, mIPack, mBlockSizes, exs);
return RangeHelper::mkPFor<0>(step, mIPack, mBlockSizes, exs);
}
/*************************
@ -581,7 +581,6 @@ namespace MultiArrayTools
return sforx_p<0,sizeof...(Indices)>
( [&](auto i) { return std::dynamic_pointer_cast<RangeBase>(std::get<i>(mSpace)); },
[&](auto i) { return num != i;} );
//return RPackNum<sizeof...(Indices)-1>::getSub(mSpace, num);
}
template <class... Ranges>
@ -596,7 +595,6 @@ namespace MultiArrayTools
return sfor_p<0,sizeof...(Ranges)>
( [&](auto i) { return std::get<i>(mSpace)->size(); },
[&](auto a, auto b) { return a * b; } );
//return RPackNum<sizeof...(Ranges)-1>::getSize(mSpace);
}
template <class... Ranges>

View file

@ -41,6 +41,46 @@ namespace MultiArrayTools
}
}
template <size_t N, class IndexPack, class BlockArray, class Exprs>
auto mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
{
constexpr size_t S = std::tuple_size<IndexPack>::value;
if constexpr(N < S-1){
return std::get<N>(ipack)
->ifor( step*std::get<N+1>(ba), mkFor<N+1>(step, ipack, ba, exs) );
}
else {
return std::get<N>(ipack)->ifor( step*std::get<N+1>(ba), exs);
}
}
template <size_t N, class IndexPack, class BlockArray, class Exprs>
auto mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
{
constexpr size_t S = std::tuple_size<IndexPack>::value;
if constexpr(N < S-1){
return std::get<N>(ipack)
->iforh( step*std::get<N+1>(ba), mkForh<N+1>(step, ipack, ba, exs) );
}
else {
return std::get<N>(ipack)->iforh( step*std::get<N+1>(ba), exs);
}
}
template <size_t N, class IndexPack, class BlockArray, class Exprs>
auto mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
{
constexpr size_t S = std::tuple_size<IndexPack>::value;
if constexpr(N < S-1){
return std::get<N>(ipack)
->pifor( step*std::get<N+1>(ba), mkFor<N+1>(step, ipack, ba, exs) );
// mkFor is correct here, because we want to multithread only the FIRST index!!
}
else {
return std::get<N>(ipack)->pifor( step*std::get<N+1>(ba), exs);
}
}
} // namespace RangeHelper
} // namespace MultiArrayTools

View file

@ -84,39 +84,6 @@ namespace MultiArrayHelper
RPackNum<N-1>::RangesToVec(rst, v);
}
template <size_t N>
template <class IndexPack, class BlockArray, class Exprs>
auto RPackNum<N>::mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
->ifor( 0, RPackNum<N-1>::mkFor(step, ipack, ba, exs) ) )
{
constexpr size_t NN = std::tuple_size<IndexPack>::value-N-1;
return std::get<NN>(ipack)
->ifor( step*std::get<NN+1>(ba), RPackNum<N-1>::mkFor(step, ipack, ba, exs) );
}
template <size_t N>
template <class IndexPack, class BlockArray, class Exprs>
auto RPackNum<N>::mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
->iforh( 0, RPackNum<N-1>::mkForh(step, ipack, ba, exs) ) )
{
constexpr size_t NN = std::tuple_size<IndexPack>::value-N-1;
return std::get<NN>(ipack)
->iforh( step*std::get<NN+1>(ba), RPackNum<N-1>::mkForh(step, ipack, ba, exs) );
}
template <size_t N>
template <class IndexPack, class BlockArray, class Exprs>
auto RPackNum<N>::mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
->pifor( 0, RPackNum<N-1>::mkFor(step, ipack, ba, exs) ) )
{
constexpr size_t NN = std::tuple_size<IndexPack>::value-N-1;
return std::get<NN>(ipack)
->pifor( step*std::get<NN+1>(ba), RPackNum<N-1>::mkFor(step, ipack, ba, exs) );
// mkFor is correct here, because we want to multithread only the FIRST index!!
}
template <size_t N>
template <class Index>
@ -248,36 +215,6 @@ namespace MultiArrayHelper
setRangeToVec(v, std::get<0>(rst));
}
template <class IndexPack, class BlockArray, class Exprs>
auto RPackNum<0>::mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->ifor(0,exs) )
{
constexpr size_t NN = std::tuple_size<IndexPack>::value-1;
return std::get<NN>(ipack)
->ifor( step*std::get<NN+1>(ba), exs);
}
template <class IndexPack, class BlockArray, class Exprs>
auto RPackNum<0>::mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->iforh(0,exs) )
{
constexpr size_t NN = std::tuple_size<IndexPack>::value-1;
return std::get<NN>(ipack)
->iforh( step*std::get<NN+1>(ba), exs);
}
template <class IndexPack, class BlockArray, class Exprs>
auto RPackNum<0>::mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->pifor(0,exs) )
{
constexpr size_t NN = std::tuple_size<IndexPack>::value-1;
return std::get<NN>(ipack)
->pifor( step*std::get<NN+1>(ba), exs);
}
template <class Index>
inline void RPackNum<0>::getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx)
{

View file

@ -125,21 +125,6 @@ namespace MultiArrayHelper
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
vector<std::intptr_t>& v);
template <class IndexPack, class BlockArray, class Exprs>
static auto mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
->ifor( 0, RPackNum<N-1>::mkFor(step, ipack, ba, exs) ) );
template <class IndexPack, class BlockArray, class Exprs>
static auto mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
->iforh( 0, RPackNum<N-1>::mkForh(step, ipack, ba, exs) ) );
template <class IndexPack, class BlockArray, class Exprs>
static auto mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
->pifor( 0, RPackNum<N-1>::mkFor(step, ipack, ba, exs) ) );
template <class Index>
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
@ -200,21 +185,6 @@ namespace MultiArrayHelper
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
vector<std::shared_ptr<RangeBase> >& v);
template <class IndexPack, class BlockArray, class Exprs>
static auto mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->ifor(0,exs) );
template <class IndexPack, class BlockArray, class Exprs>
static auto mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->iforh(0,exs) );
template <class IndexPack, class BlockArray, class Exprs>
static auto mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
->pifor(0,exs) );
template <class Index>
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);

View file

@ -270,7 +270,8 @@ namespace MultiArrayHelper
DExtTX() { mDExt = std::make_shared<ExtT<None>>(); }
DExtTX(const DExtTX& in) : mNext(in.mNext)
{ mDExt = in.mDExt->deepCopy(); }
DExtTX(DExtTX&& in) : mDExt(in.mDExt->deepCopy()), mNext(in.mNext) {}
DExtTX(DExtTX&& in) : mNext(in.mNext)
{ mDExt = in.mDExt->deepCopy(); }
DExtTX& operator=(const DExtTX& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
DExtTX& operator=(DExtTX&& in) { mNext = in.mNext; mDExt = in.mDExt->deepCopy(); return *this; }
explicit DExtTX(const DExt& in) : mDExt(in) {}