From e65635cb0e015f13b6af8db1b9293f18bb1bbe78 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 27 Mar 2024 00:28:32 +0100 Subject: [PATCH] im com --- src/opt/mpi/include/rarray.cc.h | 38 +++++++++++++++++++++++++++++++++ src/opt/mpi/include/rarray.h | 9 ++++++++ 2 files changed, 47 insertions(+) diff --git a/src/opt/mpi/include/rarray.cc.h b/src/opt/mpi/include/rarray.cc.h index 9ef65a4..3e3002a 100644 --- a/src/opt/mpi/include/rarray.cc.h +++ b/src/opt/mpi/include/rarray.cc.h @@ -191,6 +191,44 @@ namespace CNORXZ { 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 + template + void RCArray::load(const Sptr& i1, const Sptr& i2) const + { + const SizeT rsize = getRankedSize(mGeom); + if(mMap.size() != rsize){ + mMap.resize(rsize); + } + const SizeT block = ; // size of un-ranked range + Vector 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 CNORXZ diff --git a/src/opt/mpi/include/rarray.h b/src/opt/mpi/include/rarray.h index b5dfe75..9b27696 100644 --- a/src/opt/mpi/include/rarray.h +++ b/src/opt/mpi/include/rarray.h @@ -109,11 +109,20 @@ namespace CNORXZ /** Get rank geometry. */ 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 + void load(const Sptr& i1, const Sptr& i2) const; private: ObjHandle> mA; RangePtr mGeom; RangePtr mGlobal; + mutable Vector mBuf; // data from other ranks + mutable Vector mMap; // point to positions in mA or mBuf }; /** ****