- Timestamp:
- 03/22/18 10:43:20 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/server_distribution_description.cpp
r887 r1460 29 29 { /* Nothing to do */ } 30 30 31 int CServerDistributionDescription::defaultDistributedDimension(int gridDimension, 32 ServerDistributionType serType) 33 { 34 switch (serType) 35 { 36 case BAND_DISTRIBUTION: 37 return ((1 == gridDimension) ? 0 : 1); 38 break; 39 default: 40 break; 41 } 42 } 43 31 44 /*! 32 45 Compute pre-defined global index distribution of server(s). … … 100 113 \param [in] positionDimensionDistributed dimension of server on which we make the cut. 101 114 */ 102 voidCServerDistributionDescription::computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd,115 std::vector<int> CServerDistributionDescription::computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, 103 116 int positionDimensionDistributed) 104 117 { 105 switch (serverType_) { 118 int nBand = 0; 119 switch (serverType_) 120 { 106 121 case BAND_DISTRIBUTION: 107 computeBandDistribution(nServer_, positionDimensionDistributed); 108 break; 122 nBand = computeBandDistribution(nServer_, positionDimensionDistributed); 123 break; 124 case ROOT_DISTRIBUTION: 125 nBand = computeRootDistribution(nServer_); 109 126 default: 110 127 break; … … 122 139 std::vector<int> currentIndex(dim); 123 140 124 for (int idxServer = 0; idxServer < n Server_; ++idxServer)141 for (int idxServer = 0; idxServer < nBand; ++idxServer) 125 142 { 126 143 size_t ssize = 1, idx = 0; … … 161 178 } 162 179 } 180 181 // List of servers without distribution (cause total number of server is greater than number of bands, for example) 182 std::vector<int> zeroIndexServer(nServer_-nBand); 183 for (int idxServer = nBand; idxServer < nServer_; ++idxServer) 184 zeroIndexServer[idxServer-nBand] = idxServer; 185 186 return zeroIndexServer; 163 187 } 164 188 … … 172 196 \param [in] positionDimensionDistributed dimension of server on which we make the cut. 173 197 */ 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 { 198 std::vector<int> CServerDistributionDescription::computeServerGlobalByElement(std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement, 199 int clientRank, 200 int clientSize, 201 const CArray<int,1>& axisDomainOrder, 202 int positionDimensionDistributed) 203 { 204 int nBand = 0; 180 205 switch (serverType_) { 181 206 case BAND_DISTRIBUTION: 182 computeBandDistribution(nServer_, positionDimensionDistributed);207 nBand = computeBandDistribution(nServer_, positionDimensionDistributed); 183 208 break; 184 209 default: … … 194 219 idxMap[i] = idx; 195 220 if (2 == axisDomainOrder(i)) idx += 2; 196 else ++idx; 197 } 198 199 for (int idxServer = 0; idxServer < nServer_; ++idxServer) 221 else if (1 == axisDomainOrder(i)) idx += 1; 222 // nothing for scalar 223 } 224 225 for (int idxServer = 0; idxServer < nBand; ++idxServer) 200 226 { 201 227 std::vector<int> elementDimension(4); … … 247 273 } 248 274 } 275 276 // List of servers without distribution (cause total number of server is greater than number of bands, for example) 277 std::vector<int> zeroIndexServer(nServer_-nBand); 278 for (int idxServer = nBand; idxServer < nServer_; ++idxServer) 279 zeroIndexServer[idxServer-nBand] = idxServer; 280 281 return zeroIndexServer; 249 282 } 250 283 … … 297 330 \param [in] nServer number of server 298 331 */ 299 voidCServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed)332 int CServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed) 300 333 { 301 334 int dim = nGlobal_.size(); … … 324 357 int positionDistributed = (1<dim) ? positionDimensionDistributed_ : 0; 325 358 nGlobTemp = nGlobal_[positionDistributed]; 326 327 for (int i = 0; i < nServer; ++i) 359 int nbBand = std::min(nGlobTemp, nServer); 360 361 for (int i = 0; i < nbBand; ++i) 328 362 { 329 363 if (0 < i) njRangeBegin[i] = njRangeEnd[i-1]; 330 njRangeSize = nGlobTemp / n Server;331 if (i < nGlobTemp%n Server) ++njRangeSize;364 njRangeSize = nGlobTemp / nbBand; 365 if (i < nGlobTemp%nbBand) ++njRangeSize; 332 366 njRangeEnd[i] = njRangeSize + njRangeBegin[i]; 333 367 } 334 njRangeEnd[nServer-1] = nGlobTemp; 368 njRangeEnd[nbBand-1] = nGlobTemp; 369 370 for (int i = nbBand; i < nServer; ++i) 371 { 372 njRangeBegin[i] = njRangeEnd[i] = 0; 373 } 335 374 336 375 for (int i = 0; i < nServer; ++i) … … 358 397 } 359 398 } 360 } 399 400 return nbBand; 401 } 402 403 404 /*! 405 Compute global index of servers with root distribution : only root server will received data 406 \param [in] nServer number of server 407 */ 408 int CServerDistributionDescription::computeRootDistribution(int nServer, int positionDimensionDistributed) 409 { 410 int dim = nGlobal_.size(); 411 positionDimensionDistributed_ = positionDimensionDistributed; 412 if (1 == dim) positionDimensionDistributed_ = 0; 413 if (positionDimensionDistributed_ > dim) 414 ERROR("CServerDistributionDescription::computeBandDistribution(int nServer, int positionDimensionDistributed)", 415 << "Position of distributed dimension is invalid" << std::endl 416 << "Position of distributed dimension is " << positionDimensionDistributed_ 417 << "Dimension " << dim) 418 419 indexBegin_.resize(nServer); 420 dimensionSizes_.resize(nServer); 421 422 for (int i = 0; i< nServer; ++i) 423 { 424 indexBegin_[i].resize(dim); 425 dimensionSizes_[i].resize(dim); 426 } 427 428 int nGlobTemp = 0; 429 430 int positionDistributed = (1<dim) ? positionDimensionDistributed_ : 0; 431 nGlobTemp = nGlobal_[positionDistributed]; 432 int nbBand = 1 ; 433 434 435 for (int i = 0; i < nServer; ++i) 436 { 437 for (int j = 0; j < dim; ++j) 438 { 439 if (positionDistributed != j) // bad coding, need to be rewrite 440 { 441 if (1 == dim) 442 { 443 if (i==0) 444 { 445 indexBegin_[i][j] = 0; 446 dimensionSizes_[i][j] = nGlobTemp; 447 } 448 else 449 { 450 indexBegin_[i][j] = nGlobTemp-1; 451 dimensionSizes_[i][j] = 0; 452 } 453 } 454 else 455 { 456 indexBegin_[i][j] = 0; 457 dimensionSizes_[i][j] = nGlobal_[j]; 458 } 459 } 460 else 461 { 462 if (i==0) 463 { 464 indexBegin_[i][j] = 0; 465 dimensionSizes_[i][j] = nGlobTemp; 466 } 467 else 468 { 469 indexBegin_[i][j] = nGlobTemp-1; 470 dimensionSizes_[i][j] = 0; 471 } 472 } 473 } 474 } 475 476 return nbBand; 477 } 478 479 480 361 481 362 482 /*!
Note: See TracChangeset
for help on using the changeset viewer.