[1918] | 1 | #include "remote_connector.hpp" |
---|
| 2 | #include "client_client_dht_template.hpp" |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | namespace xios |
---|
| 6 | { |
---|
| 7 | |
---|
| 8 | void CRemoteConnector::computeConnector(void) |
---|
| 9 | { |
---|
| 10 | CClientClientDHTTemplate<int>::Index2VectorInfoTypeMap info ; |
---|
| 11 | for(auto& dstIndex : dstView_->getIndex()) |
---|
| 12 | { |
---|
| 13 | int rank=dstIndex.first ; |
---|
| 14 | auto& indexList=dstIndex.second ; |
---|
| 15 | auto& globalIndex = dstView_->getGlobalIndex()[rank] ; |
---|
| 16 | for(int i=0;i<indexList.numElements();i++) info[globalIndex(indexList(i))].push_back(rank) ; |
---|
| 17 | } |
---|
| 18 | CClientClientDHTTemplate<int> dataRanks(info, localComm_) ; |
---|
| 19 | |
---|
| 20 | set<size_t> setGlobalIndex ; // all global index from src |
---|
| 21 | auto& srcIndex = srcView_->getIndex() ; |
---|
| 22 | auto& globalIndex = srcView_->getGlobalIndex() ; |
---|
| 23 | int globalIndexSize = globalIndex.numElements() ; |
---|
| 24 | int indexSize = srcIndex.numElements() ; |
---|
| 25 | for(int i=0;i<indexSize;i++) |
---|
| 26 | { |
---|
| 27 | if (srcIndex(i)>=0 & srcIndex(i)<globalIndexSize) setGlobalIndex.insert(globalIndex(srcIndex(i))) ; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | CArray<size_t,1> srcGlobalIndex(setGlobalIndex.size()) ; |
---|
| 31 | int i=0 ; |
---|
| 32 | for(auto& globalIndex : setGlobalIndex) |
---|
| 33 | { |
---|
| 34 | srcGlobalIndex(i) = globalIndex ; |
---|
| 35 | i++ ; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | dataRanks.computeIndexInfoMapping(srcGlobalIndex) ; |
---|
| 39 | const auto& returnInfo = dataRanks.getInfoIndexMap() ; |
---|
| 40 | |
---|
| 41 | // so we have the info where to send data : rank and local index. |
---|
| 42 | // create the interconnector : |
---|
| 43 | map<int,vector<size_t>> element ; |
---|
| 44 | for(int i=0;i<indexSize;i++) |
---|
| 45 | { |
---|
| 46 | if (srcIndex(i)>=0 & srcIndex(i)<globalIndexSize) |
---|
| 47 | { |
---|
| 48 | size_t indGlo = globalIndex(srcIndex(i)) ; |
---|
| 49 | // don't forget that a single point can be sent multiple time (redondency ?) |
---|
| 50 | for(auto& rank : returnInfo.at(indGlo)) |
---|
| 51 | { |
---|
| 52 | connector_[rank].push_back(i) ; |
---|
| 53 | element[rank].push_back(indGlo) ; |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | for(auto rankIndex : element) |
---|
| 59 | { |
---|
| 60 | CArray<size_t,1> arrayTmp(rankIndex.second.data(), shape(rankIndex.second.size()), duplicateData) ; |
---|
| 61 | element_[rankIndex.first].reference(arrayTmp) ; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | // compute the number of senders for a remote destination view |
---|
| 65 | int commSize ; |
---|
| 66 | MPI_Comm_size(localComm_, &commSize) ; |
---|
| 67 | vector<int> ranks(commSize,0) ; |
---|
| 68 | for(auto& rank : connector_) ranks[rank.first] = 1 ; |
---|
| 69 | MPI_Allreduce(MPI_IN_PLACE,ranks.data(),commSize,MPI_INT,MPI_SUM,localComm_) ; |
---|
| 70 | for(auto& rank : connector_) nbSenders_[rank.first] = ranks[rank.first] ; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | } |
---|