Ignore:
Timestamp:
04/26/16 16:04:04 (6 years ago)
Author:
mhnguyen
Message:

Several improvements

+) Replace some time-consuming operations by simpler ones

Test
+) On Curie
+) All tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/client_client_dht_template_impl.hpp

    r839 r843  
    2424CClientClientDHTTemplate<T,H>::CClientClientDHTTemplate(const boost::unordered_map<size_t,T>& indexInfoMap, 
    2525                                                        const MPI_Comm& clientIntraComm) 
    26   : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_() 
    27 { 
     26  : H(clientIntraComm), index2InfoMapping_(), indexToInfoMappingLevel_(), nbClient_(0) 
     27{ 
     28  MPI_Comm_size(clientIntraComm, &nbClient_); 
    2829  this->computeMPICommLevel(); 
    2930  int nbLvl = this->getNbLevel(); 
     
    8889  } 
    8990 
    90   std::map<int, size_t* > client2ClientIndex; 
     91  boost::unordered_map<int, size_t* > client2ClientIndex; 
    9192  for (int idx = 0; idx < nbClient; ++idx) 
    9293  { 
     
    140141  } 
    141142 
    142   std::map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex, 
    143                                     iteIndex = client2ClientIndex.end(); 
     143  boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex, 
     144                                                iteIndex = client2ClientIndex.end(); 
    144145  for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex) 
    145146    sendIndexToClients(itIndex->first, (itIndex->second), sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request); 
     
    213214  } 
    214215 
    215   std::map<int,unsigned char*> client2ClientInfoOnReturn; 
    216   std::map<int,size_t*> client2ClientIndexOnReturn; 
     216  boost::unordered_map<int,unsigned char*> client2ClientInfoOnReturn; 
     217  boost::unordered_map<int,size_t*> client2ClientIndexOnReturn; 
    217218  currentIndex = 0; 
    218219  for (int idx = 0; idx < nbRecvClient; ++idx) 
     
    249250 
    250251  boost::unordered_map<size_t,InfoType> indexToInfoMapping; 
     252  indexToInfoMapping.rehash(std::ceil(recvNbIndexCountOnReturn/indexToInfoMapping.max_load_factor())); 
    251253  int infoIndex = 0; 
    252254  for (int idx = 0; idx < recvNbIndexCountOnReturn; ++idx) 
     
    255257  } 
    256258 
    257   indexToInfoMappingLevel_ = (indexToInfoMapping); 
     259  indexToInfoMappingLevel_.swap(indexToInfoMapping); //indexToInfoMappingLevel_ = (indexToInfoMapping); 
    258260  if (0 != recvNbIndexCount) delete [] recvIndexBuff; 
    259   for (std::map<int,size_t*>::const_iterator it = client2ClientIndex.begin(); 
    260                                             it != client2ClientIndex.end(); ++it) 
     261  for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin(); 
     262                                                        it != client2ClientIndex.end(); ++it) 
    261263      delete [] it->second; 
    262264  delete tmpGlobalIndex; 
     
    268270  } 
    269271 
    270   for (std::map<int,unsigned char*>::const_iterator it = client2ClientInfoOnReturn.begin(); 
    271                                                     it != client2ClientInfoOnReturn.end(); ++it) 
     272  for (boost::unordered_map<int,unsigned char*>::const_iterator it = client2ClientInfoOnReturn.begin(); 
     273                                                               it != client2ClientInfoOnReturn.end(); ++it) 
    272274      delete [] it->second; 
    273275 
    274   for (std::map<int,size_t*>::const_iterator it = client2ClientIndexOnReturn.begin(); 
     276  for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndexOnReturn.begin(); 
    275277                                            it != client2ClientIndexOnReturn.end(); ++it) 
    276278      delete [] it->second; 
     
    342344  } 
    343345 
    344   std::map<int, size_t*> client2ClientIndex; 
    345   std::map<int, unsigned char*> client2ClientInfo; 
     346  boost::unordered_map<int, size_t*> client2ClientIndex; 
     347  boost::unordered_map<int, unsigned char*> client2ClientInfo; 
    346348  for (int idx = 0; idx < nbClient; ++idx) 
    347349  { 
     
    407409  } 
    408410 
    409   std::map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex, 
    410                                     iteIndex = client2ClientIndex.end(); 
     411  boost::unordered_map<int, size_t* >::iterator itbIndex = client2ClientIndex.begin(), itIndex, 
     412                                                iteIndex = client2ClientIndex.end(); 
    411413  for (itIndex = itbIndex; itIndex != iteIndex; ++itIndex) 
    412414    sendIndexToClients(itIndex->first, itIndex->second, sendNbIndexBuff[itIndex->first-groupRankBegin], commLevel, request); 
    413   std::map<int, unsigned char*>::iterator itbInfo = client2ClientInfo.begin(), itInfo, 
    414                                           iteInfo = client2ClientInfo.end(); 
     415  boost::unordered_map<int, unsigned char*>::iterator itbInfo = client2ClientInfo.begin(), itInfo, 
     416                                                      iteInfo = client2ClientInfo.end(); 
    415417  for (itInfo = itbInfo; itInfo != iteInfo; ++itInfo) 
    416418    sendInfoToClients(itInfo->first, itInfo->second, sendNbInfo[itInfo->first-groupRankBegin], commLevel, request); 
     
    420422 
    421423  boost::unordered_map<size_t,InfoType> indexToInfoMapping; 
     424  indexToInfoMapping.rehash(std::ceil(currentIndex/indexToInfoMapping.max_load_factor())); 
    422425  currentIndex = 0; 
    423426  InfoType infoValue; 
     
    440443    delete [] recvInfoBuff; 
    441444  } 
    442   for (std::map<int,unsigned char*>::const_iterator it = client2ClientInfo.begin(); 
    443                                                     it != client2ClientInfo.end(); ++it) 
     445  for (boost::unordered_map<int,unsigned char*>::const_iterator it = client2ClientInfo.begin(); 
     446                                                               it != client2ClientInfo.end(); ++it) 
    444447      delete [] it->second; 
    445448 
    446   for (std::map<int,size_t*>::const_iterator it = client2ClientIndex.begin(); 
    447                                             it != client2ClientIndex.end(); ++it) 
     449  for (boost::unordered_map<int,size_t*>::const_iterator it = client2ClientIndex.begin(); 
     450                                                        it != client2ClientIndex.end(); ++it) 
    448451      delete [] it->second; 
    449452 
     
    455458  } 
    456459  else 
    457     index2InfoMapping_ = (indexToInfoMapping); 
     460    index2InfoMapping_.swap(indexToInfoMapping); //index2InfoMapping_ = (indexToInfoMapping); 
    458461} 
    459462 
Note: See TracChangeset for help on using the changeset viewer.