- Timestamp:
- 04/01/15 17:52:53 (10 years ago)
- Location:
- XIOS/trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml
r563 r584 17 17 18 18 <axis_definition> 19 <axis id="axis_atm" zoom_size="2" zoom_end=" 2" />19 <axis id="axis_atm" zoom_size="2" zoom_end="3" /> 20 20 </axis_definition> 21 21 -
XIOS/trunk/src/client_server_mapping.hpp
r569 r584 33 33 virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) = 0; 34 34 35 // In case of computing local index on client sent to server36 virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient,37 const CArray<int,1>& localIndexOnClient) = 0;35 // // In case of computing local index on client sent to server 36 // virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 37 // const CArray<int,1>& localIndexOnClient) = 0; 38 38 39 39 // Simple case, global index on client and index on servers -
XIOS/trunk/src/client_server_mapping_distributed.cpp
r569 r584 11 11 #include <limits> 12 12 #include <boost/functional/hash.hpp> 13 #include "utils.hpp" 13 14 14 15 namespace xios … … 35 36 \param [in] globalIndexOnClient global index client has 36 37 */ 37 void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient)38 {39 int ssize = globalIndexOnClient.numElements();40 CArray<int,1>* localIndexOnClient = new CArray<int,1>(ssize);41 for (int i = 0; i < ssize; ++i) (*localIndexOnClient)(i) = i;42 43 this->computeServerIndexMapping(globalIndexOnClient, *localIndexOnClient);44 delete localIndexOnClient;45 }38 //void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) 39 //{ 40 // int ssize = globalIndexOnClient.numElements(); 41 // CArray<int,1>* localIndexOnClient = new CArray<int,1>(ssize); 42 // for (int i = 0; i < ssize; ++i) (*localIndexOnClient)(i) = i; 43 // 44 // this->computeServerIndexMapping(globalIndexOnClient, *localIndexOnClient); 45 // delete localIndexOnClient; 46 //} 46 47 47 48 /*! … … 50 51 \param [in] localIndexOnClient local index on client 51 52 */ 52 void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 53 const CArray<int,1>& localIndexOnClient) 53 //void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 54 // const CArray<int,1>& localIndexOnClient) 55 void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) 54 56 { 55 57 size_t ssize = globalIndexOnClient.numElements(), hashedIndex; … … 59 61 std::map<int, std::vector<size_t> > client2ClientIndexGlobal; 60 62 std::map<int, std::vector<int> > client2ClientIndexServer; 61 std::map<int, std::vector<int> > clientLocalIndex;63 // std::map<int, std::vector<int> > clientLocalIndex; 62 64 63 65 // Number of global index whose mapping server can be found out thanks to index-server mapping … … 66 68 // Number of global index whose mapping server are on other clients 67 69 int nbIndexSendToOthers = 0; 68 boost::hash<size_t> hashGlobalIndex;70 HashXIOS<size_t> hashGlobalIndex; 69 71 for (int i = 0; i < ssize; ++i) 70 72 { … … 79 81 { 80 82 (indexGlobalOnServer_[globalIndexToServerMapping_[globalIndexClient]]).push_back(globalIndexClient); 81 (localIndexSend2Server_[globalIndexToServerMapping_[globalIndexClient]]).push_back(localIndexOnClient(i));83 // (localIndexSend2Server_[globalIndexToServerMapping_[globalIndexClient]]).push_back(localIndexOnClient(i)); 82 84 ++nbIndexAlreadyOnClient; 83 85 } … … 85 87 { 86 88 client2ClientIndexGlobal[indexClient].push_back(globalIndexClient); 87 clientLocalIndex[indexClient].push_back(i);89 // clientLocalIndex[indexClient].push_back(i); 88 90 ++nbIndexSendToOthers; 89 91 } … … 123 125 std::vector<int> demandAlreadyReceived, repondAlreadyReceived; 124 126 int nbDemandingClient = recvBuff[clientRank_], nbIndexServerReceived = 0; 127 128 resetReceivingRequestAndCount(); 125 129 while ((0 < nbDemandingClient) || (!sendRequest.empty()) || 126 130 (nbIndexServerReceived < nbIndexReceivedFromOthers)) … … 176 180 int* beginBuff = indexServerBuffBegin_[clientSourceRank]; 177 181 std::vector<size_t>& globalIndexTmp = client2ClientIndexGlobal[clientSourceRank]; 178 std::vector<int>& localIndexTmp = clientLocalIndex[clientSourceRank];182 // std::vector<int>& localIndexTmp = clientLocalIndex[clientSourceRank]; 179 183 for (int i = 0; i < count; ++i) 180 184 { 181 185 (indexGlobalOnServer_[*(beginBuff+i)]).push_back(globalIndexTmp[i]); 182 (localIndexSend2Server_[*(beginBuff+i)]).push_back(localIndexOnClient(localIndexTmp[i]));186 // (localIndexSend2Server_[*(beginBuff+i)]).push_back(localIndexOnClient(localIndexTmp[i])); 183 187 } 184 188 nbIndexServerReceived += count; … … 243 247 boost::unordered_map<size_t,int>::const_iterator it = globalIndexOfServer.begin(), 244 248 ite = globalIndexOfServer.end(); 245 boost::hash<size_t> hashGlobalIndex;249 HashXIOS<size_t> hashGlobalIndex; 246 250 for (; it != ite; ++it) 247 251 { -
XIOS/trunk/src/client_server_mapping_distributed.hpp
r569 r584 36 36 const MPI_Comm& clientIntraComm); 37 37 38 virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient );38 virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClientSendToServer); 39 39 40 virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 41 const CArray<int,1>& localIndexOnClient); 40 // virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClientSendToServer, 41 // const CArray<int,1>& localIndexOnClientSendToServer); 42 43 std::vector<int> computeConnectedServerRank(const CArray<size_t,1> globalIndexClient); 42 44 43 45 /** Default destructor */ 44 46 virtual ~CClientServerMappingDistributed(); 47 48 45 49 46 50 protected: -
XIOS/trunk/src/node/context.cpp
r583 r584 220 220 } 221 221 222 // //----------------------------------------------------------------223 //224 // void CContext::solveFieldRefInheritance(bool apply)225 // {226 // if (!this->hasId()) return;227 // vector<CField*> allField = CField::getAll();228 //// = CObjectTemplate<CField>::GetAllVectobject(this->getId());229 // std::vector<CField*>::iterator230 // it = allField.begin(), end = allField.end();231 //232 // for (; it != end; it++)233 // {234 // CField* field = *it;235 // field->solveRefInheritance(apply);236 // }237 // }238 239 222 //---------------------------------------------------------------- 240 223 … … 258 241 if (hasClient) 259 242 { 260 size_t bufferSizeMin = 1 ;243 size_t bufferSizeMin = 10*sizeof(size_t)*1024; 261 244 #define DECLARE_NODE(Name_, name_) \ 262 245 bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ? sizeof(C##Name_##Definition) : bufferSizeMin; … … 264 247 #include "node_type.conf" 265 248 std::map<int, StdSize> bufferSize = getDataSize(); 249 if (bufferSize.empty()) 250 { 251 if (client->isServerLeader()) 252 { 253 bufferSize[client->getServerLeader()] = bufferSizeMin; 254 } 255 else 256 return; 257 } 258 266 259 std::map<int, StdSize>::iterator it = bufferSize.begin(), 267 260 ite = bufferSize.end(); … … 315 308 void CContext::closeDefinition(void) 316 309 { 317 310 // There is nothing client need to send to server 318 311 if (hasClient) 319 312 { 320 313 // After xml is parsed, there are some more works with post processing 321 314 postProcessing(); 322 // 315 323 316 setClientServerBuffer(); 324 317 } … … 353 346 354 347 // There are some processings that should be done after all of above. For example: check mask or index 355 // if (hasClient && !hasServer)356 348 if (hasClient) 357 349 { … … 361 353 362 354 363 364 // if (hasClient) 365 // { 366 // //solveCalendar(); 367 // 368 // // Résolution des héritages pour le context actuel. 369 //// this->solveAllInheritance(); 370 // 371 // 372 //// //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 373 //// this->findEnabledFiles(); 374 // 375 // this->processEnabledFiles(); 376 // 377 // this->solveAllGridRef(); 378 // } 379 380 381 382 383 // solveCalendar(); 384 // 385 // // Résolution des héritages pour le context actuel. 386 // this->solveAllInheritance(); 387 // 388 // //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 389 // this->findEnabledFiles(); 390 // 391 // 392 // this->processEnabledFiles(); 393 394 /* 395 //Recherche des champs à sortir (enable à true + niveau de sortie correct) 396 // pour chaque fichier précédemment listé. 397 this->findAllEnabledFields(); 398 399 // Résolution des références de grilles pour chacun des champs. 400 this->solveAllGridRef(); 401 402 // Traitement des opérations. 403 this->solveAllOperation(); 404 405 // Traitement des expressions. 406 this->solveAllExpression(); 407 */ 408 // Nettoyage de l'arborescence 409 if (hasClient && !hasServer) CleanTree(); // Only on client side?? 410 // if (hasClient) CleanTree(); 411 if (hasClient) sendCreateFileHeader(); 355 // Nettoyage de l'arborescence 356 if (hasClient && !hasServer) CleanTree(); // Only on client side?? 357 358 if (hasClient) sendCreateFileHeader(); 412 359 } 413 360 … … 509 456 return true; 510 457 break; 511 case EVENT_ID_UPDATE_CALENDAR 458 case EVENT_ID_UPDATE_CALENDAR: 512 459 recvUpdateCalendar(event); 513 460 return true; … … 521 468 return true; 522 469 break; 470 523 471 default : 524 472 ERROR("bool CContext::dispatchEvent(CEventServer& event)", -
XIOS/trunk/src/node/distribution_client.cpp
r575 r584 17 17 dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 18 18 gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 19 isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0) 19 isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0), nIndexDomain_(), nIndexAxis_() 20 20 { 21 21 } … … 27 27 dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 28 28 gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 29 isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0) 29 isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0), nIndexDomain_(), nIndexAxis_() 30 30 { 31 31 readDistributionInfo(grid); 32 32 createGlobalIndex(); 33 createGlobalIndexSendToServer(); 33 34 } 34 35 35 36 CDistributionClient::~CDistributionClient() 36 37 { 38 if (0 != globalDataSendToServer_) delete globalDataSendToServer_; 37 39 if (0 != localDataIndex_) delete localDataIndex_; 38 40 if (0 != localDataIndexSendToServer_) delete localDataIndexSendToServer_; … … 77 79 } 78 80 81 void CDistributionClient::readDomainIndex(const std::vector<CDomain*>& domList) 82 { 83 int domainSize = domList.size(); 84 nIndexDomain_.resize(domainSize); 85 86 for (int k = 0; k < domainSize; ++k) 87 { 88 nIndexDomain_[k].resize(2); 89 int ni = domList[k]->ni; 90 int nj = domList[k]->nj; 91 nIndexDomain_[k][0].resize(ni,nj); 92 nIndexDomain_[k][1].resize(ni,nj); 93 nIndexDomain_[k][0] = domList[k]->i_index; 94 nIndexDomain_[k][1] = domList[k]->j_index; 95 } 96 } 97 98 void CDistributionClient::readAxisIndex(const std::vector<CAxis*>& axisList) 99 { 100 int axisSize = axisList.size(); 101 nIndexAxis_.resize(axisSize); 102 103 for (int k = 0; k < axisSize; ++k) 104 { 105 int n = axisList[k]->ni; 106 nIndexAxis_[k].resize(n); 107 for (int i = 0; i < n; ++i) 108 nIndexAxis_[k](i) = i; 109 } 110 } 111 79 112 /*! 80 113 Read information from domain(s) and axis to generate distribution. … … 204 237 ++idx; 205 238 } 239 readDomainIndex(domList); 240 readAxisIndex(axisList); 206 241 207 242 // Grid has only one axis and it is not distributed … … 288 323 } 289 324 325 void CDistributionClient::createGlobalIndex() 326 { 327 size_t ssize = 1, idx = 0; 328 for (int i = 0; i < this->dims_; ++i) 329 ssize *= nLocal_[i]; 330 331 this->globalIndex_ = new CArray<size_t,1>(ssize); 332 std::vector<int> idxLoop(this->dims_,0); 333 int innnerLoopSize = nLocal_[0]; 334 while (idx < ssize) 335 { 336 for (int i = 0; i < this->dims_; ++i) 337 { 338 if (idxLoop[i] == nLocal_[i]) 339 { 340 idxLoop[i] = 0; 341 ++idxLoop[i+1]; 342 } 343 } 344 345 for (int i = 0; i < innnerLoopSize; ++i) 346 { 347 size_t globalIndex = idxLoop[0] + nBeginGlobal_[0]; 348 size_t mulDim = 1; 349 for (int k = 1; k < this->dims_; ++k) 350 { 351 mulDim *= nGlob_[k-1]; 352 globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim; 353 } 354 (*this->globalIndex_)(idx) = globalIndex; 355 ++idxLoop[0]; 356 ++idx; 357 } 358 } 359 } 360 361 290 362 /*! 291 363 Create global index on client … … 296 368 take into account of C-convention, the rightmost dimension varies faster. 297 369 */ 298 void CDistributionClient::createGlobalIndex ()370 void CDistributionClient::createGlobalIndexSendToServer() 299 371 { 300 372 createLocalDomainDataIndex(); … … 397 469 398 470 // Now allocate these arrays 399 this->global Index_ = new CArray<size_t,1>(indexSend2ServerCount);471 this->globalDataSendToServer_ = new CArray<size_t,1>(indexSend2ServerCount); 400 472 localDataIndex_ = new CArray<int,1>(indexLocalDataOnClientCount); 401 473 localDataIndexSendToServer_ = new CArray<int,1>(indexSend2ServerCount); … … 507 579 globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 508 580 } 509 (*this->global Index_)(indexSend2ServerCount) = globalIndex;581 (*this->globalDataSendToServer_)(indexSend2ServerCount) = globalIndex; 510 582 (*localDataIndexSendToServer_)(indexSend2ServerCount) = indexLocalDataOnClientCount; 511 583 ++indexSend2ServerCount; … … 562 634 } 563 635 636 const CArray<size_t,1>& CDistributionClient::getGlobalDataIndexSendToServer() const 637 { 638 return (*globalDataSendToServer_); 639 } 640 564 641 /*! 565 642 Return local data index of client … … 573 650 Return local data index on client which are sent to servers 574 651 */ 575 const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer OnClient() const652 const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer() const 576 653 { 577 654 return (*localDataIndexSendToServer_); -
XIOS/trunk/src/node/distribution_client.hpp
r569 r584 37 37 38 38 virtual const CArray<int,1>& getLocalDataIndexOnClient() const; 39 virtual const CArray<int,1>& getLocalDataIndexSendToServerOnClient() const; 39 virtual const CArray<int,1>& getLocalDataIndexSendToServer() const; 40 const CArray<size_t,1>& getGlobalDataIndexSendToServer() const; 40 41 41 42 std::vector<int> getNGlob() { return nGlob_; } … … 45 46 protected: 46 47 void createGlobalIndex(); 48 void createGlobalIndexSendToServer(); 47 49 void readDistributionInfo(CGrid* grid); 48 50 void readDistributionInfo(const std::vector<CDomain*>& domList, 49 51 const std::vector<CAxis*>& axisList, 50 52 const CArray<bool,1>& axisDomainOrder); 53 void readDomainIndex(const std::vector<CDomain*>& domList); 54 void readAxisIndex(const std::vector<CAxis*>& axisList); 51 55 private: 52 56 //! Create local index of a domain … … 66 70 private: 67 71 //!< LocalData index on client 72 CArray<size_t,1>* globalDataSendToServer_; 68 73 CArray<int,1>* localDataIndex_; 69 74 CArray<int,1>* localDataIndexSendToServer_; … … 81 86 std::vector<int> nZoomBegin_; //!< Begin index of zoom of each dimension 82 87 std::vector<int> nZoomEnd_; //!< End index of zoom of each dimension 88 std::vector<std::vector<CArray<int,2> > > nIndexDomain_; //!< Local index of each domain dimension (e.x: i_index, j_index) 89 std::vector<CArray<int,1> > nIndexAxis_; 83 90 84 91 // Data_n_index of domain or axis (For now, axis uses its size as data_n_index -
XIOS/trunk/src/node/domain.cpp
r569 r584 23 23 CDomain::CDomain(void) 24 24 : CObjectTemplate<CDomain>(), CDomainAttributes() 25 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_() 25 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 26 26 { /* Ne rien faire de plus */ } 27 27 28 28 CDomain::CDomain(const StdString & id) 29 29 : CObjectTemplate<CDomain>(id), CDomainAttributes() 30 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_() 30 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 31 31 { /* Ne rien faire de plus */ } 32 32 … … 449 449 StdSize dm = zoom_ni_client * zoom_nj_client; 450 450 451 lonvalue.resize(dm); 452 latvalue.resize(dm); 451 // Make sure that this attribute is non-empty for every client. 452 if (0 != dm) 453 { 454 lonvalue.resize(dm); 455 latvalue.resize(dm); 456 } 457 453 458 454 459 for (int i = 0; i < zoom_ni_client; i++) … … 668 673 int zoom_jend=zoom_jbegin+zoom_nj-1 ; 669 674 670 671 675 // Precompute number of index 672 int globalIndexCount = 0;676 int globalIndexCountZoom = 0; 673 677 for(j=0;j<nj;j++) 674 678 for(i=0;i<ni;i++) … … 679 683 if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend) 680 684 { 681 ++globalIndexCount ;685 ++globalIndexCountZoom; 682 686 } 683 687 } 684 688 685 689 // Fill in index 686 CArray<size_t,1> globalIndexDomain(globalIndexCount); 690 CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 691 CArray<size_t,1> globalIndexDomain(ni*nj); 687 692 size_t globalIndex; 688 globalIndexCount = 0; 693 int globalIndexCount = 0; 694 globalIndexCountZoom = 0; 689 695 690 696 for(j=0;j<nj;j++) … … 694 700 j_ind=jbegin+j_index(i,j) ; 695 701 702 globalIndex = i_ind + j_ind * ni_glo; 703 globalIndexDomain(globalIndexCount) = globalIndex; 704 ++globalIndexCount; 696 705 if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend) 697 706 { 698 globalIndex = i_ind + j_ind * ni_glo; 699 globalIndexDomain(globalIndexCount) = globalIndex; 700 ++globalIndexCount; 707 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 708 ++globalIndexCountZoom; 701 709 } 702 710 } … … 724 732 clientServerMap->computeServerIndexMapping(globalIndexDomain); 725 733 const std::map<int, std::vector<size_t> >& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 726 std::vector<int> connectedServerRank; 727 for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(); it != globalIndexDomainOnServer.end(); ++it) { 728 connectedServerRank.push_back(it->first); 734 735 std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(), 736 ite = globalIndexDomainOnServer.end(); 737 indSrv_.clear(); 738 for (; it != ite; ++it) 739 { 740 int rank = it->first; 741 std::vector<size_t>::const_iterator itbVec = (it->second).begin(), 742 iteVec = (it->second).end(); 743 int nb = globalIndexDomainZoom.numElements(); 744 for (int i = 0; i < nb; ++i) 745 { 746 if (std::binary_search(itbVec, iteVec, globalIndexDomainZoom(i))) 747 { 748 indSrv_[rank].push_back(globalIndexDomainZoom(i)); 749 } 750 } 729 751 } 730 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 731 indSrv_ = globalIndexDomainOnServer; 752 753 connectedServerRank_.clear(); 754 for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 755 connectedServerRank_.push_back(it->first); 756 } 757 758 if (!indSrv_.empty()) 759 { 760 connectedServerRank_.clear(); 761 for (it = indSrv_.begin(); it != indSrv_.end(); ++it) 762 connectedServerRank_.push_back(it->first); 763 } 764 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 732 765 733 766 delete clientServerMap; … … 753 786 itbMap = indSrv_.begin(); 754 787 iteMap = indSrv_.end(); 755 for (i t = itbMap; it != iteMap; ++it)788 for (int k = 0; k < connectedServerRank_.size(); ++k) 756 789 { 757 int rank = it->first; 758 int nbData = (it->second).size(); 790 int nbData = 0; 791 int rank = connectedServerRank_[k]; 792 it = indSrv_.find(rank); 793 if (iteMap != it) 794 nbData = (it->second).size(); 795 759 796 CArray<int,1> indi(nbData) ; 760 797 CArray<int,1> indj(nbData) ; … … 807 844 *list_msgLat.back()<<*list_boundslat.back(); 808 845 } 846 809 847 eventLon.push(rank,nbConnectedClients_[rank],*list_msgLon.back()) ; 810 848 eventLat.push(rank,nbConnectedClients_[rank],*list_msgLat.back()) ; -
XIOS/trunk/src/node/domain.hpp
r553 r584 156 156 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 157 157 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 158 std::vector<int> connectedServerRank_; 158 159 159 160 DECLARE_REF_FUNC(Domain,domain) -
XIOS/trunk/src/node/grid.cpp
r575 r584 24 24 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 25 25 , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 26 , connectedDataSize_(), connectedServerRank_() 26 27 { 27 28 setVirtualDomainGroup(); … … 34 35 , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 35 36 , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 37 , connectedDataSize_(), connectedServerRank_() 36 38 { 37 39 setVirtualDomainGroup(); … … 175 177 StdSize retVal; 176 178 std::map<int, StdSize> ret; 177 const std::map<int, std::vector<int> >& distribution = clientServerMap_->getLocalIndexSendToServer(); 178 std::map<int, std::vector<int> >::const_iterator it = distribution.begin(), itE = distribution.end(); 179 std::map<int, size_t >::const_iterator it = connectedDataSize_.begin(), itE = connectedDataSize_.end(); 179 180 for (; it != itE; ++it) 180 181 { 181 retVal = it->second .size();182 retVal = it->second; 182 183 retVal *= secureFactor; 183 184 ret.insert(std::make_pair<int,StdSize>(it->first, retVal)); … … 192 193 if (this->isDomainAxisChecked) return; 193 194 195 this->solveAxisRef(areAttributesChecked); 194 196 this->solveDomainRef(areAttributesChecked); 195 this->solveAxisRef(areAttributesChecked);196 197 197 198 this->isDomainAxisChecked = areAttributesChecked; … … 337 338 client->intraComm); 338 339 339 clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 340 clientDistribution_->getLocalDataIndexSendToServerOnClient()); 341 340 clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex()); 342 341 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 343 std::vector<int> connectedServerRank; 344 for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 345 connectedServerRank.push_back(it->first); 346 } 347 nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 342 const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 343 344 std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 345 itbGlobalMap = itGlobalMap = globalIndexOnServer.begin(); 346 iteGlobalMap = globalIndexOnServer.end(); 347 348 int nbGlobalIndex = globalIndexSendToServer.numElements(); 349 for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 350 { 351 int serverRank = itGlobalMap->first; 352 std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), itVecGlobal, 353 iteVecGlobal = (itGlobalMap->second).end(); 354 for (int i = 0; i < nbGlobalIndex; ++i) 355 { 356 if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i))) 357 { 358 if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 359 connectedDataSize_[serverRank] = 0; 360 else 361 ++connectedDataSize_[serverRank]; 362 } 363 } 364 } 365 366 connectedServerRank_.clear(); 367 for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 368 connectedServerRank_.push_back(it->first); 369 } 370 if (!connectedDataSize_.empty()) 371 { 372 connectedServerRank_.clear(); 373 for (std::map<int,size_t>::const_iterator it = connectedDataSize_.begin(); it != connectedDataSize_.end(); ++it) 374 connectedServerRank_.push_back(it->first); 375 } 376 377 nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 348 378 349 379 // Get local data index on client … … 443 473 list< CArray<size_t,1>* > listOutIndex; 444 474 const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 445 const std::map<int, std::vector<int> >& localIndexSendToServer = clientServerMap_->getLocalIndexSendToServer(); 446 447 std::map<int, std::vector<size_t> >::const_iterator iteMap, itbMap, itGlobal; 448 std::map<int, std::vector<int> >::const_iterator itLocal; 449 itbMap = itGlobal = globalIndexOnServer.begin(); 450 iteMap = globalIndexOnServer.end(); 451 itLocal = localIndexSendToServer.begin(); 475 const CArray<int,1>& localIndexSendToServer = clientDistribution_->getLocalDataIndexSendToServer(); 476 const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 477 478 std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 479 itbGlobalMap = itGlobalMap = globalIndexOnServer.begin(); 480 iteGlobalMap = globalIndexOnServer.end(); 481 482 int nbGlobalIndex = globalIndexSendToServer.numElements(); 483 std::map<int,std::vector<int> >localIndexTmp; 484 std::map<int,std::vector<size_t> > globalIndexTmp; 485 for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 486 { 487 int serverRank = itGlobalMap->first; 488 std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), 489 iteVecGlobal = (itGlobalMap->second).end(); 490 for (int i = 0; i < nbGlobalIndex; ++i) 491 { 492 if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i))) 493 { 494 globalIndexTmp[serverRank].push_back(globalIndexSendToServer(i)); 495 localIndexTmp[serverRank].push_back(localIndexSendToServer(i)); 496 } 497 } 498 } 499 452 500 453 501 if (!doGridHaveDataDistributed()) 454 502 { 455 if (0 == client->clientRank)456 {457 for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns)458 {459 rank = itGlobal->first;460 int nb = (itGlobal->second).size();461 462 CArray<size_t, 1> outGlobalIndexOnServer(nb);463 CArray<int, 1> outLocalIndexToServer(nb);464 for (int k = 0; k < nb; ++k)465 {466 outGlobalIndexOnServer(k) = itGlobal->second.at(k);467 outLocalIndexToServer(k) = itLocal->second.at(k);468 }469 470 storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) ));471 listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer));472 473 list_msg.push_back(shared_ptr<CMessage>(new CMessage));474 *list_msg.back()<<getId()<<*listOutIndex.back();475 event.push(rank, 1, *list_msg.back());476 }477 client->sendEvent(event);478 } else client->sendEvent(event);503 // if (0 == client->clientRank) 504 // { 505 // for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 506 // { 507 // rank = itGlobal->first; 508 // int nb = (itGlobal->second).size(); 509 // 510 // CArray<size_t, 1> outGlobalIndexOnServer(nb); 511 // CArray<int, 1> outLocalIndexToServer(nb); 512 // for (int k = 0; k < nb; ++k) 513 // { 514 // outGlobalIndexOnServer(k) = itGlobal->second.at(k); 515 // outLocalIndexToServer(k) = itLocal->second.at(k); 516 // } 517 // 518 // storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 519 // listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 520 // 521 // list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 522 // *list_msg.back()<<getId()<<*listOutIndex.back(); 523 // event.push(rank, 1, *list_msg.back()); 524 // } 525 // client->sendEvent(event); 526 // } else client->sendEvent(event); 479 527 } 480 528 else 481 529 { 482 for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 483 { 484 rank = itGlobal->first; 485 int nb = (itGlobal->second).size(); 530 for (int ns = 0; ns < connectedServerRank_.size(); ++ns) 531 { 532 rank = connectedServerRank_[ns]; 533 int nb = 0; 534 if (globalIndexTmp.end() != globalIndexTmp.find(rank)) 535 nb = globalIndexTmp[rank].size(); 486 536 487 537 CArray<size_t, 1> outGlobalIndexOnServer(nb); … … 489 539 for (int k = 0; k < nb; ++k) 490 540 { 491 outGlobalIndexOnServer(k) = itGlobal->second.at(k);492 outLocalIndexToServer(k) = itLocal->second.at(k);541 outGlobalIndexOnServer(k) = globalIndexTmp[rank].at(k); 542 outLocalIndexToServer(k) = localIndexTmp[rank].at(k); 493 543 } 494 544 … … 498 548 list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 499 549 *list_msg.back()<<getId()<<*listOutIndex.back(); 550 500 551 event.push(rank, nbSenders[rank], *list_msg.back()); 501 552 } 553 502 554 client->sendEvent(event); 503 555 } … … 555 607 bool CGrid::doGridHaveDataToWrite() 556 608 { 557 return (0 != serverDistribution_); 609 // return (0 != serverDistribution_); 610 return (0 != writtenDataSize_); 558 611 } 559 612 -
XIOS/trunk/src/node/grid.hpp
r568 r584 223 223 CClientServerMapping* clientServerMap_; 224 224 size_t writtenDataSize_; 225 std::map<int,size_t> connectedDataSize_; 226 std::vector<int> connectedServerRank_; 225 227 }; // class CGrid 226 228 -
XIOS/trunk/src/utils.hpp
r571 r584 131 131 }; 132 132 133 template <int v> 134 struct Int2Type 135 { 136 enum { value = v }; 137 }; 138 139 template<typename T> 140 union TypeToBytes { 141 T value; 142 unsigned char bytes[sizeof(value)]; 143 }; 144 145 template<typename T> 146 struct HashAlgorithm 147 { 148 /*! 149 Adapted version of one-at-a-time hash by Bob Jenkins, 150 which is an expanded version of his Dr. Dobbs article. 151 */ 152 static inline size_t jenkins_hash(const T& value) 153 { 154 TypeToBytes<T> u; 155 (u.value) = value; 156 157 size_t hash = 0; 158 size_t length = sizeof(value); 159 160 for (size_t i = 0; i < length; ++i) 161 { 162 hash += u.bytes[i]; 163 hash += (hash << 10); 164 hash ^= (hash >> 6); 165 } 166 hash += (hash << 3); 167 hash ^= (hash >> 11); 168 hash += (hash << 15); 169 170 return hash; 171 } 172 }; 173 174 template<typename T, typename Algo = Int2Type<0> > 175 struct HashXIOS 176 { 177 std::size_t operator()(const T& val) 178 { 179 Algo al; 180 return hash_value(val, al); 181 } 182 183 private: 184 size_t hash_value(const T& val, Int2Type<0>) 185 { 186 return HashAlgorithm<T>::jenkins_hash(val); 187 } 188 }; 133 189 } 134 190
Note: See TracChangeset
for help on using the changeset viewer.