Ignore:
Timestamp:
02/15/21 21:14:02 (3 years ago)
Author:
oabramkina
Message:

Adding a possibility of tiled and non-tiled sent on the same domain.

Location:
XIOS/dev/dev_oa/src/node
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_oa/src/node/domain.cpp

    r1966 r2034  
    3535      , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 
    3636      , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 
    37       , isTiled_(false) 
     37      , isTiled_(false), isTiledOnly_(false) 
    3838   { 
    3939   } 
     
    4949      , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 
    5050      , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 
    51       , isTiled_(false) 
     51      , isTiled_(false), isTiledOnly_(false) 
    5252   { 
    5353    } 
     
    255255   { 
    256256      return isTiled_; 
     257   } 
     258   CATCH 
     259 
     260   bool CDomain::isTiledOnly(void) const 
     261   TRY 
     262   { 
     263      return isTiledOnly_; 
    257264   } 
    258265   CATCH 
     
    12851292        } 
    12861293      } 
     1294   } 
     1295   CATCH_DUMP_ATTR 
     1296 
     1297   //---------------------------------------------------------------- 
     1298 
     1299   /*! 
     1300    * For tiled domains, data_i/j_index should not take into 
     1301    * account parameters defining data (data_ni/nj, data_i/jbegin...) 
     1302    * \param [out] dataIndexI 
     1303    * \param [out] dataIndexJ 
     1304    * \param [out] infoIndexI 
     1305    * \param [out] infoIndexJ 
     1306    */ 
     1307 
     1308   void CDomain::computeCompressionTiled(CArray<int,1>& dataIndexI, CArray<int,1>& dataIndexJ, 
     1309                                         CArray<int,1>& infoIndexI, CArray<int,1>& infoIndexJ) 
     1310   TRY 
     1311   { 
     1312     const int dsize = ni * nj; 
     1313     dataIndexI.resize(dsize); 
     1314     dataIndexJ.resize(dsize); 
     1315 
     1316     dataIndexJ = 0; 
     1317     for (int k = 0; k < ni; ++k) 
     1318       dataIndexI(k) = k; 
     1319 
     1320     infoIndexI.resize(ni*nj); 
     1321     for (int j = 0; j < nj; ++j) 
     1322       for (int i = 0; i < ni; ++i) infoIndexI(i+j*ni) = i+ibegin; 
     1323 
     1324     infoIndexJ.resize(ni*nj); 
     1325     for (int j = 0; j < nj; ++j) 
     1326       for (int i = 0; i < ni; ++i) infoIndexJ(i+j*ni) = j+jbegin; 
    12871327   } 
    12881328   CATCH_DUMP_ATTR 
     
    17521792   TRY 
    17531793   { 
    1754      if (!ntiles.isEmpty() && ntiles.getValue() >1)  isTiled_ = true; 
     1794     if (!ntiles.isEmpty() && ntiles.getValue() >=1) isTiled_ = true; 
     1795     if (!tile_only.isEmpty() && tile_only.getValue() == true) { 
     1796       isTiled_ = true; 
     1797       isTiledOnly_ = true; 
     1798     } 
     1799 
    17551800     if (isTiled_) 
    17561801     { 
  • XIOS/dev/dev_oa/src/node/domain.hpp

    r1966 r2034  
    106106 
    107107         bool isTiled(void) const; 
     108         bool isTiledOnly(void) const; 
    108109         int getTileId(int i, int j) const; 
    109110         int getTileDataISize(int tileId) const; 
    110111         int getTileDataJSize(int tileId) const; 
     112         void computeCompressionTiled(CArray<int,1>& dataIndexI, CArray<int,1>& dataIndexJ, 
     113                                      CArray<int,1>& infoIndexI, CArray<int,1>& infoIndexJ); 
    111114 
    112115         std::vector<int> getNbGlob(); 
     
    228231         std::map<int, std::vector<int> > connectedServerRank_; 
    229232 
    230          //! True if and only if the data defined on the domain can be outputted in a compressed way 
     233//! True if and only if the data defined on the domain can be outputted in a compressed way 
    231234         bool isCompressible_; 
    232235         bool isRedistributed_; 
     
    235238         std::unordered_map<size_t,size_t> globalLocalIndexMap_; 
    236239 
     240//! True if tiled data is defined on the domain 
    237241         bool isTiled_; 
     242//! True if ONLY tiled data is defined on the domain 
     243         bool isTiledOnly_; 
    238244 
    239245       private: 
  • XIOS/dev/dev_oa/src/node/grid.cpp

    r1966 r2034  
    4040      , clients() 
    4141      , nTiles_(0) 
    42       , isTiled_(false) 
     42      , isTiled_(false), isTiledOnly_(false) 
    4343      , storeTileIndex() 
    4444   { 
     
    6464      , clients() 
    6565      , nTiles_(0) 
    66       , isTiled_(false) 
     66      , isTiled_(false), isTiledOnly_(false) 
    6767      , storeTileIndex() 
    6868   { 
     
    638638          else domListP[i]->checkAttributesOnClient(); 
    639639          if (domListP[i]->isTiled()) this->isTiled_ = true; 
     640          if (domListP[i]->isTiledOnly()) this->isTiledOnly_ = true; 
    640641        } 
    641642      } 
     
    802803          outLocalIndexStoreOnClient.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 
    803804          CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient[rank]; 
     805          size_t nbIndex = 0; 
     806 
     807          // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance 
     808          for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
     809          { 
     810            if (itGloe != globalDataIndex.find(globalIndex(idx))) 
     811            { 
     812              ++nbIndex; 
     813            } 
     814          } 
     815 
     816          if (doGridHaveDataDistributed(client) && (nbIndex != localIndex.numElements())) 
     817               ERROR("void CGrid::computeClientIndex()", 
     818                  << "Number of local index on client is different from number of received global index" 
     819                  << "Rank of sent client " << rank <<"." 
     820                  << "Number of local index " << nbIndex << ". " 
     821                  << "Number of received global index " << localIndex.numElements() << "."); 
     822 
     823          nbIndex = 0; 
     824          for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
     825          { 
     826            if (itGloe != globalDataIndex.find(globalIndex(idx))) 
     827            { 
     828              localIndex(idx) = globalDataIndex[globalIndex(idx)]; 
     829            } 
     830          } 
     831        } 
     832      } 
     833   } 
     834   CATCH_DUMP_ATTR 
     835 
     836   //--------------------------------------------------------------- 
     837 
     838   /* 
     839     Compute the global index and its local index taking account mask and data index. 
     840     These global indexes will be used to compute the connection of this client (sender) to its servers (receivers) 
     841     (via function computeConnectedClient) 
     842     These global indexes also correspond to data sent to servers (if any) 
     843   */ 
     844   void CGrid::computeClientIndexTiled() 
     845   TRY 
     846   { 
     847     CContext* context = CContext::getCurrent(); 
     848 
     849     CContextClient* client = context->client; 
     850     int rank = client->clientRank; 
     851 
     852     clientDistributionTiled_ = new CDistributionClient(rank, this, true); 
     853     // Get local data index on client 
     854     int nbStoreIndex = clientDistributionTiled_->getLocalDataIndexOnClient().size(); 
     855     int nbStoreGridMask = clientDistributionTiled_->getLocalMaskIndexOnClient().size(); 
     856     // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 
     857     storeIndexTiled_client.resize(nbStoreIndex); 
     858     storeMaskTiled_client.resize(nbStoreGridMask); 
     859     for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndexTiled_client(idx) = (clientDistributionTiled_->getLocalDataIndexOnClient())[idx]; 
     860     for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMaskTiled_client(idx) = (clientDistributionTiled_->getLocalMaskIndexOnClient())[idx]; 
     861 
     862     if (0 == serverDistribution_) isDataDistributed_= clientDistributionTiled_->isDataDistributed(); 
     863     else 
     864     { 
     865        // Mapping global index received from clients to the storeIndex_client 
     866        CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistributionTiled_->getGlobalDataIndexOnClient(); 
     867        CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 
     868        map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClientTiled.begin(), 
     869                                               ite = outGlobalIndexFromClientTiled.end(), it; 
     870 
     871        for (it = itb; it != ite; ++it) 
     872        { 
     873          int rank = it->first; 
     874          CArray<size_t,1>& globalIndex = outGlobalIndexFromClientTiled[rank]; 
     875          outLocalIndexStoreOnClientTiled.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 
     876          CArray<size_t,1>& localIndex = outLocalIndexStoreOnClientTiled[rank]; 
    804877          size_t nbIndex = 0; 
    805878 
     
    9781051     else 
    9791052     { 
    980        computeClientIndex(); 
     1053       if (this->isTiled_) 
     1054       { 
     1055         computeClientIndexTiled(); 
     1056         if (!this->isTiledOnly_) 
     1057           computeClientIndex(); 
     1058       } 
     1059       else 
     1060         computeClientIndex(); 
     1061 
    9811062       if (this->isTiled_) computeTileIndex(); 
    9821063       if (context->hasClient) 
     
    15431624   CATCH 
    15441625 
    1545    void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 
    1546    TRY 
    1547    { 
    1548       const StdSize size = storeIndex_client.numElements(); 
     1626   void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored, bool isTiled) const 
     1627   TRY 
     1628   { 
     1629      const CArray<int, 1>& storeIndex_clientP = isTiled ? storeIndexTiled_client : storeIndex_client; 
     1630      const CArray<bool, 1>& storeMask_clientP = isTiled ? storeMaskTiled_client : storeMask_client; 
     1631      const StdSize size = storeIndex_clientP.numElements(); 
    15491632      stored.resize(size); 
    15501633      const double nanValue = std::numeric_limits<double>::quiet_NaN(); 
    15511634 
    1552       if (storeMask_client.numElements() != 0) 
    1553         for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 
     1635      if (storeMask_clientP.numElements() != 0) 
     1636        for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_clientP(i)) ? data[storeIndex_clientP(i)] : nanValue; 
    15541637      else 
    1555         for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 
     1638        for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_clientP(i)]; 
    15561639   } 
    15571640   CATCH 
     
    25132596  CATCH_DUMP_ATTR 
    25142597 
     2598  bool CGrid::isTiled(void) const 
     2599  TRY 
     2600  { 
     2601     return isTiled_; 
     2602  } 
     2603  CATCH 
     2604 
     2605  bool CGrid::isTiledOnly(void) const 
     2606  TRY 
     2607  { 
     2608     return isTiledOnly_; 
     2609  } 
     2610  CATCH 
     2611 
    25152612  bool CGrid::isTransformed() 
    25162613  TRY 
  • XIOS/dev/dev_oa/src/node/grid.hpp

    r1966 r2034  
    9999         void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
    100100         template <int n> 
    101          void maskField(const CArray<double,n>& field, CArray<double,1>& stored) const; 
     101         void maskField(const CArray<double,n>& field, CArray<double,1>& stored, bool isTiled = false) const; 
    102102         template <int n> 
    103103         void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const;   
     
    211211      public: 
    212212         CArray<int, 1> storeIndex_client; 
     213         CArray<int, 1> storeIndexTiled_client; 
    213214         CArray<bool, 1> storeMask_client; 
     215         CArray<bool, 1> storeMaskTiled_client; 
    214216 
    215217/** Map containing indexes that will be sent in sendIndex(). */ 
     
    229231/** Map storing received indexes. Key = sender rank, value = index array. */ 
    230232         map<int, CArray<size_t, 1> > outGlobalIndexFromClient; 
     233 
     234/** Map storing received indexes. Key = sender rank, value = index array for tiled domains */ 
     235         map<int, CArray<size_t, 1> > outGlobalIndexFromClientTiled; 
    231236 
    232237// Manh Ha's comment: " A client receives global index from other clients (via recvIndex) 
     
    238243 *  The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData() */ 
    239244         map<int, CArray<size_t, 1> > outLocalIndexStoreOnClient;  
     245 
     246/** Map storing received data. Key = sender rank, value = data array. 
     247 *  The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData() */ 
     248         map<int, CArray<size_t, 1> > outLocalIndexStoreOnClientTiled; 
     249 
    240250 
    241251/** Indexes calculated based on server-like distribution. 
     
    263273 
    264274         int getNTiles(); 
     275         bool isTiled(void) const; 
     276         bool isTiledOnly(void) const; 
    265277 
    266278      private: 
     
    280292        void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 
    281293        void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 
    282         void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 
     294        void maskField_arr(const double* const data, CArray<double, 1>& stored, bool isTiled = false) const; 
    283295        void copyTile_arr(const double* const tileData, CArray<double, 1>& stored, int tileId); 
    284296 
     
    308320 
    309321        void computeClientIndex(); 
     322        void computeClientIndexTiled(); 
    310323        void computeConnectedClients(); 
    311324        void computeClientIndexScalarGrid();  
     
    325338 
    326339        int nTiles_; 
     340/** True if tiled data is defined on the grid */ 
    327341        bool isTiled_; 
     342/** True if ONLY tiled data is defined on the grid */ 
     343        bool isTiledOnly_; 
     344 
    328345/** Vector containing local domain indexes for each tile */ 
    329346        std::vector<CArray<int,1> > storeTileIndex; 
     
    337354/** Client-like distribution calculated based on the knowledge of the entire grid */ 
    338355        CDistributionClient* clientDistribution_; 
     356 
     357/** Client-like distribution calculated based on the knowledge of the entire grid in case of a tiled domain */ 
     358        CDistributionClient* clientDistributionTiled_; 
     359 
    339360 
    340361/** Server-like distribution calculated upon receiving indexes */ 
     
    409430 
    410431   template <int n> 
    411    void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const 
     432   void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored, bool isTiled) const 
    412433   { 
    413434//#ifdef __XIOS_DEBUG 
     
    419440                << "Grid = " << this->getId()) 
    420441//#endif 
    421       this->maskField_arr(field.dataFirst(), stored); 
    422    } 
     442      this->maskField_arr(field.dataFirst(), stored, isTiled); 
     443   } 
     444 
     445//   template <int n> 
     446//   void CGrid::maskFieldTiled(const CArray<double,n>& field, CArray<double,1>& stored) const 
     447//   { 
     448////#ifdef __XIOS_DEBUG 
     449//      if (this->getDataSize() != field.numElements()) 
     450//         ERROR("void CGrid::maskField(const  CArray<double,n>& field, CArray<double,1>& stored) const", 
     451//                << "[ Awaiting data of size = " << this->getDataSize() << ", " 
     452//                << "Received data size = "      << field.numElements() << " ] " 
     453//                << "The data array does not have the right size! " 
     454//                << "Grid = " << this->getId()) 
     455////#endif 
     456//      this->maskField_arr(field.dataFirst(), stored, true); 
     457//   } 
    423458 
    424459   template <int n> 
Note: See TracChangeset for help on using the changeset viewer.