Changeset 653 for XIOS/trunk/src/filter


Ignore:
Timestamp:
07/24/15 16:40:06 (9 years ago)
Author:
rlacroix
Message:

Distributions and transformations: Avoid using heap allocations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/filter/spatial_transform_filter.cpp

    r644 r653  
    7272    CContextClient* client = CContext::getCurrent()->client; 
    7373 
    74     const std::map<int, CArray<int,1>* >& localIndexToSend = gridTransformation->getLocalIndexToSendFromGridSource(); 
     74    const std::map<int, CArray<int,1> >& localIndexToSend = gridTransformation->getLocalIndexToSendFromGridSource(); 
    7575    const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& localIndexToReceive = gridTransformation->getLocalIndexToReceiveOnGridDest(); 
    7676 
     
    7878 
    7979    // Sending data from field sources to do transformations 
    80     std::map<int, CArray<int,1>* >::const_iterator itbSend = localIndexToSend.begin(), itSend, 
    81                                                    iteSend = localIndexToSend.end(); 
     80    std::map<int, CArray<int,1> >::const_iterator itbSend = localIndexToSend.begin(), itSend, 
     81                                                  iteSend = localIndexToSend.end(); 
    8282    int sendBuffSize = 0; 
    83     for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < (itSend->second)->numElements()) 
    84                                                                      ? (itSend->second)->numElements(): sendBuffSize; 
     83    for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < itSend->second.numElements()) 
     84                                                                     ? itSend->second.numElements(): sendBuffSize; 
    8585    double* sendBuff; 
    8686    if (0 != sendBuffSize) sendBuff = new double[sendBuffSize]; 
     
    8888    { 
    8989      int destRank = itSend->first; 
    90       CArray<int,1>* localIndex_p = itSend->second; 
    91       int countSize = localIndex_p->numElements(); 
     90      const CArray<int,1>& localIndex_p = itSend->second; 
     91      int countSize = localIndex_p.numElements(); 
    9292      for (int idx = 0; idx < countSize; ++idx) 
    9393      { 
    94         sendBuff[idx] = dataSrc((*localIndex_p)(idx)); 
     94        sendBuff[idx] = dataSrc(localIndex_p(idx)); 
    9595      } 
    9696      MPI_Send(sendBuff, countSize, MPI_DOUBLE, destRank, 12, client->intraComm); 
     
    9999    // Receiving data on destination fields 
    100100    std::map<int,std::vector<std::vector<std::pair<int,double> > > >::const_iterator itbRecv = localIndexToReceive.begin(), itRecv, 
    101                                                             iteRecv = localIndexToReceive.end(); 
     101                                                                                     iteRecv = localIndexToReceive.end(); 
    102102    int recvBuffSize = 0; 
    103     for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize = (recvBuffSize < (itRecv->second).size()) 
    104                                                                      ? (itRecv->second).size() : recvBuffSize; 
     103    for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize = (recvBuffSize < itRecv->second.size()) 
     104                                                                     ? itRecv->second.size() : recvBuffSize; 
    105105    double* recvBuff; 
    106106    if (0 != recvBuffSize) recvBuff = new double[recvBuffSize]; 
     
    109109      MPI_Status status; 
    110110      int srcRank = itRecv->first; 
    111       int countSize = (itRecv->second).size(); 
     111      int countSize = itRecv->second.size(); 
    112112      MPI_Recv(recvBuff, recvBuffSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &status); 
    113113      for (int idx = 0; idx < countSize; ++idx) 
    114114      { 
    115         const std::vector<std::pair<int,double> >& localIndex_p = (itRecv->second)[idx]; 
     115        const std::vector<std::pair<int,double> >& localIndex_p = itRecv->second[idx]; 
    116116        int numIndex = localIndex_p.size(); 
    117117        for (int i = 0; i < numIndex; ++i) 
    118118        { 
    119 //        if ((localIndex_p)[i].first >= dataDest.numElements() ) 
    120           dataDest((localIndex_p)[i].first) += recvBuff[idx] * ((localIndex_p)[i].second); 
     119//        if (localIndex_p[i].first >= dataDest.numElements()) 
     120          dataDest(localIndex_p[i].first) += recvBuff[idx] * localIndex_p[i].second; 
    121121        } 
    122122      } 
Note: See TracChangeset for help on using the changeset viewer.