Changeset 930
- Timestamp:
- 09/12/16 18:35:00 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/distribution.hpp
r887 r930 12 12 #include "xios_spl.hpp" 13 13 #include "array_new.hpp" 14 #include <boost/unordered_map.hpp> 14 15 15 16 namespace xios { … … 22 23 class CDistribution 23 24 { 25 public: 26 typedef boost::unordered_map<size_t,int> GlobalLocalMap; 27 24 28 public: 25 29 /** Default constructor */ -
XIOS/trunk/src/distribution_client.hpp
r887 r930 14 14 #include "domain.hpp" 15 15 #include "grid.hpp" 16 #include <boost/unordered_map.hpp>17 16 18 17 namespace xios { … … 31 30 { 32 31 public: 33 typedef boost::unordered_map<size_t,int>GlobalLocalDataMap;32 typedef CDistribution::GlobalLocalMap GlobalLocalDataMap; 34 33 35 34 public: -
XIOS/trunk/src/distribution_server.cpp
r676 r930 3 3 \author Ha NGUYEN 4 4 \since 13 Jan 2015 5 \date 04 Feb 20155 \date 10 Sep 2016 6 6 7 7 \brief Index distribution on server side. … … 13 13 14 14 CDistributionServer::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_() 16 16 { 17 17 } … … 19 19 CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin, 20 20 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_() 22 22 { 23 23 createGlobalIndex(); … … 29 29 const std::vector<int>& nGlobal) 30 30 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 31 nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin) 31 nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 32 32 { 33 33 createGlobalIndex(); … … 54 54 int innerLoopSize = nZoomSize_[0]; 55 55 56 globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor())); 56 57 while (idx<ssize) 57 58 { … … 78 79 globalIndex += (currentIndex[k])*mulDim; 79 80 } 81 globalLocalIndexMap_[globalIndex] = idx; 80 82 this->globalIndex_(idx) = globalIndex; 83 81 84 ++idx; 82 85 } … … 93 96 { 94 97 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 104 98 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) 107 101 { 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; 113 105 } 114 106 … … 123 115 { 124 116 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 134 117 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) 137 120 { 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; 143 124 } 144 125 145 globalIndex = localIndex;126 globalIndex.reference(localIndex); 146 127 } 147 128 -
XIOS/trunk/src/distribution_server.hpp
r676 r930 44 44 protected: 45 45 virtual void createGlobalIndex(); 46 47 protected: 48 GlobalLocalMap globalLocalIndexMap_; 49 46 50 private: 47 51 std::vector<int> nGlobal_;
Note: See TracChangeset
for help on using the changeset viewer.