Changeset 815 for XIOS/trunk/src/server_distribution_description.cpp
- Timestamp:
- 01/26/16 18:18:58 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/server_distribution_description.cpp
r657 r815 3 3 \author Ha NGUYEN 4 4 \since 04 Jan 2015 5 \date 24 Jul 20155 \date 11 Jan 2016 6 6 7 7 \brief Description of index distribution on server(s). … … 13 13 namespace xios 14 14 { 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 */ 20 CServerDistributionDescription::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) 17 25 { 18 26 } … … 23 31 /*! 24 32 Compute pre-defined global index distribution of server(s). 25 \param [in] nServer number of server26 33 \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 */ 36 void CServerDistributionDescription::computeServerDistribution(bool doComputeGlobalIndex, 37 int positionDimensionDistributed) 38 { 39 switch (serverType_) { 35 40 case BAND_DISTRIBUTION: 36 computeBandDistribution(nServer , positionDimensionDistributed);41 computeBandDistribution(nServer_, positionDimensionDistributed); 37 42 break; 38 43 default: … … 42 47 if (doComputeGlobalIndex) 43 48 { 44 vecGlobalIndex_.resize(nServer );49 vecGlobalIndex_.resize(nServer_); 45 50 int dim = nGlobal_.size(); 46 51 std::vector<int> currentIndex(dim); 47 52 48 for (int idxServer = 0; idxServer < nServer ; ++idxServer)53 for (int idxServer = 0; idxServer < nServer_; ++idxServer) 49 54 { 50 55 size_t ssize = 1, idx = 0; … … 92 97 Compute global index assigned to a server with a range.E.g: if a grid has 100 points and 93 98 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 95 100 \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 */ 102 void CServerDistributionDescription::computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, 103 int positionDimensionDistributed) 104 { 105 switch (serverType_) { 104 106 case BAND_DISTRIBUTION: 105 computeBandDistribution(nServer , positionDimensionDistributed);107 computeBandDistribution(nServer_, positionDimensionDistributed); 106 108 break; 107 109 default: … … 118 120 std::vector<int> currentIndex(dim); 119 121 120 for (int idxServer = 0; idxServer < nServer ; ++idxServer)122 for (int idxServer = 0; idxServer < nServer_; ++idxServer) 121 123 { 122 124 size_t ssize = 1, idx = 0; … … 167 169 { 168 170 int dim = nGlobal_.size(); 169 if (positionDimensionDistributed > dim) 171 positionDimensionDistributed_ = positionDimensionDistributed; 172 if (1 == dim) positionDimensionDistributed_ = 0; 173 if (positionDimensionDistributed_ > dim) 170 174 ERROR("CServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed)", 171 175 << "Position of distributed dimension is invalid" << std::endl 172 << "Position of distributed dimension is " << positionDimensionDistributed 176 << "Position of distributed dimension is " << positionDimensionDistributed_ 173 177 << "Dimension " << dim) 174 178 … … 187 191 std::vector<int> njRangeEnd(nServer,0); 188 192 189 int positionDistributed = (1<dim) ? positionDimensionDistributed : 0;193 int positionDistributed = (1<dim) ? positionDimensionDistributed_ : 0; 190 194 nGlobTemp = nGlobal_[positionDistributed]; 191 195 … … 259 263 return globalIndex_; 260 264 } 265 266 int CServerDistributionDescription::getDimensionDistributed() 267 { 268 return ((1<nGlobal_.size()) ? positionDimensionDistributed_ : 0); 269 } 270 261 271 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.