Ignore:
Timestamp:
11/15/17 15:21:13 (4 years ago)
Author:
oabramkina
Message:

Adding buffer evaluation in case of reading.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp

    r1311 r1330  
    3131      , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0) 
    3232      , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    33       , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 
     33      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 
     34          , isDataDistributed_(true), isCompressible_(false) 
    3435      , transformations_(0), isTransformed_(false) 
    3536      , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) 
     
    5152      , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0) 
    5253      , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    53       , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), isCompressible_(false) 
     54      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 
     55          , isDataDistributed_(true), isCompressible_(false) 
    5456      , transformations_(0), isTransformed_(false) 
    5557      , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) 
     
    102104    * TODO: Refactor code 
    103105    */ 
    104    std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client) 
    105    { 
    106      std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 
     106   std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting) 
     107   { 
     108     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); 
    107109 
    108110     // The grid indexes require a similar size as the actual data 
    109      std::map<int, StdSize> dataSizes = getDataBufferSize(client); 
     111     std::map<int, StdSize> dataSizes = getDataBufferSize(client, "", bufferForWriting); 
    110112     // for (size_t i = 0; i < dataSizes.size(); ++i) 
    111113     // { 
     
    151153    * \param client contextClient used to determine the size of connected receivers 
    152154    * \param id the id used to tag the data 
     155    * \param bufferForWriting flag indicating if a buffer is used to send data for writing 
    153156    * \return A map associating the sender rank with its minimum buffer size. 
    154157    */ 
    155    std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/) 
     158   std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/) 
    156159   {      
    157160     // The record index is sometimes sent along with the data but we always 
     
    160163                                                       + 2 * sizeof(size_t)  
    161164                                                       + sizeof(size_t); 
    162      // CContext* context = CContext::getCurrent(); 
    163      // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
    164      // std::vector<std::map<int, StdSize> > dataSizes(nbSrvPools); 
    165      // for (int p = 0; p < nbSrvPools; ++p)  
    166      // { 
    167      //   std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[client].end(); 
    168      //   for (size_t k = 0; k < connectedServerRank_[p].size(); ++k) 
    169      //   { 
    170      //     int rank = connectedServerRank_[p][k]; 
    171      //     std::map<int, size_t>::const_iterator it = connectedDataSize_[client].find(rank); 
    172      //     size_t count = (it != itEnd) ? it->second : 0; 
    173  
    174      //     dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 
    175      //   } 
    176         
    177      // } 
    178165 
    179166     std::map<int, StdSize> dataSizes; 
    180167     int receiverSize = client->serverSize; 
    181      std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[receiverSize].end(); 
    182      for (size_t k = 0; k < connectedServerRank_[receiverSize].size(); ++k) 
     168     std::map<int,size_t>& dataSizeMap = bufferForWriting ? connectedDataSize_[receiverSize]: connectedDataSizeRead_; 
     169     std::vector<int>& connectedServerRanks = bufferForWriting ? connectedServerRank_[receiverSize] : connectedServerRankRead_; 
     170 
     171     std::map<int, size_t>::const_iterator itEnd = dataSizeMap.end(); 
     172     for (size_t k = 0; k < connectedServerRanks.size(); ++k) 
    183173     { 
    184        int rank = connectedServerRank_[receiverSize][k]; 
    185        std::map<int, size_t>::const_iterator it = connectedDataSize_[receiverSize].find(rank); 
     174       int rank = connectedServerRanks[k]; 
     175       std::map<int, size_t>::const_iterator it = dataSizeMap.find(rank); 
    186176       size_t count = (it != itEnd) ? it->second : 0; 
    187177 
     
    15511541  { 
    15521542    CContext* context = CContext::getCurrent(); 
     1543    connectedServerRankRead_ = ranks; 
    15531544 
    15541545    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
     
    16591650        CArray<size_t,1> outIndex; 
    16601651        buffer >> outIndex; 
    1661         outGlobalIndexFromClient.insert(std::make_pair(rank, outIndex));         
     1652        outGlobalIndexFromClient.insert(std::make_pair(rank, outIndex)); 
     1653        connectedDataSizeRead_[rank] = outIndex.numElements(); 
    16621654 
    16631655        if (doGridHaveDataDistributed(client)) 
Note: See TracChangeset for help on using the changeset viewer.