diff --git a/src/opt/mpi/include/rarray.cc.h b/src/opt/mpi/include/rarray.cc.h index b1383c4..ee56d1c 100644 --- a/src/opt/mpi/include/rarray.cc.h +++ b/src/opt/mpi/include/rarray.cc.h @@ -356,27 +356,29 @@ namespace CNORXZ template template - OpRoot RArray::rop(const Sptr& i) + OpRoot RArray::operator()(const Sptr& i) + //OpRoot RArray::rop(const Sptr& i) { return (*mB)(i); } template template - inline decltype(auto) RArray::rop(const SPack& pack) + inline decltype(auto) RArray::operator()(const SPack& pack) + //inline decltype(auto) RArray::rop(const SPack& pack) { typedef typename std::remove_reference{}])>::type I0; if constexpr(is_rank_index::value){ // preliminary: CXZ_ASSERT(mB->formatIsTrivial(), "array has non-trivial format, rank operations require trivial format"); - /* + auto ri = pack[CSizeT<0>{}]; auto li = iter<1,sizeof...(Indices)> ( [&](auto i) { return pack[CSizeT{}]; }, [](const auto&... x) { return mindexPtr( (x * ...) ); } ); - */ - return oproot(*mB, mindexPtr(pack)); + return roproot(*this, ri, li); + //return oproot(*mB, mindexPtr(pack)); } else { return (*mB)(pack); @@ -384,7 +386,8 @@ namespace CNORXZ } template - inline decltype(auto) RArray::rop(const DPack& pack) + inline decltype(auto) RArray::operator()(const DPack& pack) + //inline decltype(auto) RArray::rop(const DPack& pack) { return (*mB)(pack); } diff --git a/src/opt/mpi/include/rarray.h b/src/opt/mpi/include/rarray.h index 1390d82..0782f7b 100644 --- a/src/opt/mpi/include/rarray.h +++ b/src/opt/mpi/include/rarray.h @@ -221,14 +221,17 @@ namespace CNORXZ /** @copydoc ArrayBase::operator() */ template - OpRoot rop(const Sptr& i); + OpRoot operator()(const Sptr& i); + //OpRoot rop(const Sptr& i); /** @copydoc ArrayBase::operator() */ template - inline decltype(auto) rop(const SPack& pack); + inline decltype(auto) operator()(const SPack& pack); + //inline decltype(auto) rop(const SPack& pack); /** @copydoc ArrayBase::operator() */ - inline decltype(auto) rop(const DPack& pack); + inline decltype(auto) operator()(const DPack& pack); + //inline decltype(auto) rop(const DPack& pack); /** @copydoc ArrayBase::data() */ T* data(); diff --git a/src/opt/mpi/include/rop_types.cc.h b/src/opt/mpi/include/rop_types.cc.h index 31983c5..3002a00 100644 --- a/src/opt/mpi/include/rop_types.cc.h +++ b/src/opt/mpi/include/rop_types.cc.h @@ -56,18 +56,24 @@ namespace CNORXZ template constexpr ROpRoot::ROpRoot(RArray& a, const Sptr& ri, const Sptr& li) : - mData(a.data()), + mLocal(&a.local()), + mData(a.buffermap().data()), + //mData(a.data()), mRIndex(ri), mIndex(li) { - CXZ_ERROR("nope"); + //CXZ_ERROR("nope"); + CXZ_ASSERT(a.buffermap().size() == ri->lmax().val(), + "data map not properly initialized: map size = " << a.buffermap().size() + << ", rank index range size = " << ri->lmax().val()); } template template constexpr ROpRoot& ROpRoot::operator=(const Op& in) { - OI::a(mIndex, [](auto& a, const auto& b) { a = b; }, in); + (*mLocal)(mindexPtr(mRIndex->local()*mIndex)) = in; + //OI::a(mIndex, [](auto& a, const auto& b) { a = b; }, in); return *this; } @@ -75,14 +81,16 @@ namespace CNORXZ template constexpr ROpRoot& ROpRoot::operator+=(const Op& in) { - OI::a(mIndex, [](auto& a, const auto& b) { a += b; }, in); + (*mLocal)(mindexPtr(mRIndex->local()*mIndex)) += in; + //OI::a(mIndex, [](auto& a, const auto& b) { a += b; }, in); return *this; } template constexpr ROpRoot& ROpRoot::operator=(const ROpRoot& in) { - OI::a(mIndex, [](auto& a, const auto& b) { a = b; }, in); + (*mLocal)(mindexPtr(mRIndex->local()*mIndex)) = in; + //OI::a(mIndex, [](auto& a, const auto& b) { a = b; }, in); return *this; } @@ -90,20 +98,20 @@ namespace CNORXZ template constexpr decltype(auto) ROpRoot::operator()(const PosT& pos) const { - return mData[pos.val()]; + return (mData[pos.val()])[pos.next().val()]; } template constexpr decltype(auto) ROpRoot::operator()() const { - return mData[0]; + return (mData[0])[0]; } template template constexpr decltype(auto) ROpRoot::rootSteps(const IndexId& id) const { - return mIndex->stepSize(id); + return mRIndex->stepSize(id) << mIndex->stepSize(id); } template diff --git a/src/opt/mpi/include/rop_types.h b/src/opt/mpi/include/rop_types.h index 2b10bfa..5415182 100644 --- a/src/opt/mpi/include/rop_types.h +++ b/src/opt/mpi/include/rop_types.h @@ -76,7 +76,8 @@ namespace CNORXZ private: - T* mData; + ArrayBase* mLocal; + const T* const* mData; Sptr mRIndex; Sptr mIndex; }; diff --git a/src/opt/mpi/tests/roperation_unit_test.cc b/src/opt/mpi/tests/roperation_unit_test.cc index 1a1f50d..ce9b17b 100644 --- a/src/opt/mpi/tests/roperation_unit_test.cc +++ b/src/opt/mpi/tests/roperation_unit_test.cc @@ -133,8 +133,10 @@ namespace for(const auto& r: *imap1){ req[r] = true; } + res.load(x, AB, req); // DUMMY, not used... mM1.load(xp, AB, req); - res.rop(x*A*B) = mapXpr(xp,x,imap1, mM1(xp*A*B) - mM1(x*A*B) ); + //res.rop(x*A*B) = mapXpr(xp,x,imap1, mM1(xp*A*B) - mM1(x*A*B) ); + res(x*A*B) = mapXpr(xp,x,imap1, mM1(xp*A*B) - mM1(x*A*B) ); for(SizeT x0 = 0; x0 != T; ++x0) { for(SizeT x1 = 0; x1 != L; ++x1)