This commit is contained in:
Christian Zimmermann 2024-03-27 00:28:32 +01:00
parent c972a9db52
commit e65635cb0e
2 changed files with 47 additions and 0 deletions

View file

@ -192,6 +192,44 @@ namespace CNORXZ
return mGeom; return mGeom;
} }
SizeT getRankedSize(const RangePtr& r, const RangePtr& x)
{
SizeT rsize = 1;
for(SizeT mu = 0; mu != r->dim(); ++mu){
const RangePtr s = r->sub(mu);
const RangePtr y = x->sub(mu);
if(s->size() > 1){
rsize *= getRankedSize(s,y);
}
else {
}
}
return rsize;
}
template <typename T>
template <class Index1, class Index2>
void RCArray<T>::load(const Sptr<Index1>& i1, const Sptr<Index2>& i2) const
{
const SizeT rsize = getRankedSize(mGeom);
if(mMap.size() != rsize){
mMap.resize(rsize);
}
const SizeT block = ; // size of un-ranked range
Vector<T> sendbuf;
SizeT sendc = 0;
SizeT recvc = 0;
// make src-tar-map!!!
i1->ifor( operation( [](const SizeT ptar, const SizeT psrc) {
const SizeT sendr = psrc/mA.size();
const SizeT recvr = ptar/mA.size();
if(sendr == getRankNumber()) { }
if(recvr == getRankNumber()) { }
}, pos(i1), pos(i2) ) );
// MPI_Sendrecv()!!!
}
} // namespace mpi } // namespace mpi
} // namespace CNORXZ } // namespace CNORXZ

View file

@ -110,10 +110,19 @@ namespace CNORXZ
/** Get rank geometry. */ /** Get rank geometry. */
RangePtr geom() const; RangePtr geom() const;
/** Load all data from other ranks that is accessed by i2 in a loop over i1.
@param i1 Loop index.
@param i2 Access index.
*/
template <class Index1, class Index2>
void load(const Sptr<Index1>& i1, const Sptr<Index2>& i2) const;
private: private:
ObjHandle<CArrayBase<T>> mA; ObjHandle<CArrayBase<T>> mA;
RangePtr mGeom; RangePtr mGeom;
RangePtr mGlobal; RangePtr mGlobal;
mutable Vector<T> mBuf; // data from other ranks
mutable Vector<const T*> mMap; // point to positions in mA or mBuf
}; };
/** **** /** ****