Changeset 1938 for XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution
- Timestamp:
- 09/22/20 16:28:47 (4 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp
r1930 r1938 1 1 #include "grid_remote_connector.hpp" 2 2 #include "client_client_dht_template.hpp" 3 #include "mpi.hpp" 3 4 4 5 … … 7 8 { 8 9 9 CGridRemoteConnector::CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm )10 : srcView_(srcView), dstView_(dstView), localComm_(localComm) 10 CGridRemoteConnector::CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) 11 : srcView_(srcView), dstView_(dstView), localComm_(localComm), remoteSize_(remoteSize) 11 12 {} 12 13 … … 74 75 75 76 CClientClientDHTTemplate<int> dataRanks(dataInfo, localComm_) ; 76 /* 77 CClientClientDHTTemplate<int>::Index2VectorInfoTypeMap info ; // info map 78 79 // generate list of global index for dst view, and insert it into DHT map 80 int nDst = dstView_.size() ; 81 vector<size_t> dstGlobalIndex ; 82 vector<size_t> dstSliceSize(nDst) ; 83 dstSliceSize[nDst-1] = 1 ; 84 for(int i=nDst-2; i>=0; i--) dstSliceSize[i] = dstView_[i+1]->getGlobalSize()*dstSliceSize[i+1] ; 85 for(auto& ranks : dstView_[0]->getLocalSize()) 86 { 87 dstGlobalIndex.clear() ; 88 int rank=ranks.first ; 89 size_t sliceIndex=0 ; 90 dstView_[nDst-1]->getGlobalIndex(rank, dstGlobalIndex, sliceIndex, dstSliceSize.data(), dstView_.data(), nDst-1) ; 91 for(auto globalIndex : dstGlobalIndex) info[globalIndex].push_back(rank) ; // insert into DHT 92 } 93 94 CClientClientDHTTemplate<int> dataRanks(info, localComm_) ; 95 */ 77 96 78 // generate list of global index for src view 97 79 int nSrc = srcView_.size() ; 98 80 vector<size_t> srcSliceSize(nSrc) ; 99 // srcSliceSize[nSrc-1] = 1 ;100 // for(int i=nSrc-2; i>=0; i--) srcSliceSize[i] = srcView_[i+1]->getGlobalSize()*srcSliceSize[i+1] ;101 81 102 82 srcSliceSize[0] = 1 ; … … 112 92 113 93 vector<map<int, set<size_t>>> elements(nSrc) ; // internal representation of elements composing the grid 114 115 // srcSliceSize[nSrc-1] = srcView_[nSrc-1]->getGlobalSize() ;116 // for(int i=nSrc-2 ; i>=0 ; i--) srcSliceSize[i] = srcView_[i]->getGlobalSize()*srcSliceSize[i+1] ;117 94 118 95 for(auto& indRanks : returnInfo) … … 143 120 } 144 121 } 122 123 // So what about when there is some server that have no data to receive 124 // they must be inform they receive an event with no data. 125 // So find remote servers with no data, and one client will take in charge 126 // that it receive global index with no data (0-size) 127 vector<int> ranks(remoteSize_,0) ; 128 for(auto& it : elements_[0]) ranks[it.first] = 1 ; 129 MPI_Allreduce(MPI_IN_PLACE, ranks.data(), remoteSize_, MPI_INT, MPI_SUM, localComm_) ; 130 int commRank, commSize ; 131 MPI_Comm_rank(localComm_,&commRank) ; 132 MPI_Comm_size(localComm_,&commSize) ; 133 int pos=0 ; 134 for(int i=0; i<remoteSize_ ; i++) 135 if (ranks[i]==0) 136 { 137 if (pos%commSize==commRank) for(auto& element : elements_) element[i] = CArray<size_t,1>(0) ; 138 pos++ ; 139 } 145 140 } 146 141 142 147 143 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp
r1918 r1938 18 18 public: 19 19 20 CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm ) ;20 CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) ; 21 21 void computeConnector(void) ; 22 22 void computeGenericMethod(void) ; … … 28 28 vector<CDistributedView*> dstView_ ; 29 29 MPI_Comm localComm_ ; 30 int remoteSize_ ; 30 31 31 32 } ;
Note: See TracChangeset
for help on using the changeset viewer.