Ignore:
Timestamp:
09/22/20 16:28:47 (4 years ago)
Author:
ymipsl
Message:

XIOS Coupling branch : Solve spurious situation :

  • when client have no data on their local grid or local grid is 0 sized
  • when sever have no data on their local grid or local grid is 0 sized
  • holes in grid (missing global point) that cover a full client or a full server

YM

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  
    11#include "grid_remote_connector.hpp" 
    22#include "client_client_dht_template.hpp" 
     3#include "mpi.hpp" 
    34 
    45 
     
    78{ 
    89   
    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)  
    1112  {} 
    1213 
     
    7475 
    7576    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 
    9678    // generate list of global index for src view 
    9779    int nSrc = srcView_.size() ; 
    9880    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] ; 
    10181    
    10282    srcSliceSize[0] = 1 ;   
     
    11292 
    11393    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] ; 
    11794 
    11895    for(auto& indRanks : returnInfo) 
     
    143120      } 
    144121    } 
     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      } 
    145140  } 
    146141 
     142 
    147143} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp

    r1918 r1938  
    1818    public: 
    1919 
    20       CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm) ; 
     20      CGridRemoteConnector(vector<CLocalView*>& srcView, vector<CDistributedView*>& dstView, MPI_Comm localComm, int remoteSize) ; 
    2121      void computeConnector(void) ; 
    2222      void computeGenericMethod(void) ; 
     
    2828      vector<CDistributedView*> dstView_ ; 
    2929      MPI_Comm localComm_ ; 
     30      int remoteSize_ ; 
    3031 
    3132  } ; 
Note: See TracChangeset for help on using the changeset viewer.