rindex: distinguish between lex and pos
This commit is contained in:
parent
d9a546a5cc
commit
5d76ae6e36
4 changed files with 128 additions and 118 deletions
|
@ -3,85 +3,89 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
/*================+
|
||||
| CROpRoot |
|
||||
+================*/
|
||||
namespace mpi
|
||||
{
|
||||
|
||||
/*================+
|
||||
| CROpRoot |
|
||||
+================*/
|
||||
|
||||
template <typename T, class IndexT>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) CROpRoot<T,IndexT>::operator()(const PosT& pos) const
|
||||
{
|
||||
const SizeT L = mIndex->lmax().val();
|
||||
const SizeT m = mIndex->myrank()
|
||||
const SizeT dst = ( m + pos.val() ) % L;
|
||||
const SizeT src = ( m - pos.val() + L ) % L;
|
||||
|
||||
}
|
||||
template <typename T, class IndexT>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) CROpRoot<T,IndexT>::operator()(const PosT& pos) const
|
||||
{
|
||||
const SizeT L = mIndex->lmax().val();
|
||||
const SizeT m = mIndex->myrank();
|
||||
const SizeT dst = ( m + pos.val() ) % L;
|
||||
const SizeT src = ( m - pos.val() + L ) % L;
|
||||
|
||||
}
|
||||
|
||||
template <typename T, class IndexT>
|
||||
constexpr decltype(auto) CROpRoot<T,IndexT>::operator()() const
|
||||
{
|
||||
template <typename T, class IndexT>
|
||||
constexpr decltype(auto) CROpRoot<T,IndexT>::operator()() const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, class IndexT>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) CROpRoot<T,IndexT>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
template <typename T, class IndexT>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) CROpRoot<T,IndexT>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*===============+
|
||||
| ROpRoot |
|
||||
+===============*/
|
||||
/*===============+
|
||||
| ROpRoot |
|
||||
+===============*/
|
||||
|
||||
template <typename T, class IndexT>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) ROpRoot<T,IndexT>::operator()(const PosT& pos) const
|
||||
{
|
||||
template <typename T, class IndexT>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) ROpRoot<T,IndexT>::operator()(const PosT& pos) const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, class IndexT>
|
||||
constexpr decltype(auto) ROpRoot<T,IndexT>::operator()() const
|
||||
{
|
||||
template <typename T, class IndexT>
|
||||
constexpr decltype(auto) ROpRoot<T,IndexT>::operator()() const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, class IndexT>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) ROpRoot<T,IndexT>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
template <typename T, class IndexT>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) ROpRoot<T,IndexT>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*====================+
|
||||
| RContraction |
|
||||
+====================*/
|
||||
/*====================+
|
||||
| RContraction |
|
||||
+====================*/
|
||||
|
||||
template <class CXpr>
|
||||
constexpr RContraction<CXpr>::RContraction(CXpr&& cxpr) :
|
||||
mCXpr(std::forward<CXpr>(cxpr))
|
||||
{}
|
||||
template <class CXpr>
|
||||
constexpr RContraction<CXpr>::RContraction(CXpr&& cxpr) :
|
||||
mCXpr(std::forward<CXpr>(cxpr))
|
||||
{}
|
||||
|
||||
template <class CXpr>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) RContraction<CXpr>::operator()(const PosT& pos) const
|
||||
{
|
||||
template <class CXpr>
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) RContraction<CXpr>::operator()(const PosT& pos) const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template <class CXpr>
|
||||
constexpr decltype(auto) RContraction<CXpr>::operator()() const
|
||||
{
|
||||
template <class CXpr>
|
||||
constexpr decltype(auto) RContraction<CXpr>::operator()() const
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
template <class CXpr>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) RContraction<CXpr>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
template <class CXpr>
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) RContraction<CXpr>::rootSteps(const IndexId<I>& id) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mpi
|
||||
} // namespace CNORXZ
|
||||
|
|
|
@ -14,67 +14,70 @@
|
|||
|
||||
namespace CNORXZ
|
||||
{
|
||||
template <typename T, class IndexT>
|
||||
class CROpRoot : public COpInterface<CROpRoot<T,IndexT>>
|
||||
namespace mpi
|
||||
{
|
||||
public:
|
||||
typedef COpInterface<CROpRoot<T,IndexT>> OI;
|
||||
template <typename T, class IndexT>
|
||||
class CROpRoot : public COpInterface<CROpRoot<T,IndexT>>
|
||||
{
|
||||
public:
|
||||
typedef COpInterface<CROpRoot<T,IndexT>> OI;
|
||||
|
||||
constexpr CROpRoot() = default;
|
||||
constexpr CROpRoot() = default;
|
||||
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||
|
||||
constexpr decltype(auto) operator()() const;
|
||||
constexpr decltype(auto) operator()() const;
|
||||
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
|
||||
private:
|
||||
const T* mData;
|
||||
COpRoot
|
||||
};
|
||||
private:
|
||||
const T* mData;
|
||||
COpRoot
|
||||
};
|
||||
|
||||
template <typename T, class IndexT>
|
||||
class ROpRoot : public OpInterface<ROpRoot<T,IndexT>>
|
||||
{
|
||||
public:
|
||||
typedef OpInterface<ROpRoot<T,IndexT>> OI;
|
||||
template <typename T, class IndexT>
|
||||
class ROpRoot : public OpInterface<ROpRoot<T,IndexT>>
|
||||
{
|
||||
public:
|
||||
typedef OpInterface<ROpRoot<T,IndexT>> OI;
|
||||
|
||||
constexpr ROpRoot() = default;
|
||||
constexpr ROpRoot() = default;
|
||||
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||
|
||||
constexpr decltype(auto) operator()() const;
|
||||
constexpr decltype(auto) operator()() const;
|
||||
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
template <class CXpr>
|
||||
class RContraction : public OpInterfacte<RContraction<CXpr>>
|
||||
{
|
||||
public:
|
||||
typedef OpInterfacte<RContraction<CXpr>> OI;
|
||||
template <class CXpr>
|
||||
class RContraction : public OpInterfacte<RContraction<CXpr>>
|
||||
{
|
||||
public:
|
||||
typedef OpInterfacte<RContraction<CXpr>> OI;
|
||||
|
||||
constexpr RContraction() = default;
|
||||
constexpr RContraction(CXpr&& cxpr);
|
||||
constexpr RContraction() = default;
|
||||
constexpr RContraction(CXpr&& cxpr);
|
||||
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||
template <class PosT>
|
||||
constexpr decltype(auto) operator()(const PosT& pos) const;
|
||||
|
||||
constexpr decltype(auto) operator()() const;
|
||||
constexpr decltype(auto) operator()() const;
|
||||
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
template <SizeT I>
|
||||
constexpr decltype(auto) rootSteps(const IndexId<I>& id) const;
|
||||
|
||||
private:
|
||||
CXpr mCXpr;
|
||||
};
|
||||
}
|
||||
private:
|
||||
CXpr mCXpr;
|
||||
};
|
||||
} // namespace mpi
|
||||
} // namespace CNORXZ
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,9 +56,9 @@ namespace CNORXZ
|
|||
template <class IndexI, class IndexK>
|
||||
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator=(SizeT pos)
|
||||
{
|
||||
IB::mPos = pos; // = lex
|
||||
if(pos >= lmax().val()){
|
||||
IB::mPos = pmax().val();
|
||||
mLex = pos; // = lex
|
||||
if(mLex >= lmax().val()){
|
||||
mLex = lmax().val();
|
||||
return *this;
|
||||
}
|
||||
// pos is the lexicographic position of the global range.
|
||||
|
@ -72,7 +72,7 @@ namespace CNORXZ
|
|||
if constexpr(has_static_sub<IndexI>::value){
|
||||
constexpr SizeT NI = index_dim<IndexI>::value;
|
||||
iter<0,NI>( [&](auto mu) {
|
||||
const SizeT jmu = (IB::mPos / (ilf[mu].val()*klf[mu].val())) %
|
||||
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
|
||||
(i[mu]->lmax().val() * k[mu]->lmax().val());
|
||||
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
|
||||
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
|
||||
|
@ -81,7 +81,7 @@ namespace CNORXZ
|
|||
else if constexpr( has_static_sub<IndexK>::value){
|
||||
constexpr SizeT NI = index_dim<IndexK>::value;
|
||||
iter<0,NI>( [&](auto mu) {
|
||||
const SizeT jmu = (IB::mPos / (ilf[mu].val()*klf[mu].val())) %
|
||||
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
|
||||
(i[mu]->lmax().val() * k[mu]->lmax().val());
|
||||
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
|
||||
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
|
||||
|
@ -90,7 +90,7 @@ namespace CNORXZ
|
|||
else {
|
||||
const SizeT NI = mI->dim();
|
||||
for(SizeT mu = 0; mu != NI; ++mu){
|
||||
const SizeT jmu = (IB::mPos / (ilf[mu].val()*klf[mu].val())) %
|
||||
const SizeT jmu = (mLex / (ilf[mu].val()*klf[mu].val())) %
|
||||
(i[mu]->lmax().val() * k[mu]->lmax().val());
|
||||
r += ( jmu / i[mu]->lmax().val() ) * klf[mu].val();
|
||||
l += ( jmu % i[mu]->lmax().val() ) * ilf[mu].val();
|
||||
|
@ -98,6 +98,7 @@ namespace CNORXZ
|
|||
}
|
||||
*mI = l;
|
||||
*mK = r;
|
||||
IB::mPos = mK->pos() * mI->pmax().val() + mI->pos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -152,13 +153,13 @@ namespace CNORXZ
|
|||
template <class IndexI, class IndexK>
|
||||
SizeT RIndex<IndexI,IndexK>::lex() const
|
||||
{
|
||||
return IB::mPos;
|
||||
return mLex;
|
||||
}
|
||||
|
||||
template <class IndexI, class IndexK>
|
||||
constexpr decltype(auto) RIndex<IndexI,IndexK>::pmax() const
|
||||
{
|
||||
return UPos(mK->lmax().val() * mI->lmax().val());
|
||||
return UPos(mK->pmax().val() * mI->pmax().val());
|
||||
}
|
||||
|
||||
template <class IndexI, class IndexK>
|
||||
|
@ -302,11 +303,11 @@ namespace CNORXZ
|
|||
RIndex<IndexI,IndexK>& RIndex<IndexI,IndexK>::operator()()
|
||||
{
|
||||
if(mI->lex() >= mI->lmax().val()){
|
||||
IB::mPos = lmax().val();
|
||||
mLex = lmax().val();
|
||||
}
|
||||
if constexpr(has_static_sub<IndexI>::value){
|
||||
constexpr SizeT NI = index_dim<IndexI>::value;
|
||||
IB::mPos = iter<0,NI>
|
||||
mLex = iter<0,NI>
|
||||
([&](auto i) {
|
||||
return mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
|
||||
mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() +
|
||||
|
@ -316,7 +317,7 @@ namespace CNORXZ
|
|||
}
|
||||
else if constexpr( has_static_sub<IndexK>::value){
|
||||
constexpr SizeT NI = index_dim<IndexK>::value;
|
||||
IB::mPos = iter<0,NI>
|
||||
mLex = iter<0,NI>
|
||||
([&](auto i) {
|
||||
return mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
|
||||
mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() +
|
||||
|
@ -326,14 +327,15 @@ namespace CNORXZ
|
|||
}
|
||||
else {
|
||||
const SizeT NI = mI->dim();
|
||||
IB::mPos = 0;
|
||||
mLex = 0;
|
||||
for(SizeT i = 0; i != NI; ++i){
|
||||
IB::mPos += mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
|
||||
mLex += mK->pack()[i]->lex() * mK->lexFormat()[i].val() *
|
||||
mI->lexFormat()[i].val() * mI->pack()[i]->lmax().val() +
|
||||
mI->pack()[i]->lex() * mI->lexFormat()[i].val() *
|
||||
mK->lexFormat()[i].val();
|
||||
}
|
||||
}
|
||||
IB::mPos = mK->pos() * mI->pmax().val() + mI->pos();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ namespace CNORXZ
|
|||
Sptr<IndexI> local() const;
|
||||
|
||||
private:
|
||||
SizeT mLex = 0;
|
||||
Sptr<RangeType> mRange; /**< RRange. */
|
||||
Sptr<IndexI> mI; /**< Index on the local range of the THIS rank. */
|
||||
Sptr<IndexK> mK; /**< Multi-index indicating the current rank. */
|
||||
|
|
Loading…
Reference in a new issue