mpi: raindex: fixes + hdf5_mpi: improve unit test
This commit is contained in:
parent
54028c58b1
commit
ffec135eec
4 changed files with 30 additions and 10 deletions
|
@ -92,10 +92,10 @@ namespace CNORXZ
|
||||||
void RDataset::readbase(void* dest, RangePtr readRange, Sptr<YIndex> beg) const
|
void RDataset::readbase(void* dest, RangePtr readRange, Sptr<YIndex> beg) const
|
||||||
{
|
{
|
||||||
RangePtr dr = readRange;
|
RangePtr dr = readRange;
|
||||||
bool parallel = dr->stype() == "R";
|
|
||||||
if(not dr){
|
if(not dr){
|
||||||
dr = mFileRange;
|
dr = mFileRange;
|
||||||
}
|
}
|
||||||
|
bool parallel = dr->stype() == "R";
|
||||||
if(parallel){
|
if(parallel){
|
||||||
dr = readRange->sub(1);
|
dr = readRange->sub(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,15 +39,19 @@ namespace
|
||||||
mFilename = "parallel_test_file.h5";
|
mFilename = "parallel_test_file.h5";
|
||||||
Vector<RangePtr> grv(4);
|
Vector<RangePtr> grv(4);
|
||||||
grv[0] = CRangeFactory(5).create();
|
grv[0] = CRangeFactory(5).create();
|
||||||
grv[1] = CRangeFactory(14).create();
|
grv[1] = CRangeFactory(16).create();
|
||||||
grv[2] = CRangeFactory(10).create();
|
grv[2] = CRangeFactory(10).create();
|
||||||
grv[3] = CRangeFactory(3).create();
|
grv[3] = CRangeFactory(3).create();
|
||||||
const RangePtr g1 = CRangeFactory(1).create();
|
const RangePtr g1 = CRangeFactory(1).create();
|
||||||
const RangePtr g2 = CRangeFactory(2).create();
|
const RangePtr g2 = CRangeFactory(2).create();
|
||||||
|
const RangePtr g4 = CRangeFactory(4).create();
|
||||||
mGeom = yrange(Vector<RangePtr>{g1,g2,g2,g1});
|
mGeom = yrange(Vector<RangePtr>{g1,g2,g2,g1});
|
||||||
|
mGeom2 = yrange(Vector<RangePtr>{g1,g4,g1,g1});
|
||||||
const RangePtr gr = yrange(grv);
|
const RangePtr gr = yrange(grv);
|
||||||
const RangePtr rr = rrange(gr,mGeom);
|
const RangePtr rr = rrange(gr,mGeom);
|
||||||
mLR = rr->sub(1);
|
mLR = rr->sub(1);
|
||||||
|
const RangePtr rr2 = rrange(gr,mGeom2);
|
||||||
|
mLR2 = rr2->sub(1);
|
||||||
Vector<Double> vec = Numbers::get(14,gr->size()+10);
|
Vector<Double> vec = Numbers::get(14,gr->size()+10);
|
||||||
Vector<Double> loc(mLR->size());
|
Vector<Double> loc(mLR->size());
|
||||||
for(auto k = CIndex(mGeom); k.lex() != k.lmax().val(); ++k){
|
for(auto k = CIndex(mGeom); k.lex() != k.lmax().val(); ++k){
|
||||||
|
@ -57,11 +61,24 @@ namespace
|
||||||
}
|
}
|
||||||
auto locarr = MArray<Double>( mLR, loc );
|
auto locarr = MArray<Double>( mLR, loc );
|
||||||
mA = RArray<Double>( locarr, mGeom );
|
mA = RArray<Double>( locarr, mGeom );
|
||||||
|
auto rr2x = std::dynamic_pointer_cast<RRange<YRange,YRange>>(rr2);
|
||||||
|
assert(rr2x);
|
||||||
|
mA2 = RArray<Double>( 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<Double> mA;
|
RArray<Double> mA;
|
||||||
RangePtr mGeom;
|
RangePtr mGeom;
|
||||||
RangePtr mLR;
|
RangePtr mLR;
|
||||||
|
RArray<Double> mA2;
|
||||||
|
RangePtr mGeom2;
|
||||||
|
RangePtr mLR2;
|
||||||
String mFilename;
|
String mFilename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,11 +105,11 @@ namespace
|
||||||
//{ (*i)->close(); auto dset = std::make_shared<SRDataset<Double>>(name, par); *i = dset;
|
//{ (*i)->close(); auto dset = std::make_shared<SRDataset<Double>>(name, par); *i = dset;
|
||||||
// return dset; } );
|
// return dset; } );
|
||||||
auto dat = getRDataset<Double>(h5f.open().getGroup("dir")->open(),"dat");
|
auto dat = getRDataset<Double>(h5f.open().getGroup("dir")->open(),"dat");
|
||||||
auto a = dat->read(mGeom);
|
auto a = dat->read(mGeom2);
|
||||||
h5f.close();
|
h5f.close();
|
||||||
|
|
||||||
auto i = std::make_shared<CIndex>(mLR);
|
auto i = std::make_shared<CIndex>(mLR2);
|
||||||
i->ifor( operation( [](Double a, Double b) { EXPECT_EQ(a,b); }, mA(i), a(i) ), NoF{} )();
|
i->ifor( operation( [](Double a, Double b) { EXPECT_EQ(a,b); }, mA2(i), a(i) ), NoF{} )();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace CNORXZ
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename RIndex<YIndex,YIndex>::IB IB;
|
typedef typename RIndex<YIndex,YIndex>::IB IB;
|
||||||
|
using RIndex<YIndex,YIndex>::operator=;
|
||||||
|
|
||||||
DEFAULT_MEMBERS(RAIndex);
|
DEFAULT_MEMBERS(RAIndex);
|
||||||
RAIndex(const T* loc, const RangePtr& range, SizeT lexpos = 0);
|
RAIndex(const T* loc, const RangePtr& range, SizeT lexpos = 0);
|
||||||
|
@ -47,17 +48,18 @@ namespace CNORXZ
|
||||||
const T* operator->() const;
|
const T* operator->() const;
|
||||||
|
|
||||||
void setBufferSize();
|
void setBufferSize();
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void setBuffer() const;
|
private:
|
||||||
|
|
||||||
const T* mLoc = nullptr;
|
const T* mLoc = nullptr;
|
||||||
mutable Vector<T> mBuf; // used if iterating over content on different rank
|
mutable Vector<T> mBuf; // used if iterating over content on different rank
|
||||||
mutable SizeT mMin; // current global minimum position in the buffer
|
mutable SizeT mMin; // current global minimum position in the buffer
|
||||||
mutable SizeT mMax; // current global maximum position in the buffer
|
mutable SizeT mMax; // current global maximum position in the buffer
|
||||||
SizeT mBufSize;
|
SizeT mBufSize;
|
||||||
|
|
||||||
|
protected:
|
||||||
SizeT mThisRank;
|
SizeT mThisRank;
|
||||||
|
void setBuffer() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -66,6 +68,7 @@ namespace CNORXZ
|
||||||
public:
|
public:
|
||||||
typedef RAIndex<T> AI;
|
typedef RAIndex<T> AI;
|
||||||
typedef typename AI::IB IB;
|
typedef typename AI::IB IB;
|
||||||
|
using typename AI::operator=;
|
||||||
|
|
||||||
DEFAULT_MEMBERS(RBIndex);
|
DEFAULT_MEMBERS(RBIndex);
|
||||||
RBIndex(T* loc, const RangePtr& range, SizeT lexpos = 0);
|
RBIndex(T* loc, const RangePtr& range, SizeT lexpos = 0);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace CNORXZ
|
||||||
YIndex ke(geom, geom->size());
|
YIndex ke(geom, geom->size());
|
||||||
auto mu = std::make_shared<CIndex>(geom->sub().range());
|
auto mu = std::make_shared<CIndex>(geom->sub().range());
|
||||||
MArray<MArray<RangePtr>> rs(geom->sub().range());
|
MArray<MArray<RangePtr>> 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<RangePtr> elem(geom->dim());
|
Vector<RangePtr> elem(geom->dim());
|
||||||
for(; k != ke; ++k){
|
for(; k != ke; ++k){
|
||||||
mu->ifor( operation( [&](const SizeT i, const MArray<RangePtr>& el){
|
mu->ifor( operation( [&](const SizeT i, const MArray<RangePtr>& el){
|
||||||
|
|
Loading…
Reference in a new issue