Ignore:
Timestamp:
07/31/17 17:59:25 (7 years ago)
Author:
mhnguyen
Message:

Fixing the blocking problem where there are more servers than the number of grid band distribution

+) Correct this problem not only for writing but also for reading
+) Allow "zero-size" domain, axis (i.e: domain, axis with ni = 0, and/or nj=0)

Test
+) On Curie
+) Work in both cases: Read and Write data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/server_distribution_description.cpp

    r887 r1232  
    100100  \param [in] positionDimensionDistributed dimension of server on which we make the cut. 
    101101*/ 
    102 void CServerDistributionDescription::computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, 
     102std::vector<int> CServerDistributionDescription::computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, 
    103103                                                                     int positionDimensionDistributed) 
    104104{ 
     105  int nBand  = 0; 
    105106  switch (serverType_) { 
    106107    case BAND_DISTRIBUTION: 
    107       computeBandDistribution(nServer_, positionDimensionDistributed); 
     108      nBand = computeBandDistribution(nServer_, positionDimensionDistributed); 
    108109      break; 
    109110    default: 
     
    122123  std::vector<int> currentIndex(dim); 
    123124 
    124   for (int idxServer = 0; idxServer < nServer_; ++idxServer) 
     125  for (int idxServer = 0; idxServer < nBand; ++idxServer) 
    125126  { 
    126127    size_t ssize = 1, idx = 0; 
     
    161162    } 
    162163  } 
     164 
     165    // List of servers without distribution (cause total number of server is greater than number of bands, for example) 
     166  std::vector<int> zeroIndexServer(nServer_-nBand);  
     167  for (int idxServer = nBand; idxServer < nServer_; ++idxServer) 
     168    zeroIndexServer[idxServer-nBand] = idxServer; 
     169 
     170  return zeroIndexServer; 
    163171} 
    164172 
     
    172180  \param [in] positionDimensionDistributed dimension of server on which we make the cut. 
    173181*/ 
    174 void CServerDistributionDescription::computeServerGlobalByElement(std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement, 
    175                                                                   int clientRank, 
    176                                                                   int clientSize, 
    177                                                                   const CArray<int,1>& axisDomainOrder, 
    178                                                                   int positionDimensionDistributed) 
    179 { 
     182std::vector<int> CServerDistributionDescription::computeServerGlobalByElement(std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement, 
     183                                                                              int clientRank, 
     184                                                                              int clientSize, 
     185                                                                              const CArray<int,1>& axisDomainOrder, 
     186                                                                              int positionDimensionDistributed) 
     187{ 
     188  int nBand  = 0; 
    180189  switch (serverType_) { 
    181190    case BAND_DISTRIBUTION: 
    182       computeBandDistribution(nServer_, positionDimensionDistributed); 
     191      nBand = computeBandDistribution(nServer_, positionDimensionDistributed); 
    183192      break; 
    184193    default: 
     
    197206  } 
    198207 
    199   for (int idxServer = 0; idxServer < nServer_; ++idxServer) 
     208  for (int idxServer = 0; idxServer < nBand; ++idxServer) 
    200209  { 
    201210    std::vector<int> elementDimension(4); 
     
    247256    } 
    248257  } 
     258 
     259  // List of servers without distribution (cause total number of server is greater than number of bands, for example) 
     260  std::vector<int> zeroIndexServer(nServer_-nBand);  
     261  for (int idxServer = nBand; idxServer < nServer_; ++idxServer) 
     262    zeroIndexServer[idxServer-nBand] = idxServer; 
     263 
     264  return zeroIndexServer; 
    249265} 
    250266 
     
    297313  \param [in] nServer number of server 
    298314*/ 
    299 void CServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed) 
     315int CServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed) 
    300316{ 
    301317  int dim = nGlobal_.size(); 
     
    324340  int positionDistributed = (1<dim) ? positionDimensionDistributed_ : 0; 
    325341  nGlobTemp = nGlobal_[positionDistributed]; 
    326  
    327   for (int i = 0; i < nServer; ++i) 
     342  int nbBand = std::min(nGlobTemp, nServer); 
     343 
     344  for (int i = 0; i < nbBand; ++i) 
    328345  { 
    329346    if (0 < i) njRangeBegin[i] = njRangeEnd[i-1]; 
    330     njRangeSize = nGlobTemp / nServer; 
    331     if (i < nGlobTemp%nServer) ++njRangeSize; 
     347    njRangeSize = nGlobTemp / nbBand; 
     348    if (i < nGlobTemp%nbBand) ++njRangeSize; 
    332349    njRangeEnd[i] = njRangeSize + njRangeBegin[i]; 
    333350  } 
    334   njRangeEnd[nServer-1] = nGlobTemp; 
     351  njRangeEnd[nbBand-1] = nGlobTemp; 
     352 
     353  for (int i = nbBand; i < nServer; ++i) 
     354  { 
     355    njRangeBegin[i] = njRangeEnd[i] = 0; 
     356  } 
    335357 
    336358  for (int i = 0; i < nServer; ++i) 
     
    358380    } 
    359381  } 
     382 
     383  return nbBand; 
    360384} 
    361385 
Note: See TracChangeset for help on using the changeset viewer.