Changeset 1938


Ignore:
Timestamp:
09/22/20 16:28:47 (12 months 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
Files:
5 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  } ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp

    r1934 r1938  
    18401840      gathererConnector_->transfer(event, 2, value, 0.);  
    18411841      bounds.resize(2,n) ; 
    1842       bounds=CArray<double,2>(bounds.dataFirst(),shape(2,n),neverDeleteData) ;  
     1842      if (bounds.numElements() > 0 ) bounds=CArray<double,2>(bounds.dataFirst(),shape(2,n),neverDeleteData) ;  
    18431843    } 
    18441844    else if (type=="label") 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r1934 r1938  
    22752275        for(int rank : ranks) vectGlobalIndex[rank].push_back(index) ; 
    22762276      } 
    2277       for(auto& vect : vectGlobalIndex ) globalIndex.emplace(vect.first, CArray<size_t,1>(vect.second.data(), shape(vect.second.size()),duplicateData)) ;  
     2277      for(auto& vect : vectGlobalIndex ) globalIndex.emplace(vect.first, CArray<size_t,1>(vect.second.data(), shape(vect.second.size()),duplicateData)) ; 
     2278    // some servers receves no index (zeroIndex array) => root process take them into account. 
     2279      if (context->getIntraCommRank()==0)  
     2280        for(auto& rank : zeroIndex) globalIndex[rank] = CArray<size_t,1>() ;  
    22782281    } 
    22792282    else if (type==EDistributionType::NONE) // domain is not distributed ie all servers get the same local domain 
     
    25002503      gathererConnector_->transfer(event, value, 0.);  
    25012504      lonvalue_2d.resize(ni,nj) ; 
    2502       lonvalue_2d=CArray<double,2>(value.dataFirst(),shape(ni,nj),neverDeleteData) ;  
     2505      if (lonvalue_2d.numElements()>0) lonvalue_2d=CArray<double,2>(value.dataFirst(),shape(ni,nj),neverDeleteData) ;  
    25032506    } 
    25042507    else if (type=="lat") 
     
    25072510      gathererConnector_->transfer(event, value, 0.);  
    25082511      latvalue_2d.resize(ni,nj) ; 
    2509       latvalue_2d=CArray<double,2>(value.dataFirst(),shape(ni,nj),neverDeleteData) ;  
     2512      if (latvalue_2d.numElements()>0) latvalue_2d=CArray<double,2>(value.dataFirst(),shape(ni,nj),neverDeleteData) ;  
    25102513    } 
    25112514    else if (type=="boundslon") 
     
    25142517      gathererConnector_->transfer(event, nvertex, value, 0.);  
    25152518      bounds_lon_2d.resize(nvertex,ni,nj) ; 
    2516       bounds_lon_2d=CArray<double,3>(value.dataFirst(),shape(nvertex,ni,nj),neverDeleteData) ;  
     2519      if (bounds_lon_2d.numElements()>0) bounds_lon_2d=CArray<double,3>(value.dataFirst(),shape(nvertex,ni,nj),neverDeleteData) ;  
    25172520    } 
    25182521    else if (type=="boundslat") 
     
    25212524      gathererConnector_->transfer(event, nvertex, value, 0.);  
    25222525      bounds_lat_2d.resize(nvertex,ni,nj) ; 
    2523       bounds_lat_2d=CArray<double,3>(value.dataFirst(),shape(nvertex,ni,nj),neverDeleteData) ;  
     2526      if (bounds_lat_2d.numElements()>0) bounds_lat_2d=CArray<double,3>(value.dataFirst(),shape(nvertex,ni,nj),neverDeleteData) ;  
    25242527    } 
    25252528    else if (type=="area")  
     
    25282531      gathererConnector_->transfer(event, value, 0.);  
    25292532      area.resize(ni,nj) ; 
    2530       area=CArray<double,2>(value.dataFirst(),shape(ni,nj),neverDeleteData) ;  
     2533      if (area.numElements()>0) area=CArray<double,2>(value.dataFirst(),shape(ni,nj),neverDeleteData) ;  
    25312534    } 
    25322535  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r1934 r1938  
    26682668      } 
    26692669    } 
    2670     CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm()) ; 
     2670    CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
    26712671    gridRemoteConnector.computeConnector() ; 
    26722672     
     
    27542754      } 
    27552755    } 
    2756     CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm()) ; 
     2756    CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
    27572757    gridRemoteConnector.computeConnector() ; 
    27582758     
Note: See TracChangeset for help on using the changeset viewer.