- Timestamp:
- 01/31/19 12:12:52 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_omp/src/filter/spatial_transform_filter.cpp
r1601 r1646 5 5 #include "context_client.hpp" 6 6 #include "timer.hpp" 7 #ifdef _usingEP 7 8 using namespace ep_lib; 9 #endif 8 10 9 11 namespace xios … … 197 199 198 200 CContextClient* client = CContext::getCurrent()->client; 201 int rank; 202 MPI_Comm_rank (client->intraComm, &rank); 199 203 200 204 // Get default value for output data … … 206 210 const std::list<CGridTransformation::RecvIndexGridDestinationMap>& listLocalIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 207 211 const std::list<size_t>& listNbLocalIndexToReceive = gridTransformation->getNbLocalIndexToReceiveOnGridDest(); 208 const std::list<std::vector<bool> >& listLocalIndexMaskOnDest = gridTransformation->getLocalMaskIndexOnGridDest();209 212 const std::vector<CGenericAlgorithmTransformation*>& listAlgos = gridTransformation->getAlgos(); 210 213 … … 215 218 std::list<CGridTransformation::RecvIndexGridDestinationMap>::const_iterator itListRecv = listLocalIndexToReceive.begin(); 216 219 std::list<size_t>::const_iterator itNbListRecv = listNbLocalIndexToReceive.begin(); 217 std::list<std::vector<bool> >::const_iterator itLocalMaskIndexOnDest = listLocalIndexMaskOnDest.begin();218 220 std::vector<CGenericAlgorithmTransformation*>::const_iterator itAlgo = listAlgos.begin(); 219 221 220 for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++it LocalMaskIndexOnDest, ++itAlgo)222 for (; itListSend != iteListSend; ++itListSend, ++itListRecv, ++itNbListRecv, ++itAlgo) 221 223 { 222 224 CArray<double,1> dataCurrentSrc(dataCurrentDest); … … 228 230 int idxSendBuff = 0; 229 231 std::vector<double*> sendBuff(localIndexToSend.size()); 232 double* sendBuffRank; 230 233 for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 231 234 { 235 int destRank = itSend->first; 232 236 if (0 != itSend->second.numElements()) 233 sendBuff[idxSendBuff] = new double[itSend->second.numElements()]; 237 { 238 if (rank != itSend->first) 239 sendBuff[idxSendBuff] = new double[itSend->second.numElements()]; 240 else 241 sendBuffRank = new double[itSend->second.numElements()]; 242 } 234 243 } 235 244 … … 242 251 const CArray<int,1>& localIndex_p = itSend->second; 243 252 int countSize = localIndex_p.numElements(); 244 for (int idx = 0; idx < countSize; ++idx) 245 { 246 sendBuff[idxSendBuff][idx] = dataCurrentSrc(localIndex_p(idx)); 247 } 248 MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRecvRequest[position++]); 253 if (destRank != rank) 254 { 255 for (int idx = 0; idx < countSize; ++idx) 256 { 257 sendBuff[idxSendBuff][idx] = dataCurrentSrc(localIndex_p(idx)); 258 } 259 MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRecvRequest[position++]); 260 261 } 262 else 263 { 264 for (int idx = 0; idx < countSize; ++idx) 265 { 266 sendBuffRank[idx] = dataCurrentSrc(localIndex_p(idx)); 267 } 268 } 249 269 } 250 270 … … 254 274 iteRecv = localIndexToReceive.end(); 255 275 int recvBuffSize = 0; 256 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize += itRecv->second.size(); //(recvBuffSize < itRecv->second.size()) 257 //? itRecv->second.size() : recvBuffSize; 276 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 277 { 278 if (itRecv->first != rank ) 279 recvBuffSize += itRecv->second.size(); 280 } 281 //(recvBuffSize < itRecv->second.size()) ? itRecv->second.size() : recvBuffSize; 258 282 double* recvBuff; 283 259 284 if (0 != recvBuffSize) recvBuff = new double[recvBuffSize]; 260 285 int currentBuff = 0; … … 262 287 { 263 288 int srcRank = itRecv->first; 264 int countSize = itRecv->second.size(); 265 MPI_Irecv(recvBuff + currentBuff, countSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &sendRecvRequest[position++]); 266 currentBuff += countSize; 289 if (srcRank != rank) 290 { 291 int countSize = itRecv->second.size(); 292 MPI_Irecv(recvBuff + currentBuff, countSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &sendRecvRequest[position++]); 293 currentBuff += countSize; 294 } 267 295 } 268 296 std::vector<MPI_Status> status(sendRecvRequest.size()); 269 MPI_Waitall(sendRecvRequest.size(), &sendRecvRequest[0], &status[0]); 297 MPI_Waitall(position, &sendRecvRequest[0], &status[0]); 298 299 270 300 271 301 dataCurrentDest.resize(*itNbListRecv); 272 const std::vector<bool>& localMaskDest = *itLocalMaskIndexOnDest; 273 for (int i = 0; i < localMaskDest.size(); ++i) 274 if (localMaskDest[i]) dataCurrentDest(i) = 0.0; 275 else dataCurrentDest(i) = defaultValue; 302 dataCurrentDest = 0.0; 276 303 277 304 std::vector<bool> localInitFlag(dataCurrentDest.numElements(), true); … … 280 307 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 281 308 { 282 int countSize = itRecv->second.size();283 309 const std::vector<std::pair<int,double> >& localIndex_p = itRecv->second; 284 (*itAlgo)->apply(localIndex_p, 285 recvBuff+currentBuff, 286 dataCurrentDest, 287 localInitFlag, 288 ignoreMissingValue,firstPass); 289 290 currentBuff += countSize; 310 int srcRank = itRecv->first; 311 if (srcRank != rank) 312 { 313 int countSize = itRecv->second.size(); 314 (*itAlgo)->apply(localIndex_p, 315 recvBuff+currentBuff, 316 dataCurrentDest, 317 localInitFlag, 318 ignoreMissingValue,firstPass); 319 currentBuff += countSize; 320 } 321 else 322 { 323 (*itAlgo)->apply(localIndex_p, 324 sendBuffRank, 325 dataCurrentDest, 326 localInitFlag, 327 ignoreMissingValue,firstPass); 328 } 329 291 330 firstPass=false ; 292 331 } … … 298 337 { 299 338 if (0 != itSend->second.numElements()) 300 delete [] sendBuff[idxSendBuff]; 339 { 340 if (rank != itSend->first) 341 delete [] sendBuff[idxSendBuff]; 342 else 343 delete [] sendBuffRank; 344 } 301 345 } 302 346 if (0 != recvBuffSize) delete [] recvBuff;
Note: See TracChangeset
for help on using the changeset viewer.