Ignore:
Timestamp:
07/12/18 19:12:32 (6 years ago)
Author:
oabramkina
Message:

Replacing axis zoom by axis extract.
Zoom private attributes are gone for good.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r1558 r1559  
    302302      { 
    303303        this->checkData(); 
    304         this->checkZoom(); 
    305304        this->checkMask(); 
    306305        this->checkLabel(); 
     
    333332   } 
    334333 
    335    /*! 
    336      Check validity of zoom info and fill in values if any. 
    337    */ 
    338    void CAxis::checkZoom(void) 
    339    { 
    340      if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 
    341      if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 
    342      if (zoom_index.isEmpty()) 
    343      { 
    344        zoom_index.setValue(index.getValue()); 
    345      } 
    346      if (zoom_n.isEmpty()) zoom_n.setValue(n); 
    347      if (zoom_begin.isEmpty()) zoom_begin.setValue(begin); 
    348    } 
    349  
    350334    size_t CAxis::getGlobalWrittenSize(void) 
    351335    { 
    352       if (zoomByIndex()) return  global_zoom_index.numElements(); 
    353       else return global_zoom_n ; 
     336      return n_glo ; 
    354337    } 
    355338 
     
    416399    // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    417400    isCompressible_ = !mask.isEmpty(); 
    418   } 
    419  
    420   /* 
    421     Check whether we do zooming by indexing 
    422     return true if do zooming by index 
    423   */ 
    424   bool CAxis::zoomByIndex() 
    425   { 
    426     return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 
    427401  } 
    428402 
     
    561535        size_t ni = this->n.getValue(); 
    562536        size_t ibegin = this->begin.getValue(); 
    563         size_t global_zoom_end = global_zoom_begin+global_zoom_n-1; 
    564         size_t nZoomCount = 0; 
    565537        size_t nbIndex = index.numElements(); 
    566538 
     
    585557            { 
    586558              ind += ibegin; 
    587               if (ind >= global_zoom_begin && ind <= global_zoom_end) 
    588                 writtenInd.insert(ind); 
     559              writtenInd.insert(ind); 
    589560            } 
    590561          } 
     
    680651    // We describe the distribution of client (server) on which data are written 
    681652    std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 
    682     nBegin[0]       = zoom_begin; 
    683     nSize[0]        = zoom_n;    
     653    nBegin[0]       = 0; 
     654    nSize[0]        = n; 
    684655    nBeginGlobal[0] = 0;  
    685656    nGlob[0]        = n_glo; 
     
    694665    CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    695666                                     itSrve = writtenGlobalIndex.end(), itSrv;   
    696     if (!zoomByIndex()) 
    697     {    
    698       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    699       { 
    700         indGlo = *itSrv; 
    701         if (ite != globalLocalIndexMap_.find(indGlo)) 
    702         {           
    703           ++nbWritten; 
    704         }                  
    705       } 
    706  
    707       localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
     667    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     668    { 
     669      indGlo = *itSrv; 
     670      if (ite != globalLocalIndexMap_.find(indGlo)) 
     671      { 
     672        ++nbWritten; 
     673      } 
     674    } 
     675 
     676    localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    708677//      localIndexToWriteOnServer.resize(nbWritten); 
    709678 
    710       nbWritten = 0; 
    711       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    712       { 
    713         indGlo = *itSrv; 
    714         if (ite != globalLocalIndexMap_.find(indGlo)) 
    715         { 
    716           localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    717           ++nbWritten; 
    718         }                  
    719       } 
    720     } 
    721     else 
    722     { 
    723       nbWritten = 0; 
    724       std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 
    725                                                           ite = globalLocalIndexMap_.end(), it; 
    726       for (int i = 0; i < zoom_index.numElements(); ++i) 
    727       { 
    728          if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
    729           ++nbWritten; 
    730       } 
    731  
    732       localIndexToWriteOnServer.resize(nbWritten); 
    733  
    734       nbWritten = 0; 
    735       for (int i = 0; i < zoom_index.numElements(); ++i) 
    736       { 
    737          if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
    738          { 
    739            localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 
    740            ++nbWritten; 
    741          } 
    742       } 
    743     } 
    744  
    745     // if (isCompressible()) 
    746     // { 
    747     //   nbWritten = 0; 
    748     //   std::unordered_map<size_t,size_t> localGlobalIndexMap; 
    749     //   for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    750     //   { 
    751     //     indGlo = *itSrv; 
    752     //     if (ite != globalLocalIndexMap_.find(indGlo)) 
    753     //     { 
    754     //       localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo; 
    755     //       ++nbWritten; 
    756     //     }                  
    757     //   } 
    758  
    759     //   nbWritten = 0; 
    760     //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
    761     //   { 
    762     //     if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
    763     //     { 
    764     //       ++nbWritten; 
    765     //     } 
    766     //   } 
    767  
    768     //   compressedIndexToWriteOnServer.resize(nbWritten); 
    769     //   nbWritten = 0; 
    770     //   for (int idx = 0; idx < data_index.numElements(); ++idx) 
    771     //   { 
    772     //     if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
    773     //     { 
    774     //       compressedIndexToWriteOnServer(nbWritten) = localGlobalIndexMap[data_index(idx)]; 
    775     //       ++nbWritten; 
    776     //     } 
    777     //   } 
    778  
    779     //   numberWrittenIndexes_ = nbWritten; 
    780     //   if (isDistributed()) 
    781     //   { 
    782               
    783     //     MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    784     //     MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    785     //     offsetWrittenIndexes_ -= numberWrittenIndexes_; 
    786     //   } 
    787     //   else 
    788     //     totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
    789     // } 
     679    nbWritten = 0; 
     680    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     681    { 
     682      indGlo = *itSrv; 
     683      if (ite != globalLocalIndexMap_.find(indGlo)) 
     684      { 
     685        localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
     686        ++nbWritten; 
     687      } 
     688    } 
    790689  } 
    791690 
     
    805704      // We describe the distribution of client (server) on which data are written 
    806705      std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 
    807       nBegin[0]       = zoom_begin; 
    808       nSize[0]        = zoom_n;    
     706      nBegin[0]       = 0; 
     707      nSize[0]        = n; 
    809708      nBeginGlobal[0] = 0;  
    810709      nGlob[0]        = n_glo; 
     
    928827  { 
    929828    int ni_srv, begin_srv, end_srv; 
    930     int global_zoom_end, zoom_end; 
    931     bool zoomIndex = zoomByIndex(); 
    932      
    933     std::vector<int> zoom_index_tmp; 
    934     std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 
    935  
    936829    buffer >> ni_srv >> begin_srv >> end_srv;     
    937830    buffer >> isCompressible_;             
     
    940833    n.setValue(ni_srv); 
    941834    begin.setValue(begin_srv); 
    942  
    943     // If we have zoom by index then process it 
    944     if (zoomIndex) 
    945     { 
    946       zoom_index_tmp.resize(global_zoom_index.numElements()); 
    947       std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 
    948       std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 
    949       itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 
    950       itZoomEnd   = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv);       
    951       int sz = std::distance(itZoomBegin, itZoomEnd); 
    952       zoom_index.resize(sz); 
    953       itZoom = itZoomBegin; 
    954       for (int i = 0; i < sz; ++i, ++itZoom) 
    955       { 
    956         zoom_index(i) = *(itZoom); 
    957       } 
    958     } 
    959  
    960     global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 
    961     global_zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    962     global_zoom_end   = global_zoom_begin + global_zoom_n - 1; 
    963  
    964     zoom_begin = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomBegin) 
    965                            : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
    966     zoom_end   = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1  
    967                            : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
    968     zoom_n     = zoom_end - zoom_begin + 1; 
    969  
    970     if (zoom_n<=0) 
    971     { 
    972       zoom_n = 0; zoom_begin=global_zoom_begin; //0; zoom_begin = 0;  
    973     } 
    974  
    975     if (n_glo == n) 
    976     { 
    977       zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
    978                              : global_zoom_begin;       
    979       zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    980     } 
    981835  } 
    982836 
     
    1064918  void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 
    1065919  {  
    1066     CArray<int,1> tmp_index, tmp_data_index, tmp_zoom_index; 
     920    CArray<int,1> tmp_index, tmp_data_index; 
    1067921    CArray<bool,1> tmp_mask; 
    1068922    CArray<double,1> tmp_val; 
     
    1123977 
    1124978      list<CMessage> listData; 
    1125       list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 
     979      list<CArray<int,1> > list_indi, list_dataInd; 
    1126980      list<CArray<bool,1> > list_mask; 
    1127981      list<CArray<double,1> > list_val; 
     
    12461100  { 
    12471101    int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 
    1248     vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived);     
     1102    vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 
    12491103    vector<CArray<bool,1> > vec_mask(nbReceived); 
    12501104    vector<CArray<double,1> > vec_val(nbReceived); 
Note: See TracChangeset for help on using the changeset viewer.