Changeset 1460 for XIOS/dev/branch_openmp/src/distribution_server.cpp
- Timestamp:
- 03/22/18 10:43:20 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/distribution_server.cpp
r1205 r1460 11 11 12 12 namespace xios { 13 14 CDistributionServer::CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex)15 : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_()16 {17 }18 19 CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin,20 const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal)21 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_()22 {23 createGlobalIndex();24 }25 13 26 14 CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin, … … 37 25 const std::vector<CArray<int,1> >& globalIndexElements, 38 26 const CArray<int,1>& elementOrder, 39 const std::vector<int>& nZoomBegin Server,40 const std::vector<int>& nZoomSize Server,27 const std::vector<int>& nZoomBegin, 28 const std::vector<int>& nZoomSize, 41 29 const std::vector<int>& nZoomBeginGlobal, 42 30 const std::vector<int>& nGlobal) 43 31 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 44 nZoomSize_(nZoomSize Server), nZoomBegin_(nZoomBeginServer), globalLocalIndexMap_()32 nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 45 33 { 46 34 createGlobalIndex(globalIndexElements, elementOrder); … … 184 172 /*! 185 173 Compute local index for writing data on server 186 \param [in] globalIndex global index received from client187 \return local index of written data 188 */ 189 CArray<size_t,1> CDistributionServer::computeLocalIndex(const CArray<size_t,1>& globalIndex) 190 { 191 int ssize = globalIndex.numElements();192 CArray<size_t,1> localIndex( ssize);174 \param [in] globalIndex Global index received from client 175 */ 176 void CDistributionServer::computeLocalIndex(CArray<size_t,1>& globalIndex) 177 { 178 size_t ssize = globalIndex.numElements(); 179 size_t localIndexSize = std::min(globalIndex_.numElements(), ssize); 180 CArray<size_t,1> localIndex(localIndexSize); 193 181 GlobalLocalMap::const_iterator ite = globalLocalIndexMap_.end(), it; 194 for (int idx = 0; idx < ssize; ++idx) 182 int i = 0; 183 for (size_t idx = 0; idx < ssize; ++idx) 195 184 { 196 185 it = globalLocalIndexMap_.find(globalIndex(idx)); 197 186 if (ite != it) 198 localIndex(idx) = it->second; 199 } 200 201 return localIndex; 202 } 203 204 /*! 205 Compute local index for writing data on server 206 \param [in] globalIndex Global index received from client 207 */ 208 void CDistributionServer::computeLocalIndex(CArray<size_t,1>& globalIndex) 209 { 210 int ssize = globalIndex.numElements(); 211 CArray<size_t,1> localIndex(ssize); 212 GlobalLocalMap::const_iterator ite = globalLocalIndexMap_.end(), it; 213 for (int idx = 0; idx < ssize; ++idx) 214 { 215 it = globalLocalIndexMap_.find(globalIndex(idx)); 216 if (ite != it) 217 localIndex(idx) = it->second; 187 { 188 localIndex(i) = it->second; 189 ++i; 190 } 218 191 } 219 192 … … 234 207 } 235 208 209 /*! 210 Get the size of grid index in server (e.x: sizeGrid *= size of each dimensiion) 211 */ 212 int CDistributionServer::getGridSize() const 213 { 214 return globalLocalIndexMap_.size(); 215 } 236 216 237 217 const std::vector<int>& CDistributionServer::getZoomBeginGlobal() const … … 249 229 return nZoomSize_; 250 230 } 231 232 void CDistributionServer::partialClear(void) 233 { 234 GlobalLocalMap void1 ; 235 globalLocalIndexMap_.swap(void1) ; 236 } 237 251 238 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.