Changeset 815
- Timestamp:
- 01/26/16 18:18:58 (9 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/axis.cpp
r786 r815 351 351 { 352 352 sendServerAttribut(globalDim, orderPositionInGrid, distType); 353 sendValue( );353 sendValue(globalDim, orderPositionInGrid, distType); 354 354 } 355 355 … … 357 357 } 358 358 359 void CAxis::sendValue() 359 void CAxis::sendValue(const std::vector<int>& globalDim, int orderPositionInGrid, 360 CServerDistributionDescription::ServerDistributionType distType) 360 361 { 361 362 if (n.getValue() == n_glo.getValue()) … … 365 366 else 366 367 { 367 computeConnectedServer( );368 computeConnectedServer(globalDim, orderPositionInGrid, distType); 368 369 sendDistributedValue(); 369 370 } 370 371 } 371 372 372 void CAxis::computeConnectedServer() 373 void CAxis::computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 374 CServerDistributionDescription::ServerDistributionType distType) 373 375 { 374 376 CContext* context = CContext::getCurrent(); … … 418 420 } 419 421 420 std::vector<int> nGlobDomain(1); 421 nGlobDomain[0] = n_glo.getValue(); 422 423 size_t globalSizeIndex = 1, indexBegin, indexEnd; 424 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 425 indexBegin = 0; 426 for (int i = 0; i < clientSize; ++i) 427 { 428 range = globalSizeIndex / clientSize; 429 if (i < (globalSizeIndex%clientSize)) ++range; 430 if (i == client->clientRank) break; 431 indexBegin += range; 432 } 433 indexEnd = indexBegin + range - 1; 434 435 CServerDistributionDescription serverDescription(nGlobDomain); 436 serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 437 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 438 clientServerMap->computeServerIndexMapping(globalIndexAxis); 439 const std::map<int, std::vector<size_t> >& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 422 CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 423 int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 424 std::map<int, std::vector<size_t> > globalIndexAxisOnServer; 425 if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 426 { 427 std::vector<int> nGlobAxis(1); 428 nGlobAxis[0] = n_glo.getValue(); 429 430 size_t globalSizeIndex = 1, indexBegin, indexEnd; 431 for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 432 indexBegin = 0; 433 for (int i = 0; i < clientSize; ++i) 434 { 435 range = globalSizeIndex / clientSize; 436 if (i < (globalSizeIndex%clientSize)) ++range; 437 if (i == client->clientRank) break; 438 indexBegin += range; 439 } 440 indexEnd = indexBegin + range - 1; 441 442 CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 443 serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 444 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 445 clientServerMap->computeServerIndexMapping(globalIndexAxis); 446 globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 447 delete clientServerMap; 448 } 449 else 450 { 451 std::vector<size_t> globalIndexServer(n_glo.getValue()); 452 for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 453 { 454 globalIndexServer[idx] = idx; 455 } 456 457 for (int idx = 0; idx < nbServer; ++idx) 458 { 459 globalIndexAxisOnServer[idx] = globalIndexServer; 460 } 461 } 440 462 441 463 std::map<int, std::vector<size_t> >::const_iterator it = globalIndexAxisOnServer.begin(), … … 476 498 connectedServerRank_.push_back(it->first); 477 499 } 478 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 479 delete clientServerMap; 500 nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 480 501 } 481 502 … … 774 795 CContext* context = CContext::getCurrent(); 775 796 CContextClient* client = context->client; 776 777 CServerDistributionDescription serverDescription(globalDim);778 779 797 int nbServer = client->serverSize; 780 798 781 serverDescription.computeServerDistribution(nbServer, false, distType); 799 CServerDistributionDescription serverDescription(globalDim, nbServer); 800 serverDescription.computeServerDistribution(); 801 782 802 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 783 803 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); -
XIOS/trunk/src/node/axis.hpp
r775 r815 128 128 void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 129 129 CServerDistributionDescription::ServerDistributionType disType); 130 void sendValue(); 131 void computeConnectedServer(void); 130 void sendValue(const std::vector<int>& globalDim, int orderPositionInGrid, 131 CServerDistributionDescription::ServerDistributionType distType); 132 void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 133 CServerDistributionDescription::ServerDistributionType distType); 132 134 void sendDistributedValue(); 133 135 void sendNonDistributedValue(); -
XIOS/trunk/src/node/domain.cpp
r813 r815 465 465 lon_g.resize(ni_glo) ; 466 466 lat_g.resize(nj_glo) ; 467 468 467 468 469 469 int* ibegin_g = new int[client->clientSize] ; 470 470 int* jbegin_g = new int[client->clientSize] ; … … 480 480 v=nj ; 481 481 MPI_Allgather(&v,1,MPI_INT,nj_g,1,MPI_INT,client->intraComm) ; 482 482 483 483 MPI_Allgatherv(lon.dataFirst(),ni,MPI_DOUBLE,lon_g.dataFirst(),ni_g, ibegin_g,MPI_DOUBLE,client->intraComm) ; 484 484 MPI_Allgatherv(lat.dataFirst(),nj,MPI_DOUBLE,lat_g.dataFirst(),nj_g, jbegin_g,MPI_DOUBLE,client->intraComm) ; 485 485 486 486 delete[] ibegin_g ; 487 487 delete[] jbegin_g ; … … 494 494 { 495 495 int i,j,k; 496 496 497 497 const int nvertexValue = 4; 498 498 boundsLon.resize(nvertexValue,ni*nj); … … 510 510 bounds_lon_end= (lon(0) +360 + lon(ni_glo-1))/2 ; 511 511 } 512 512 513 513 for(j=0;j<nj;++j) 514 514 for(i=0;i<ni;++i) … … 520 520 : (lon(ibegin + i + 1)+lon(ibegin + i))/2; 521 521 } 522 522 523 523 524 524 boundsLat.resize(nvertexValue,nj*ni); … … 546 546 } 547 547 } 548 548 549 549 double latStepEnd = lat(nj_glo-1)-lat(nj_glo-2); 550 550 if (isSouthPole) bounds_lat_end=lat(nj_glo-1); … … 563 563 if ( -90 + bounds_lat_end <= 0.1*std::abs(latStepEnd)) bounds_lat_end=-90 ; 564 564 } 565 } 566 565 } 566 567 567 for(j=0;j<nj;++j) 568 568 for(i=0;i<ni;++i) … … 1222 1222 void CDomain::sendServerAttribut(void) 1223 1223 { 1224 CServerDistributionDescription serverDescription(nGlobDomain_);1225 1226 1224 CContext* context = CContext::getCurrent(); 1227 1225 CContextClient* client = context->client; 1228 1226 int nbServer = client->serverSize; 1229 1227 1230 if (isUnstructed_) serverDescription.computeServerDistribution(nbServer,0); 1231 else serverDescription.computeServerDistribution(nbServer,1); 1228 CServerDistributionDescription serverDescription(nGlobDomain_, nbServer); 1229 if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 1230 else serverDescription.computeServerDistribution(false, 1); 1232 1231 1233 1232 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); … … 1372 1371 indexEnd = indexBegin + range - 1; 1373 1372 1374 CServerDistributionDescription serverDescription(nGlobDomain_ );1375 if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange( nbServer,std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0);1376 else serverDescription.computeServerGlobalIndexInRange( nbServer,std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1);1373 CServerDistributionDescription serverDescription(nGlobDomain_, nbServer); 1374 if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 1375 else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 1377 1376 1378 1377 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), -
XIOS/trunk/src/node/grid.cpp
r803 r815 419 419 420 420 // Then compute distribution on server side 421 CServerDistributionDescription serverDistributionDescription(globalDim_); 422 serverDistributionDescription.computeServerGlobalIndexInRange(client->serverSize, 423 std::make_pair<size_t,size_t>(indexBegin, indexEnd), 424 positionDimensionDistributed_); 421 CServerDistributionDescription serverDistributionDescription(globalDim_, client->serverSize); 422 serverDistributionDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), positionDimensionDistributed_); 425 423 426 424 // Finally, compute index mapping between client(s) and server(s) -
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 -
XIOS/trunk/src/server_distribution_description.hpp
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). … … 30 30 31 31 /** Default constructor */ 32 CServerDistributionDescription(const std::vector<int>& globalDimensionSize); 32 CServerDistributionDescription(const std::vector<int>& globalDimensionSize, 33 int nServer, 34 ServerDistributionType serType=BAND_DISTRIBUTION); 35 33 36 /** Default destructor */ 34 37 virtual ~CServerDistributionDescription(); 35 38 36 void computeServerDistribution(int nServer, int positionDimensionDistributed = 1, 37 bool doComputeGlobalIndex = false, 38 ServerDistributionType type = BAND_DISTRIBUTION); 39 40 void computeServerGlobalIndexInRange(int nServer, 41 const std::pair<size_t, size_t>& indexBeginEnd, 42 int positionDimensionDistributed = 1, 43 ServerDistributionType = BAND_DISTRIBUTION); 39 void computeServerDistribution(bool doComputeGlobalIndex = false, int positionDimensionDistributed = 1); 40 void computeServerGlobalIndexInRange(const std::pair<size_t, size_t>& indexBeginEnd, int positionDimensionDistributed = 1); 44 41 45 42 std::vector<std::vector<int> > getServerIndexBegin() const; … … 47 44 const std::vector<CArray<size_t,1> >& getGlobalIndex() const; 48 45 const boost::unordered_map<size_t,int>& getGlobalIndexRange() const; 46 int getDimensionDistributed(); 49 47 50 48 protected: … … 62 60 //!< In case we need only global index of one server with specific rank 63 61 boost::unordered_map<size_t,int> globalIndex_; 62 63 //!< Type of distribution on server side 64 ServerDistributionType serverType_; 65 66 //!< Number of server 67 int nServer_; 68 69 //!< Position of dimension distributed on server side (by default, the second dimension) 70 int positionDimensionDistributed_; 64 71 }; 65 72
Note: See TracChangeset
for help on using the changeset viewer.