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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.