Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

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

    r1545 r1642  
    1414#include "distribution_client.hpp" 
    1515 
    16 using namespace ep_lib; 
    17  
    1816namespace xios { 
    1917 
     
    2826      , transformationMap_(), hasValue(false), hasLabel(false) 
    2927      , computedWrittenIndex_(false) 
    30       , clients() 
     28          , clients() 
    3129   { 
    3230   } 
     
    4038      , transformationMap_(), hasValue(false), hasLabel(false) 
    4139      , computedWrittenIndex_(false) 
    42       , clients() 
     40          , clients() 
    4341   { 
    4442   } 
     
    4745   { /* Ne rien faire de plus */ } 
    4846 
    49    std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = 0; 
    50  
     47   std::map<StdString, ETranformationType> CAxis::transformationMapList_ = std::map<StdString, ETranformationType>(); 
     48   bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_); 
    5149   bool CAxis::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
     50   TRY 
    5251   { 
    5352     m["zoom_axis"] = TRANS_ZOOM_AXIS; 
    5453     m["interpolate_axis"] = TRANS_INTERPOLATE_AXIS; 
     54     m["extract_axis"] = TRANS_EXTRACT_AXIS; 
    5555     m["inverse_axis"] = TRANS_INVERSE_AXIS; 
    5656     m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS; 
     
    5959     m["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 
    6060     m["duplicate_scalar"] = TRANS_DUPLICATE_SCALAR_TO_AXIS; 
    61    } 
    62  
    63    bool CAxis::initializeTransformationMap() 
    64    { 
    65      if(CAxis::transformationMapList_ptr == 0) CAxis::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 
    66      (*CAxis::transformationMapList_ptr)["zoom_axis"]        = TRANS_ZOOM_AXIS; 
    67      (*CAxis::transformationMapList_ptr)["interpolate_axis"] = TRANS_INTERPOLATE_AXIS; 
    68      (*CAxis::transformationMapList_ptr)["inverse_axis"]     = TRANS_INVERSE_AXIS; 
    69      (*CAxis::transformationMapList_ptr)["reduce_domain"]    = TRANS_REDUCE_DOMAIN_TO_AXIS; 
    70      (*CAxis::transformationMapList_ptr)["extract_domain"]   = TRANS_EXTRACT_DOMAIN_TO_AXIS; 
    71      (*CAxis::transformationMapList_ptr)["reduce_axis"]      = TRANS_REDUCE_AXIS_TO_AXIS; 
    72      (*CAxis::transformationMapList_ptr)["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 
    73      (*CAxis::transformationMapList_ptr)["duplicate_scalar"] = TRANS_DUPLICATE_SCALAR_TO_AXIS; 
    74    } 
     61 
     62   } 
     63   CATCH 
    7564 
    7665   ///--------------------------------------------------------------- 
    7766 
    7867   const std::set<StdString> & CAxis::getRelFiles(void) const 
     68   TRY 
    7969   { 
    8070      return (this->relFiles); 
    8171   } 
     72   CATCH 
    8273 
    8374   bool CAxis::IsWritten(const StdString & filename) const 
     75   TRY 
    8476   { 
    8577      return (this->relFiles.find(filename) != this->relFiles.end()); 
    8678   } 
     79   CATCH 
    8780 
    8881   bool CAxis::isWrittenCompressed(const StdString& filename) const 
     82   TRY 
    8983   { 
    9084      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 
    9185   } 
     86   CATCH 
    9287 
    9388   bool CAxis::isDistributed(void) const 
     89   TRY 
    9490   { 
    9591      bool distributed = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 
    9692             (!this->n.isEmpty() && (this->n != this->n_glo)); 
    97       // A same stupid condition to make sure that if there is only one client, axis 
     93      // A condition to make sure that if there is only one client, axis 
    9894      // should be considered to be distributed. This should be a temporary solution      
    9995      distributed |= (1 == CContext::getCurrent()->client->clientSize); 
    10096      return distributed; 
    10197   } 
     98   CATCH 
    10299 
    103100   /*! 
     
    107104    */ 
    108105   bool CAxis::isCompressible(void) const 
     106   TRY 
    109107   { 
    110108      return isCompressible_; 
    111109   } 
     110   CATCH 
    112111 
    113112   void CAxis::addRelFile(const StdString & filename) 
     113   TRY 
    114114   { 
    115115      this->relFiles.insert(filename); 
    116116   } 
     117   CATCH_DUMP_ATTR 
    117118 
    118119   void CAxis::addRelFileCompressed(const StdString& filename) 
     120   TRY 
    119121   { 
    120122      this->relFilesCompressed.insert(filename); 
    121123   } 
     124   CATCH_DUMP_ATTR 
    122125 
    123126   //---------------------------------------------------------------- 
     
    128131   */ 
    129132   int CAxis::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     133   TRY 
    130134   { 
    131135     int writtenSize; 
     
    133137     return numberWrittenIndexes_[writtenSize]; 
    134138   } 
     139   CATCH_DUMP_ATTR 
    135140 
    136141   /*! 
     
    139144   */ 
    140145   int CAxis::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     146   TRY 
    141147   { 
    142148     int writtenSize; 
     
    144150     return totalNumberWrittenIndexes_[writtenSize]; 
    145151   } 
     152   CATCH_DUMP_ATTR 
    146153 
    147154   /*! 
     
    150157   */ 
    151158   int CAxis::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 
     159   TRY 
    152160   { 
    153161     int writtenSize; 
     
    155163     return offsetWrittenIndexes_[writtenSize]; 
    156164   } 
     165   CATCH_DUMP_ATTR 
    157166 
    158167   CArray<int, 1>& CAxis::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 
     168   TRY 
    159169   { 
    160170     int writtenSize; 
     
    162172     return compressedIndexToWriteOnServer[writtenSize]; 
    163173   } 
     174   CATCH_DUMP_ATTR 
     175 
    164176   //---------------------------------------------------------------- 
    165177 
     
    171183   std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 
    172184                                                         CServerDistributionDescription::ServerDistributionType distType) 
     185   TRY 
    173186   { 
    174187 
     
    234247       } 
    235248     } 
    236  
    237249     return attributesSizes; 
    238250   } 
     251   CATCH_DUMP_ATTR 
    239252 
    240253   //---------------------------------------------------------------- 
     
    247260 
    248261   CAxis* CAxis::createAxis() 
     262   TRY 
    249263   { 
    250264     CAxis* axis = CAxisGroup::get("axis_definition")->createChild(); 
    251265     return axis; 
    252266   } 
     267   CATCH 
    253268 
    254269   /*! 
     
    257272   */ 
    258273   void CAxis::checkAttributes(void) 
    259    { 
    260       if (this->n_glo.isEmpty()) 
     274   TRY 
     275   { 
     276     CContext* context=CContext::getCurrent(); 
     277 
     278     if (this->n_glo.isEmpty()) 
    261279        ERROR("CAxis::checkAttributes(void)", 
    262280              << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     
    298316      } 
    299317 
    300       // Remove this check because it doen't make sense in case of a hole or overlapping axes 
    301318      if (!this->value.isEmpty()) 
    302319      { 
    303 //        StdSize true_size = value.numElements(); 
    304 //        if (this->n.getValue() != true_size) 
    305 //          ERROR("CAxis::checkAttributes(void)", 
    306 //                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    307 //                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     320        // Avoid this check at writing because it fails in case of a hole 
     321        if (context->hasClient) 
     322        { 
     323          StdSize true_size = value.numElements(); 
     324          if (this->n.getValue() != true_size) 
     325            ERROR("CAxis::checkAttributes(void)", 
     326                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     327                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size 
     328                << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     329        } 
    308330        this->hasValue = true; 
    309331      } 
     
    311333      this->checkBounds(); 
    312334 
    313       CContext* context=CContext::getCurrent(); 
    314335      if (context->hasClient) 
    315336      { 
     337        this->checkMask(); 
    316338        this->checkData(); 
    317         this->checkZoom(); 
    318         this->checkMask(); 
    319339        this->checkLabel(); 
    320340      } 
    321341   } 
     342   CATCH_DUMP_ATTR 
    322343 
    323344   /*! 
    324       Check the validity of data and fill in values if any. 
     345      Check the validity of data, fill in values if any, and apply mask. 
    325346   */ 
    326347   void CAxis::checkData() 
     348   TRY 
    327349   { 
    328350      if (data_begin.isEmpty()) data_begin.setValue(0); 
     
    342364      { 
    343365        data_index.resize(data_n); 
    344         for (int i = 0; i < data_n; ++i) data_index(i) = i; 
    345       } 
    346    } 
    347  
    348    /*! 
    349      Check validity of zoom info and fill in values if any. 
    350    */ 
    351    void CAxis::checkZoom(void) 
    352    { 
    353      if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 
    354      if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 
    355      if (zoom_index.isEmpty()) 
    356      { 
    357        zoom_index.setValue(index.getValue()); 
    358      } 
    359      if (zoom_n.isEmpty()) zoom_n.setValue(n); 
    360      if (zoom_begin.isEmpty()) zoom_begin.setValue(begin); 
    361    } 
     366        for (int i = 0; i < data_n; ++i) 
     367        { 
     368          if ((i+data_begin) >= 0 && (i+data_begin<n)) 
     369          { 
     370            if (mask(i+data_begin)) 
     371              data_index(i) = i+data_begin; 
     372            else 
     373              data_index(i) = -1; 
     374          } 
     375          else 
     376            data_index(i) = -1; 
     377        } 
     378      } 
     379      else 
     380      { 
     381        if (data_index.numElements() != data_n) 
     382        { 
     383          ERROR("CAxis::checkData(void)", 
     384                << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     385                << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 
     386        } 
     387        for (int i = 0; i < data_n; ++i) 
     388        { 
     389          if ((i+data_begin) >= 0 && (i+data_begin<n) && !mask(i+data_begin)) 
     390            data_index(i) = -1; 
     391        } 
     392      } 
     393 
     394   } 
     395   CATCH_DUMP_ATTR 
    362396 
    363397    size_t CAxis::getGlobalWrittenSize(void) 
    364398    { 
    365       if (zoomByIndex()) return  global_zoom_index.numElements(); 
    366       else return global_zoom_n ; 
     399      return n_glo ; 
    367400    } 
    368401 
     
    371404   */ 
    372405   void CAxis::checkMask() 
     406   TRY 
    373407   { 
    374408      if (!mask.isEmpty()) 
    375409      { 
    376          if (mask.extent(0) != n) 
    377            ERROR("CAxis::checkMask(void)", 
    378                  << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    379                  << "The mask does not have the same size as the local domain." << std::endl 
    380                  << "Local size is " << n.getValue() << "." << std::endl 
    381                  << "Mask size is " << mask.extent(0) << "."); 
    382       } 
    383       else // (mask.isEmpty()) 
    384       { // If no mask was defined, we create a default one without any masked point. 
    385          mask.resize(n); 
    386          for (int i = 0; i < n; ++i) 
    387          { 
    388            mask(i) = true; 
    389          } 
    390       } 
    391    } 
     410        if (mask.extent(0) != n) 
     411        { 
     412          ERROR("CAxis::checkMask(void)", 
     413              << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     414              << "The mask does not have the same size as the local domain." << std::endl 
     415              << "Local size is " << n.getValue() << "." << std::endl 
     416              << "Mask size is " << mask.extent(0) << "."); 
     417        } 
     418      } 
     419      else 
     420      { 
     421        mask.resize(n); 
     422        mask = true; 
     423      } 
     424   } 
     425   CATCH_DUMP_ATTR 
    392426 
    393427   /*! 
     
    395429   */ 
    396430   void CAxis::checkBounds() 
     431   TRY 
    397432   { 
    398433     if (!bounds.isEmpty()) 
     
    407442     else hasBounds = false; 
    408443   } 
     444   CATCH_DUMP_ATTR 
    409445 
    410446  void CAxis::checkLabel() 
     447  TRY 
    411448  { 
    412449    if (!label.isEmpty()) 
     
    421458    else hasLabel = false; 
    422459  } 
     460  CATCH_DUMP_ATTR 
    423461 
    424462  /*! 
     
    426464  */ 
    427465  void CAxis::checkEligibilityForCompressedOutput() 
     466  TRY 
    428467  { 
    429468    // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    430469    isCompressible_ = !mask.isEmpty(); 
    431470  } 
    432  
    433   /* 
    434     Check whether we do zooming by indexing 
    435     return true if do zooming by index 
    436   */ 
    437   bool CAxis::zoomByIndex() 
    438   { 
    439     return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 
    440   } 
     471  CATCH_DUMP_ATTR 
    441472 
    442473  /*! 
     
    444475  */ 
    445476  bool CAxis::dispatchEvent(CEventServer& event) 
     477  TRY 
    446478  { 
    447479     if (SuperClass::dispatchEvent(event)) return true; 
     
    469501     } 
    470502  } 
     503  CATCH 
    471504 
    472505   /*! 
     
    474507   */ 
    475508   void CAxis::checkAttributesOnClient() 
     509   TRY 
    476510   { 
    477511     if (this->areClientAttributesChecked_) return; 
     
    482516     this->areClientAttributesChecked_ = true; 
    483517   } 
     518   CATCH_DUMP_ATTR 
    484519 
    485520   /* 
     
    489524   void CAxis::checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, 
    490525                                                          CServerDistributionDescription::ServerDistributionType distType) 
     526   TRY 
    491527   { 
    492528     CContext* context=CContext::getCurrent() ; 
     
    502538     this->isClientAfterTransformationChecked = true; 
    503539   } 
     540   CATCH_DUMP_ATTR 
    504541 
    505542   /* 
     
    512549   void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
    513550                                     CServerDistributionDescription::ServerDistributionType distType) 
     551   TRY 
    514552   { 
    515553     if (!this->areClientAttributesChecked_) checkAttributesOnClient(); 
     
    522560     this->isChecked = true; 
    523561   } 
     562   CATCH_DUMP_ATTR 
    524563 
    525564  /*! 
     
    530569  void CAxis::sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
    531570                             CServerDistributionDescription::ServerDistributionType distType) 
     571  TRY 
    532572  { 
    533573     sendDistributionAttribute(globalDim, orderPositionInGrid, distType); 
     
    544584     }      
    545585  } 
     586  CATCH_DUMP_ATTR 
    546587 
    547588  /* 
     
    555596  void CAxis::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 
    556597                                     CServerDistributionDescription::ServerDistributionType distType) 
     598  TRY 
    557599  { 
    558600    CContext* context = CContext::getCurrent(); 
     
    574616        size_t ni = this->n.getValue(); 
    575617        size_t ibegin = this->begin.getValue(); 
    576         size_t global_zoom_end = global_zoom_begin+global_zoom_n-1; 
    577         size_t nZoomCount = 0; 
    578618        size_t nbIndex = index.numElements(); 
    579619 
     
    588628 
    589629        // Calculate the compressed index if any 
    590         std::set<int> writtenInd; 
    591         if (isCompressible_) 
    592         { 
    593           for (int idx = 0; idx < data_index.numElements(); ++idx) 
    594           { 
    595             int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
    596  
    597             if (ind >= 0 && ind < ni && mask(ind)) 
    598             { 
    599               ind += ibegin; 
    600               if (ind >= global_zoom_begin && ind <= global_zoom_end) 
    601                 writtenInd.insert(ind); 
    602             } 
    603           } 
    604         } 
     630//        std::set<int> writtenInd; 
     631//        if (isCompressible_) 
     632//        { 
     633//          for (int idx = 0; idx < data_index.numElements(); ++idx) 
     634//          { 
     635//            int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
     636// 
     637//            if (ind >= 0 && ind < ni && mask(ind)) 
     638//            { 
     639//              ind += ibegin; 
     640//              writtenInd.insert(ind); 
     641//            } 
     642//          } 
     643//        } 
    605644 
    606645        // Compute the global index of the current client (process) hold 
     
    635674 
    636675        CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType); 
    637  
     676       
    638677        std::vector<int> serverZeroIndex; 
    639678        serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); 
     
    654693        if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION) 
    655694        { 
    656           for(int i=1; i<nbServer; ++i)  
    657           { 
    658             indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 
    659           } 
    660  
     695          for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 
    661696          serverZeroIndexLeader.clear() ; 
    662697        } 
    663  
     698          
    664699        CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_[nbServer].begin(), 
    665700                                                             ite = indSrv_[nbServer].end(); 
     
    675710          connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
    676711 
    677          nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
     712        nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
    678713 
    679714        delete clientServerMap; 
     
    681716    } 
    682717  } 
     718  CATCH_DUMP_ATTR 
    683719 
    684720  /* 
     
    688724  */ 
    689725  void CAxis::computeWrittenIndex() 
     726  TRY 
    690727  {   
    691728    if (computedWrittenIndex_) return; 
     
    697734    // We describe the distribution of client (server) on which data are written 
    698735    std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 
    699     nBegin[0]       = zoom_begin; 
    700     nSize[0]        = zoom_n;    
     736    nBegin[0]       = begin; 
     737    nSize[0]        = n; 
    701738    nBeginGlobal[0] = 0;  
    702739    nGlob[0]        = n_glo; 
     
    711748    CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    712749                                     itSrve = writtenGlobalIndex.end(), itSrv;   
    713     if (!zoomByIndex()) 
    714     {    
    715       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    716       { 
    717         indGlo = *itSrv; 
    718         if (ite != globalLocalIndexMap_.find(indGlo)) 
    719         {           
    720           ++nbWritten; 
    721         }                  
    722       } 
    723  
    724       localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    725 //      localIndexToWriteOnServer.resize(nbWritten); 
    726  
    727       nbWritten = 0; 
    728       for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    729       { 
    730         indGlo = *itSrv; 
    731         if (ite != globalLocalIndexMap_.find(indGlo)) 
    732         { 
    733           localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    734           ++nbWritten; 
    735         }                  
    736       } 
    737     } 
    738     else 
    739     { 
    740       nbWritten = 0; 
    741       std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 
    742                                                           ite = globalLocalIndexMap_.end(), it; 
    743       for (int i = 0; i < zoom_index.numElements(); ++i) 
    744       { 
    745          if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
    746           ++nbWritten; 
    747       } 
    748  
    749       localIndexToWriteOnServer.resize(nbWritten); 
    750  
    751       nbWritten = 0; 
    752       for (int i = 0; i < zoom_index.numElements(); ++i) 
    753       { 
    754          if (ite != globalLocalIndexMap_.find(zoom_index(i))) 
    755          { 
    756            localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 
    757            ++nbWritten; 
    758          } 
    759       } 
    760     } 
    761  
    762   } 
     750 
     751    localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
     752    nbWritten = 0; 
     753    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
     754    { 
     755      indGlo = *itSrv; 
     756      if (ite != globalLocalIndexMap_.find(indGlo)) 
     757      { 
     758        localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
     759      } 
     760      else 
     761      { 
     762        localIndexToWriteOnServer(nbWritten) = -1; 
     763      } 
     764      ++nbWritten; 
     765    } 
     766 
     767  } 
     768  CATCH_DUMP_ATTR 
    763769 
    764770  void CAxis::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 
     771  TRY 
    765772  { 
    766773    int writtenCommSize; 
     
    777784      // We describe the distribution of client (server) on which data are written 
    778785      std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 
    779       nBegin[0]       = zoom_begin; 
    780       nSize[0]        = zoom_n;    
     786      nBegin[0]       = 0; 
     787      nSize[0]        = n; 
    781788      nBeginGlobal[0] = 0;  
    782789      nGlob[0]        = n_glo; 
     
    798805        }                  
    799806      } 
     807// 
     808//      nbWritten = 0; 
     809//      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     810//      { 
     811//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
     812//        { 
     813//          ++nbWritten; 
     814//        } 
     815//      } 
     816// 
     817//      compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 
     818//      nbWritten = 0; 
     819//      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     820//      { 
     821//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
     822//        { 
     823//          compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 
     824//          ++nbWritten; 
     825//        } 
     826//      } 
    800827 
    801828      nbWritten = 0; 
     
    823850      { 
    824851              
    825         ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); 
    826         ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm); 
     852        ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 
     853        ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 
    827854        offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; 
    828855      } 
     
    831858    } 
    832859  } 
     860  CATCH_DUMP_ATTR 
    833861 
    834862  /*! 
     
    841869  void CAxis::sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, 
    842870                                        CServerDistributionDescription::ServerDistributionType distType) 
     871  TRY 
    843872  { 
    844873    std::list<CContextClient*>::iterator it; 
     
    865894          const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 
    866895          const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid]; 
    867           const int end   = begin + ni - 1;           
    868896 
    869897          msgs.push_back(CMessage()); 
    870898          CMessage& msg = msgs.back(); 
    871899          msg << this->getId(); 
    872           msg << ni << begin << end;           
     900          msg << ni << begin; 
    873901          msg << isCompressible_;                     
    874902 
     
    880908    } 
    881909  } 
     910  CATCH_DUMP_ATTR 
    882911 
    883912  /* 
     
    886915  */ 
    887916  void CAxis::recvDistributionAttribute(CEventServer& event) 
     917  TRY 
    888918  { 
    889919    CBufferIn* buffer = event.subEvents.begin()->buffer; 
     
    892922    get(axisId)->recvDistributionAttribute(*buffer); 
    893923  } 
     924  CATCH 
    894925 
    895926  /* 
     
    898929  */ 
    899930  void CAxis::recvDistributionAttribute(CBufferIn& buffer) 
    900   { 
    901     int ni_srv, begin_srv, end_srv; 
    902     int global_zoom_end, zoom_end; 
    903     bool zoomIndex = zoomByIndex(); 
    904      
    905     std::vector<int> zoom_index_tmp; 
    906     std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 
    907  
    908     buffer >> ni_srv >> begin_srv >> end_srv;     
     931  TRY 
     932  { 
     933    int ni_srv, begin_srv; 
     934    buffer >> ni_srv >> begin_srv; 
    909935    buffer >> isCompressible_;             
    910936 
     
    912938    n.setValue(ni_srv); 
    913939    begin.setValue(begin_srv); 
    914  
    915     // If we have zoom by index then process it 
    916     if (zoomIndex) 
    917     { 
    918       zoom_index_tmp.resize(global_zoom_index.numElements()); 
    919       std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 
    920       std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 
    921       itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 
    922       itZoomEnd   = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv);       
    923       int sz = std::distance(itZoomBegin, itZoomEnd); 
    924       zoom_index.resize(sz); 
    925       itZoom = itZoomBegin; 
    926       for (int i = 0; i < sz; ++i, ++itZoom) 
    927       { 
    928         zoom_index(i) = *(itZoom); 
    929       } 
    930     } 
    931  
    932     global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 
    933     global_zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    934     global_zoom_end   = global_zoom_begin + global_zoom_n - 1; 
    935  
    936     zoom_begin = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomBegin) 
    937                            : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
    938     zoom_end   = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1  
    939                            : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 
    940     zoom_n     = zoom_end - zoom_begin + 1; 
    941  
    942     if (zoom_n<=0) 
    943     { 
    944       zoom_n = 0; zoom_begin=global_zoom_begin; //0; zoom_begin = 0;  
    945     } 
    946  
    947     if (n_glo == n) 
    948     { 
    949       zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 
    950                              : global_zoom_begin;       
    951       zoom_n     = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 
    952     } 
    953   } 
     940  } 
     941  CATCH_DUMP_ATTR 
    954942 
    955943  /* 
     
    959947  */ 
    960948  void CAxis::sendNonDistributedAttributes() 
     949  TRY 
    961950  { 
    962951    std::list<CContextClient*>::iterator it; 
    963952    for (it=clients.begin(); it!=clients.end(); ++it) 
    964     { 
    965       CContextClient* client = *it; 
     953        { 
     954          CContextClient* client = *it; 
    966955 
    967956      CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 
     
    10121001    } 
    10131002  } 
     1003  CATCH_DUMP_ATTR 
    10141004 
    10151005  /* 
     
    10181008  */ 
    10191009  void CAxis::recvNonDistributedAttributes(CEventServer& event) 
     1010  TRY 
    10201011  { 
    10211012    list<CEventServer::SSubEvent>::iterator it; 
     
    10281019    } 
    10291020  } 
     1021  CATCH 
    10301022 
    10311023  /* 
     
    10351027  */ 
    10361028  void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 
     1029  TRY 
    10371030  {  
    1038     CArray<int,1> tmp_index, tmp_data_index, tmp_zoom_index; 
     1031    CArray<int,1> tmp_index, tmp_data_index; 
    10391032    CArray<bool,1> tmp_mask; 
    10401033    CArray<double,1> tmp_val; 
     
    10761069    for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[index(idx)] = idx; 
    10771070  } 
     1071  CATCH_DUMP_ATTR 
    10781072 
    10791073  /* 
    1080     Send attributes of axis from a group of client to other group of clients/servers  
    1081     on supposing that these attributes are distributed among the clients of the sending group 
    1082     In the future, if new attributes are added, they should also be processed in this function 
     1074    Send axis attributes from a group of clients to another group of clients/servers 
     1075    supposing that these attributes are distributed among the clients of the sending group 
     1076    In future, if new attributes are added, they should also be processed in this function 
    10831077  */ 
    10841078  void CAxis::sendDistributedAttributes(void) 
    1085   { 
    1086     int ns, n, i, j, ind, nv, idx; 
     1079  TRY 
     1080  { 
     1081    int ind, idx; 
    10871082    std::list<CContextClient*>::iterator it; 
    10881083 
     
    10951090 
    10961091      list<CMessage> listData; 
    1097       list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 
    1098       list<CArray<bool,1> > list_mask; 
     1092      list<CArray<int,1> > list_indi, list_dataInd; 
    10991093      list<CArray<double,1> > list_val; 
    11001094      list<CArray<double,2> > list_bounds; 
    11011095      list<CArray<string,1> > list_label; 
    11021096 
     1097      // Cut off the ghost points 
    11031098      int nbIndex = index.numElements(); 
    11041099      CArray<int,1> dataIndex(nbIndex); 
     
    11071102      { 
    11081103        if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
    1109           dataIndex(idx) = 1; 
     1104          dataIndex(data_index(idx)) = 1; 
    11101105      } 
    11111106 
     
    11141109      for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 
    11151110      { 
    1116         int nbData = 0; 
     1111        int nbData = 0, nbDataCount = 0; 
    11171112        int rank = connectedServerRank_[nbServer][k]; 
    11181113        it = indSrv_[nbServer].find(rank); 
     
    11211116 
    11221117        list_indi.push_back(CArray<int,1>(nbData)); 
    1123         list_dataInd.push_back(CArray<int,1>(nbData));         
    1124         list_mask.push_back(CArray<bool,1>(nbData)); 
     1118        list_dataInd.push_back(CArray<int,1>(nbData)); 
    11251119 
    11261120        if (hasValue) 
     
    11341128 
    11351129        CArray<int,1>& indi = list_indi.back(); 
    1136         CArray<int,1>& dataIndi = list_dataInd.back();         
    1137         CArray<bool,1>& maskIndi = list_mask.back(); 
    1138  
    1139         for (n = 0; n < nbData; ++n) 
     1130        CArray<int,1>& dataIndi = list_dataInd.back(); 
     1131        dataIndi = -1; 
     1132 
     1133        for (int n = 0; n < nbData; ++n) 
    11401134        { 
    11411135          idx = static_cast<int>(it->second[n]); 
     
    11441138          ind = globalLocalIndexMap_[idx]; 
    11451139          dataIndi(n) = dataIndex(ind); 
    1146           maskIndi(n) = mask(ind); 
    11471140 
    11481141          if (hasValue) 
     
    11681161        listData.push_back(CMessage()); 
    11691162        listData.back() << this->getId() 
    1170                         << list_indi.back() << list_dataInd.back() << list_mask.back(); 
     1163                        << list_indi.back() << list_dataInd.back(); 
    11711164 
    11721165        listData.back() << hasValue; 
     
    11881181    } 
    11891182  } 
     1183  CATCH_DUMP_ATTR 
    11901184 
    11911185  /* 
     
    11941188  */ 
    11951189  void CAxis::recvDistributedAttributes(CEventServer& event) 
     1190  TRY 
    11961191  { 
    11971192    string axisId; 
     
    12091204    get(axisId)->recvDistributedAttributes(ranks, buffers); 
    12101205  } 
     1206  CATCH 
    12111207 
    12121208  /* 
     
    12161212  */ 
    12171213  void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) 
     1214  TRY 
    12181215  { 
    12191216    int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 
    1220     vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived);     
    1221     vector<CArray<bool,1> > vec_mask(nbReceived); 
     1217    vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 
    12221218    vector<CArray<double,1> > vec_val(nbReceived); 
    12231219    vector<CArray<double,2> > vec_bounds(nbReceived); 
     
    12291225      buffer >> vec_indi[idx]; 
    12301226      buffer >> vec_dataInd[idx];       
    1231       buffer >> vec_mask[idx]; 
    12321227 
    12331228      buffer >> hasValue; 
     
    12561251    globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor())); 
    12571252    nbIndexGlob = 0; 
     1253    int nbIndLoc = 0; 
    12581254    for (idx = 0; idx < nbReceived; ++idx) 
    12591255    { 
     
    12621258      { 
    12631259         gloInd = tmp(ind); 
     1260         nbIndLoc = (gloInd % n_glo)-begin; 
    12641261         if (0 == globalLocalIndexMap_.count(gloInd)) 
    12651262         { 
    1266            index(nbIndexGlob) = gloInd % n_glo;            
    1267            globalLocalIndexMap_[gloInd] = nbIndexGlob;   
     1263           index(nbIndexGlob) = gloInd % n_glo; 
     1264           globalLocalIndexMap_[gloInd] = nbIndexGlob; 
    12681265           ++nbIndexGlob; 
    12691266         }  
     
    12781275    CArray<int,1> nonCompressedData(nbData); 
    12791276    nonCompressedData = -1;    
    1280     mask.resize(nbData); 
     1277    // Mask is incorporated into data_index and is not sent/received anymore 
     1278    mask.resize(0); 
    12811279    if (hasValue) 
    12821280      value.resize(nbData); 
     
    12911289      CArray<int,1>& indi = vec_indi[idx]; 
    12921290      CArray<int,1>& dataIndi = vec_dataInd[idx]; 
    1293       CArray<bool,1>& maskIndi = vec_mask[idx]; 
    12941291      int nb = indi.numElements(); 
    12951292      for (int n = 0; n < nb; ++n) 
     
    12991296        nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd); 
    13001297 
    1301         if (!mask(locInd)) // Only rewrite mask if it's not true 
    1302           mask(locInd) = maskIndi(n); 
    1303          
    13041298        if (hasValue) 
    13051299          value(locInd) = vec_val[idx](n); 
     
    13161310    } 
    13171311     
    1318     int nbCompressedData = 0;  
     1312    int nbCompressedData = 0; 
    13191313    for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 
    13201314    { 
    13211315      if (0 <= nonCompressedData(idx)) 
    1322         ++nbCompressedData;         
     1316        ++nbCompressedData; 
    13231317    } 
    13241318 
     
    13301324      { 
    13311325        data_index(nbCompressedData) = idx % n; 
    1332         ++nbCompressedData;         
     1326        ++nbCompressedData; 
    13331327      } 
    13341328    } 
    13351329 
    13361330    data_begin.setValue(0); 
    1337   } 
     1331    data_n.setValue(data_index.numElements()); 
     1332  } 
     1333  CATCH_DUMP_ATTR 
    13381334 
    13391335  /*! 
     
    13451341  */ 
    13461342  bool CAxis::isEqual(CAxis* obj) 
     1343  TRY 
    13471344  { 
    13481345    vector<StdString> excludedAttr; 
     
    13681365    return objEqual; 
    13691366  } 
     1367  CATCH_DUMP_ATTR 
    13701368 
    13711369  /* 
     
    13751373  */ 
    13761374  CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) 
     1375  TRY 
    13771376  { 
    13781377    transformationMap_.push_back(std::make_pair(transType, CTransformation<CAxis>::createTransformation(transType,id))); 
    13791378    return transformationMap_.back().second; 
    13801379  } 
     1380  CATCH_DUMP_ATTR 
    13811381 
    13821382  /* 
     
    13841384  */ 
    13851385  bool CAxis::hasTransformation() 
     1386  TRY 
    13861387  { 
    13871388    return (!transformationMap_.empty()); 
    13881389  } 
     1390  CATCH_DUMP_ATTR 
    13891391 
    13901392  /* 
     
    13931395  */ 
    13941396  void CAxis::setTransformations(const TransMapTypes& axisTrans) 
     1397  TRY 
    13951398  { 
    13961399    transformationMap_ = axisTrans; 
    13971400  } 
     1401  CATCH_DUMP_ATTR 
    13981402 
    13991403  /* 
     
    14021406  */ 
    14031407  CAxis::TransMapTypes CAxis::getAllTransformations(void) 
     1408  TRY 
    14041409  { 
    14051410    return transformationMap_; 
    14061411  } 
     1412  CATCH_DUMP_ATTR 
    14071413 
    14081414  /* 
     
    14111417  */ 
    14121418  void CAxis::duplicateTransformation(CAxis* src) 
     1419  TRY 
    14131420  { 
    14141421    if (src->hasTransformation()) 
     
    14171424    } 
    14181425  } 
     1426  CATCH_DUMP_ATTR 
    14191427 
    14201428  /*! 
     
    14221430   */ 
    14231431  void CAxis::solveInheritanceTransformation() 
     1432  TRY 
    14241433  { 
    14251434    if (hasTransformation() || !hasDirectAxisReference()) 
     
    14381447        refAxis[i]->setTransformations(axis->getAllTransformations()); 
    14391448  } 
     1449  CATCH_DUMP_ATTR 
    14401450 
    14411451  void CAxis::setContextClient(CContextClient* contextClient) 
     1452  TRY 
    14421453  { 
    14431454    if (clientsSet.find(contextClient)==clientsSet.end()) 
     
    14461457      clientsSet.insert(contextClient); 
    14471458    } 
    1448 } 
     1459  } 
     1460  CATCH_DUMP_ATTR 
    14491461 
    14501462  void CAxis::parse(xml::CXMLNode & node) 
     1463  TRY 
    14511464  { 
    14521465    SuperClass::parse(node); 
     
    14621475 
    14631476        nodeElementName = node.getElementName(); 
    1464  
    1465         if(transformationMapList_ptr == 0) initializeTransformationMap(); 
    1466         std::map<StdString, ETranformationType>::const_iterator ite = (*CAxis::transformationMapList_ptr).end(), it; 
    1467         it = (*CAxis::transformationMapList_ptr).find(nodeElementName); 
     1477        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 
     1478        it = transformationMapList_.find(nodeElementName); 
    14681479        if (ite != it) 
    14691480        { 
     
    14811492    } 
    14821493  } 
     1494  CATCH_DUMP_ATTR 
    14831495 
    14841496  DEFINE_REF_FUNC(Axis,axis) 
Note: See TracChangeset for help on using the changeset viewer.