Changeset 1250 for XIOS


Ignore:
Timestamp:
09/01/17 13:39:53 (7 years ago)
Author:
mhnguyen
Message:

Fixing bug on mask grid

+) Add mask_0d for scalar grid
+) Transmit grid's attributes (mask) from client and reconstruct them correctly on server
+) Rebuild data in the input of data flow on the server side

Test
+) On Curie
+) Simple test

Location:
XIOS/dev/XIOS_DEV_CMIP6/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/config/grid_attribute.conf

    r932 r1250  
    22DECLARE_ATTRIBUTE(StdString, description) 
    33 
    4 DECLARE_ARRAY(bool, 1, mask_1d) 
    5 DECLARE_ARRAY(bool, 2, mask_2d) 
    6 DECLARE_ARRAY(bool, 3, mask_3d) 
    7 DECLARE_ARRAY(bool, 4, mask_4d) 
    8 DECLARE_ARRAY(bool, 5, mask_5d) 
    9 DECLARE_ARRAY(bool, 6, mask_6d) 
    10 DECLARE_ARRAY(bool, 7, mask_7d) 
     4DECLARE_ARRAY(bool, 1, mask_1d, false) 
     5DECLARE_ARRAY(bool, 2, mask_2d, false) 
     6DECLARE_ARRAY(bool, 3, mask_3d, false) 
     7DECLARE_ARRAY(bool, 4, mask_4d, false) 
     8DECLARE_ARRAY(bool, 5, mask_5d, false) 
     9DECLARE_ARRAY(bool, 6, mask_6d, false) 
     10DECLARE_ARRAY(bool, 7, mask_7d, false) 
    1111 
     12// Meaningless, only server for coherent purpose (for scalar grid) 
     13DECLARE_ARRAY(bool, 1, mask_0d, false) 
    1214 
    1315// An array contains order of axis and domains composing of the grid 
  • XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.cpp

    r1158 r1250  
    478478  localDataIndex_.resize(indexLocalDataOnClientCount); 
    479479  localMaskIndex_.resize(indexSend2ServerCount); 
     480  localMaskedDataIndex_.resize(indexSend2ServerCount); 
    480481  globalDataIndex_.rehash(std::ceil(indexLocalDataOnClientCount/globalDataIndex_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount); 
    481482  globalLocalDataSendToServerMap_.rehash(std::ceil(indexSend2ServerCount/globalLocalDataSendToServerMap_.max_load_factor())); //globalLocalDataSendToServerMap_.reserve(indexSend2ServerCount); 
     
    561562              globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 
    562563              localMaskIndex_[indexSend2ServerCount] = gridMaskIndex; 
     564              localMaskedDataIndex_[indexSend2ServerCount] = indexLocalDataOnClientCount; 
    563565              ++indexSend2ServerCount; 
    564566            } 
     
    653655} 
    654656 
     657/*! 
     658  Return local mask index of client 
     659*/ 
     660const std::vector<int>& CDistributionClient::getLocalMaskedDataIndexOnClient() 
     661{ 
     662  if (!isComputed_) createGlobalIndexSendToServer(); 
     663  return localMaskedDataIndex_; 
     664} 
     665 
    655666} // namespace xios 
  • XIOS/dev/XIOS_DEV_CMIP6/src/distribution_client.hpp

    r1144 r1250  
    4545    GlobalLocalDataMap& getGlobalDataIndexOnClient(); 
    4646    const std::vector<int>& getLocalMaskIndexOnClient(); 
     47    const std::vector<int>& getLocalMaskedDataIndexOnClient(); 
    4748 
    4849    std::vector<int> getNGlob() { return nGlob_; } 
     
    8283    std::vector<int> localDataIndex_; 
    8384    std::vector<int> localMaskIndex_; 
     85    std::vector<int> localMaskedDataIndex_; 
    8486 
    8587  private: 
  • XIOS/dev/XIOS_DEV_CMIP6/src/filter/source_filter.cpp

    r1249 r1250  
    3232    packet->status = CDataPacket::NO_ERROR; 
    3333 
    34     packet->data.resize(grid->storeIndex_client.numElements()); 
    35     grid->inputField(data, packet->data) ; 
     34    packet->data.resize(grid->storeIndex_client.numElements());     
     35     
     36    if (compression) 
     37    { 
     38      packet->data = defaultValue; 
     39      grid->uncompressField(data, packet->data);     
     40    } 
     41    else 
     42      grid->inputField(data, packet->data); 
     43 
     44     
     45     
    3646    // if (compression) grid->inputField(data, packet->data) ; 
    3747    // else 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp

    r1248 r1250  
    950950     { 
    951951        if (!instantDataFilter) 
    952           instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,false)); 
     952          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid,true)); 
    953953 
    954954             // If the field data is to be read by the client or/and written to a file 
     
    965965     { 
    966966       if (!instantDataFilter) 
    967          instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false)); 
     967         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true)); 
    968968 
    969969             // If the field data is to be read by the client or/and written to a file 
     
    10161016         { 
    10171017            if (check_if_active.isEmpty()) check_if_active = false;  
    1018             instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, true, NoneDu, false, 
     1018            instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, false, NoneDu, false, 
    10191019                                                                                                        detectMissingValues, defaultValue)); 
    10201020         } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp

    r1239 r1250  
    8989     { 
    9090       std::vector<int> dataNindex = clientDistribution_->getDataNIndex(); 
    91        for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i]; 
     91       for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i];        
    9292     } 
    9393     return retvalue; 
     
    339339 
    340340     // TODO: Transfer grid attributes 
    341      if (!context->hasClient && context->hasServer) this->createMask(); 
     341     //if (!context->hasClient && context->hasServer) this->createMask(); 
    342342     this->computeIndex(); 
    343343 
     
    447447 
    448448      switch (dim) { 
     449        case 0: 
     450          modifyGridMask(mask_0d, indexToModify, modifyValue); 
     451          break; 
    449452        case 1: 
    450453          modifyGridMask(mask_1d, indexToModify, modifyValue); 
     
    485488 
    486489      switch (dim) { 
     490        case 0: 
     491          modifyGridMaskSize(mask_0d, newDimensionSize, newValue); 
     492          break; 
    487493        case 1: 
    488494          modifyGridMaskSize(mask_1d, newDimensionSize, newValue); 
     
    12531259   } 
    12541260 
     1261   void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const 
     1262   { 
     1263      const std::vector<int>& localMaskedDataIndex = clientDistribution_->getLocalMaskedDataIndexOnClient(); 
     1264      const int size = localMaskedDataIndex.size(); 
     1265       
     1266      for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; 
     1267   } 
     1268 
    12551269  void CGrid::computeClientIndexScalarGrid() 
    12561270  { 
     
    12611275      CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client)  
    12621276                                                    : context->client; 
     1277 
     1278      int rank = client->clientRank; 
     1279 
     1280      clientDistribution_ = new CDistributionClient(rank, this); 
    12631281 
    12641282      storeIndex_client.resize(1); 
     
    16881706          } 
    16891707          else // scalar 
    1690           {  
     1708          {   
    16911709          } 
    16921710        } 
    16931711         
    1694         modifyMaskSize(nSize, true); 
     1712        if (nSize.empty()) // Scalar grid 
     1713        { 
     1714          nBegin.push_back(0); 
     1715          nSize.push_back(1); 
     1716          nBeginGlobal.push_back(0);               
     1717          nGlob.push_back(1);   
     1718        } 
     1719 
     1720        modifyMaskSize(nSize, false); 
     1721 
    16951722        // These below codes are reserved for future 
    1696         // CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob);  
    1697         // map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 
    1698         //                                        ite = outGlobalIndexFromClient.end(), it;   
    1699         // const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex(); 
    1700         // CDistributionServer::GlobalLocalMap::const_iterator itSrv; 
    1701         // size_t nb = 0; 
    1702         // for (it = itb; it != ite; ++it) 
    1703         // { 
    1704         //   CArray<size_t,1>& globalInd = it->second; 
    1705         //   for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
    1706         //   { 
    1707         //     if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 
    1708         //   } 
    1709         // } 
     1723        CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob);  
     1724        map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(), 
     1725                                               ite = outGlobalIndexFromClient.end(), it;   
     1726        const CDistributionServer::GlobalLocalMap&  globalLocalMask = srvDist.getGlobalLocalIndex(); 
     1727        CDistributionServer::GlobalLocalMap::const_iterator itSrv; 
     1728        size_t nb = 0; 
     1729        for (it = itb; it != ite; ++it) 
     1730        { 
     1731          CArray<size_t,1>& globalInd = it->second; 
     1732          for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
     1733          { 
     1734            if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb; 
     1735          } 
     1736        } 
    17101737         
    1711         // CArray<int,1> indexToModify(nb); 
    1712         // nb = 0;     
    1713         // for (it = itb; it != ite; ++it) 
    1714         // { 
    1715         //   CArray<size_t,1>& globalInd = it->second; 
    1716         //   for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
    1717         //   { 
    1718         //     itSrv = globalLocalMask.find(globalInd(idx)); 
    1719         //     if (globalLocalMask.end() != itSrv)  
    1720         //     { 
    1721         //       indexToModify(nb) = itSrv->second; 
    1722         //       ++nb; 
    1723         //     } 
    1724         //   } 
    1725         // } 
    1726  
    1727         // modifyMask(indexToModify, true); 
     1738        CArray<int,1> indexToModify(nb); 
     1739        nb = 0;     
     1740        for (it = itb; it != ite; ++it) 
     1741        { 
     1742          CArray<size_t,1>& globalInd = it->second; 
     1743          for (size_t idx = 0; idx < globalInd.numElements(); ++idx) 
     1744          { 
     1745            itSrv = globalLocalMask.find(globalInd(idx)); 
     1746            if (globalLocalMask.end() != itSrv)  
     1747            { 
     1748              indexToModify(nb) = itSrv->second; 
     1749              ++nb; 
     1750            } 
     1751          } 
     1752        } 
     1753 
     1754        modifyMask(indexToModify, true); 
    17281755      } 
    17291756 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp

    r1243 r1250  
    9595         void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
    9696         template <int n> 
    97          void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;       
     97         void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;   
     98         template <int n> 
     99         void uncompressField(const CArray<double,n>& data, CArray<double,1>& outData) const;  
    98100 
    99101         virtual void parse(xml::CXMLNode& node); 
     
    252254        void storeField_arr(const double* const data, CArray<double, 1>& stored) const; 
    253255        void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 
     256        void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 
    254257 
    255258        void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); 
     
    353356                << "Grid = " << this->GetName()) 
    354357      this->restoreField_arr(stored, field.dataFirst()); 
     358   } 
     359 
     360   /*! 
     361     This function removes the effect of mask on received data on the server. 
     362     This function only serve for the checking purpose. TODO: Something must be done to seperate mask and data_index from each other in received data 
     363     \data data received data with masking effect on the server 
     364     \outData data without masking effect 
     365   */ 
     366   template <int N> 
     367   void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const 
     368   {       
     369     uncompressField_arr(data.dataFirst(), outData); 
    355370   } 
    356371 
Note: See TracChangeset for help on using the changeset viewer.