Ignore:
Timestamp:
01/26/16 18:18:58 (8 years ago)
Author:
mhnguyen
Message:

Fixing the bug in ticket 72

+) The distributed axis on client side send info to correct corresponding server
+) Improve serverdistributiondescription class to make it more flexible
+) Create new test_basic_2D only for test cases of 2-d grid

Test
+) On Curie
+) All tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/server_distribution_description.cpp

    r657 r815  
    33   \author Ha NGUYEN 
    44   \since 04 Jan 2015 
    5    \date 24 Jul 2015 
     5   \date 11 Jan 2016 
    66 
    77   \brief Description of index distribution on server(s). 
     
    1313namespace xios 
    1414{ 
    15 CServerDistributionDescription::CServerDistributionDescription(const std::vector<int>& globalDimensionSize) 
    16   : nGlobal_(globalDimensionSize), indexBegin_(), dimensionSizes_(), globalIndex_(), vecGlobalIndex_() 
     15  /*! 
     16  \param [in] globalDimensionSize global dimension of grid 
     17  \param [in] nServer number of server 
     18  \param [in] serType type of server distribution. For now, we can distribute server by band or plan 
     19  */ 
     20CServerDistributionDescription::CServerDistributionDescription(const std::vector<int>& globalDimensionSize, 
     21                                                               int nServer, 
     22                                                               ServerDistributionType serType) 
     23  : nGlobal_(globalDimensionSize), indexBegin_(), dimensionSizes_(), globalIndex_(), 
     24    vecGlobalIndex_(), serverType_(serType), nServer_(nServer), positionDimensionDistributed_(1) 
    1725{ 
    1826} 
     
    2331/*! 
    2432  Compute pre-defined global index distribution of server(s). 
    25   \param [in] nServer number of server 
    2633  \param [in] doComputeGlobalIndex flag to compute global index on each server. By default, false 
    27   \param [in] serType type of server distribution. For now, we can distribute server by band or plan 
    28 */ 
    29 void CServerDistributionDescription::computeServerDistribution(int nServer, 
    30                                                                int positionDimensionDistributed, 
    31                                                                bool doComputeGlobalIndex, 
    32                                                                ServerDistributionType serType) 
    33 { 
    34   switch (serType) { 
     34 
     35*/ 
     36void CServerDistributionDescription::computeServerDistribution(bool doComputeGlobalIndex, 
     37                                                               int positionDimensionDistributed) 
     38{ 
     39  switch (serverType_) { 
    3540    case BAND_DISTRIBUTION: 
    36       computeBandDistribution(nServer, positionDimensionDistributed); 
     41      computeBandDistribution(nServer_, positionDimensionDistributed); 
    3742      break; 
    3843    default: 
     
    4247  if (doComputeGlobalIndex) 
    4348  { 
    44     vecGlobalIndex_.resize(nServer); 
     49    vecGlobalIndex_.resize(nServer_); 
    4550    int dim = nGlobal_.size(); 
    4651    std::vector<int> currentIndex(dim); 
    4752 
    48     for (int idxServer = 0; idxServer < nServer; ++idxServer) 
     53    for (int idxServer = 0; idxServer < nServer_; ++idxServer) 
    4954    { 
    5055      size_t ssize = 1, idx = 0; 
     
    9297  Compute global index assigned to a server with a range.E.g: if a grid has 100 points and 
    9398  there are 2 servers, the first one takes index from 0 to 49, the second has index from 50 to 99 
    94   \param [in] nServer number of server 
     99 
    95100  \param [in] indexBeginEnd begining and ending index of range 
    96   \param [in] serType type of server distribution. For now, we can distribute server by band or plan 
    97 */ 
    98 void CServerDistributionDescription::computeServerGlobalIndexInRange(int nServer, 
    99                                                                      const std::pair<size_t, size_t>& indexBeginEnd, 
    100                                                                      int positionDimensionDistributed, 
    101                                                                      ServerDistributionType distributionType) 
    102 { 
    103   switch (distributionType) { 
     101*/ 
     102void CServerDistributionDescription::computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, 
     103                                                                     int positionDimensionDistributed) 
     104{ 
     105  switch (serverType_) { 
    104106    case BAND_DISTRIBUTION: 
    105       computeBandDistribution(nServer, positionDimensionDistributed); 
     107      computeBandDistribution(nServer_, positionDimensionDistributed); 
    106108      break; 
    107109    default: 
     
    118120  std::vector<int> currentIndex(dim); 
    119121 
    120   for (int idxServer = 0; idxServer < nServer; ++idxServer) 
     122  for (int idxServer = 0; idxServer < nServer_; ++idxServer) 
    121123  { 
    122124    size_t ssize = 1, idx = 0; 
     
    167169{ 
    168170  int dim = nGlobal_.size(); 
    169   if (positionDimensionDistributed > dim) 
     171  positionDimensionDistributed_ = positionDimensionDistributed; 
     172  if (1 == dim) positionDimensionDistributed_ = 0; 
     173  if (positionDimensionDistributed_ > dim) 
    170174    ERROR("CServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed)", 
    171175          << "Position of distributed dimension is invalid" << std::endl 
    172           << "Position of distributed dimension is " << positionDimensionDistributed 
     176          << "Position of distributed dimension is " << positionDimensionDistributed_ 
    173177          << "Dimension " << dim) 
    174178 
     
    187191  std::vector<int> njRangeEnd(nServer,0); 
    188192 
    189   int positionDistributed = (1<dim) ? positionDimensionDistributed : 0; 
     193  int positionDistributed = (1<dim) ? positionDimensionDistributed_ : 0; 
    190194  nGlobTemp = nGlobal_[positionDistributed]; 
    191195 
     
    259263  return globalIndex_; 
    260264} 
     265 
     266int CServerDistributionDescription::getDimensionDistributed() 
     267{ 
     268  return ((1<nGlobal_.size()) ? positionDimensionDistributed_ : 0); 
     269} 
     270 
    261271} // namespace xios 
Note: See TracChangeset for help on using the changeset viewer.