Changeset 709


Ignore:
Timestamp:
09/29/15 14:01:53 (9 years ago)
Author:
mhnguyen
Message:

Correcting a bug in interpolation domain

+) Replace shared send buffer by seperate buffer for each proc
+) Remove some redundant codes

Test
+) On Curie
+) test_client, test_complete and test_remap pass

Location:
XIOS/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/bld.cfg

    r691 r709  
    3030src::remap $PWD/extern/remap/src 
    3131bld::lib xios 
    32 bld::lib::remap mapper 
    33 bld::target libxios.a libmapper.a 
     32bld::target libxios.a  
    3433#bld::target generate_fortran_interface.exe  
    3534bld::target xios_server.exe test_remap.exe 
    36 #bld::target test_new_features.exe test_unstruct_complete.exe  
     35bld::target test_new_features.exe test_unstruct_complete.exe  
    3736bld::target test_client.exe test_complete.exe 
    3837bld::exe_dep 
  • XIOS/trunk/inputs/REMAP/iodef.xml

    r689 r709  
    1313 
    1414 
    15    <file_definition type="multiple_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 
     15   <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 
    1616     <file id="output" name="output"> 
    1717        <field field_ref="src_field" name="field" /> 
     
    3232     <domain id="src_domain" /> 
    3333     <domain id="dst_domain" domain_src="src_domain"> 
    34        <interpolate_domain file="weight.nc"/> 
     34<!--       <interpolate_domain file="weight.nc"/>--> 
     35       <interpolate_domain/> 
    3536     </domain> 
    36      <domain id="dst_domain_regular" domain_src="src_domain"> 
     37     <domain id="dst_domain_regular" domain_src="src_domain" ni_glo="180" nj_glo="90"> 
    3738       <generate_rectilinear_domain /> 
    3839       <interpolate_domain/> 
  • XIOS/trunk/src/filter/spatial_transform_filter.cpp

    r690 r709  
    8080    std::map<int, CArray<int,1> >::const_iterator itbSend = localIndexToSend.begin(), itSend, 
    8181                                                  iteSend = localIndexToSend.end(); 
    82     int sendBuffSize = 0; 
    83     for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize = (sendBuffSize < itSend->second.numElements()) 
    84                                                                      ? itSend->second.numElements(): sendBuffSize; 
    85     double* sendBuff; 
    86     if (0 != sendBuffSize) sendBuff = new double[sendBuffSize]; 
     82    int idxSendBuff = 0; 
     83    std::vector<double*> sendBuff(localIndexToSend.size()); 
     84    for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 
     85    { 
     86      if (0 != itSend->second.numElements()) 
     87        sendBuff[idxSendBuff] = new double[itSend->second.numElements()]; 
     88    } 
     89 
     90    idxSendBuff = 0; 
    8791    std::vector<MPI_Request> sendRequest; 
    88     for (itSend = itbSend; itSend != iteSend; ++itSend) 
     92    for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 
    8993    { 
    9094      int destRank = itSend->first; 
     
    9397      for (int idx = 0; idx < countSize; ++idx) 
    9498      { 
    95         sendBuff[idx] = dataSrc(localIndex_p(idx)); 
     99        sendBuff[idxSendBuff][idx] = dataSrc(localIndex_p(idx)); 
    96100      } 
    97101      sendRequest.push_back(MPI_Request()); 
    98       MPI_Isend(sendBuff, countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRequest.back()); 
     102      MPI_Isend(sendBuff[idxSendBuff], countSize, MPI_DOUBLE, destRank, 12, client->intraComm, &sendRequest.back()); 
    99103    } 
    100104 
     
    113117      int countSize = itRecv->second.size(); 
    114118      MPI_Recv(recvBuff, recvBuffSize, MPI_DOUBLE, srcRank, 12, client->intraComm, &status); 
     119      int countBuff = 0; 
     120      MPI_Get_count(&status, MPI_DOUBLE, &countBuff); 
     121      if (countBuff != countSize) 
     122        ERROR("CSpatialTransformFilterEngine::apply(const CArray<double, 1>& dataSrc, CArray<double,1>& dataDest)", 
     123              "Incoherent between the received size and expected size"); 
    115124      for (int idx = 0; idx < countSize; ++idx) 
    116125      { 
     
    119128        for (int i = 0; i < numIndex; ++i) 
    120129        { 
    121 //        if (localIndex_p[i].first >= dataDest.numElements()) 
    122130          dataDest(localIndex_p[i].first) += recvBuff[idx] * localIndex_p[i].second; 
    123131        } 
     
    125133    } 
    126134 
    127     std::vector<MPI_Status> requestStatus(sendRequest.size()); 
    128     if (!sendRequest.empty()) MPI_Wait(&sendRequest[0], &requestStatus[0]); 
    129     if (0 != sendBuffSize) delete [] sendBuff; 
     135 
     136    if (!sendRequest.empty()) MPI_Waitall(sendRequest.size(), &sendRequest[0], MPI_STATUSES_IGNORE); 
     137    idxSendBuff = 0; 
     138    for (itSend = itbSend; itSend != iteSend; ++itSend, ++idxSendBuff) 
     139    { 
     140      if (0 != itSend->second.numElements()) 
     141        delete [] sendBuff[idxSendBuff]; 
     142    } 
    130143    if (0 != recvBuffSize) delete [] recvBuff; 
    131144  } 
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r707 r709  
    16251625                  } 
    16261626/* 
    1627                   int ssize = nZoomBeginGlobal.size(); 
    16281627                  for (int i = numElement - 1; i >= 0; --i) 
    16291628 
    16301629 
    1631                   start.resize(ssize); 
    1632                   count.resize(ssize); 
    1633  
    1634                   for (int i = 0; i < ssize; ++i) 
     1630                  start.reserve(nZoomBeginGlobal.size()); 
     1631                  count.reserve(nZoomBeginGlobal.size()); 
     1632 
     1633 
     1634                  for (int i = numElement - 1; i >= 0; --i) 
    16351635                  { 
    1636                     start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1]; 
    1637                     count[i] = nZoomSizeServer[ssize - i - 1]; 
     1636                    if (axisDomainOrder(i)) 
     1637                    { 
     1638                      CDomain* domain = CDomain::get(domainList[idxDomain]); 
     1639 
     1640                      if (CDomain::type_attr::unstructured != domain->type) 
     1641                      { 
     1642                        start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     1643                        count.push_back(nZoomSizeServer[idx]); 
     1644                      } 
     1645                      --idx; 
     1646                      start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     1647                      count.push_back(nZoomSizeServer[idx]); 
     1648                      --idx; 
     1649 
     1650                      --idxDomain; 
     1651                      //idx -= 2; 
     1652                    } 
     1653                    else 
     1654                    { 
     1655                      CAxis* axis = CAxis::get(axisList[idxAxis]); 
     1656 
     1657                      start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 
     1658                      count.push_back(nZoomSizeServer[idx]); 
     1659 
     1660                      --idxAxis; 
     1661                      --idx; 
     1662                    } 
    16381663                  } 
    1639 */ 
     1664 
     1665//                  int ssize = nZoomBeginGlobal.size(); 
     1666// 
     1667//                  start.resize(ssize); 
     1668//                  count.resize(ssize); 
     1669// 
     1670//                  for (int i = 0; i < ssize; ++i) 
     1671//                  { 
     1672//                    start[i] = nZoomBeginServer[ssize - i - 1] - nZoomBeginGlobal[ssize - i - 1]; 
     1673//                    count[i] = nZoomSizeServer[ssize - i - 1]; 
     1674//                  } 
    16401675                } 
    16411676 
  • XIOS/trunk/src/test/test_remap.f90

    r689 r709  
    119119                            bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex) 
    120120 
    121   CALL xios_set_domain_attr("dst_domain_regular", ni_glo=180, nj_glo=90, type="rectilinear") 
     121  CALL xios_set_domain_attr("dst_domain_regular", type="rectilinear") 
    122122 
    123123  dtime%second = 3600 
  • XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp

    r689 r709  
    7676  { 
    7777    nVertexSrc = constNVertex; 
     78    domainSrc_->fillInRectilinearBoundLonLat(boundsLonSrc, boundsLatSrc); 
    7879  } 
    7980 
     
    114115  } 
    115116 
     117 
     118 
    116119  // Ok, now use mapper to calculate 
    117120  int nSrcLocal = domainSrc_->i_index.numElements(); 
    118121  int nDstLocal = domainDest_->i_index.numElements(); 
     122  long int * globalSrc = new long int [nSrcLocal]; 
     123  long int * globalDst = new long int [nDstLocal]; 
     124 
     125  long int globalIndex; 
     126  int i_ind, j_ind; 
     127  for (int idx = 0; idx < nSrcLocal; ++idx) 
     128  { 
     129    i_ind=domainSrc_->i_index(idx) ; 
     130    j_ind=domainSrc_->j_index(idx) ; 
     131 
     132    globalIndex = i_ind + j_ind * domainSrc_->ni_glo; 
     133    globalSrc[idx] = globalIndex; 
     134  } 
     135 
     136  for (int idx = 0; idx < nDstLocal; ++idx) 
     137  { 
     138    i_ind=domainDest_->i_index(idx) ; 
     139    j_ind=domainDest_->j_index(idx) ; 
     140 
     141    globalIndex = i_ind + j_ind * domainDest_->ni_glo; 
     142    globalDst[idx] = globalIndex; 
     143  } 
     144 
     145 
     146  // Calculate weight index 
    119147  Mapper mapper(client->intraComm); 
    120148  mapper.setVerbosity(PROGRESS) ; 
    121   mapper.setSourceMesh(boundsLonSrc.dataFirst(), boundsLatSrc.dataFirst(), nVertexSrc, nSrcLocal, &srcPole[0]); 
    122   mapper.setTargetMesh(boundsLonDest.dataFirst(), boundsLatDest.dataFirst(), nVertexDest, nDstLocal, &dstPole[0]); 
     149  mapper.setSourceMesh(boundsLonSrc.dataFirst(), boundsLatSrc.dataFirst(), nVertexSrc, nSrcLocal, &srcPole[0], globalSrc); 
     150  mapper.setTargetMesh(boundsLonDest.dataFirst(), boundsLatDest.dataFirst(), nVertexDest, nDstLocal, &dstPole[0], globalDst); 
    123151  std::vector<double> timings = mapper.computeWeights(orderInterp); 
    124152 
     153  std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 
    125154  for (int idx = 0;  idx < mapper.nWeights; ++idx) 
    126155  { 
    127     transformationMapping_[mapper.targetWeightId[idx]].push_back(mapper.sourceWeightId[idx]); 
    128     transformationWeight_[mapper.targetWeightId[idx]].push_back(mapper.remapMatrix[idx]); 
    129   } 
     156    interpMapValue[mapper.targetWeightId[idx]].push_back(make_pair(mapper.sourceWeightId[idx],mapper.remapMatrix[idx])); 
     157  } 
     158  exchangeRemapInfo(interpMapValue); 
     159 
     160  delete [] globalSrc; 
     161  delete [] globalDst; 
    130162} 
    131163 
     
    141173} 
    142174 
     175void CDomainAlgorithmInterpolate::readRemapInfo() 
     176{ 
     177  CContext* context = CContext::getCurrent(); 
     178  CContextClient* client=context->client; 
     179  int clientRank = client->clientRank; 
     180 
     181  std::string filename = interpDomain_->file.getValue(); 
     182  std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 
     183  readInterpolationInfo(filename, interpMapValue); 
     184 
     185  exchangeRemapInfo(interpMapValue); 
     186} 
     187 
     188 
    143189/*! 
    144190  Read remap information from file then distribute it among clients 
    145191*/ 
    146 void CDomainAlgorithmInterpolate::readRemapInfo() 
     192void CDomainAlgorithmInterpolate::exchangeRemapInfo(const std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 
    147193{ 
    148194  CContext* context = CContext::getCurrent(); 
    149195  CContextClient* client=context->client; 
    150196  int clientRank = client->clientRank; 
    151  
    152   std::string filename = interpDomain_->file.getValue(); 
    153   std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 
    154   readInterpolationInfo(filename, interpMapValue); 
    155197 
    156198  boost::unordered_map<size_t,int> globalIndexOfDomainDest; 
     
    189231  int* sendBuff = new int[nbClient]; 
    190232  int* recvBuff = new int[nbClient]; 
    191   for (int i = 0; i < nbClient; ++i) sendBuff[i] = 0; 
     233  for (int i = 0; i < nbClient; ++i) 
     234  { 
     235    sendBuff[i] = 0; 
     236    recvBuff[i] = 0; 
     237  } 
    192238  int sendBuffSize = 0; 
    193239  std::map<int, std::vector<size_t> >::const_iterator itbMap = globalIndexInterpSendToClient.begin(), itMap, 
     
    195241  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    196242  { 
     243    const std::vector<size_t>& tmp = itMap->second; 
    197244    int sizeIndex = 0, mapSize = (itMap->second).size(); 
    198245    for (int idx = 0; idx < mapSize; ++idx) 
    199246    { 
    200       sizeIndex += interpMapValue[(itMap->second)[idx]].size(); 
     247      sizeIndex += interpMapValue.at((itMap->second)[idx]).size(); 
    201248    } 
    202249    sendBuff[itMap->first] = sizeIndex; 
    203250    sendBuffSize += sizeIndex; 
    204251  } 
     252 
    205253 
    206254  MPI_Allreduce(sendBuff, recvBuff, nbClient, MPI_INT, MPI_SUM, client->intraComm); 
     
    211259 
    212260  std::vector<MPI_Request> sendRequest; 
    213   // Now send index and weight 
    214   int sendOffSet = 0; 
     261 
     262  int sendOffSet = 0, l = 0; 
    215263  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    216264  { 
     265    const std::vector<size_t>& indexToSend = itMap->second; 
     266    int mapSize = indexToSend.size(); 
    217267    int k = 0; 
    218     int mapSize = (itMap->second).size(); 
    219  
    220268    for (int idx = 0; idx < mapSize; ++idx) 
    221269    { 
    222       std::vector<std::pair<int,double> >& interpMap = interpMapValue[(itMap->second)[idx]]; 
     270      const std::vector<std::pair<int,double> >& interpMap = interpMapValue.at(indexToSend[idx]); 
    223271      for (int i = 0; i < interpMap.size(); ++i) 
    224272      { 
    225         sendIndexDestBuff[k] = (itMap->second)[idx]; 
    226         sendIndexSrcBuff[k]  = interpMap[i].first; 
    227         sendWeightBuff[k]    = interpMap[i].second; 
     273        sendIndexDestBuff[l] = indexToSend[idx]; 
     274        sendIndexSrcBuff[l]  = interpMap[i].first; 
     275        sendWeightBuff[l]    = interpMap[i].second; 
    228276        ++k; 
     277        ++l; 
    229278      } 
    230279    } 
     
    303352 
    304353  std::vector<MPI_Status> requestStatus(sendRequest.size()); 
    305   MPI_Wait(&sendRequest[0], &requestStatus[0]); 
     354  MPI_Waitall(sendRequest.size(), &sendRequest[0], MPI_STATUS_IGNORE); 
    306355 
    307356  delete [] sendIndexDestBuff; 
     
    322371*/ 
    323372void CDomainAlgorithmInterpolate::readInterpolationInfo(std::string& filename, 
    324                                                                 std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 
     373                                                        std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 
    325374{ 
    326375  int ncid ; 
  • XIOS/trunk/src/transformation/domain_algorithm_interpolate.hpp

    r689 r709  
    3232  void computeRemap(); 
    3333  void readRemapInfo(); 
    34  
     34  void exchangeRemapInfo(const std::map<int,std::vector<std::pair<int,double> > >& interpMapValue); 
    3535private: 
    3636  CInterpolateDomain* interpDomain_; 
  • XIOS/trunk/src/transformation/generic_algorithm_transformation.cpp

    r668 r709  
    3232                                                             std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource) 
    3333{ 
    34   std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), 
    35                                                    itTransMap = itbTransMap, 
     34  std::map<int, std::vector<int> >::const_iterator itbTransMap = transformationMapping_.begin(), itTransMap, 
    3635                                                   iteTransMap = transformationMapping_.end(); 
    3736  std::map<int, std::vector<double> >::const_iterator itTransWeight = transformationWeight_.begin(); 
    38   std::map<size_t, std::vector<std::pair<size_t,double> > >::iterator iteWeight, itWeight; 
    39   std::vector<int>::const_iterator itbVec, itVec, iteVec; 
    4037  std::vector<std::vector<size_t> > globalIndexSrcGrid; 
    4138  CArray<size_t,1> globalIndexDestGrid; 
Note: See TracChangeset for help on using the changeset viewer.