Ignore:
Timestamp:
07/10/17 15:16:17 (7 years ago)
Author:
mhnguyen
Message:

Porting non-continuous axis zoom to dev branch

+) Port axis zoom
+) Resolve some merge conflicts
+) Revert some codes

Test
+) On Curie
+) Ok

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1158 r1202  
    2727      , hasBounds_(false), isCompressible_(false) 
    2828      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    29       , transformationMap_(), hasValue(false), doZoomByIndex_(false), hasLabel(false) 
     29      , transformationMap_(), hasValue(false), hasLabel(false) 
    3030      , computedWrittenIndex_(false) 
    3131   { 
     
    3838      , hasBounds_(false), isCompressible_(false) 
    3939      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    40       , transformationMap_(), hasValue(false), doZoomByIndex_(false), hasLabel(false) 
     40      , transformationMap_(), hasValue(false), hasLabel(false) 
    4141      , computedWrittenIndex_(false) 
    4242   { 
     
    365365    else hasLabel = false; 
    366366  } 
     367 
    367368  void CAxis::checkEligibilityForCompressedOutput() 
    368369  { 
    369370    // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    370371    isCompressible_ = !mask.isEmpty(); 
     372  } 
     373 
     374  bool CAxis::zoomByIndex() 
     375  { 
     376    return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 
    371377  } 
    372378 
     
    477483      size_t nbIndex = index.numElements(); 
    478484 
    479       if (doZoomByIndex_)  
    480       { 
    481         nZoomCount = zoom_index.numElements(); 
    482       } 
    483       else 
    484       { 
    485         for (size_t idx = 0; idx < nbIndex; ++idx) 
    486         { 
    487           globalLocalIndexMap_[index(idx)] = idx; 
    488           size_t globalIndex = index(idx); 
    489           if (globalIndex >= global_zoom_begin && globalIndex <= global_zoom_end) ++nZoomCount; 
    490         } 
    491       } 
    492  
    493  
    494       CArray<size_t,1> globalIndexAxis(nbIndex); 
    495       std::vector<size_t> globalAxisZoom(nZoomCount); 
    496       nZoomCount = 0; 
    497       if (doZoomByIndex_)  
    498       { 
    499         int nbIndexZoom = zoom_index.numElements();         
    500         for (int i = 0; i < nbIndexZoom; ++i) 
    501         {    
    502           globalIndexAxis(i) = zoom_index(i); 
    503         } 
    504       } 
    505       else  
    506       { 
    507         for (size_t idx = 0; idx < nbIndex; ++idx) 
    508         { 
    509           size_t globalIndex = index(idx); 
    510           globalIndexAxis(idx) = globalIndex; 
    511           if (globalIndex >= global_zoom_begin && globalIndex <= global_zoom_end) 
    512           { 
    513             globalAxisZoom[nZoomCount] = globalIndex; 
    514             ++nZoomCount; 
    515           } 
    516         } 
    517  
    518         int end       = begin + n -1;         
    519         zoom_begin    = global_zoom_begin > begin ? global_zoom_begin : begin; 
    520         int zoom_end  = global_zoom_end < end ? zoom_end : end; 
    521         zoom_n        = zoom_end-zoom_begin+1; 
    522       } 
    523  
     485      for (size_t idx = 0; idx < nbIndex; ++idx) 
     486      { 
     487        globalLocalIndexMap_[index(idx)] = idx; 
     488      } 
    524489      std::set<int> writtenInd; 
    525490      if (isCompressible_) 
     
    593558      indSrv_.swap(globalIndexAxisOnServer); 
    594559 
    595       CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 
     560      CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_.begin(), 
    596561                                                           ite = indSrv_.end(); 
    597562 
     
    625590                                                          ite = globalLocalIndexMap_.end(), it;           
    626591      CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    627                                        itSrve = writtenGlobalIndex.end(), itSrv;       
    628  
    629       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    630       { 
    631         indGlo = *itSrv; 
    632         if (ite != globalLocalIndexMap_.find(indGlo)) 
    633         {           
    634           ++nbWritten; 
    635         }                  
    636       } 
    637  
    638       localIndexToWriteOnServer.resize(nbWritten); 
    639  
    640       nbWritten = 0; 
    641       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    642       { 
    643         indGlo = *itSrv; 
    644         if (ite != globalLocalIndexMap_.find(indGlo)) 
    645         { 
    646           localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    647           ++nbWritten; 
    648         }                  
     592                                       itSrve = writtenGlobalIndex.end(), itSrv;   
     593      if (!zoomByIndex()) 
     594      {    
     595        for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     596        { 
     597          indGlo = *itSrv; 
     598          if (ite != globalLocalIndexMap_.find(indGlo)) 
     599          {           
     600            ++nbWritten; 
     601          }                  
     602        } 
     603 
     604        localIndexToWriteOnServer.resize(nbWritten); 
     605 
     606        nbWritten = 0; 
     607        for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     608        { 
     609          indGlo = *itSrv; 
     610          if (ite != globalLocalIndexMap_.find(indGlo)) 
     611          { 
     612            localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
     613            ++nbWritten; 
     614          }                  
     615        } 
     616      } 
     617      else 
     618      { 
     619        nbWritten = 0; 
     620        boost::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 
     621                                                            ite = globalLocalIndexMap_.end(), it; 
     622        for (int i = 0; i < zoom_index.numElements(); ++i) 
     623        { 
     624           if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
     625            ++nbWritten; 
     626        } 
     627 
     628        localIndexToWriteOnServer.resize(nbWritten); 
     629 
     630        nbWritten = 0; 
     631        for (int i = 0; i < zoom_index.numElements(); ++i) 
     632        { 
     633           if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
     634           { 
     635             localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 
     636             ++nbWritten; 
     637           } 
     638        } 
    649639      } 
    650640 
     
    731721          const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 
    732722          const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid]; 
    733           const int end   = begin + ni - 1; 
     723          const int end   = begin + ni - 1;           
    734724 
    735725          msgs.push_back(CMessage()); 
     
    737727          msg << this->getId(); 
    738728          msg << ni << begin << end; 
    739           msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
     729          // msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
    740730          msg << isCompressible_; 
    741731          msg << orderPositionInGrid; 
     
    792782          msg << this->getId(); 
    793783          msg << index.getValue() << dataIndex << mask.getValue(); 
    794  
    795           msg << doZoomByIndex_; 
    796           if (doZoomByIndex_) msg << zoom_index.getValue(); 
    797784          msg << hasValue; 
    798785          if (hasValue) msg << value.getValue(); 
     
    834821    mask.reference(tmp_mask); 
    835822 
    836     buffer >> doZoomByIndex_; 
    837     if (doZoomByIndex_) 
    838     { 
    839       buffer >> tmp_zoom_index; 
    840       zoom_index.reference(tmp_zoom_index); 
    841     } 
    842  
    843823    buffer >> hasValue; 
    844824    if (hasValue) 
     
    864844    int ns, n, i, j, ind, nv, idx; 
    865845    CContext* context = CContext::getCurrent(); 
    866  
    867     //int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     846     
    868847    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    869848    for (int p = 0; p < nbSrvPools; ++p) 
     
    903882        list_mask.push_back(CArray<bool,1>(nbData)); 
    904883 
    905         if (doZoomByIndex_) 
    906           list_zoomInd.push_back(CArray<int,1>(nbData)); 
    907  
    908884        if (hasValue) 
    909885          list_val.push_back(CArray<double,1>(nbData)); 
     
    926902          dataIndi(n) = dataIndex(ind); 
    927903          maskIndi(n) = mask(ind); 
    928  
    929           if (doZoomByIndex_) 
    930           { 
    931             CArray<int,1>& zoomIndi = list_zoomInd.back(); 
    932             zoomIndi(n) = zoom_index(ind); 
    933           } 
    934904 
    935905          if (hasValue) 
     
    950920        listData.back() << this->getId() 
    951921                        << list_indi.back() << list_dataInd.back() << list_mask.back(); 
    952  
    953         listData.back() << doZoomByIndex_;            
    954         if (doZoomByIndex_) 
    955           listData.back() << list_zoomInd.back(); 
    956922 
    957923        listData.back() << hasValue; 
     
    1003969      buffer >> vec_mask[idx]; 
    1004970 
    1005       buffer >> doZoomByIndex_; 
    1006       if (doZoomByIndex_) 
    1007         buffer >> vec_zoomInd[idx]; 
    1008  
    1009971      buffer >> hasValue; 
    1010972      if (hasValue) 
     
    10751037    data_begin.setValue(0); 
    10761038 
    1077     if (doZoomByIndex_) 
    1078     { 
    1079       int nbZoomIndex = 0; 
    1080       for (int idx = 0; idx < nbReceived; ++idx) 
    1081       { 
    1082         nbZoomIndex += vec_zoomInd[idx].numElements(); 
    1083       } 
    1084  
    1085       zoom_index.resize(nbZoomIndex); 
    1086       nbZoomIndex = 0;       
    1087       for (int idx = 0; idx < nbReceived; ++idx) 
    1088       {       
    1089         CArray<int,1>& tmp = vec_zoomInd[idx]; 
    1090         for (int i = 0; i < tmp.size(); ++i) 
    1091         { 
    1092           zoom_index(nbZoomIndex) = tmp(i); 
    1093           ++nbZoomIndex; 
    1094         }        
    1095       } 
    1096     } 
    1097  
    10981039    if (hasLabel) 
    10991040    { 
     
    11121053  void CAxis::recvDistributionAttribute(CBufferIn& buffer) 
    11131054  { 
    1114     int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 
     1055    int ni_srv, begin_srv, end_srv; 
     1056    int global_zoom_end, zoom_end; 
     1057    bool zoomIndex = zoomByIndex(); 
     1058     
     1059    std::vector<int> zoom_index_tmp; 
     1060    std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 
    11151061 
    11161062    buffer >> ni_srv >> begin_srv >> end_srv; 
    1117     buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 
     1063    // buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp;    
    11181064    buffer >> isCompressible_; 
    11191065    buffer >> orderPosInGrid; 
    1120     buffer >> globalDimGrid; 
    1121  
     1066    buffer >> globalDimGrid;     
     1067 
     1068    // Set up new local size of axis on the receiving clients 
    11221069    n.setValue(ni_srv); 
    11231070    begin.setValue(begin_srv); 
    1124     global_zoom_begin = global_zoom_begin_tmp; 
    1125     global_zoom_n  = global_zoom_n_tmp; 
    1126     int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 
    1127  
    1128     zoom_begin = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
    1129     zoom_end_srv   = global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
    1130     zoom_n  = zoom_end_srv - zoom_begin_srv + 1; 
     1071 
     1072    // If we have zoom by index then process it 
     1073    if (zoomIndex) 
     1074    { 
     1075      zoom_index_tmp.resize(global_zoom_index.numElements()); 
     1076      std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 
     1077      std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 
     1078      itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 
     1079      itZoomEnd   = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv);       
     1080      int sz = std::distance(itZoomBegin, itZoomEnd); 
     1081      zoom_index.resize(sz); 
     1082      itZoom = itZoomBegin; 
     1083      for (int i = 0; i < sz; ++i, ++itZoom) 
     1084      { 
     1085        zoom_index(i) = *(itZoom); 
     1086      } 
     1087    } 
     1088 
     1089    global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 
     1090    global_zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
     1091    global_zoom_end   = global_zoom_begin + global_zoom_n - 1; 
     1092 
     1093    zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
     1094                           : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
     1095    zoom_end   = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1  
     1096                           : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
     1097    zoom_n     = zoom_end - zoom_begin + 1; 
    11311098 
    11321099    if (zoom_n<=0) 
    11331100    { 
    1134       zoom_begin = 0; zoom_end_srv = 0; zoom_n = 0; 
     1101      zoom_begin = 0; zoom_n = 0; 
    11351102    } 
    11361103 
    11371104    if (n_glo == n) 
    11381105    { 
    1139       zoom_begin = global_zoom_begin; 
    1140       zoom_end_srv   = global_zoom_end; //zoom_end; 
    1141       zoom_n     = zoom_end_srv - zoom_begin + 1; 
     1106      zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
     1107                             : global_zoom_begin;       
     1108      zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    11421109    } 
    11431110  } 
Note: See TracChangeset for help on using the changeset viewer.