Changeset 568 for XIOS/trunk/src/server_distribution_description.cpp
- Timestamp:
- 03/10/15 10:49:09 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/server_distribution_description.cpp
r557 r568 13 13 { 14 14 CServerDistributionDescription::CServerDistributionDescription(const std::vector<int>& globalDimensionSize) 15 : nGlobal_(globalDimensionSize), indexBegin_(), dimensionSizes_(), globalIndex_( 0), vecGlobalIndex_()15 : nGlobal_(globalDimensionSize), indexBegin_(), dimensionSizes_(), globalIndex_(), vecGlobalIndex_() 16 16 { 17 17 … … 20 20 CServerDistributionDescription::~CServerDistributionDescription() 21 21 { 22 if (0 != globalIndex_) delete globalIndex_;22 // if (0 != globalIndex_) delete globalIndex_; 23 23 if (!vecGlobalIndex_.empty()) 24 24 for (int i = 0; i < vecGlobalIndex_.size(); ++i) delete vecGlobalIndex_[i]; … … 92 92 } 93 93 94 void CServerDistributionDescription::computeServerGlobalIndexInRange(int nServer, 95 const std::pair<size_t, size_t>& indexBeginEnd, 96 ServerDistributionType distributionType) 97 { 98 switch (distributionType) { 99 case BAND_DISTRIBUTION: 100 computeBandDistribution(nServer); 101 break; 102 default: 103 break; 104 } 105 106 size_t indexBegin = indexBeginEnd.first; 107 size_t indexEnd = indexBeginEnd.second; 108 if (indexBegin > indexEnd) 109 ERROR("CServerDistributionDescription::computeServerGlobalIndexInRange", 110 << "Index begin is larger than index end"); 111 112 int dim = nGlobal_.size(); 113 std::vector<int> currentIndex(dim); 114 115 for (int idxServer = 0; idxServer < nServer; ++idxServer) 116 { 117 size_t ssize = 1, idx = 0; 118 for (int j = 0; j < dim; ++j) ssize *= dimensionSizes_[idxServer][j]; 119 vecGlobalIndex_[idxServer] = new CArray<size_t,1>(ssize); 120 121 std::vector<int> idxLoop(dim,0); 122 123 int innerLoopSize = dimensionSizes_[idxServer][0]; 124 125 while (idx<ssize) 126 { 127 for (int idxDim = 0; idxDim < dim-1; ++idxDim) 128 { 129 if (idxLoop[idxDim] == dimensionSizes_[idxServer][idxDim]) 130 { 131 idxLoop[idxDim] = 0; 132 ++idxLoop[idxDim+1]; 133 } 134 } 135 136 for (int idxDim = 1; idxDim < dim; ++idxDim) currentIndex[idxDim] = idxLoop[idxDim] + indexBegin_[idxServer][idxDim]; 137 138 size_t mulDim, globalIndex; 139 for (int j = 0; j < innerLoopSize; ++j) 140 { 141 mulDim = 1; 142 globalIndex = j + indexBegin_[idxServer][0]; 143 144 for (int k = 1; k < dim; ++k) 145 { 146 mulDim *= nGlobal_[k-1]; 147 globalIndex += (currentIndex[k])*mulDim; 148 } 149 if ((indexBegin <= globalIndex) && (globalIndex <= indexEnd)) 150 globalIndex_.insert(std::make_pair<size_t,int>(globalIndex, idxServer)); 151 ++idx; 152 } 153 idxLoop[0] += innerLoopSize; 154 } 155 } 156 157 } 158 94 159 /*! 95 160 Compute global index of servers with band distribution … … 178 243 } 179 244 245 const boost::unordered_map<size_t,int>& CServerDistributionDescription::getGlobalIndexRange() const 246 { 247 return globalIndex_; 248 } 180 249 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.