Changeset 568
- Timestamp:
- 03/10/15 10:49:09 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/client_server_mapping.cpp
r567 r568 21 21 22 22 void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 23 const CArray<int,1>& localIndexOnClient) 24 { 25 // defaultComputeServerIndexMapping(globalIndexOnClient, globalIndexServer); 26 } 27 28 29 void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 23 30 const std::vector<CArray<size_t,1>* >& globalIndexServer) 24 31 { … … 26 33 } 27 34 28 void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient,29 const CArray<int,1>& localIndexOnClient,30 const std::vector<CArray<size_t,1>* >& globalIndexOnServer)31 {32 defaultComputeServerIndexMapping(globalIndexOnClient, globalIndexOnServer, &localIndexOnClient);33 }35 //void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 36 // const CArray<int,1>& localIndexOnClient, 37 // const std::vector<CArray<size_t,1>* >& globalIndexOfServer) 38 //{ 39 // defaultComputeServerIndexMapping(globalIndexOnClient, globalIndexOfServer, &localIndexOnClient); 40 //} 34 41 35 42 /*! … … 68 75 } 69 76 } 70 71 77 72 78 /*! -
XIOS/trunk/src/client_server_mapping.hpp
r567 r568 13 13 #include "array_new.hpp" 14 14 #include "mpi.hpp" 15 #include <boost/unordered_map.hpp> 15 16 16 17 namespace xios { … … 34 35 35 36 virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 36 const CArray<int,1>& localIndexOnClient, 37 const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 37 const CArray<int,1>& localIndexOnClient); 38 39 // virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 40 // const CArray<int,1>& localIndexOnClient, 41 // const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 38 42 39 43 std::map<int,int> computeConnectedClients(int nbServer, int nbClient, … … 49 53 const CArray<int,1>* localIndexOnClient = 0); 50 54 51 pr ivate:55 protected: 52 56 //! Global index of data on SERVER, which are calculated by client(s) 53 57 std::map<int, std::vector<size_t> > indexGlobalOnServer_; -
XIOS/trunk/src/node/axis.cpp
r567 r568 109 109 void CAxis::checkZoom(void) 110 110 { 111 StdSize zoom_begin,zoom_end, zoom_size ;111 StdSize zoom_begin,zoom_end, zoom_size, axisSize; 112 112 113 113 zoom_begin = (this->zoom_begin.isEmpty()) ? 0 : this->zoom_begin.getValue() ; … … 118 118 if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1 ; 119 119 if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1 ; 120 121 if ( (zoom_begin < 0) || (zoom_begin > size-1) || (zoom_end<0) || (zoom_end>size-1) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) 120 axisSize = size.getValue(); 121 122 if ( (zoom_begin < 0) || (zoom_begin > axisSize-1) || (zoom_end<0) || (zoom_end>axisSize-1) || (zoom_size<1) || (zoom_size>axisSize) || (zoom_begin>zoom_end)) 122 123 ERROR("CAxis::checkAttributes(void)",<< "One or more attribut of <zoom_begin>, <zoom_end>, <zoom_size>, are not well specified") ; 123 124 -
XIOS/trunk/src/node/grid.cpp
r567 r568 13 13 #include "context_server.hpp" 14 14 #include "array_new.hpp" 15 #include "client_server_mapping_distributed.hpp" 15 16 16 17 namespace xios { … … 22 23 , isChecked(false), isDomainAxisChecked(false), storeIndex(1) 23 24 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 24 , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_( ), writtenDataSize_(0), globalDim_()25 , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 25 26 { 26 27 setVirtualDomainGroup(); … … 32 33 , isChecked(false), isDomainAxisChecked(false), storeIndex(1) 33 34 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 34 , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_( ), writtenDataSize_(0), globalDim_()35 , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 35 36 { 36 37 setVirtualDomainGroup(); … … 174 175 StdSize retVal; 175 176 std::map<int, StdSize> ret; 176 const std::map<int, std::vector<int> >& distribution = clientServerMap_ .getLocalIndexSendToServer();177 const std::map<int, std::vector<int> >& distribution = clientServerMap_->getLocalIndexSendToServer(); 177 178 std::map<int, std::vector<int> >::const_iterator it = distribution.begin(), itE = distribution.end(); 178 179 for (; it != itE; ++it) … … 280 281 { 281 282 int idx = 0; 283 std::vector<int> axisPositionMap; 284 for (int i = 0; i < axisDomainOrder.numElements(); ++i) 285 { 286 if (false == axisDomainOrder(i)) 287 { 288 axisPositionMap.push_back(idx); 289 ++idx; 290 } 291 else idx += 2; 292 } 293 282 294 computeGridGlobalDimension(getDomains(), getAxis(), axisDomainOrder); 283 295 for (int i = 0; i < axisListP.size(); ++i) 284 296 { 285 while (this->axisDomainOrder(idx)) idx += 2;286 297 if (sendAtt) 287 axisListP[i]->sendCheckedAttributes(globalDim_, idx);298 axisListP[i]->sendCheckedAttributes(globalDim_,axisPositionMap[i]); 288 299 else 289 axisListP[i]->checkAttributesOnClient(globalDim_, idx);300 axisListP[i]->checkAttributesOnClient(globalDim_,axisPositionMap[i]); 290 301 ++idx; 291 302 } … … 303 314 // First of all, compute distribution on client side 304 315 clientDistribution_ = new CDistributionClient(client->clientRank, this); 316 size_t globalSizeIndex = 1, indexBegin, indexEnd; 317 int range, clientSize = client->clientSize; 318 for (int i = 0; i < globalDim_.size(); ++i) globalSizeIndex *= globalDim_[i]; 319 indexBegin = 0; 320 for (int i = 0; i < clientSize; ++i) 321 { 322 range = globalSizeIndex / clientSize; 323 if (i < (globalSizeIndex%clientSize)) ++range; 324 if (i == client->clientRank) break; 325 indexBegin += range; 326 } 327 indexEnd = indexBegin + range - 1; 305 328 306 329 // Then compute distribution on server side 307 330 serverDistributionDescription_ = new CServerDistributionDescription(clientDistribution_->getNGlob()); 308 331 serverDistributionDescription_->computeServerDistribution(client->serverSize, true); 332 serverDistributionDescription_->computeServerGlobalIndexInRange(client->serverSize, 333 std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 309 334 310 335 // Finally, compute index mapping between client(s) and server(s) 311 clientServerMap_.computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 312 clientDistribution_->getLocalDataIndexSendToServerOnClient(), 313 serverDistributionDescription_->getGlobalIndex()); 314 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_.getGlobalIndexOnServer(); 336 clientServerMap_ = new CClientServerMappingDistributed(serverDistributionDescription_->getGlobalIndexRange(), 337 client->intraComm); 338 339 clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 340 clientDistribution_->getLocalDataIndexSendToServerOnClient()); 341 342 // clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 343 // clientDistribution_->getLocalDataIndexSendToServerOnClient(), 344 // serverDistributionDescription_->getGlobalIndex()); 345 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 315 346 std::vector<int> connectedServerRank; 316 347 for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 317 348 connectedServerRank.push_back(it->first); 318 349 } 319 nbSenders = clientServerMap_ .computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank);350 nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 320 351 321 352 // Get local data index on client … … 415 446 list<shared_ptr<CMessage> > list_msg ; 416 447 list< CArray<size_t,1>* > listOutIndex; 417 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_ .getGlobalIndexOnServer();418 const std::map<int, std::vector<int> >& localIndexSendToServer = clientServerMap_ .getLocalIndexSendToServer();448 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 449 const std::map<int, std::vector<int> >& localIndexSendToServer = clientServerMap_->getLocalIndexSendToServer(); 419 450 420 451 std::map<int, std::vector<size_t> >::const_iterator iteMap, itbMap, itGlobal; -
XIOS/trunk/src/node/grid.hpp
r567 r568 221 221 CDistributionServer* serverDistribution_; 222 222 CServerDistributionDescription* serverDistributionDescription_; 223 CClientServerMapping clientServerMap_;223 CClientServerMapping* clientServerMap_; 224 224 size_t writtenDataSize_; 225 225 }; // class CGrid -
XIOS/trunk/src/server_distribution_description.cpp
r557 r568 13 13 { 14 14 CServerDistributionDescription::CServerDistributionDescription(const std::vector<int>& globalDimensionSize) 15 : nGlobal_(globalDimensionSize), indexBegin_(), dimensionSizes_(), globalIndex_( 0), vecGlobalIndex_()15 : nGlobal_(globalDimensionSize), indexBegin_(), dimensionSizes_(), globalIndex_(), vecGlobalIndex_() 16 16 { 17 17 … … 20 20 CServerDistributionDescription::~CServerDistributionDescription() 21 21 { 22 if (0 != globalIndex_) delete globalIndex_;22 // if (0 != globalIndex_) delete globalIndex_; 23 23 if (!vecGlobalIndex_.empty()) 24 24 for (int i = 0; i < vecGlobalIndex_.size(); ++i) delete vecGlobalIndex_[i]; … … 92 92 } 93 93 94 void CServerDistributionDescription::computeServerGlobalIndexInRange(int nServer, 95 const std::pair<size_t, size_t>& indexBeginEnd, 96 ServerDistributionType distributionType) 97 { 98 switch (distributionType) { 99 case BAND_DISTRIBUTION: 100 computeBandDistribution(nServer); 101 break; 102 default: 103 break; 104 } 105 106 size_t indexBegin = indexBeginEnd.first; 107 size_t indexEnd = indexBeginEnd.second; 108 if (indexBegin > indexEnd) 109 ERROR("CServerDistributionDescription::computeServerGlobalIndexInRange", 110 << "Index begin is larger than index end"); 111 112 int dim = nGlobal_.size(); 113 std::vector<int> currentIndex(dim); 114 115 for (int idxServer = 0; idxServer < nServer; ++idxServer) 116 { 117 size_t ssize = 1, idx = 0; 118 for (int j = 0; j < dim; ++j) ssize *= dimensionSizes_[idxServer][j]; 119 vecGlobalIndex_[idxServer] = new CArray<size_t,1>(ssize); 120 121 std::vector<int> idxLoop(dim,0); 122 123 int innerLoopSize = dimensionSizes_[idxServer][0]; 124 125 while (idx<ssize) 126 { 127 for (int idxDim = 0; idxDim < dim-1; ++idxDim) 128 { 129 if (idxLoop[idxDim] == dimensionSizes_[idxServer][idxDim]) 130 { 131 idxLoop[idxDim] = 0; 132 ++idxLoop[idxDim+1]; 133 } 134 } 135 136 for (int idxDim = 1; idxDim < dim; ++idxDim) currentIndex[idxDim] = idxLoop[idxDim] + indexBegin_[idxServer][idxDim]; 137 138 size_t mulDim, globalIndex; 139 for (int j = 0; j < innerLoopSize; ++j) 140 { 141 mulDim = 1; 142 globalIndex = j + indexBegin_[idxServer][0]; 143 144 for (int k = 1; k < dim; ++k) 145 { 146 mulDim *= nGlobal_[k-1]; 147 globalIndex += (currentIndex[k])*mulDim; 148 } 149 if ((indexBegin <= globalIndex) && (globalIndex <= indexEnd)) 150 globalIndex_.insert(std::make_pair<size_t,int>(globalIndex, idxServer)); 151 ++idx; 152 } 153 idxLoop[0] += innerLoopSize; 154 } 155 } 156 157 } 158 94 159 /*! 95 160 Compute global index of servers with band distribution … … 178 243 } 179 244 245 const boost::unordered_map<size_t,int>& CServerDistributionDescription::getGlobalIndexRange() const 246 { 247 return globalIndex_; 248 } 180 249 } // namespace xios -
XIOS/trunk/src/server_distribution_description.hpp
r554 r568 13 13 #include "xmlioserver_spl.hpp" 14 14 #include "array_new.hpp" 15 #include <boost/unordered_map.hpp> 15 16 16 17 namespace xios … … 36 37 ServerDistributionType type = BAND_DISTRIBUTION); 37 38 38 const CArray<size_t,1>& computeServerGlobalIndex(int nServer, int serverRank, 39 ServerDistributionType = BAND_DISTRIBUTION); 39 void computeServerGlobalIndexInRange(int nServer, 40 const std::pair<size_t, size_t>& indexBeginEnd, 41 ServerDistributionType = BAND_DISTRIBUTION); 40 42 41 43 std::vector<std::vector<int> > getServerIndexBegin() const; 42 44 std::vector<std::vector<int> > getServerDimensionSizes() const; 43 45 const std::vector<CArray<size_t,1>* >& getGlobalIndex() const; 46 const boost::unordered_map<size_t,int>& getGlobalIndexRange() const; 44 47 45 48 protected: … … 56 59 57 60 //!< In case we need only global index of one server with specific rank 58 CArray<size_t,1>*globalIndex_;61 boost::unordered_map<size_t,int> globalIndex_; 59 62 }; 60 63
Note: See TracChangeset
for help on using the changeset viewer.