Changeset 1330


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

Adding buffer evaluation in case of reading.

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

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/cxios.cpp

    r1243 r1330  
    158158    // Initialize all aspects MPI 
    159159    CServer::initialize(); 
    160     if (CServer::getRank()==0) globalRegistry = new CRegistry(CServer::intraComm) ; 
     160    if (CServer::getRank()==0 && CServer::serverLevel != 1) globalRegistry = new CRegistry(CServer::intraComm) ; 
    161161     
    162162    if (printLogs2Files) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp

    r1314 r1330  
    153153    * \return A map associating the server rank with its minimum buffer size. 
    154154    */ 
    155    std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client) 
    156    { 
    157      // For now the assumption is that secondary server pools consist of the same number of procs. 
    158      // CHANGE the line below if the assumption changes. 
    159      // CContext* context = CContext::getCurrent(); 
    160      // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 
    161  
    162      std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 
     155   std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) 
     156   { 
     157 
     158     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); 
    163159 
    164160     bool isNonDistributed = (n = n_glo);      
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp

    r1249 r1330  
    7474         CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom); 
    7575 
    76          std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 
     76         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); 
    7777 
    7878         /// Test /// 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp

    r1318 r1330  
    297297   } 
    298298 
    299    void CContext::setClientServerBuffer(CContextClient* contextClient) 
     299   /*! 
     300    Sets client buffers. 
     301    \param [in] contextClient 
     302    \param [in] bufferForWriting True if buffers are used for sending data for writing 
     303    This flag is only true for client and server-1 for communication with server-2 
     304  */ 
     305   void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting) 
    300306   { 
    301307      // Estimated minimum event size for small events (10 is an arbitrary constant just for safety) 
     
    314320     // Compute the buffer sizes needed to send the attributes and data corresponding to fields 
    315321     std::map<int, StdSize> maxEventSize; 
    316      std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize, contextClient); 
    317      std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize, contextClient); 
     322     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize, contextClient, bufferForWriting); 
     323     std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize, contextClient, bufferForWriting); 
    318324 
    319325     std::map<int, StdSize>::iterator it, ite = dataBufferSize.end(); 
     
    544550     distributeFiles(); 
    545551 
    546      setClientServerBuffer(client); 
     552     setClientServerBuffer(client, (hasClient && !hasServer)); 
    547553     for (int i = 0; i < clientPrimServer.size(); ++i) 
    548          setClientServerBuffer(clientPrimServer[i]); 
     554         setClientServerBuffer(clientPrimServer[i], true); 
    549555 
    550556     if (hasClient) 
     
    13341340   /*! 
    13351341    * Compute the required buffer size to send the attributes (mostly those grid related). 
    1336     * 
    13371342    * \param maxEventSize [in/out] the size of the bigger event for each connected server 
     1343    * \param [in] contextClient 
     1344    * \param [in] bufferForWriting True if buffers are used for sending data for writing 
     1345      This flag is only true for client and server-1 for communication with server-2 
    13381346    */ 
    1339    std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient) 
     1347   std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, 
     1348                                                           CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 
    13401349   { 
    13411350     std::map<int, StdSize> attributesSize; 
    13421351 
    1343      if (hasClient) 
    1344      { 
    1345        size_t numEnabledFiles = this->enabledWriteModeFiles.size(); 
     1352//     if (hasClient) 
     1353     { 
     1354       std::vector<CFile*>& fileList = bufferForWriting ? this->enabledWriteModeFiles : this->enabledReadModeFiles; 
     1355//       size_t numEnabledFiles = this->enabledWriteModeFiles.size(); 
     1356       size_t numEnabledFiles = fileList.size(); 
    13461357       for (size_t i = 0; i < numEnabledFiles; ++i) 
    13471358       { 
    1348          CFile* file = this->enabledWriteModeFiles[i]; 
    1349          // if (file->getContextClient() == contextClient) 
     1359//           CFile* file = this->enabledWriteModeFiles[i]; 
     1360         CFile* file = fileList[i]; 
     1361//         if (file->getContextClient() == contextClient) 
    13501362         { 
    13511363           std::vector<CField*> enabledFields = file->getEnabledFields(); 
     
    13531365           for (size_t j = 0; j < numEnabledFields; ++j) 
    13541366           { 
    1355              const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 
     1367             const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient, bufferForWriting); 
    13561368             std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    13571369             for (; it != itE; ++it) 
    13581370             { 
    13591371               // If attributesSize[it->first] does not exist, it will be zero-initialized 
    1360                // so we can use it safely without checking for its existance 
     1372               // so we can use it safely without checking for its existence 
    13611373               if (attributesSize[it->first] < it->second) 
    13621374                 attributesSize[it->first] = it->second; 
     
    13691381       } 
    13701382 
    1371       // Not a good approach here, duplicate code 
    1372        if (!hasServer) 
    1373        { 
    1374          size_t numEnabledFiles = this->enabledReadModeFiles.size(); 
    1375          for (size_t i = 0; i < numEnabledFiles; ++i) 
    1376          { 
    1377            CFile* file = this->enabledReadModeFiles[i];   
    1378            { 
    1379              std::vector<CField*> enabledFields = file->getEnabledFields(); 
    1380              size_t numEnabledFields = enabledFields.size(); 
    1381              for (size_t j = 0; j < numEnabledFields; ++j) 
    1382              { 
    1383                const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 
    1384                std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    1385                for (; it != itE; ++it) 
    1386                { 
    1387                  // If attributesSize[it->first] does not exist, it will be zero-initialized 
    1388                  // so we can use it safely without checking for its existance 
    1389                  if (attributesSize[it->first] < it->second) 
    1390                    attributesSize[it->first] = it->second; 
    1391  
    1392                  if (maxEventSize[it->first] < it->second) 
    1393                    maxEventSize[it->first] = it->second; 
    1394                } 
    1395              } 
    1396            } 
    1397          } 
    1398        } 
     1383//      // Not a good approach here, duplicate code 
     1384//       if (!hasServer) 
     1385//       { 
     1386//         size_t numEnabledFiles = this->enabledReadModeFiles.size(); 
     1387//         for (size_t i = 0; i < numEnabledFiles; ++i) 
     1388//         { 
     1389//           CFile* file = this->enabledReadModeFiles[i]; 
     1390//           { 
     1391//             std::vector<CField*> enabledFields = file->getEnabledFields(); 
     1392//             size_t numEnabledFields = enabledFields.size(); 
     1393//             for (size_t j = 0; j < numEnabledFields; ++j) 
     1394//             { 
     1395//               const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 
     1396//               std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
     1397//               for (; it != itE; ++it) 
     1398//               { 
     1399//                 // If attributesSize[it->first] does not exist, it will be zero-initialized 
     1400//                 // so we can use it safely without checking for its existance 
     1401//                 if (attributesSize[it->first] < it->second) 
     1402//                   attributesSize[it->first] = it->second; 
     1403// 
     1404//                 if (maxEventSize[it->first] < it->second) 
     1405//                   maxEventSize[it->first] = it->second; 
     1406//               } 
     1407//             } 
     1408//           } 
     1409//         } 
     1410//       } 
    13991411     } 
    14001412 
     
    14041416   /*! 
    14051417    * Compute the required buffer size to send the fields data. 
    1406     * 
    14071418    * \param maxEventSize [in/out] the size of the bigger event for each connected server 
     1419    * \param [in] contextClient 
     1420    * \param [in] bufferForWriting True if buffers are used for sending data for writing 
     1421      This flag is only true for client and server-1 for communication with server-2 
    14081422    */ 
    1409    std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient) 
    1410    { 
    1411      CFile::mode_attr::t_enum mode = hasClient ? CFile::mode_attr::write : CFile::mode_attr::read; 
     1423   std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize, 
     1424                                                      CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 
     1425   { 
     1426//     CFile::mode_attr::t_enum mode = hasClient ? CFile::mode_attr::write : CFile::mode_attr::read; 
    14121427 
    14131428     std::map<int, StdSize> dataSize; 
    14141429 
    14151430     // Find all reference domain and axis of all active fields 
    1416      size_t numEnabledFiles = this->enabledFiles.size(); 
     1431     std::vector<CFile*>& fileList = bufferForWriting ? this->enabledWriteModeFiles : this->enabledReadModeFiles; 
     1432     size_t numEnabledFiles = fileList.size(); 
     1433//     size_t numEnabledFiles = this->enabledFiles.size(); 
    14171434     for (size_t i = 0; i < numEnabledFiles; ++i) 
    14181435     { 
    1419        CFile* file = this->enabledFiles[i]; 
     1436//       CFile* file = this->enabledFiles[i]; 
     1437       CFile* file = fileList[i]; 
    14201438       if (file->getContextClient() == contextClient) 
    14211439       { 
    1422          CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue(); 
    1423  
    1424          if (fileMode == mode) 
     1440//         CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue(); 
     1441//         if (fileMode == mode) 
     1442 
    14251443         { 
    14261444           std::vector<CField*> enabledFields = file->getEnabledFields(); 
     
    14291447           { 
    14301448             // const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 
    1431             const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 
     1449            const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient,bufferForWriting); 
    14321450             // for (size_t c = 0; c < mapSize.size(); ++c) 
    14331451             // { 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/context.hpp

    r1318 r1330  
    134134         void sendGridComponentEnabledFieldsInFiles(const std::vector<CFile*>& activeFiles)       ; 
    135135 
    136 //         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize); 
    137 //         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize); 
    138 //         void setClientServerBuffer(); 
    139          std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient); 
    140          std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient); 
    141          void setClientServerBuffer(CContextClient* contextClient); 
     136         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 
     137         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 
     138         void setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting = false); 
    142139 
    143140         // Distribute files (in write mode) among secondary-server pools according to the estimated data flux 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp

    r1325 r1330  
    129129    * \return A map associating the server rank with its minimum buffer size. 
    130130    */ 
    131    std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client) 
    132    { 
    133      CContext* context = CContext::getCurrent(); 
    134      // For now the assumption is that secondary server pools consist of the same number of procs. 
    135      // CHANGE the line below if the assumption changes. 
    136      // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 
    137  
    138      std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 
     131   std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) 
     132   { 
     133 
     134     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); 
    139135 
    140136     if (client->isServerLeader()) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp

    r1311 r1330  
    9797         CArray<int,1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom); 
    9898 
    99          std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 
     99         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); 
    100100 
    101101         bool isEmpty(void) const; 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp

    r1327 r1330  
    911911   } 
    912912 
    913    std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client) 
    914    { 
    915      return grid->getAttributesBufferSize(client); 
    916    } 
    917  
    918    std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client) 
    919    { 
    920      return grid->getDataBufferSize(client, getId()); 
     913   std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 
     914   { 
     915     return grid->getAttributesBufferSize(client, bufferForWriting); 
     916   } 
     917 
     918   std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 
     919   { 
     920     return grid->getDataBufferSize(client, getId(), bufferForWriting); 
    921921   } 
    922922 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp

    r1318 r1330  
    100100         void resetNStepMax(); 
    101101 
    102          std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client); 
    103          std::map<int, StdSize> getGridDataBufferSize(CContextClient* client); // Grid data buffer size for each connection of contextclient 
     102         std::map<int, StdSize> getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); 
     103         // Grid data buffer size for each connection of contextclient 
     104         std::map<int, StdSize> getGridDataBufferSize(CContextClient* client, bool bufferForWriting = false); 
    104105 
    105106         void setContextClient(CContextClient* newContextClient); 
  • 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)) 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp

    r1294 r1330  
    166166         void computeDomConServer(); 
    167167         std::map<int, int> getDomConServerSide(); 
    168          std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 
    169          std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = ""); 
     168         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, bool bufferForWriting = false); 
     169         std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = "", bool bufferForWriting = false); 
    170170         std::vector<StdString> getDomainList(); 
    171171         std::vector<StdString> getAxisList(); 
     
    326326        int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
    327327 
    328 /** Map storing local ranks of connected receivers. Key = size of receiver's intracomm */ 
     328/** Map storing local ranks of connected receivers. Key = size of receiver's intracomm. 
     329  * It is calculated in computeConnectedClients(). */ 
    329330        std::map<int, std::vector<int> > connectedServerRank_; 
    330331 
    331 /** Map storing the size of data to be send. Key = size of receiver's intracomm */ 
     332/** Map storing the size of data to be send. Key = size of receiver's intracomm 
     333  * It is calculated in computeConnectedClients(). */ 
    332334        std::map<int, std::map<int,size_t> > connectedDataSize_; 
     335 
     336/** Ranks of connected receivers in case of reading. It is calculated in recvIndex(). */ 
     337        std::vector<int> connectedServerRankRead_; 
     338 
     339/** Size of data to be send in case of reading. It is calculated in recvIndex(). */ 
     340        std::map<int,size_t> connectedDataSizeRead_; 
    333341 
    334342        bool isDataDistributed_;         
  • XIOS/dev/XIOS_DEV_CMIP6/src/object_template.hpp

    r1158 r1330  
    5555         /// Traitement statique /// 
    5656         static void ClearAllAttributes(void); 
    57          std::map<int, size_t> getMinimumBufferSizeForAttributes(); 
     57         std::map<int, size_t> getMinimumBufferSizeForAttributes(CContextClient* client); 
    5858         void sendAttributToServer(const string& id); 
    5959         void sendAttributToServer(const string& id, CContextClient* client); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/object_template_impl.hpp

    r1283 r1330  
    181181 
    182182   template<typename T> 
    183    std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes() 
    184    { 
    185      // Use correct context client to send message 
    186      CContext* context = CContext::getCurrent(); 
    187      // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    188      int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    189      for (int i = 0; i < nbSrvPools; ++i) 
     183   std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes(CContextClient* client) 
     184   { 
     185     std::map<int, size_t> minimumSizes; 
     186 
     187     if (client->isServerLeader()) 
    190188     { 
    191        CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 
    192  
    193        std::map<int, size_t> minimumSizes; 
    194  
    195        if (contextClientTmp->isServerLeader()) 
     189       size_t minimumSize = 0; 
     190       CAttributeMap& attrMap = *this; 
     191       CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 
     192       for (; it != itE; ++it) 
    196193       { 
    197          size_t minimumSize = 0; 
    198          CAttributeMap& attrMap = *this; 
    199          CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 
    200          for (; it != itE; ++it) 
     194         if (!it->second->isEmpty()) 
    201195         { 
    202            if (!it->second->isEmpty()) 
    203            { 
    204              size_t size = it->second->getName().size() + sizeof(size_t) + it->second->size(); 
    205              if (size > minimumSize) 
    206                minimumSize = size; 
    207            } 
    208          } 
    209  
    210          if (minimumSize) 
    211          { 
    212            // Account for extra header info 
    213            minimumSize += CEventClient::headerSize + getIdServer().size() + sizeof(size_t); 
    214  
    215            const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    216            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    217              minimumSizes.insert(std::make_pair(*itRank, minimumSize)); 
     196           size_t size = it->second->getName().size() + sizeof(size_t) + it->second->size(); 
     197           if (size > minimumSize) 
     198             minimumSize = size; 
    218199         } 
    219200       } 
    220        return minimumSizes; 
     201 
     202       if (minimumSize) 
     203       { 
     204         // Account for extra header info 
     205         minimumSize += CEventClient::headerSize + getIdServer().size() + sizeof(size_t); 
     206 
     207         const std::list<int>& ranks = client->getRanksServerLeader(); 
     208         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     209           minimumSizes.insert(std::make_pair(*itRank, minimumSize)); 
     210       } 
    221211     } 
    222    } 
     212     return minimumSizes; 
     213   } 
     214 
    223215 
    224216   template<typename T> 
Note: See TracChangeset for help on using the changeset viewer.