diff --git a/src/opt/hdf5_mpi/lib/h5_rdataset.cc b/src/opt/hdf5_mpi/lib/h5_rdataset.cc index 5936c55..327fd2b 100644 --- a/src/opt/hdf5_mpi/lib/h5_rdataset.cc +++ b/src/opt/hdf5_mpi/lib/h5_rdataset.cc @@ -92,10 +92,10 @@ namespace CNORXZ void RDataset::readbase(void* dest, RangePtr readRange, Sptr beg) const { RangePtr dr = readRange; - bool parallel = dr->stype() == "R"; if(not dr){ dr = mFileRange; } + bool parallel = dr->stype() == "R"; if(parallel){ dr = readRange->sub(1); } diff --git a/src/opt/hdf5_mpi/tests/h5_mpi_basic_unit_test.cc b/src/opt/hdf5_mpi/tests/h5_mpi_basic_unit_test.cc index 7eb0cc7..3ce83dd 100644 --- a/src/opt/hdf5_mpi/tests/h5_mpi_basic_unit_test.cc +++ b/src/opt/hdf5_mpi/tests/h5_mpi_basic_unit_test.cc @@ -39,15 +39,19 @@ namespace mFilename = "parallel_test_file.h5"; Vector grv(4); grv[0] = CRangeFactory(5).create(); - grv[1] = CRangeFactory(14).create(); + grv[1] = CRangeFactory(16).create(); grv[2] = CRangeFactory(10).create(); grv[3] = CRangeFactory(3).create(); const RangePtr g1 = CRangeFactory(1).create(); const RangePtr g2 = CRangeFactory(2).create(); + const RangePtr g4 = CRangeFactory(4).create(); mGeom = yrange(Vector{g1,g2,g2,g1}); + mGeom2 = yrange(Vector{g1,g4,g1,g1}); const RangePtr gr = yrange(grv); const RangePtr rr = rrange(gr,mGeom); mLR = rr->sub(1); + const RangePtr rr2 = rrange(gr,mGeom2); + mLR2 = rr2->sub(1); Vector vec = Numbers::get(14,gr->size()+10); Vector loc(mLR->size()); for(auto k = CIndex(mGeom); k.lex() != k.lmax().val(); ++k){ @@ -57,11 +61,24 @@ namespace } auto locarr = MArray( mLR, loc ); mA = RArray( locarr, mGeom ); + auto rr2x = std::dynamic_pointer_cast>(rr2); + assert(rr2x); + mA2 = RArray( rr2x ); + auto i1 = mA.begin(); + auto i2 = mA2.begin(); + assert(i1.lmax().val() == i2.lmax().val()); + for(i1 = 0; i1.lex() != i1.lmax().val(); ++i1){ + i2 = i1.lex(); + i2.set( *i1 ); + } } RArray mA; RangePtr mGeom; RangePtr mLR; + RArray mA2; + RangePtr mGeom2; + RangePtr mLR2; String mFilename; }; @@ -88,11 +105,11 @@ namespace //{ (*i)->close(); auto dset = std::make_shared>(name, par); *i = dset; // return dset; } ); auto dat = getRDataset(h5f.open().getGroup("dir")->open(),"dat"); - auto a = dat->read(mGeom); + auto a = dat->read(mGeom2); h5f.close(); - auto i = std::make_shared(mLR); - i->ifor( operation( [](Double a, Double b) { EXPECT_EQ(a,b); }, mA(i), a(i) ), NoF{} )(); + auto i = std::make_shared(mLR2); + i->ifor( operation( [](Double a, Double b) { EXPECT_EQ(a,b); }, mA2(i), a(i) ), NoF{} )(); } } diff --git a/src/opt/mpi/include/raindex.h b/src/opt/mpi/include/raindex.h index b5d9f41..3d33366 100644 --- a/src/opt/mpi/include/raindex.h +++ b/src/opt/mpi/include/raindex.h @@ -34,6 +34,7 @@ namespace CNORXZ { public: typedef typename RIndex::IB IB; + using RIndex::operator=; DEFAULT_MEMBERS(RAIndex); RAIndex(const T* loc, const RangePtr& range, SizeT lexpos = 0); @@ -47,17 +48,18 @@ namespace CNORXZ const T* operator->() const; void setBufferSize(); - - private: - void setBuffer() const; - + private: const T* mLoc = nullptr; mutable Vector mBuf; // used if iterating over content on different rank mutable SizeT mMin; // current global minimum position in the buffer mutable SizeT mMax; // current global maximum position in the buffer SizeT mBufSize; + + protected: SizeT mThisRank; + void setBuffer() const; + }; template @@ -66,6 +68,7 @@ namespace CNORXZ public: typedef RAIndex AI; typedef typename AI::IB IB; + using typename AI::operator=; DEFAULT_MEMBERS(RBIndex); RBIndex(T* loc, const RangePtr& range, SizeT lexpos = 0); diff --git a/src/opt/mpi/lib/rrange.cc b/src/opt/mpi/lib/rrange.cc index b3e3976..1395e02 100644 --- a/src/opt/mpi/lib/rrange.cc +++ b/src/opt/mpi/lib/rrange.cc @@ -32,7 +32,7 @@ namespace CNORXZ YIndex ke(geom, geom->size()); auto mu = std::make_shared(geom->sub().range()); MArray> rs(geom->sub().range()); - rs(mu) = operation( [&](const SizeT i) { return rsplit(global->sub(i), geom->sub(i)); } , xpr(mu) ); + rs(mu) = operation( [&](const SizeT i) { return rsplit(global->savesub(i), geom->savesub(i)); } , xpr(mu) ); Vector elem(geom->dim()); for(; k != ke; ++k){ mu->ifor( operation( [&](const SizeT i, const MArray& el){