Changeset 863 for XIOS


Ignore:
Timestamp:
06/09/16 11:32:47 (8 years ago)
Author:
mhnguyen
Message:

Some minor improvements for DHT

+) Use to minimize the redundant loops

Test
+) ON Curie
+) It works well.

File:
1 edited

Legend:

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

    r860 r863  
    105105  size_t index; 
    106106  HashXIOS<size_t> hashGlobalIndex; 
     107  boost::unordered_map<size_t,int> nbIndices; 
     108  nbIndices.rehash(std::ceil(ssize/nbIndices.max_load_factor())); 
    107109  for (int i = 0; i < ssize; ++i) 
    108110  { 
    109111    index = indices(i); 
    110     hashedVal  = hashGlobalIndex(index); 
    111     itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashedVal); 
    112     int indexClient = std::distance(itbClientHash, itClientHash)-1; 
    113     ++sendNbIndexBuff[indexClient]; 
     112    if (0 == nbIndices.count(index)) 
     113    { 
     114      hashedVal  = hashGlobalIndex(index); 
     115      itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashedVal); 
     116      int indexClient = std::distance(itbClientHash, itClientHash)-1; 
     117      ++sendNbIndexBuff[indexClient]; 
     118      nbIndices[index] = 1; 
     119    } 
    114120  } 
    115121 
     
    129135  { 
    130136    index = indices(i); 
    131     hashedVal  = hashGlobalIndex(index); 
    132     itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashedVal); 
    133     { 
     137    if (1 == nbIndices[index]) 
     138    { 
     139      hashedVal  = hashGlobalIndex(index); 
     140      itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashedVal); 
    134141      int indexClient = std::distance(itbClientHash, itClientHash)-1; 
    135       { 
    136         client2ClientIndex[indexClient+groupRankBegin][sendNbIndexBuff[indexClient]] = index; 
    137         ++sendNbIndexBuff[indexClient]; 
    138       } 
     142      client2ClientIndex[indexClient+groupRankBegin][sendNbIndexBuff[indexClient]] = index; 
     143      ++sendNbIndexBuff[indexClient]; 
     144      ++nbIndices[index]; 
    139145    } 
    140146  } 
     
    597603  for (it = itb; it != ite; ++it) 
    598604  { 
    599     int infoVecSize = it->second.size(); 
    600     for (int idx = 0; idx < infoVecSize; ++idx) 
    601     { 
    602       size_t hashIndex = hashGlobalIndex(it->first); 
    603       itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashIndex); 
    604       { 
    605         int indexClient = std::distance(itbClientHash, itClientHash)-1; 
    606         { 
    607           ++sendNbIndexBuff[indexClient]; 
    608         } 
    609       } 
    610     } 
     605    size_t hashIndex = hashGlobalIndex(it->first); 
     606    itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashIndex); 
     607    int indexClient = std::distance(itbClientHash, itClientHash)-1; 
     608    sendNbIndexBuff[indexClient] += it->second.size(); 
    611609  } 
    612610 
     
    628626  { 
    629627    const std::vector<InfoType>& infoTmp = it->second; 
     628    size_t hashIndex = hashGlobalIndex(it->first); 
     629    itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashIndex); 
     630    int indexClient = std::distance(itbClientHash, itClientHash)-1; 
    630631    for (int idx = 0; idx < infoTmp.size(); ++idx) 
    631632    { 
    632       size_t hashIndex = hashGlobalIndex(it->first); 
    633       itClientHash = std::upper_bound(itbClientHash, iteClientHash, hashIndex); 
    634       { 
    635         int indexClient = std::distance(itbClientHash, itClientHash)-1; 
    636         { 
    637           client2ClientIndex[indexClient + groupRankBegin][sendNbIndexBuff[indexClient]] = it->first;; 
    638 //          ProcessDHTElement<InfoType>::packElement(it->second, client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]); 
    639           ProcessDHTElement<InfoType>::packElement(infoTmp[idx], client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]); 
    640           ++sendNbIndexBuff[indexClient]; 
    641         } 
    642       } 
     633      client2ClientIndex[indexClient + groupRankBegin][sendNbIndexBuff[indexClient]] = it->first;; 
     634  //          ProcessDHTElement<InfoType>::packElement(it->second, client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]); 
     635      ProcessDHTElement<InfoType>::packElement(infoTmp[idx], client2ClientInfo[indexClient + groupRankBegin], sendNbInfo[indexClient]); 
     636      ++sendNbIndexBuff[indexClient]; 
    643637    } 
    644638  } 
     
    695689  Index2VectorInfoTypeMap indexToInfoMapping; 
    696690  indexToInfoMapping.rehash(std::ceil(currentIndex/indexToInfoMapping.max_load_factor())); 
     691//  boost::unordered_map<size_t,int> tmpInfoSize; 
     692//  tmpInfoSize.rehash(std::ceil(currentIndex/tmpInfoSize.max_load_factor())); 
     693//  currentIndex = 0; 
     694//  for (int idx = 0; idx < nbRecvClient; ++idx) 
     695//  { 
     696//    int count = recvNbIndexClientCount[idx]; 
     697//    for (int i = 0; i < count; ++i) 
     698//    { 
     699//      ++tmpInfoSize[*(recvIndexBuff+currentIndex+i)]; 
     700//    } 
     701//    currentIndex += count; 
     702//  } 
     703// 
     704//  for (boost::unordered_map<size_t,int>::iterator it=tmpInfoSize.begin(); it != tmpInfoSize.end(); ++it) 
     705//  { 
     706//    indexToInfoMapping[it->first].resize(it->second); 
     707//    it->second = 0; 
     708//  } 
     709 
    697710  currentIndex = 0; 
    698711  InfoType infoValue; 
     
    701714  for (int idx = 0; idx < nbRecvClient; ++idx) 
    702715  { 
     716//    size_t index; 
    703717    int count = recvNbIndexClientCount[idx]; 
    704718    for (int i = 0; i < count; ++i) 
    705719    { 
     720//      index = *(recvIndexBuff+currentIndex+i); 
    706721      ProcessDHTElement<InfoType>::unpackElement(infoValue, infoBuff, infoIndex); 
    707 //      indexToInfoMapping[*(recvIndexBuff+currentIndex+i)] = infoValue; 
     722//      ProcessDHTElement<InfoType>::unpackElement(indexToInfoMapping[index][tmpInfoSize[index]], infoBuff, infoIndex); 
     723//      ++tmpInfoSize[index]; 
    708724      indexToInfoMapping[*(recvIndexBuff+currentIndex+i)].push_back(infoValue); 
    709725    } 
Note: See TracChangeset for help on using the changeset viewer.