Changeset 930


Ignore:
Timestamp:
09/12/16 18:35:00 (8 years ago)
Author:
mhnguyen
Message:

Improving the performance of on server side

+) Replace searching algorithm for global-local index with a better one

Test
+) On Curie
+) Work correct

Location:
XIOS/trunk/src
Files:
4 edited

Legend:

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

    r887 r930  
    1212#include "xios_spl.hpp" 
    1313#include "array_new.hpp" 
     14#include <boost/unordered_map.hpp> 
    1415 
    1516namespace xios { 
     
    2223class CDistribution 
    2324{ 
     25  public: 
     26  typedef boost::unordered_map<size_t,int> GlobalLocalMap; 
     27 
    2428  public: 
    2529    /** Default constructor */ 
  • XIOS/trunk/src/distribution_client.hpp

    r887 r930  
    1414#include "domain.hpp" 
    1515#include "grid.hpp" 
    16 #include <boost/unordered_map.hpp> 
    1716 
    1817namespace xios { 
     
    3130{ 
    3231public: 
    33   typedef boost::unordered_map<size_t,int> GlobalLocalDataMap; 
     32  typedef CDistribution::GlobalLocalMap GlobalLocalDataMap; 
    3433 
    3534  public: 
  • XIOS/trunk/src/distribution_server.cpp

    r676 r930  
    33   \author Ha NGUYEN 
    44   \since 13 Jan 2015 
    5    \date 04 Feb 2015 
     5   \date 10 Sep 2016 
    66 
    77   \brief Index distribution on server side. 
     
    1313 
    1414CDistributionServer::CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex) 
    15   : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_() 
     15  : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_() 
    1616{ 
    1717} 
     
    1919CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin, 
    2020                                         const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal) 
    21   : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin) 
     21  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 
    2222{ 
    2323  createGlobalIndex(); 
     
    2929                                         const std::vector<int>& nGlobal) 
    3030  : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 
    31     nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin) 
     31    nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 
    3232{ 
    3333  createGlobalIndex(); 
     
    5454  int innerLoopSize = nZoomSize_[0]; 
    5555 
     56  globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor())); 
    5657  while (idx<ssize) 
    5758  { 
     
    7879        globalIndex += (currentIndex[k])*mulDim; 
    7980      } 
     81      globalLocalIndexMap_[globalIndex] = idx; 
    8082      this->globalIndex_(idx) = globalIndex; 
     83 
    8184      ++idx; 
    8285    } 
     
    9396{ 
    9497  int ssize = globalIndex.numElements(); 
    95   int nbGlobalIndex = this->globalIndex_.numElements(); 
    96  
    97   std::vector<int>::iterator it; 
    98   std::vector<int> permutIndex(nbGlobalIndex); 
    99   XIOSAlgorithms::fillInIndex(nbGlobalIndex, permutIndex); 
    100   XIOSAlgorithms::sortWithIndex<size_t, CArrayStorage>(this->globalIndex_, permutIndex); 
    101   typedef XIOSBinarySearchWithIndex<size_t, CArrayStorage> BinarySearch; 
    102   BinarySearch binarySearch(this->globalIndex_); 
    103  
    10498  CArray<size_t,1> localIndex(ssize); 
    105   int idx = 0; 
    106   for (int i = 0; i < ssize; ++i) 
     99  GlobalLocalMap::const_iterator ite = globalLocalIndexMap_.end(), it; 
     100  for (int idx = 0; idx < ssize; ++idx) 
    107101  { 
    108     if (binarySearch.search(permutIndex.begin(), permutIndex.end(), globalIndex(i), it)) 
    109     { 
    110       localIndex(idx) = *it; 
    111       ++idx; 
    112     } 
     102    it = globalLocalIndexMap_.find(globalIndex(idx)); 
     103    if (ite != it) 
     104      localIndex(idx) = it->second; 
    113105  } 
    114106 
     
    123115{ 
    124116  int ssize = globalIndex.numElements(); 
    125   int nbGlobalIndex = this->globalIndex_.numElements(); 
    126  
    127   std::vector<int>::iterator it; 
    128   std::vector<int> permutIndex(nbGlobalIndex); 
    129   XIOSAlgorithms::fillInIndex(nbGlobalIndex, permutIndex); 
    130   XIOSAlgorithms::sortWithIndex<size_t, CArrayStorage>(this->globalIndex_, permutIndex); 
    131   typedef XIOSBinarySearchWithIndex<size_t, CArrayStorage> BinarySearch; 
    132   BinarySearch binarySearch(this->globalIndex_); 
    133  
    134117  CArray<size_t,1> localIndex(ssize); 
    135   int idx = 0; 
    136   for (int i = 0; i < ssize; ++i) 
     118  GlobalLocalMap::const_iterator ite = globalLocalIndexMap_.end(), it; 
     119  for (int idx = 0; idx < ssize; ++idx) 
    137120  { 
    138     if (binarySearch.search(permutIndex.begin(), permutIndex.end(), globalIndex(i), it)) 
    139     { 
    140       localIndex(idx) = *it; 
    141       ++idx; 
    142     } 
     121    it = globalLocalIndexMap_.find(globalIndex(idx)); 
     122    if (ite != it) 
     123      localIndex(idx) = it->second; 
    143124  } 
    144125 
    145   globalIndex = localIndex; 
     126  globalIndex.reference(localIndex); 
    146127} 
    147128 
  • XIOS/trunk/src/distribution_server.hpp

    r676 r930  
    4444  protected: 
    4545    virtual void createGlobalIndex(); 
     46 
     47  protected: 
     48    GlobalLocalMap globalLocalIndexMap_; 
     49 
    4650  private: 
    4751    std::vector<int> nGlobal_; 
Note: See TracChangeset for help on using the changeset viewer.