diff --git a/src/opt/mpi/include/rop_types.cc.h b/src/opt/mpi/include/rop_types.cc.h index 350fba4..813a062 100644 --- a/src/opt/mpi/include/rop_types.cc.h +++ b/src/opt/mpi/include/rop_types.cc.h @@ -3,85 +3,89 @@ namespace CNORXZ { - /*================+ - | CROpRoot | - +================*/ + namespace mpi + { + + /*================+ + | CROpRoot | + +================*/ - template - template - constexpr decltype(auto) CROpRoot::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 + template + constexpr decltype(auto) CROpRoot::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 - constexpr decltype(auto) CROpRoot::operator()() const - { + template + constexpr decltype(auto) CROpRoot::operator()() const + { - } + } - template - template - constexpr decltype(auto) CROpRoot::rootSteps(const IndexId& id) const - { + template + template + constexpr decltype(auto) CROpRoot::rootSteps(const IndexId& id) const + { - } + } - /*===============+ - | ROpRoot | - +===============*/ + /*===============+ + | ROpRoot | + +===============*/ - template - template - constexpr decltype(auto) ROpRoot::operator()(const PosT& pos) const - { + template + template + constexpr decltype(auto) ROpRoot::operator()(const PosT& pos) const + { - } + } - template - constexpr decltype(auto) ROpRoot::operator()() const - { + template + constexpr decltype(auto) ROpRoot::operator()() const + { - } + } - template - template - constexpr decltype(auto) ROpRoot::rootSteps(const IndexId& id) const - { + template + template + constexpr decltype(auto) ROpRoot::rootSteps(const IndexId& id) const + { - } + } - /*====================+ - | RContraction | - +====================*/ + /*====================+ + | RContraction | + +====================*/ - template - constexpr RContraction::RContraction(CXpr&& cxpr) : - mCXpr(std::forward(cxpr)) - {} + template + constexpr RContraction::RContraction(CXpr&& cxpr) : + mCXpr(std::forward(cxpr)) + {} - template - template - constexpr decltype(auto) RContraction::operator()(const PosT& pos) const - { + template + template + constexpr decltype(auto) RContraction::operator()(const PosT& pos) const + { - } + } - template - constexpr decltype(auto) RContraction::operator()() const - { + template + constexpr decltype(auto) RContraction::operator()() const + { - } + } - template - template - constexpr decltype(auto) RContraction::rootSteps(const IndexId& id) const - { + template + template + constexpr decltype(auto) RContraction::rootSteps(const IndexId& id) const + { - } - -} + } + + } // namespace mpi +} // namespace CNORXZ diff --git a/src/opt/mpi/include/rop_types.h b/src/opt/mpi/include/rop_types.h index c9f8406..814e0fd 100644 --- a/src/opt/mpi/include/rop_types.h +++ b/src/opt/mpi/include/rop_types.h @@ -14,67 +14,70 @@ namespace CNORXZ { - template - class CROpRoot : public COpInterface> + namespace mpi { - public: - typedef COpInterface> OI; + template + class CROpRoot : public COpInterface> + { + public: + typedef COpInterface> OI; - constexpr CROpRoot() = default; + constexpr CROpRoot() = default; - template - constexpr decltype(auto) operator()(const PosT& pos) const; + template + constexpr decltype(auto) operator()(const PosT& pos) const; - constexpr decltype(auto) operator()() const; + constexpr decltype(auto) operator()() const; - template - constexpr decltype(auto) rootSteps(const IndexId& id) const; + template + constexpr decltype(auto) rootSteps(const IndexId& id) const; - private: - const T* mData; - COpRoot - }; + private: + const T* mData; + COpRoot + }; - template - class ROpRoot : public OpInterface> - { - public: - typedef OpInterface> OI; + template + class ROpRoot : public OpInterface> + { + public: + typedef OpInterface> OI; - constexpr ROpRoot() = default; + constexpr ROpRoot() = default; - template - constexpr decltype(auto) operator()(const PosT& pos) const; + template + constexpr decltype(auto) operator()(const PosT& pos) const; - constexpr decltype(auto) operator()() const; + constexpr decltype(auto) operator()() const; - template - constexpr decltype(auto) rootSteps(const IndexId& id) const; + template + constexpr decltype(auto) rootSteps(const IndexId& id) const; - private: + private: - }; + }; - template - class RContraction : public OpInterfacte> - { - public: - typedef OpInterfacte> OI; + template + class RContraction : public OpInterfacte> + { + public: + typedef OpInterfacte> OI; - constexpr RContraction() = default; - constexpr RContraction(CXpr&& cxpr); + constexpr RContraction() = default; + constexpr RContraction(CXpr&& cxpr); - template - constexpr decltype(auto) operator()(const PosT& pos) const; + template + constexpr decltype(auto) operator()(const PosT& pos) const; - constexpr decltype(auto) operator()() const; + constexpr decltype(auto) operator()() const; - template - constexpr decltype(auto) rootSteps(const IndexId& id) const; + template + constexpr decltype(auto) rootSteps(const IndexId& id) const; - private: - CXpr mCXpr; - }; -} + private: + CXpr mCXpr; + }; + } // namespace mpi +} // namespace CNORXZ #endif diff --git a/src/opt/mpi/include/rrange.cc.h b/src/opt/mpi/include/rrange.cc.h index 18c0c5f..986cea1 100644 --- a/src/opt/mpi/include/rrange.cc.h +++ b/src/opt/mpi/include/rrange.cc.h @@ -56,9 +56,9 @@ namespace CNORXZ template RIndex& RIndex::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::value){ constexpr SizeT NI = index_dim::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::value){ constexpr SizeT NI = index_dim::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 SizeT RIndex::lex() const { - return IB::mPos; + return mLex; } template constexpr decltype(auto) RIndex::pmax() const { - return UPos(mK->lmax().val() * mI->lmax().val()); + return UPos(mK->pmax().val() * mI->pmax().val()); } template @@ -302,11 +303,11 @@ namespace CNORXZ RIndex& RIndex::operator()() { if(mI->lex() >= mI->lmax().val()){ - IB::mPos = lmax().val(); + mLex = lmax().val(); } if constexpr(has_static_sub::value){ constexpr SizeT NI = index_dim::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::value){ constexpr SizeT NI = index_dim::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; } diff --git a/src/opt/mpi/include/rrange.h b/src/opt/mpi/include/rrange.h index 3aa0767..1179642 100644 --- a/src/opt/mpi/include/rrange.h +++ b/src/opt/mpi/include/rrange.h @@ -146,6 +146,7 @@ namespace CNORXZ Sptr local() const; private: + SizeT mLex = 0; Sptr mRange; /**< RRange. */ Sptr mI; /**< Index on the local range of the THIS rank. */ Sptr mK; /**< Multi-index indicating the current rank. */