Ignore:
Timestamp:
03/23/16 16:11:09 (8 years ago)
Author:
mhnguyen
Message:

Cleaning up some redundant coeds and making some improvements

+) Remove some XIOS Search to make code run faster
+) Remove some commented codes

Test
+) On Curie
+) All tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/grid.cpp

    r829 r831  
    459459     const CClientServerMapping::GlobalIndexMap& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    460460 
    461      const std::vector<size_t>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
     461     const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 
     462     CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 
    462463     CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
    463464     itGlobalMap  = itbGlobalMap = globalIndexOnServer.begin(); 
    464465     iteGlobalMap = globalIndexOnServer.end(); 
    465466 
    466      typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
    467      std::vector<int>::iterator itVec; 
    468      int nbGlobalIndex = globalIndexSendToServer.size(); 
    469467     for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    470468     { 
    471469       int serverRank = itGlobalMap->first; 
    472470       int indexSize = itGlobalMap->second.size(); 
    473        std::vector<int> permutIndex(indexSize); 
    474        XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
    475        XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(itGlobalMap->second, permutIndex); 
    476        BinarySearch binSearch(itGlobalMap->second); 
    477        for (int i = 0; i < nbGlobalIndex; ++i) 
     471       const std::vector<size_t>& indexVec = itGlobalMap->second; 
     472       for (int idx = 0; idx < indexSize; ++idx) 
    478473       { 
    479          if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexSendToServer[i], itVec)) 
    480          { 
    481            if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
    482              connectedDataSize_[serverRank] = 1; 
    483            else 
    484              ++connectedDataSize_[serverRank]; 
    485          } 
     474          itGlobalLocalIndexMap = globalLocalIndexSendToServer.find(indexVec[idx]); 
     475          if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap) 
     476          { 
     477             if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
     478               connectedDataSize_[serverRank] = 1; 
     479             else 
     480               ++connectedDataSize_[serverRank]; 
     481          } 
    486482       } 
    487483     } 
     
    788784    list<CArray<size_t,1> > listOutIndex; 
    789785    const CClientServerMapping::GlobalIndexMap& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    790     const std::vector<int>& localIndexSendToServer = clientDistribution_->getLocalDataIndexSendToServer(); 
    791     const std::vector<size_t>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
     786    const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 
     787    CDistributionClient::GlobalLocalDataMap::const_iterator itIndex = globalLocalIndexSendToServer.begin(), 
     788                                                           iteIndex = globalLocalIndexSendToServer.end(); 
    792789 
    793790    if (!doGridHaveDataDistributed()) 
     
    795792      if (0 == client->clientRank) 
    796793      { 
    797         CArray<size_t,1> outGlobalIndexOnServer(globalIndexSendToServer.size()); 
    798         for (int idx = 0; idx < globalIndexSendToServer.size();++idx) 
    799           outGlobalIndexOnServer(idx) = globalIndexSendToServer[idx]; 
    800  
    801         CArray<int,1> outLocalIndexToServer(localIndexSendToServer.size()); 
    802         for (int idx = 0; idx < localIndexSendToServer.size();++idx) 
    803           outLocalIndexToServer(idx) = localIndexSendToServer[idx]; 
     794        int indexSize = globalLocalIndexSendToServer.size(); 
     795        CArray<size_t,1> outGlobalIndexOnServer(indexSize); 
     796        CArray<int,1> outLocalIndexToServer(indexSize); 
     797        for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx) 
     798        { 
     799          outGlobalIndexOnServer(idx) = itIndex->first; 
     800          outLocalIndexToServer(idx) = itIndex->second; 
     801        } 
    804802 
    805803        for (rank = 0; rank < client->serverSize; ++rank) 
     
    821819    else 
    822820    { 
    823       CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
    824       itbGlobalMap = itGlobalMap = globalIndexOnServer.begin(); 
     821      CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 
     822      itGlobalMap = globalIndexOnServer.begin(); 
    825823      iteGlobalMap = globalIndexOnServer.end(); 
    826824 
    827       int nbGlobalIndex = globalIndexSendToServer.size(); 
    828825      std::map<int,std::vector<int> >localIndexTmp; 
    829826      std::map<int,std::vector<size_t> > globalIndexTmp; 
    830  
    831       typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
    832       std::vector<int>::iterator itVec; 
    833827      for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    834828      { 
    835829        int serverRank = itGlobalMap->first; 
    836830        int indexSize = itGlobalMap->second.size(); 
    837         std::vector<int> permutIndex(indexSize); 
    838         XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
    839         XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(itGlobalMap->second, permutIndex); 
    840         BinarySearch binSearch(itGlobalMap->second); 
    841  
    842         for (int i = 0; i < nbGlobalIndex; ++i) 
     831        const std::vector<size_t>& indexVec = itGlobalMap->second; 
     832        for (int idx = 0; idx < indexSize; ++idx) 
    843833        { 
    844           if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexSendToServer[i], itVec)) 
     834          itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 
     835          if (iteIndex != itIndex) 
    845836          { 
    846             globalIndexTmp[serverRank].push_back(globalIndexSendToServer[i]); 
    847             localIndexTmp[serverRank].push_back(localIndexSendToServer[i]); 
     837            globalIndexTmp[serverRank].push_back(itIndex->first); 
     838            localIndexTmp[serverRank].push_back(itIndex->second); 
    848839          } 
    849840        } 
Note: See TracChangeset for help on using the changeset viewer.