Changeset 1236 for XIOS/dev


Ignore:
Timestamp:
08/04/17 16:03:34 (7 years ago)
Author:
mhnguyen
Message:

Making some changes to allow pools with different number of server

+) Associate context client to each grid distribution (This should be changed in the future)
+) Correct some buffer size estimation
+) Clean some redundant code and add comments

Location:
XIOS/dev/XIOS_DEV_CMIP6/src/node
Files:
9 edited

Legend:

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

    r1235 r1236  
    137137    * \return A map associating the server rank with its minimum buffer size. 
    138138    */ 
    139    std::map<int, StdSize> CAxis::getAttributesBufferSize() 
     139   std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client) 
    140140   { 
    141141     // For now the assumption is that secondary server pools consist of the same number of procs. 
    142142     // CHANGE the line below if the assumption changes. 
    143      CContext* context = CContext::getCurrent(); 
    144      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 
     143     // CContext* context = CContext::getCurrent(); 
     144     // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 
    145145 
    146146     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 
    147147 
    148      bool isNonDistributed = (n == n_glo); 
     148     bool isNonDistributed = (n = n_glo);      
    149149 
    150150     if (client->isServerLeader()) 
     
    168168     { 
    169169       // size estimation for sendDistributedValue 
    170        boost::unordered_map<int, vector<size_t> >::const_iterator it, ite = indSrv_.end(); 
    171        for (it = indSrv_.begin(); it != ite; ++it) 
     170       boost::unordered_map<int, vector<size_t> >::const_iterator it, ite = indSrv_[client].end(); 
     171       for (it = indSrv_[client].begin(); it != ite; ++it) 
    172172       { 
    173173         size_t sizeIndexEvent = CArray<int,1>::size(it->second.size()); 
    174          if (isCompressible_) 
    175            sizeIndexEvent += CArray<int,1>::size(indWrittenSrv_[it->first].size()); 
     174         // if (isCompressible_) 
     175         //   sizeIndexEvent += CArray<int,1>::size(indWrittenSrv_[it->first].size()); 
    176176 
    177177         size_t sizeValEvent = CArray<double,1>::size(it->second.size()); 
     
    505505 
    506506    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
     507 
     508    connectedServerRank_.clear(); 
     509    nbSenders.clear(); 
     510 
    507511    for (int p = 0; p < nbSrvPools; ++p) 
    508512    { 
     
    589593 
    590594 
    591       indSrv_.swap(globalIndexAxisOnServer); 
    592       CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_.begin(), 
    593                                                            ite = indSrv_.end(); 
    594       connectedServerRank_.clear(); 
    595       for (it = indSrv_.begin(); it != ite; ++it) { 
    596         connectedServerRank_.push_back(it->first); 
     595      indSrv_[client].swap(globalIndexAxisOnServer); 
     596      CClientServerMapping::GlobalIndexMap::const_iterator it  = indSrv_[client].begin(), 
     597                                                           ite = indSrv_[client].end(); 
     598       
     599      for (it = indSrv_[client].begin(); it != ite; ++it) { 
     600        connectedServerRank_[client].push_back(it->first); 
    597601      } 
    598602 
    599603      for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
    600         connectedServerRank_.push_back(*it); 
     604        connectedServerRank_[client].push_back(*it); 
    601605 
    602606       // Even if a client has no index, it must connect to at least one server and  
    603607       // send an "empty" data to this server 
    604        if (connectedServerRank_.empty()) 
    605         connectedServerRank_.push_back(client->clientRank % client->serverSize); 
    606  
    607       nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
     608       if (connectedServerRank_[client].empty()) 
     609        connectedServerRank_[client].push_back(client->clientRank % client->serverSize); 
     610 
     611      nbSenders[client] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]); 
    608612 
    609613      delete clientServerMap; 
     
    10191023 
    10201024      boost::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 
    1021       iteMap = indSrv_.end(); 
    1022       for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1025      iteMap = indSrv_[client].end(); 
     1026      for (int k = 0; k < connectedServerRank_[client].size(); ++k) 
    10231027      { 
    10241028        int nbData = 0; 
    1025         int rank = connectedServerRank_[k];         
    1026         it = indSrv_.find(rank); 
     1029        int rank = connectedServerRank_[client][k];         
     1030        it = indSrv_[client].find(rank); 
    10271031        if (iteMap != it) 
    10281032          nbData = it->second.size(); 
     
    10901094          listData.back() << list_label.back(); 
    10911095 
    1092         eventData.push(rank, nbConnectedClients_[rank], listData.back()); 
     1096        eventData.push(rank, nbSenders[client][rank], listData.back()); 
    10931097      } 
    10941098 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp

    r1235 r1236  
    7373         int getOffsetWrittenIndexes() const; 
    7474 
    75          std::map<int, StdSize> getAttributesBufferSize(); 
     75         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 
    7676 
    7777         /// Test /// 
     
    156156         //! True if and only if the data defined on the axis can be outputted in a compressed way 
    157157         bool isCompressible_; 
    158          std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 
    159          boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
    160          std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 
     158         std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server 
     159         std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server 
     160         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 
    161161         boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 
    162162         std::vector<int> indexesToWrite; 
    163163         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
    164          std::vector<int> connectedServerRank_;          
     164         std::map<CContextClient*, std::vector<int> > connectedServerRank_;          
    165165         bool hasBounds; 
    166166         bool hasLabel;          
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp

    r1232 r1236  
    13201320       { 
    13211321         CFile* file = this->enabledWriteModeFiles[i]; 
    1322 //        if (file->getContextClient() == contextClient) 
     1322         // if (file->getContextClient() == contextClient) 
    13231323         { 
    13241324           std::vector<CField*> enabledFields = file->getEnabledFields(); 
     
    13261326           for (size_t j = 0; j < numEnabledFields; ++j) 
    13271327           { 
    1328              const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(); 
     1328             const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 
    13291329             std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    13301330             for (; it != itE; ++it) 
     
    13541354             for (size_t j = 0; j < numEnabledFields; ++j) 
    13551355             { 
    1356                const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(); 
     1356               const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient); 
    13571357               std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    13581358               for (; it != itE; ++it) 
     
    14011401           for (size_t j = 0; j < numEnabledFields; ++j) 
    14021402           { 
    1403              const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(); 
    1404              for (size_t c = 0; c < mapSize.size(); ++c) 
    1405              { 
    1406                std::map<int, StdSize>::const_iterator it = mapSize[c].begin(), itE = mapSize[c].end(); 
     1403             // const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 
     1404            const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 
     1405             // for (size_t c = 0; c < mapSize.size(); ++c) 
     1406             // { 
     1407               std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    14071408               for (; it != itE; ++it) 
    14081409               { 
     
    14171418                   maxEventSize[it->first] = it->second; 
    14181419               } 
    1419              } 
     1420             // } 
    14201421           } 
    14211422         } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp

    r1232 r1236  
    1818#include "server_distribution_description.hpp" 
    1919#include "client_server_mapping_distributed.hpp" 
    20 #include "zoom_domain.hpp" 
    21 #include "interpolate_domain.hpp" 
    22 #include "generate_rectilinear_domain.hpp" 
    2320 
    2421#include <algorithm> 
     
    3027   CDomain::CDomain(void) 
    3128      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    32       , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() 
     29      , isChecked(false), relFiles(), isClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_() 
    3330      , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 
    3431      , isClientAfterTransformationChecked(false), hasLonLat(false) 
     
    4138   CDomain::CDomain(const StdString & id) 
    4239      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    43       , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_(), connectedServerZoomRank_() 
     40      , isChecked(false), relFiles(), isClientChecked(false), nbSenders(), indSrv_(), connectedServerRank_()  
    4441      , hasBounds(false), hasArea(false), isCompressible_(false), isUnstructed_(false) 
    4542      , isClientAfterTransformationChecked(false), hasLonLat(false) 
     
    119116    * \return A map associating the server rank with its minimum buffer size. 
    120117    */ 
    121    std::map<int, StdSize> CDomain::getAttributesBufferSize() 
     118   std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client) 
    122119   { 
    123120     CContext* context = CContext::getCurrent(); 
    124121     // For now the assumption is that secondary server pools consist of the same number of procs. 
    125122     // CHANGE the line below if the assumption changes. 
    126      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 
     123     // CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[0] : context->client; 
    127124 
    128125     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 
     
    141138     } 
    142139 
    143      boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_.end(); 
    144      std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); 
    145      for (size_t k = 0; k < connectedServerRank_.size(); ++k) 
    146      { 
    147        int rank = connectedServerRank_[k]; 
    148        boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_.find(rank); 
     140     boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_[client].end(); 
     141     // std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); 
     142     for (size_t k = 0; k < connectedServerRank_[client].size(); ++k) 
     143     { 
     144       int rank = connectedServerRank_[client][k]; 
     145       boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_[client].find(rank); 
    149146       size_t idxCount = (it != itIndexEnd) ? it->second.size() : 0; 
    150147 
    151148       // size estimation for sendIndex (and sendArea which is always smaller or equal) 
    152149       size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); 
    153        if (isCompressible_) 
    154        { 
    155          std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank); 
    156          size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0; 
    157          sizeIndexEvent += CArray<int,1>::size(writtenIdxCount); 
    158        } 
     150       // if (isCompressible_) 
     151       // { 
     152       //   std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank); 
     153       //   size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0; 
     154       //   sizeIndexEvent += CArray<int,1>::size(writtenIdxCount); 
     155       // } 
    159156 
    160157       // size estimation for sendLonLat 
     
    761758   } 
    762759 
     760   /* 
     761     General check of the domain to verify its mandatory attributes 
     762   */ 
    763763   void CDomain::checkDomain(void) 
    764764   { 
     
    16861686  { 
    16871687    CContext* context=CContext::getCurrent() ; 
    1688  
    1689     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1688     
     1689    // This line should be changed soon. 
    16901690    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     1691 
     1692    nbSenders.clear(); 
     1693    connectedServerRank_.clear(); 
     1694 
    16911695    for (int p = 0; p < nbSrvPools; ++p) 
    16921696    { 
     
    18301834      CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
    18311835                                                           ite = globalIndexDomainOnServer.end(); 
    1832       indSrv_.swap(globalIndexDomainOnServer); 
    1833       connectedServerRank_.clear(); 
    1834       for (it = indSrv_.begin(); it != ite; ++it)  
    1835         connectedServerRank_.push_back(it->first); 
     1836      indSrv_[client].swap(globalIndexDomainOnServer); 
     1837      connectedServerRank_[client].clear(); 
     1838      for (it = indSrv_[client].begin(); it != ite; ++it)  
     1839        connectedServerRank_[client].push_back(it->first); 
    18361840 
    18371841      for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
    1838         connectedServerRank_.push_back(*it); 
     1842        connectedServerRank_[client].push_back(*it); 
    18391843 
    18401844       // Even if a client has no index, it must connect to at least one server and  
    18411845       // send an "empty" data to this server 
    1842        if (connectedServerRank_.empty()) 
    1843         connectedServerRank_.push_back(client->clientRank % client->serverSize); 
    1844  
    1845       nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    1846  
    1847      //  clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 
    1848      //  CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 
    1849      //  indZoomSrv_.swap(globalIndexDomainZoomOnServer); 
    1850        
    1851      // for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 
    1852      //   connectedServerZoomRank_.push_back(it->first); 
    1853  
    1854      //  nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank_); 
     1846       if (connectedServerRank_[client].empty()) 
     1847        connectedServerRank_[client].push_back(client->clientRank % client->serverSize); 
     1848 
     1849      nbSenders[client] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]); 
    18551850 
    18561851      delete clientServerMap; 
     
    19601955  { 
    19611956    sendDistributionAttributes(); 
    1962     sendIndex();    
    1963     // sendIndexZoom();  
     1957    sendIndex();        
    19641958    sendMask(); 
    19651959    sendLonLat(); 
     
    19891983 
    19901984      boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 
    1991       iteIndex = indSrv_.end(); 
    1992       for (int k = 0; k < connectedServerRank_.size(); ++k) 
     1985      iteIndex = indSrv_[client].end(); 
     1986      for (int k = 0; k < connectedServerRank_[client].size(); ++k) 
    19931987      { 
    19941988        int nbIndGlob = 0; 
    1995         int rank = connectedServerRank_[k]; 
    1996         itIndex = indSrv_.find(rank); 
     1989        int rank = connectedServerRank_[client][k]; 
     1990        itIndex = indSrv_[client].find(rank); 
    19971991        if (iteIndex != itIndex) 
    19981992          nbIndGlob = itIndex->second.size(); 
     
    20112005        list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 
    20122006        
    2013         eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
     2007        eventIndex.push(rank, nbSenders[client][rank], list_msgsIndex.back()); 
    20142008      } 
    20152009 
     
    20172011    } 
    20182012  } 
    2019  
    2020   /*! 
    2021     Send global index and zoom index from client to connected client(s) 
    2022     zoom index can be smaller than global index. 
    2023     This function can be used in the future??? 
    2024   */ 
    2025   // void CDomain::sendIndexZoom() 
    2026   // { 
    2027   //   int ns, n, i, j, ind, nv, idx; 
    2028   //   CContext* context = CContext::getCurrent(); 
    2029  
    2030   //   // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    2031   //   int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
    2032   //   for (int p = 0; p < nbSrvPools; ++p) 
    2033   //   { 
    2034   //     CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; 
    2035   //     CEventClient eventIndexZoom(getType(), EVENT_ID_INDEX_ZOOM); 
    2036  
    2037   //     list<CMessage> list_msgsIndex; 
    2038   //     list<CArray<int,1> > list_indZoom; 
    2039  
    2040   //     boost::unordered_map<int, vector<size_t> >::const_iterator itZoom, iteZoom; 
    2041   //     iteZoom = indZoomSrv_.end(); 
    2042   //     for (int k = 0; k < connectedServerZoomRank_.size(); ++k) 
    2043   //     { 
    2044   //       int nbIndGlob = 0; 
    2045   //       int rank = connectedServerZoomRank_[k]; 
    2046   //       int nbIndZoom = 0; 
    2047   //       itZoom = indZoomSrv_.find(rank); 
    2048   //       if (iteZoom != itZoom) 
    2049   //         nbIndZoom = itZoom->second.size(); 
    2050          
    2051   //       list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 
    2052   //       CArray<int,1>& indZoom = list_indZoom.back(); 
    2053   //       for (n = 0; n < nbIndZoom; ++n) 
    2054   //       { 
    2055   //         indZoom(n) = static_cast<int>(itZoom->second[n]); 
    2056   //       } 
    2057  
    2058   //       list_msgsIndex.push_back(CMessage()); 
    2059   //       list_msgsIndex.back() << this->getId(); // enum ne fonctionne pour les message => ToFix         
    2060   //       list_msgsIndex.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back       
    2061  
    2062   //       eventIndexZoom.push(rank, nbConnectedClientsZoom_[rank], list_msgsIndex.back()); 
    2063   //     } 
    2064  
    2065   //     client->sendEvent(eventIndexZoom); 
    2066   //   } 
    2067   // } 
    20682013 
    20692014  /*! 
     
    21442089 
    21452090      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2146       iteMap = indSrv_.end(); 
    2147       for (int k = 0; k < connectedServerRank_.size(); ++k) 
     2091      iteMap = indSrv_[client].end(); 
     2092      for (int k = 0; k < connectedServerRank_[client].size(); ++k) 
    21482093      { 
    21492094        int nbData = 0; 
    2150         int rank = connectedServerRank_[k]; 
    2151         it = indSrv_.find(rank); 
     2095        int rank = connectedServerRank_[client][k]; 
     2096        it = indSrv_[client].find(rank); 
    21522097        if (iteMap != it) 
    21532098          nbData = it->second.size(); 
     
    21632108        list_msgsMask.push_back(CMessage()); 
    21642109        list_msgsMask.back() << this->getId() << list_mask.back(); 
    2165         eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 
     2110        eventMask.push(rank, nbSenders[client][rank], list_msgsMask.back()); 
    21662111      } 
    21672112      client->sendEvent(eventMask); 
     
    21922137 
    21932138      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2194       iteMap = indSrv_.end(); 
    2195       for (int k = 0; k < connectedServerRank_.size(); ++k) 
     2139      iteMap = indSrv_[client].end(); 
     2140      for (int k = 0; k < connectedServerRank_[client].size(); ++k) 
    21962141      { 
    21972142        int nbData = 0; 
    2198         int rank = connectedServerRank_[k]; 
    2199         it = indSrv_.find(rank); 
     2143        int rank = connectedServerRank_[client][k]; 
     2144        it = indSrv_[client].find(rank); 
    22002145        if (iteMap != it) 
    22012146          nbData = it->second.size(); 
     
    22122157        list_msgsArea.back() << this->getId() << hasArea; 
    22132158        list_msgsArea.back() << list_area.back(); 
    2214         eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 
     2159        eventArea.push(rank, nbSenders[client][rank], list_msgsArea.back()); 
    22152160      } 
    22162161      client->sendEvent(eventArea); 
     
    22452190 
    22462191      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2247       iteMap = indSrv_.end(); 
    2248       for (int k = 0; k < connectedServerRank_.size(); ++k) 
     2192      iteMap = indSrv_[client].end(); 
     2193      for (int k = 0; k < connectedServerRank_[client].size(); ++k) 
    22492194      { 
    22502195        int nbData = 0; 
    2251         int rank = connectedServerRank_[k]; 
    2252         it = indSrv_.find(rank); 
     2196        int rank = connectedServerRank_[client][k]; 
     2197        it = indSrv_[client].find(rank); 
    22532198        if (iteMap != it) 
    22542199          nbData = it->second.size(); 
     
    23072252        } 
    23082253 
    2309         eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 
    2310         eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 
     2254        eventLon.push(rank, nbSenders[client][rank], list_msgsLon.back()); 
     2255        eventLat.push(rank, nbSenders[client][rank], list_msgsLat.back()); 
    23112256      } 
    23122257      client->sendEvent(eventLon); 
     
    23632308 
    23642309      boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2365       iteMap = indSrv_.end(); 
    2366       for (int k = 0; k < connectedServerRank_.size(); ++k) 
     2310      iteMap = indSrv_[client].end(); 
     2311      for (int k = 0; k < connectedServerRank_[client].size(); ++k) 
    23672312      { 
    23682313        int nbData = 0; 
    2369         int rank = connectedServerRank_[k]; 
    2370         it = indSrv_.find(rank); 
     2314        int rank = connectedServerRank_[client][k]; 
     2315        it = indSrv_[client].find(rank); 
    23712316        if (iteMap != it) 
    23722317          nbData = it->second.size(); 
     
    23862331        list_msgsDataIndex.back() << this->getId(); 
    23872332        list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
    2388         eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 
     2333        eventDataIndex.push(rank, nbSenders[client][rank], list_msgsDataIndex.back()); 
    23892334      } 
    23902335      client->sendEvent(eventDataIndex); 
     
    24052350        case EVENT_ID_INDEX: 
    24062351          recvIndex(event); 
    2407           return true; 
    2408           break; 
    2409         case EVENT_ID_INDEX_ZOOM: 
    2410           recvIndexZoom(event); 
    24112352          return true; 
    24122353          break; 
     
    25082449 
    25092450  /*! 
    2510     Receive index event from clients(s) 
    2511     \param[in] event event contain info about rank and associated index 
    2512   */ 
    2513   void CDomain::recvIndexZoom(CEventServer& event) 
    2514   { 
    2515     string domainId; 
    2516     std::map<int, CBufferIn*> rankBuffers; 
    2517  
    2518     list<CEventServer::SSubEvent>::iterator it; 
    2519     for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
    2520     {       
    2521       CBufferIn* buffer = it->buffer; 
    2522       *buffer >> domainId; 
    2523       rankBuffers[it->rank] = buffer;         
    2524     } 
    2525     get(domainId)->recvIndexZoom(rankBuffers); 
    2526   } 
    2527  
    2528   /*! 
    2529     Receive index information from client(s) 
    2530     \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    2531   */ 
    2532   void CDomain::recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers) 
    2533   { 
    2534     int nbReceived = rankBuffers.size(), i, ind, index, type_int; 
    2535     recvClientZoomRanks_.resize(nbReceived);     
    2536     int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 
    2537  
    2538     std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 
    2539     ind = 0; 
    2540     for (ind = 0; it != ite; ++it, ++ind) 
    2541     {        
    2542        recvClientZoomRanks_[ind] = it->first; 
    2543        CBufferIn& buffer = *(it->second); 
    2544        buffer >> indGlobZoom_[it->first] >> doZoomByIndex_;         
    2545     } 
    2546  
    2547     int nbZoomInd = 0; 
    2548     for (i = 0; i < nbReceived; ++i) 
    2549     { 
    2550       nbZoomInd += indGlobZoom_[recvClientZoomRanks_[i]].numElements(); 
    2551     } 
    2552  
    2553     if (doZoomByIndex_) 
    2554     { 
    2555       zoom_i_index.resize(nbZoomInd); 
    2556       zoom_j_index.resize(nbZoomInd); 
    2557        
    2558       nbZoomInd = 0; 
    2559       for (i = 0; i < nbReceived; ++i) 
    2560       { 
    2561         CArray<int,1>& tmp = indGlobZoom_[recvClientRanks_[i]]; 
    2562         for (ind = 0; ind < tmp.numElements(); ++ind) 
    2563         { 
    2564            index = tmp(ind); 
    2565            zoom_i_index(nbZoomInd) = index % ni_glo; 
    2566            zoom_j_index(nbZoomInd) = index / ni_glo; 
    2567            ++nbZoomInd; 
    2568         }  
    2569       }       
    2570     } 
    2571     else  
    2572     { 
    2573     } 
    2574   } 
    2575  
    2576   /*! 
    25772451    Receive attributes event from clients(s) 
    25782452    \param[in] event event contain info about rank and associated attributes 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp

    r1215 r1236  
    5050           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT,  
    5151           EVENT_ID_AREA, EVENT_ID_MASK, 
    52            EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT, 
    53            EVENT_ID_INDEX_ZOOM 
     52           EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT 
    5453         } ; 
    55  
    56  
    5754 
    5855      public: 
     
    9996         int getOffsetWrittenIndexes() const; 
    10097 
    101          std::map<int, StdSize> getAttributesBufferSize(); 
    102          CArray<size_t,1> localIndexToWriteOnServer; 
    103          CArray<int, 1> compressedIndexToWriteOnServer; 
     98         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 
    10499 
    105100         bool isEmpty(void) const; 
     
    107102         bool isCompressible(void) const;  
    108103  
     104         std::vector<int> getNbGlob(); 
     105         bool isEqual(CDomain* domain); 
     106 
     107         static bool dispatchEvent(CEventServer& event); 
     108 
     109      public: 
     110         /// Mutateur /// 
     111         void addRelFile(const StdString & filename); 
     112         void addRelFileCompressed(const StdString& filename);             
     113          
     114         void computeWrittenIndex(); 
     115 
     116         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
     117                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g); 
     118 
     119         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
     120                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 
     121          
     122         void fillInLonLat(); 
     123         bool distributionAttributesHaveValue() const; 
     124 
     125         size_t getGlobalWrittenSize() ; 
     126         /// Destructeur /// 
     127         virtual ~CDomain(void); 
     128 
     129         /// Accesseurs statiques /// 
     130         static StdString GetName(void); 
     131         static StdString GetDefName(void); 
     132 
     133         static ENodeType GetType(void);         
     134 
     135      public: 
    109136         CArray<double, 1> lonvalue, latvalue; 
    110137         CArray<double, 2> bounds_lonvalue, bounds_latvalue; 
    111138         CArray<double, 1> areavalue; 
    112139 
    113          vector<int> connectedServer ; // list of connected server 
    114          vector<int> nbSenders ; // for each communication with a server, number of communicating client 
    115          vector<int> nbDataSrv ; // size of data to send to each server 
    116          vector< vector<int> > i_indSrv ; // for each server, i global index to send 
    117          vector< vector<int> > j_indSrv ; // for each server, j global index to send 
    118          std::vector<int> getNbGlob(); 
    119          bool isEqual(CDomain* domain); 
    120       public: 
    121          /// Mutateur /// 
    122          void addRelFile(const StdString & filename); 
    123          void addRelFileCompressed(const StdString& filename); 
    124          void completeLonLatClient(void);          
    125          void computeConnectedClients(); 
    126          void computeWrittenIndex(); 
    127  
    128          void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    129                                          CArray<double,1>& lon_g, CArray<double,1>& lat_g); 
    130  
    131          void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    132                                            CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 
    133           
    134          void fillInLonLat(); 
    135          bool distributionAttributesHaveValue() const; 
    136  
    137          static bool dispatchEvent(CEventServer& event); 
    138          static void recvDistributionAttributes(CEventServer& event); 
    139          static void recvIndex(CEventServer& event); 
    140          static void recvIndexZoom(CEventServer& event); 
    141          static void recvMask(CEventServer& event); 
    142          static void recvZoom(CEventServer& event); 
    143          static void recvLon(CEventServer& event); 
    144          static void recvLat(CEventServer& event); 
    145          static void recvArea(CEventServer& event); 
    146          static void recvDataIndex(CEventServer& event); 
    147          void recvDistributionAttributes(CBufferIn& buffer);                   
    148          void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 
    149          void recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers); 
    150          void recvMask(std::map<int, CBufferIn*>& rankBuffers); 
    151          void recvLon(std::map<int, CBufferIn*>& rankBuffers); 
    152          void recvLat(std::map<int, CBufferIn*>& rankBuffers); 
    153          void recvArea(std::map<int, CBufferIn*>& rankBuffers);          
    154          void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 
    155          size_t getGlobalWrittenSize() ; 
    156          /// Destructeur /// 
    157          virtual ~CDomain(void); 
    158  
    159          /// Accesseurs statiques /// 
    160          static StdString GetName(void); 
    161          static StdString GetDefName(void); 
    162  
    163          static ENodeType GetType(void); 
    164          const std::map<int, vector<size_t> >& getIndexServer() const; 
     140         CArray<size_t,1> localIndexToWriteOnServer; 
     141         CArray<int, 1> compressedIndexToWriteOnServer; 
     142 
    165143         CArray<bool, 1> localMask; 
    166144         bool isCurvilinear ; 
     
    192170         void sendMask(); 
    193171         void sendArea(); 
    194          void sendLonLat(); 
    195          void sendIndexZoom(); 
     172         void sendLonLat();          
    196173         void sendDataIndex(); 
    197174         void convertLonLatValue(); 
     
    199176         void fillInCurvilinearLonLat(); 
    200177         void fillInUnstructuredLonLat(); 
     178          
     179         static void recvDistributionAttributes(CEventServer& event); 
     180         static void recvIndex(CEventServer& event); 
     181         static void recvIndexZoom(CEventServer& event); 
     182         static void recvMask(CEventServer& event);          
     183         static void recvLon(CEventServer& event); 
     184         static void recvLat(CEventServer& event); 
     185         static void recvArea(CEventServer& event); 
     186         static void recvDataIndex(CEventServer& event); 
     187         void recvDistributionAttributes(CBufferIn& buffer);                   
     188         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);          
     189         void recvMask(std::map<int, CBufferIn*>& rankBuffers); 
     190         void recvLon(std::map<int, CBufferIn*>& rankBuffers); 
     191         void recvLat(std::map<int, CBufferIn*>& rankBuffers); 
     192         void recvArea(std::map<int, CBufferIn*>& rankBuffers);          
     193         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 
     194 
     195         void completeLonLatClient(void);   
     196         void computeConnectedClients();     
     197 
    201198       private:          
    202199         bool doZoomByIndex_; 
     
    205202         bool isClientChecked; // Verify whether all attributes of domain on the client side are good 
    206203         bool isClientAfterTransformationChecked; 
    207          std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_, indGlobZoom_; 
    208          std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server 
    209  
    210          boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
    211          boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server 
    212          std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 
     204         std::map<int, CArray<int,1> > indGlob_; 
     205         std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server 
     206 
     207         std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server          
     208         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server 
    213209         std::vector<int> indexesToWrite; 
    214          std::vector<int> recvClientRanks_, recvClientZoomRanks_; 
    215          int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
    216          std::vector<int> connectedServerRank_, connectedServerZoomRank_;          
     210         std::vector<int> recvClientRanks_; 
     211         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;          
     212         std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_; 
     213         std::map<CContextClient*, std::vector<int> > connectedServerRank_; 
     214 
    217215         //! True if and only if the data defined on the domain can be outputted in a compressed way 
    218216         bool isCompressible_; 
     
    220218         TransMapTypes transformationMap_;          
    221219         bool isUnstructed_; 
    222          boost::unordered_map<size_t,size_t> globalLocalIndexMap_, globalLocalIndexZoomMap_; 
     220         boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 
    223221        
    224222       private: 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp

    r1235 r1236  
    143143       if (client->isServerLeader()) 
    144144       { 
    145           for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++) 
     145          for (it = grid->storeIndex_toSrv[client].begin(); it != grid->storeIndex_toSrv[client].end(); it++) 
    146146          { 
    147147            int rank = it->first; 
     
    163163    else 
    164164    { 
    165       for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++) 
     165      for (it = grid->storeIndex_toSrv[client].begin(); it != grid->storeIndex_toSrv[client].end(); it++) 
    166166      { 
    167167        int rank = it->first; 
     
    175175 
    176176        list_msg.back() << getId() << data_tmp; 
    177         event.push(rank, grid->nbSenders[0][rank], list_msg.back()); 
     177        event.push(rank, grid->nbSenders[client][rank], list_msg.back()); 
    178178      } 
    179179      client->sendEvent(event); 
     
    423423        } 
    424424 
    425         event.push(it->first, grid->nbReadSenders[0][it->first], msg); 
     425        event.push(it->first, grid->nbReadSenders[client][it->first], msg); 
    426426      } 
    427427      client->sendEvent(event); 
     
    860860   } 
    861861 
    862    std::map<int, StdSize> CField::getGridAttributesBufferSize() 
    863    { 
    864      return grid->getAttributesBufferSize(); 
    865    } 
    866  
    867    std::vector<std::map<int, StdSize> > CField::getGridDataBufferSize() 
    868    { 
    869      return grid->getDataBufferSize(getId()); 
     862   std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client) 
     863   { 
     864     return grid->getAttributesBufferSize(client); 
     865   } 
     866 
     867   std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client) 
     868   { 
     869     return grid->getDataBufferSize(client, getId()); 
    870870   } 
    871871 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp

    r1232 r1236  
    100100         void resetNStepMax(); 
    101101 
    102          std::map<int, StdSize> getGridAttributesBufferSize(); 
    103          std::vector<std::map<int, StdSize> > getGridDataBufferSize(); // Grid data buffer size for each connection of contextclient 
     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 
    104104 
    105105       public: 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp

    r1235 r1236  
    100100    * TODO: Refactor code 
    101101    */ 
    102    std::map<int, StdSize> CGrid::getAttributesBufferSize() 
     102   std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client) 
    103103   { 
    104104     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(); 
    105105 
    106106     // The grid indexes require a similar size as the actual data 
    107      std::vector<std::map<int, StdSize> > dataSizes = getDataBufferSize(); 
    108      for (size_t i = 0; i < dataSizes.size(); ++i) 
    109      { 
    110        std::map<int, StdSize>::iterator it, itE = dataSizes[i].end(); 
    111        for (it = dataSizes[i].begin(); it != itE; ++it) 
     107     std::map<int, StdSize> dataSizes = getDataBufferSize(client); 
     108     // for (size_t i = 0; i < dataSizes.size(); ++i) 
     109     // { 
     110       std::map<int, StdSize>::iterator it, itE = dataSizes.end(); 
     111       for (it = dataSizes.begin(); it != itE; ++it) 
    112112       { 
    113113         it->second += 2 * sizeof(bool); 
     
    115115           attributesSizes[it->first] = it->second; 
    116116       } 
    117      } 
    118  
    119      std::map<int, StdSize>::iterator it, itE; 
     117     // } 
     118 
     119      
    120120     // Account for the axis attributes 
    121121     std::vector<CAxis*> axisList = getAxis(); 
    122122     for (size_t i = 0; i < axisList.size(); ++i) 
    123123     { 
    124        std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize();        
     124       std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client);        
    125125       for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it) 
    126126       { 
     
    134134     for (size_t i = 0; i < domList.size(); ++i) 
    135135     { 
    136        std::map<int, StdSize> domAttBuffSize = domList[i]->getAttributesBufferSize(); 
     136       std::map<int, StdSize> domAttBuffSize = domList[i]->getAttributesBufferSize(client); 
    137137       for (it = domAttBuffSize.begin(), itE = domAttBuffSize.end(); it != itE; ++it) 
    138138       { 
     
    143143 
    144144     return attributesSizes; 
    145    } 
     145  } 
    146146 
    147147   /*! 
     
    151151    * \return A map associating the server rank with its minimum buffer size. 
    152152    */ 
    153    std::vector<std::map<int, StdSize> > CGrid::getDataBufferSize(const std::string& id /*= ""*/) 
     153   std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/) 
    154154   {      
    155155     // The record index is sometimes sent along with the data but we always 
     
    158158                                                       + 2 * sizeof(size_t)  
    159159                                                       + sizeof(size_t); 
    160      CContext* context = CContext::getCurrent(); 
    161      int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
    162      std::vector<std::map<int, StdSize> > dataSizes(nbSrvPools); 
    163      for (int p = 0; p < nbSrvPools; ++p)  
     160     // CContext* context = CContext::getCurrent(); 
     161     // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     162     // std::vector<std::map<int, StdSize> > dataSizes(nbSrvPools); 
     163     // for (int p = 0; p < nbSrvPools; ++p)  
     164     // { 
     165     //   std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[client].end(); 
     166     //   for (size_t k = 0; k < connectedServerRank_[p].size(); ++k) 
     167     //   { 
     168     //     int rank = connectedServerRank_[p][k]; 
     169     //     std::map<int, size_t>::const_iterator it = connectedDataSize_[client].find(rank); 
     170     //     size_t count = (it != itEnd) ? it->second : 0; 
     171 
     172     //     dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 
     173     //   } 
     174        
     175     // } 
     176 
     177     std::map<int, StdSize> dataSizes; 
     178     std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[client].end(); 
     179     for (size_t k = 0; k < connectedServerRank_[client].size(); ++k) 
    164180     { 
    165        std::map<int, size_t>::const_iterator itEnd = connectedDataSize_[p].end(); 
    166        for (size_t k = 0; k < connectedServerRank_[p].size(); ++k) 
    167        { 
    168          int rank = connectedServerRank_[p][k]; 
    169          std::map<int, size_t>::const_iterator it = connectedDataSize_[p].find(rank); 
    170          size_t count = (it != itEnd) ? it->second : 0; 
    171  
    172          dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 
    173        } 
    174         
     181       int rank = connectedServerRank_[client][k]; 
     182       std::map<int, size_t>::const_iterator it = connectedDataSize_[client].find(rank); 
     183       size_t count = (it != itEnd) ? it->second : 0; 
     184 
     185       dataSizes.insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 
    175186     } 
    176187 
     
    251262 
    252263   //--------------------------------------------------------------- 
    253  
     264   /* 
     265     Find all reference of grid's components and inherite attributes if necessary 
     266   */ 
    254267   void CGrid::solveDomainAxisRef(bool areAttributesChecked) 
    255268   { 
     
    262275   } 
    263276 
     277   /* 
     278     Go up hierachy reference and fill in the base reference with attributes of the children 
     279     This function should be only used after reading component's attributes from file 
     280   */ 
    264281   void CGrid::solveDomainAxisBaseRef() 
    265282   { 
     
    332349   } 
    333350 
     351   /* 
     352     Create mask of grid from mask of its components 
     353   */ 
    334354   void CGrid::createMask(void) 
    335355   { 
     
    371391   } 
    372392 
     393   /* 
     394     Check validity of grid's mask by using the masks of its components 
     395   */ 
    373396   void CGrid::checkMask(void) 
    374397   { 
     
    410433   } 
    411434 
     435   /* 
     436     Modify value of mask in a certain index 
     437     This function can be used to correct the mask of grid after being constructed with createMask 
     438     \param [in] indexToModify 
     439     \param [in] modifyValue 
     440   */ 
    412441   void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue) 
    413442   { 
     
    444473   } 
    445474 
     475   /* 
     476     Change the mask size. This function is used on reconstructing mask in server side 
     477     \param [in] newDimensionSize 
     478     \param [in] newValue  
     479   */ 
    446480   void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue) 
    447481   {       
     
    539573        } 
    540574      } 
    541    } 
    542    std::vector<int> CGrid::getAxisPositionInGrid() const 
    543    { 
    544      return axisPositionInGrid_; 
    545575   } 
    546576 
     
    612642   //--------------------------------------------------------------- 
    613643 
     644   /* 
     645     Compute the global index and its local index on taking account of mask, data index. 
     646     These global index then will be used to compute the connection of this client to other clients in the different group 
     647     (via function computeConnectedClient) 
     648     These global index also corresponding to data sent to other clients (if any) 
     649   */ 
    614650   void CGrid::computeClientIndex() 
    615651   { 
    616652     CContext* context = CContext::getCurrent(); 
    617653 
    618      // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    619      // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    620654     // This needs to change one day 
    621      // It works only for the same number of procs on secondary pools 
    622655     int nbSrvPools = 1;  
    623656     for (int p = 0; p < nbSrvPools; ++p) 
     
    682715     Compute the connected clients and index to send to these clients. 
    683716     Each client can connect to a pool of other clients, each of which can have a piece of information of a grid 
    684  
    685717   */ 
    686718   void CGrid::computeConnectedClients() 
     
    688720     CContext* context = CContext::getCurrent(); 
    689721     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    690      connectedServerRank_.resize(nbSrvPools); 
    691      connectedDataSize_.resize(nbSrvPools); 
    692      nbSenders.resize(nbSrvPools); 
     722     connectedServerRank_.clear(); 
     723     connectedDataSize_.clear(); 
     724     globalIndexOnServer_.clear(); 
     725     nbSenders.clear(); 
    693726 
    694727     for (int p = 0; p < nbSrvPools; ++p) 
     
    696729       CContextClient* client = (context->hasServer) ? context->clientPrimServer[p] : context->client; 
    697730 
    698        connectedServerRank_[p].clear(); 
     731       connectedServerRank_[client].clear(); 
    699732 
    700733       if (!doGridHaveDataDistributed(client)) 
     
    706739            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    707740            { 
    708               connectedServerRank_[p].push_back(*itRank); 
    709               connectedDataSize_[p][*itRank] = ssize; 
     741              connectedServerRank_[client].push_back(*itRank); 
     742              connectedDataSize_[client][*itRank] = ssize; 
    710743            } 
    711744          } 
     
    730763         *it = serverZeroIndex[*it]; 
    731764 
    732        computeIndexByElement(indexServerOnElement, globalIndexOnServer_); 
     765       computeIndexByElement(indexServerOnElement, globalIndexOnServer_[client]); 
    733766 
    734767       const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = clientDistribution_->getGlobalLocalDataSendToServer(); 
    735768       CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 
    736769       CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
    737        itbGlobalMap = globalIndexOnServer_.begin(); 
    738        iteGlobalMap = globalIndexOnServer_.end(); 
     770       itbGlobalMap = globalIndexOnServer_[client].begin(); 
     771       iteGlobalMap = globalIndexOnServer_[client].end(); 
    739772 
    740773       for (itGlobalMap  = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
     
    748781            if (iteGlobalLocalIndexMap != itGlobalLocalIndexMap) 
    749782            { 
    750                if (connectedDataSize_[p].end() == connectedDataSize_[p].find(serverRank)) 
    751                  connectedDataSize_[p][serverRank] = 1; 
     783               if (connectedDataSize_[client].end() == connectedDataSize_[client].find(serverRank)) 
     784                 connectedDataSize_[client][serverRank] = 1; 
    752785               else 
    753                  ++connectedDataSize_[p][serverRank]; 
     786                 ++connectedDataSize_[client][serverRank]; 
    754787            } 
    755788         } 
     
    758791       // Connected servers which really have index 
    759792       for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) { 
    760          connectedServerRank_[p].push_back(itGlobalMap->first); 
     793         connectedServerRank_[client].push_back(itGlobalMap->first); 
    761794       } 
    762795 
    763796       // Connected servers which have no index at all 
    764797       for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 
    765          connectedServerRank_[p].push_back(*it); 
     798         connectedServerRank_[client].push_back(*it); 
    766799 
    767800       // Even if a client has no index, it must connect to at least one server and  
    768801       // send an "empty" data to this server 
    769        if (connectedServerRank_[p].empty()) 
    770         connectedServerRank_[p].push_back(client->clientRank % client->serverSize); 
    771  
    772        nbSenders[p] = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[p]); 
     802       if (connectedServerRank_[client].empty()) 
     803        connectedServerRank_[client].push_back(client->clientRank % client->serverSize); 
     804 
     805       nbSenders[client] = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]); 
    773806     } 
    774807   } 
     
    12581291    CContext* context = CContext::getCurrent();     
    12591292    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    1260     connectedServerRank_.resize(nbSrvPools); 
    1261     connectedDataSize_.resize(nbSrvPools); 
    1262     nbSenders.resize(nbSrvPools); 
     1293    connectedServerRank_.clear(); 
     1294    connectedDataSize_.clear(); 
     1295    nbSenders.clear(); 
    12631296 
    12641297    for (int p = 0; p < nbSrvPools; ++p) 
     
    12671300                                                    : context->client; 
    12681301 
    1269       connectedServerRank_[p].clear(); 
     1302      connectedServerRank_[client].clear(); 
    12701303 
    12711304      if (client->isServerLeader()) 
     
    12761309          int rank = *itRank; 
    12771310          int nb = 1; 
    1278           connectedServerRank_[p].push_back(rank); 
    1279           connectedDataSize_[p][rank] = nb; 
    1280           nbSenders[p][rank] = nb; 
     1311          connectedServerRank_[client].push_back(rank); 
     1312          connectedDataSize_[client][rank] = nb; 
     1313          nbSenders[client][rank] = nb; 
    12811314        } 
    12821315      } 
     
    12881321          int rank = *itRank; 
    12891322          int nb = 1; 
    1290           connectedServerRank_[p].push_back(rank); 
    1291           connectedDataSize_[p][rank] = nb; 
    1292           nbSenders[p][rank] = nb; 
     1323          connectedServerRank_[client].push_back(rank); 
     1324          connectedDataSize_[client][rank] = nb; 
     1325          nbSenders[client][rank] = nb; 
    12931326        }         
    12941327      } 
     
    13021335    CContext* context = CContext::getCurrent(); 
    13031336    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     1337    storeIndex_toSrv.clear(); 
     1338 
    13041339    for (int p = 0; p < nbSrvPools; ++p) 
    13051340    { 
     
    13171352          int rank = *itRank; 
    13181353          int nb = 1; 
    1319           storeIndex_toSrv.insert(std::make_pair(rank, CArray<int,1>(nb))); 
     1354          storeIndex_toSrv[client].insert(std::make_pair(rank, CArray<int,1>(nb))); 
    13201355          listOutIndex.push_back(CArray<size_t,1>(nb)); 
    13211356 
    1322           CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[rank]; 
     1357          CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[client][rank]; 
    13231358          CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 
    13241359 
     
    13291364          } 
    13301365 
    1331           storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 
     1366          if (context->hasClient && !context->hasServer) 
     1367            storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 
     1368 
    13321369          listMsg.push_back(CMessage()); 
    13331370          listMsg.back() << getId( )<< isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
     
    13431380        { 
    13441381          int rank = *itRank; 
    1345           int nb = 1; 
    1346           storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(nb))); 
    1347           CArray<int, 1>& outLocalIndexToServer = storeIndex_fromSrv[rank]; 
     1382          int nb = 1;           
     1383          CArray<int, 1> outLocalIndexToServer; 
    13481384          for (int k = 0; k < nb; ++k) 
    13491385          { 
    13501386            outLocalIndexToServer(k)  = 0; 
    13511387          } 
     1388 
     1389          if (context->hasClient && !context->hasServer) 
     1390            storeIndex_fromSrv.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 
    13521391        } 
    13531392        client->sendEvent(event); 
     
    13601399    CContext* context = CContext::getCurrent(); 
    13611400    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
     1401    storeIndex_toSrv.clear(); 
    13621402    for (int p = 0; p < nbSrvPools; ++p) 
    13631403    { 
     
    13891429          for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    13901430          { 
    1391             storeIndex_toSrv.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 
    1392             storeIndex_fromSrv.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 
     1431            storeIndex_toSrv[client].insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 
     1432            if (context->hasClient && !context->hasServer) 
     1433              storeIndex_fromSrv.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 
     1434             
    13931435            listOutIndex.push_back(CArray<size_t,1>(outGlobalIndexOnServer)); 
    13941436 
     
    14201462      { 
    14211463        CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 
    1422         itGlobalMap = globalIndexOnServer_.begin(); 
    1423         iteGlobalMap = globalIndexOnServer_.end(); 
     1464        itGlobalMap = globalIndexOnServer_[client].begin(); 
     1465        iteGlobalMap = globalIndexOnServer_[client].end(); 
    14241466 
    14251467        std::map<int,std::vector<int> >localIndexTmp; 
     
    14411483        } 
    14421484 
    1443         for (int ns = 0; ns < connectedServerRank_[p].size(); ++ns) 
    1444         { 
    1445           rank = connectedServerRank_[p][ns]; 
     1485        for (int ns = 0; ns < connectedServerRank_[client].size(); ++ns) 
     1486        { 
     1487          rank = connectedServerRank_[client][ns]; 
    14461488          int nb = 0; 
    14471489          if (globalIndexTmp.end() != globalIndexTmp.find(rank)) 
    14481490            nb = globalIndexTmp[rank].size(); 
    14491491 
    1450           storeIndex_toSrv.insert(make_pair(rank, CArray<int,1>(nb))); 
     1492          storeIndex_toSrv[client].insert(make_pair(rank, CArray<int,1>(nb))); 
    14511493          listOutIndex.push_back(CArray<size_t,1>(nb)); 
    14521494 
    1453           CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[rank]; 
     1495          CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv[client][rank]; 
    14541496          CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 
    14551497 
     
    14641506          listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
    14651507 
    1466           event.push(rank, nbSenders[p][rank], listMsg.back()); 
     1508          event.push(rank, nbSenders[client][rank], listMsg.back()); 
    14671509        } 
    14681510 
     
    14951537    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    14961538    nbSrvPools = 1;     
    1497     nbReadSenders.resize(nbSrvPools); 
     1539    nbReadSenders.clear(); 
    14981540    for (int p = 0; p < nbSrvPools; ++p) 
    14991541    { 
     
    16881730      if (isScalarGrid()) return; 
    16891731 
    1690       nbReadSenders[p] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
     1732      nbReadSenders[client] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
    16911733    } 
    16921734  } 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp

    r1235 r1236  
    162162         void computeDomConServer(); 
    163163         std::map<int, int> getDomConServerSide(); 
    164          std::map<int, StdSize> getAttributesBufferSize(); 
    165          std::vector<std::map<int, StdSize> > getDataBufferSize(const std::string& id = ""); 
     164         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client); 
     165         std::map<int, StdSize> getDataBufferSize(CContextClient* client, const std::string& id = ""); 
    166166         std::vector<StdString> getDomainList(); 
    167167         std::vector<StdString> getAxisList(); 
     
    175175         std::vector<int> getAxisOrder(); 
    176176         std::vector<int> getGlobalDimension(); 
    177          bool isScalarGrid() const; 
    178          std::vector<int> getAxisPositionInGrid() const; 
     177         bool isScalarGrid() const;          
    179178 
    180179         bool doGridHaveDataToWrite(); 
     
    200199         bool hasTransform(); 
    201200         size_t getGlobalWrittenSize(void) ; 
     201 
    202202      public: 
    203  
    204          /// Propriétés privées /// 
    205          bool isChecked; 
    206          bool isDomainAxisChecked; 
    207          bool isIndexSent; 
    208  
    209203         CArray<int, 1> storeIndex_client; 
    210204 
    211          map<int, CArray<int, 1> > storeIndex_toSrv; 
    212          map<int, CArray<int, 1> > storeIndex_fromSrv; 
    213          std::vector<map<int,int> > nbSenders, nbReadSenders; 
     205         std::map<CContextClient*, map<int, CArray<int, 1> > > storeIndex_toSrv; // Same grid but can be sent to several pools 
     206         map<int, CArray<int, 1> > storeIndex_fromSrv; // Support, for now, reading with level-1 server 
     207         std::map<CContextClient*, std::map<int,int> > nbSenders, nbReadSenders; 
    214208 
    215209         map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient, outGlobalIndexFromClient; 
     
    282276 
    283277      private: 
     278         bool isChecked; 
     279         bool isDomainAxisChecked; 
     280         bool isIndexSent; 
     281 
    284282        CDomainGroup* vDomainGroup_; 
    285283        CAxisGroup* vAxisGroup_; 
     
    293291        size_t writtenDataSize_; 
    294292        int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 
    295         std::vector<std::map<int,size_t> > connectedDataSize_; 
    296         std::vector<std::vector<int> > connectedServerRank_; 
     293        std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_; 
     294        std::map<CContextClient*, std::vector<int> > connectedServerRank_; 
    297295        bool isDataDistributed_;         
    298296         //! True if and only if the data defined on the grid can be outputted in a compressed way 
     
    307305        std::map<CGrid*, std::pair<bool,StdString> > gridSrc_; 
    308306        bool hasTransform_; 
    309         CClientServerMapping::GlobalIndexMap globalIndexOnServer_; 
     307        std::map<CContextClient*, CClientServerMapping::GlobalIndexMap> globalIndexOnServer_; 
    310308            // List order of axis and domain in a grid, if there is a domain, it will take value 1 (true), axis 0 (false) 
    311309        std::vector<int> order_; 
Note: See TracChangeset for help on using the changeset viewer.