Changeset 930 for XIOS/trunk/src/distribution_server.cpp
- Timestamp:
- 09/12/16 18:35:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.