From de7ac23f87ca11a949dbbea65caa2a846274e0a4 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Sun, 13 Oct 2024 23:32:36 -0700 Subject: [PATCH] mpi: rmap: fix bug --- src/opt/mpi/include/rmap_xpr.cc.h | 8 ++++++-- src/opt/mpi/include/rmap_xpr.h | 1 + src/opt/mpi/tests/roperation_unit_test.cc | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/opt/mpi/include/rmap_xpr.cc.h b/src/opt/mpi/include/rmap_xpr.cc.h index efead35..785db32 100644 --- a/src/opt/mpi/include/rmap_xpr.cc.h +++ b/src/opt/mpi/include/rmap_xpr.cc.h @@ -36,7 +36,9 @@ namespace CNORXZ for(six = 0; six != sie; ++six){ tix.at( f(*six) ); if(six.rank() == myrank){ - const SizeT idx = (tix.pos() - locsz*tix.rank() + tarsize) % tarsize; + //const SizeT idx = (tix.pos() - locsz*tix.rank() + tarsize) % tarsize; + const SizeT idx = (tix.pos() - locsz*myrank + tarsize) % tarsize; + //const SizeT idx = tix.pos(); (*m)[six.local()->pos()] = idx; } } @@ -46,7 +48,9 @@ namespace CNORXZ << mapsize << ", expected " << six.pmax().val()); for(six = 0; six != sie; ++six){ tix.at( f(*six) ); - const SizeT idx = (tix.pos() - locsz*tix.rank() + tarsize) % tarsize; + //const SizeT idx = (tix.pos() - locsz*tix.rank() + tarsize) % tarsize; + const SizeT idx = (tix.pos() - locsz*myrank + tarsize) % tarsize; + //const SizeT idx = tix.pos() (*m)[six.pos()] = idx; } } diff --git a/src/opt/mpi/include/rmap_xpr.h b/src/opt/mpi/include/rmap_xpr.h index a3786e8..2f435fd 100644 --- a/src/opt/mpi/include/rmap_xpr.h +++ b/src/opt/mpi/include/rmap_xpr.h @@ -20,6 +20,7 @@ namespace CNORXZ template struct MapSetup,SrcIndex,F> { + // CAUTION: This needs to be aware of entire geometry!!! static void setup(const Sptr>& ti, const Sptr& si, const F& f, const Sptr>& m); diff --git a/src/opt/mpi/tests/roperation_unit_test.cc b/src/opt/mpi/tests/roperation_unit_test.cc index ce9b17b..917758d 100644 --- a/src/opt/mpi/tests/roperation_unit_test.cc +++ b/src/opt/mpi/tests/roperation_unit_test.cc @@ -57,11 +57,12 @@ namespace mMRange = ltr*ll1r*ll2r*ll3r*scr; Vector data(mMRange->size()); Vector data2(mMRange->size()); + Double xxx = 1; for(SizeT i = 0; i != mRXRange->sub(1)->size(); ++i){ for(SizeT j = 0; j != scr->size(); ++j){ const SizeT k = i*scr->size() + j; - data[k] = vec[i] * static_cast(j+2); - data2[k] = vec[i] / static_cast(j+2); + data[k] = vec[i] * static_cast(j+2) + (xxx += 3*mpi::getRankNumber()); + data2[k] = vec[i] / static_cast(j+2) + (xxx += 5*mpi::getRankNumber()); if(k > 0){ assert(data[k] != data[k-1]); } @@ -108,8 +109,14 @@ namespace TEST_F(ROp_Test, Check) { EXPECT_EQ(mM1.size(), mM2.size()); + EXPECT_EQ(mM1.size(), mAll1.size()); + for(auto i = mM1.begin(); i.lex() != i.lmax().val(); ++i){ + const auto a1 = *i; + const auto a2 = mAll1[i.lex()]; + EXPECT_EQ(a1, a2); + } } - + TEST_F(ROp_Test, Difference) { RArray res( MArray(mM1.range()->sub(1)), mGeom ); @@ -131,7 +138,7 @@ namespace (std::get<2>(vec)+1)%L, (std::get<3>(vec)+1)%L); } ); Vector req(xp->range()->size(), false); for(const auto& r: *imap1){ - req[r] = true; + req[(r+mpi::getRankNumber()*16*12*12*12/4)%req.size()] = true; } res.load(x, AB, req); // DUMMY, not used... mM1.load(xp, AB, req); @@ -161,7 +168,7 @@ namespace EXPECT_EQ(a1, a2); } } - + TEST_F(ROp_Test, Contract) { Vector comp(mRXRange->size());