Changeset 584


Ignore:
Timestamp:
04/01/15 17:52:53 (9 years ago)
Author:
mhnguyen
Message:

Implementing new hash algorithm and fixing bug related to zoom

+) Replace boost hash with hash algorithm of Jenkins
+) Domain, if an attribute is non-empty for one client, it should also be non-empty for others inspite of zoom
+) Replace the way to find the number of client connecting to a server to make sure every server receive a message

Test
+) On Curie
+) test_client: passed and results are same like before
+) test_complete: passed, results are partially the same, the different part comes from added working operation

Location:
XIOS/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml

    r563 r584  
    1717 
    1818  <axis_definition> 
    19     <axis id="axis_atm" zoom_size="2" zoom_end="2" /> 
     19    <axis id="axis_atm" zoom_size="2" zoom_end="3" /> 
    2020  </axis_definition> 
    2121 
  • XIOS/trunk/src/client_server_mapping.hpp

    r569 r584  
    3333    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) = 0; 
    3434 
    35     // In case of computing local index on client sent to server 
    36     virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    37                                            const CArray<int,1>& localIndexOnClient) = 0; 
     35//    // In case of computing local index on client sent to server 
     36//    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     37//                                           const CArray<int,1>& localIndexOnClient) = 0; 
    3838 
    3939    // Simple case, global index on client and index on servers 
  • XIOS/trunk/src/client_server_mapping_distributed.cpp

    r569 r584  
    1111#include <limits> 
    1212#include <boost/functional/hash.hpp> 
     13#include "utils.hpp" 
    1314 
    1415namespace xios 
     
    3536   \param [in] globalIndexOnClient global index client has 
    3637*/ 
    37 void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) 
    38 { 
    39   int ssize = globalIndexOnClient.numElements(); 
    40   CArray<int,1>* localIndexOnClient = new CArray<int,1>(ssize); 
    41   for (int i = 0; i < ssize; ++i) (*localIndexOnClient)(i) = i; 
    42  
    43   this->computeServerIndexMapping(globalIndexOnClient, *localIndexOnClient); 
    44   delete localIndexOnClient; 
    45 } 
     38//void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) 
     39//{ 
     40//  int ssize = globalIndexOnClient.numElements(); 
     41//  CArray<int,1>* localIndexOnClient = new CArray<int,1>(ssize); 
     42//  for (int i = 0; i < ssize; ++i) (*localIndexOnClient)(i) = i; 
     43// 
     44//  this->computeServerIndexMapping(globalIndexOnClient, *localIndexOnClient); 
     45//  delete localIndexOnClient; 
     46//} 
    4647 
    4748/*! 
     
    5051   \param [in] localIndexOnClient local index on client 
    5152*/ 
    52 void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    53                                                                 const CArray<int,1>& localIndexOnClient) 
     53//void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     54//                                                                const CArray<int,1>& localIndexOnClient) 
     55void CClientServerMappingDistributed::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) 
    5456{ 
    5557  size_t ssize = globalIndexOnClient.numElements(), hashedIndex; 
     
    5961  std::map<int, std::vector<size_t> > client2ClientIndexGlobal; 
    6062  std::map<int, std::vector<int> > client2ClientIndexServer; 
    61   std::map<int, std::vector<int> > clientLocalIndex; 
     63//  std::map<int, std::vector<int> > clientLocalIndex; 
    6264 
    6365  // Number of global index whose mapping server can be found out thanks to index-server mapping 
     
    6668  // Number of global index whose mapping server are on other clients 
    6769  int nbIndexSendToOthers = 0; 
    68   boost::hash<size_t> hashGlobalIndex; 
     70  HashXIOS<size_t> hashGlobalIndex; 
    6971  for (int i = 0; i < ssize; ++i) 
    7072  { 
     
    7981      { 
    8082        (indexGlobalOnServer_[globalIndexToServerMapping_[globalIndexClient]]).push_back(globalIndexClient); 
    81         (localIndexSend2Server_[globalIndexToServerMapping_[globalIndexClient]]).push_back(localIndexOnClient(i)); 
     83//        (localIndexSend2Server_[globalIndexToServerMapping_[globalIndexClient]]).push_back(localIndexOnClient(i)); 
    8284        ++nbIndexAlreadyOnClient; 
    8385      } 
     
    8587      { 
    8688        client2ClientIndexGlobal[indexClient].push_back(globalIndexClient); 
    87         clientLocalIndex[indexClient].push_back(i); 
     89//        clientLocalIndex[indexClient].push_back(i); 
    8890        ++nbIndexSendToOthers; 
    8991      } 
     
    123125  std::vector<int> demandAlreadyReceived, repondAlreadyReceived; 
    124126  int nbDemandingClient = recvBuff[clientRank_], nbIndexServerReceived = 0; 
     127 
     128  resetReceivingRequestAndCount(); 
    125129  while ((0 < nbDemandingClient) || (!sendRequest.empty()) || 
    126130         (nbIndexServerReceived < nbIndexReceivedFromOthers)) 
     
    176180        int* beginBuff = indexServerBuffBegin_[clientSourceRank]; 
    177181        std::vector<size_t>& globalIndexTmp = client2ClientIndexGlobal[clientSourceRank]; 
    178         std::vector<int>& localIndexTmp = clientLocalIndex[clientSourceRank]; 
     182//        std::vector<int>& localIndexTmp = clientLocalIndex[clientSourceRank]; 
    179183        for (int i = 0; i < count; ++i) 
    180184        { 
    181185          (indexGlobalOnServer_[*(beginBuff+i)]).push_back(globalIndexTmp[i]); 
    182           (localIndexSend2Server_[*(beginBuff+i)]).push_back(localIndexOnClient(localIndexTmp[i])); 
     186//          (localIndexSend2Server_[*(beginBuff+i)]).push_back(localIndexOnClient(localIndexTmp[i])); 
    183187        } 
    184188        nbIndexServerReceived += count; 
     
    243247  boost::unordered_map<size_t,int>::const_iterator it  = globalIndexOfServer.begin(), 
    244248                                                   ite = globalIndexOfServer.end(); 
    245   boost::hash<size_t> hashGlobalIndex; 
     249  HashXIOS<size_t> hashGlobalIndex; 
    246250  for (; it != ite; ++it) 
    247251  { 
  • XIOS/trunk/src/client_server_mapping_distributed.hpp

    r569 r584  
    3636                                    const MPI_Comm& clientIntraComm); 
    3737 
    38     virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient); 
     38    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClientSendToServer); 
    3939 
    40     virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    41                                            const CArray<int,1>& localIndexOnClient); 
     40//    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClientSendToServer, 
     41//                                           const CArray<int,1>& localIndexOnClientSendToServer); 
     42 
     43    std::vector<int> computeConnectedServerRank(const CArray<size_t,1> globalIndexClient); 
    4244 
    4345    /** Default destructor */ 
    4446    virtual ~CClientServerMappingDistributed(); 
     47 
     48 
    4549 
    4650  protected: 
  • XIOS/trunk/src/node/context.cpp

    r583 r584  
    220220} 
    221221 
    222 //   //---------------------------------------------------------------- 
    223 // 
    224 //   void CContext::solveFieldRefInheritance(bool apply) 
    225 //   { 
    226 //      if (!this->hasId()) return; 
    227 //      vector<CField*> allField = CField::getAll(); 
    228 ////              = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 
    229 //      std::vector<CField*>::iterator 
    230 //         it = allField.begin(), end = allField.end(); 
    231 // 
    232 //      for (; it != end; it++) 
    233 //      { 
    234 //         CField* field = *it; 
    235 //         field->solveRefInheritance(apply); 
    236 //      } 
    237 //   } 
    238  
    239222   //---------------------------------------------------------------- 
    240223 
     
    258241     if (hasClient) 
    259242     { 
    260        size_t bufferSizeMin = 1; 
     243       size_t bufferSizeMin = 10*sizeof(size_t)*1024; 
    261244#define DECLARE_NODE(Name_, name_)    \ 
    262245   bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ?  sizeof(C##Name_##Definition) : bufferSizeMin; 
     
    264247#include "node_type.conf" 
    265248       std::map<int, StdSize> bufferSize = getDataSize(); 
     249       if (bufferSize.empty()) 
     250       { 
     251         if (client->isServerLeader()) 
     252         { 
     253           bufferSize[client->getServerLeader()] = bufferSizeMin; 
     254         } 
     255         else 
     256          return; 
     257       } 
     258 
    266259       std::map<int, StdSize>::iterator  it = bufferSize.begin(), 
    267260                                        ite = bufferSize.end(); 
     
    315308   void CContext::closeDefinition(void) 
    316309   { 
    317  
     310     // There is nothing client need to send to server 
    318311     if (hasClient) 
    319312     { 
    320313       // After xml is parsed, there are some more works with post processing 
    321314       postProcessing(); 
    322 // 
     315 
    323316       setClientServerBuffer(); 
    324317     } 
     
    353346 
    354347    // There are some processings that should be done after all of above. For example: check mask or index 
    355 //    if (hasClient && !hasServer) 
    356348    if (hasClient) 
    357349    { 
     
    361353 
    362354 
    363  
    364 //      if (hasClient) 
    365 //      { 
    366 //        //solveCalendar(); 
    367 // 
    368 //        // Résolution des héritages pour le context actuel. 
    369 ////        this->solveAllInheritance(); 
    370 // 
    371 // 
    372 ////        //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    373 ////        this->findEnabledFiles(); 
    374 // 
    375 //        this->processEnabledFiles(); 
    376 // 
    377 //        this->solveAllGridRef(); 
    378 //      } 
    379  
    380  
    381  
    382  
    383 //      solveCalendar(); 
    384 // 
    385 //      // Résolution des héritages pour le context actuel. 
    386 //      this->solveAllInheritance(); 
    387 // 
    388 //      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    389 //      this->findEnabledFiles(); 
    390 // 
    391 // 
    392 //      this->processEnabledFiles(); 
    393  
    394 /* 
    395       //Recherche des champs à sortir (enable à true + niveau de sortie correct) 
    396       // pour chaque fichier précédemment listé. 
    397       this->findAllEnabledFields(); 
    398  
    399       // Résolution des références de grilles pour chacun des champs. 
    400       this->solveAllGridRef(); 
    401  
    402       // Traitement des opérations. 
    403       this->solveAllOperation(); 
    404  
    405       // Traitement des expressions. 
    406       this->solveAllExpression(); 
    407 */ 
    408       // Nettoyage de l'arborescence 
    409       if (hasClient && !hasServer) CleanTree(); // Only on client side?? 
    410 //      if (hasClient) CleanTree(); 
    411       if (hasClient) sendCreateFileHeader(); 
     355    // Nettoyage de l'arborescence 
     356    if (hasClient && !hasServer) CleanTree(); // Only on client side?? 
     357 
     358    if (hasClient) sendCreateFileHeader(); 
    412359   } 
    413360 
     
    509456             return true; 
    510457             break; 
    511            case EVENT_ID_UPDATE_CALENDAR : 
     458           case EVENT_ID_UPDATE_CALENDAR: 
    512459             recvUpdateCalendar(event); 
    513460             return true; 
     
    521468             return true; 
    522469             break; 
     470 
    523471           default : 
    524472             ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
  • XIOS/trunk/src/node/distribution_client.cpp

    r575 r584  
    1717   dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 
    1818   gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 
    19    isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0) 
     19   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0), nIndexDomain_(), nIndexAxis_() 
    2020{ 
    2121} 
     
    2727   dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_(), 
    2828   gridMask_(), localDomainIndex_(), localAxisIndex_(), indexMap_(), indexDomainData_(), indexAxisData_(), 
    29    isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0) 
     29   isDataDistributed_(true), axisNum_(0), domainNum_(0), localDataIndexSendToServer_(0), nIndexDomain_(), nIndexAxis_() 
    3030{ 
    3131  readDistributionInfo(grid); 
    3232  createGlobalIndex(); 
     33  createGlobalIndexSendToServer(); 
    3334} 
    3435 
    3536CDistributionClient::~CDistributionClient() 
    3637{ 
     38  if (0 != globalDataSendToServer_) delete globalDataSendToServer_; 
    3739  if (0 != localDataIndex_) delete localDataIndex_; 
    3840  if (0 != localDataIndexSendToServer_) delete localDataIndexSendToServer_; 
     
    7779} 
    7880 
     81void CDistributionClient::readDomainIndex(const std::vector<CDomain*>& domList) 
     82{ 
     83  int domainSize = domList.size(); 
     84  nIndexDomain_.resize(domainSize); 
     85 
     86  for (int k = 0; k < domainSize; ++k) 
     87  { 
     88    nIndexDomain_[k].resize(2); 
     89    int ni = domList[k]->ni; 
     90    int nj = domList[k]->nj; 
     91    nIndexDomain_[k][0].resize(ni,nj); 
     92    nIndexDomain_[k][1].resize(ni,nj); 
     93    nIndexDomain_[k][0] = domList[k]->i_index; 
     94    nIndexDomain_[k][1] = domList[k]->j_index; 
     95  } 
     96} 
     97 
     98void CDistributionClient::readAxisIndex(const std::vector<CAxis*>& axisList) 
     99{ 
     100  int axisSize = axisList.size(); 
     101  nIndexAxis_.resize(axisSize); 
     102 
     103  for (int k = 0; k < axisSize; ++k) 
     104  { 
     105    int n = axisList[k]->ni; 
     106    nIndexAxis_[k].resize(n); 
     107    for (int i = 0; i < n; ++i) 
     108      nIndexAxis_[k](i) = i; 
     109  } 
     110} 
     111 
    79112/*! 
    80113  Read information from domain(s) and axis to generate distribution. 
     
    204237    ++idx; 
    205238  } 
     239  readDomainIndex(domList); 
     240  readAxisIndex(axisList); 
    206241 
    207242  // Grid has only one axis and it is not distributed 
     
    288323} 
    289324 
     325void CDistributionClient::createGlobalIndex() 
     326{ 
     327  size_t ssize = 1, idx = 0; 
     328  for (int i = 0; i < this->dims_; ++i) 
     329    ssize *= nLocal_[i]; 
     330 
     331  this->globalIndex_ = new CArray<size_t,1>(ssize); 
     332  std::vector<int> idxLoop(this->dims_,0); 
     333  int innnerLoopSize = nLocal_[0]; 
     334  while (idx < ssize) 
     335  { 
     336    for (int i = 0; i < this->dims_; ++i) 
     337    { 
     338      if (idxLoop[i] == nLocal_[i]) 
     339      { 
     340        idxLoop[i] = 0; 
     341        ++idxLoop[i+1]; 
     342      } 
     343    } 
     344 
     345    for (int i = 0; i < innnerLoopSize; ++i) 
     346    { 
     347      size_t globalIndex = idxLoop[0] + nBeginGlobal_[0]; 
     348      size_t mulDim = 1; 
     349      for (int k = 1; k < this->dims_; ++k) 
     350      { 
     351        mulDim *= nGlob_[k-1]; 
     352        globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim; 
     353      } 
     354      (*this->globalIndex_)(idx) = globalIndex; 
     355      ++idxLoop[0]; 
     356      ++idx; 
     357    } 
     358  } 
     359} 
     360 
     361 
    290362/*! 
    291363   Create global index on client 
     
    296368take into account of C-convention, the rightmost dimension varies faster. 
    297369*/ 
    298 void CDistributionClient::createGlobalIndex() 
     370void CDistributionClient::createGlobalIndexSendToServer() 
    299371{ 
    300372  createLocalDomainDataIndex(); 
     
    397469 
    398470  // Now allocate these arrays 
    399   this->globalIndex_ = new CArray<size_t,1>(indexSend2ServerCount); 
     471  this->globalDataSendToServer_ = new CArray<size_t,1>(indexSend2ServerCount); 
    400472  localDataIndex_ = new CArray<int,1>(indexLocalDataOnClientCount); 
    401473  localDataIndexSendToServer_ = new CArray<int,1>(indexSend2ServerCount); 
     
    507579            globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 
    508580          } 
    509           (*this->globalIndex_)(indexSend2ServerCount) = globalIndex; 
     581          (*this->globalDataSendToServer_)(indexSend2ServerCount) = globalIndex; 
    510582          (*localDataIndexSendToServer_)(indexSend2ServerCount) = indexLocalDataOnClientCount; 
    511583          ++indexSend2ServerCount; 
     
    562634} 
    563635 
     636const CArray<size_t,1>& CDistributionClient::getGlobalDataIndexSendToServer() const 
     637{ 
     638  return (*globalDataSendToServer_); 
     639} 
     640 
    564641/*! 
    565642  Return local data index of client 
     
    573650  Return local data index on client which are sent to servers 
    574651*/ 
    575 const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServerOnClient() const 
     652const CArray<int,1>& CDistributionClient::getLocalDataIndexSendToServer() const 
    576653{ 
    577654  return (*localDataIndexSendToServer_); 
  • XIOS/trunk/src/node/distribution_client.hpp

    r569 r584  
    3737 
    3838    virtual const CArray<int,1>& getLocalDataIndexOnClient() const; 
    39     virtual const CArray<int,1>& getLocalDataIndexSendToServerOnClient() const; 
     39    virtual const CArray<int,1>& getLocalDataIndexSendToServer() const; 
     40    const CArray<size_t,1>& getGlobalDataIndexSendToServer() const; 
    4041 
    4142    std::vector<int> getNGlob() { return nGlob_; } 
     
    4546  protected: 
    4647    void createGlobalIndex(); 
     48    void createGlobalIndexSendToServer(); 
    4749    void readDistributionInfo(CGrid* grid); 
    4850    void readDistributionInfo(const std::vector<CDomain*>& domList, 
    4951                              const std::vector<CAxis*>& axisList, 
    5052                              const CArray<bool,1>& axisDomainOrder); 
     53    void readDomainIndex(const std::vector<CDomain*>& domList); 
     54    void readAxisIndex(const std::vector<CAxis*>& axisList); 
    5155  private: 
    5256    //! Create local index of a domain 
     
    6670  private: 
    6771    //!< LocalData index on client 
     72    CArray<size_t,1>* globalDataSendToServer_; 
    6873    CArray<int,1>* localDataIndex_; 
    6974    CArray<int,1>* localDataIndexSendToServer_; 
     
    8186    std::vector<int> nZoomBegin_; //!< Begin index of zoom of each dimension 
    8287    std::vector<int> nZoomEnd_; //!< End index of zoom of each dimension 
     88    std::vector<std::vector<CArray<int,2> > > nIndexDomain_; //!< Local index of each domain dimension (e.x: i_index, j_index) 
     89    std::vector<CArray<int,1> > nIndexAxis_; 
    8390 
    8491    // Data_n_index of domain or axis (For now, axis uses its size as data_n_index 
  • XIOS/trunk/src/node/domain.cpp

    r569 r584  
    2323   CDomain::CDomain(void) 
    2424      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    25       , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_() 
     25      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    2626   { /* Ne rien faire de plus */ } 
    2727 
    2828   CDomain::CDomain(const StdString & id) 
    2929      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    30       , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_() 
     30      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    3131         { /* Ne rien faire de plus */ } 
    3232 
     
    449449      StdSize dm = zoom_ni_client * zoom_nj_client; 
    450450 
    451       lonvalue.resize(dm); 
    452       latvalue.resize(dm); 
     451      // Make sure that this attribute is non-empty for every client. 
     452      if (0 != dm) 
     453      { 
     454        lonvalue.resize(dm); 
     455        latvalue.resize(dm); 
     456      } 
     457 
    453458 
    454459      for (int i = 0; i < zoom_ni_client; i++) 
     
    668673    int zoom_jend=zoom_jbegin+zoom_nj-1 ; 
    669674 
    670  
    671675    // Precompute number of index 
    672     int globalIndexCount = 0; 
     676    int globalIndexCountZoom = 0; 
    673677    for(j=0;j<nj;j++) 
    674678      for(i=0;i<ni;i++) 
     
    679683        if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend) 
    680684        { 
    681           ++globalIndexCount; 
     685          ++globalIndexCountZoom; 
    682686        } 
    683687      } 
    684688 
    685689    // Fill in index 
    686     CArray<size_t,1> globalIndexDomain(globalIndexCount); 
     690    CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 
     691    CArray<size_t,1> globalIndexDomain(ni*nj); 
    687692    size_t globalIndex; 
    688     globalIndexCount = 0; 
     693    int globalIndexCount = 0; 
     694    globalIndexCountZoom = 0; 
    689695 
    690696    for(j=0;j<nj;j++) 
     
    694700        j_ind=jbegin+j_index(i,j) ; 
    695701 
     702        globalIndex = i_ind + j_ind * ni_glo; 
     703        globalIndexDomain(globalIndexCount) = globalIndex; 
     704        ++globalIndexCount; 
    696705        if (i_ind >= zoom_ibegin && i_ind <= zoom_iend && j_ind >= zoom_jbegin && j_ind <= zoom_jend) 
    697706        { 
    698           globalIndex = i_ind + j_ind * ni_glo; 
    699           globalIndexDomain(globalIndexCount) = globalIndex; 
    700           ++globalIndexCount; 
     707          globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     708          ++globalIndexCountZoom; 
    701709        } 
    702710      } 
     
    724732    clientServerMap->computeServerIndexMapping(globalIndexDomain); 
    725733    const std::map<int, std::vector<size_t> >& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 
    726     std::vector<int> connectedServerRank; 
    727     for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(); it != globalIndexDomainOnServer.end(); ++it) { 
    728       connectedServerRank.push_back(it->first); 
     734 
     735    std::map<int, std::vector<size_t> >::const_iterator it = globalIndexDomainOnServer.begin(), 
     736                                                       ite = globalIndexDomainOnServer.end(); 
     737    indSrv_.clear(); 
     738    for (; it != ite; ++it) 
     739    { 
     740      int rank = it->first; 
     741      std::vector<size_t>::const_iterator itbVec  = (it->second).begin(), 
     742                                           iteVec = (it->second).end(); 
     743      int nb = globalIndexDomainZoom.numElements(); 
     744      for (int i = 0; i < nb; ++i) 
     745      { 
     746        if (std::binary_search(itbVec, iteVec, globalIndexDomainZoom(i))) 
     747        { 
     748          indSrv_[rank].push_back(globalIndexDomainZoom(i)); 
     749        } 
     750      } 
    729751    } 
    730     nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 
    731     indSrv_ = globalIndexDomainOnServer; 
     752 
     753    connectedServerRank_.clear(); 
     754    for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 
     755      connectedServerRank_.push_back(it->first); 
     756    } 
     757 
     758    if (!indSrv_.empty()) 
     759    { 
     760      connectedServerRank_.clear(); 
     761      for (it = indSrv_.begin(); it != indSrv_.end(); ++it) 
     762        connectedServerRank_.push_back(it->first); 
     763    } 
     764    nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    732765 
    733766    delete clientServerMap; 
     
    753786    itbMap = indSrv_.begin(); 
    754787    iteMap = indSrv_.end(); 
    755     for (it = itbMap; it != iteMap; ++it) 
     788    for (int k = 0; k < connectedServerRank_.size(); ++k) 
    756789    { 
    757       int rank = it->first; 
    758       int nbData = (it->second).size(); 
     790      int nbData = 0; 
     791      int rank = connectedServerRank_[k]; 
     792      it = indSrv_.find(rank); 
     793      if (iteMap != it) 
     794        nbData = (it->second).size(); 
     795 
    759796      CArray<int,1> indi(nbData) ; 
    760797      CArray<int,1> indj(nbData) ; 
     
    807844        *list_msgLat.back()<<*list_boundslat.back(); 
    808845      } 
     846 
    809847      eventLon.push(rank,nbConnectedClients_[rank],*list_msgLon.back()) ; 
    810848      eventLat.push(rank,nbConnectedClients_[rank],*list_msgLat.back()) ; 
  • XIOS/trunk/src/node/domain.hpp

    r553 r584  
    156156         std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 
    157157         std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 
     158         std::vector<int> connectedServerRank_; 
    158159 
    159160         DECLARE_REF_FUNC(Domain,domain) 
  • XIOS/trunk/src/node/grid.cpp

    r575 r584  
    2424      , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 
    2525      , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 
     26      , connectedDataSize_(), connectedServerRank_() 
    2627   { 
    2728     setVirtualDomainGroup(); 
     
    3435      , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 
    3536      , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 
     37      , connectedDataSize_(), connectedServerRank_() 
    3638   { 
    3739     setVirtualDomainGroup(); 
     
    175177     StdSize retVal; 
    176178     std::map<int, StdSize> ret; 
    177      const std::map<int, std::vector<int> >& distribution = clientServerMap_->getLocalIndexSendToServer(); 
    178      std::map<int, std::vector<int> >::const_iterator it = distribution.begin(), itE = distribution.end(); 
     179     std::map<int, size_t >::const_iterator it = connectedDataSize_.begin(), itE = connectedDataSize_.end(); 
    179180     for (; it != itE; ++it) 
    180181     { 
    181         retVal = it->second.size(); 
     182        retVal = it->second; 
    182183        retVal *= secureFactor; 
    183184        ret.insert(std::make_pair<int,StdSize>(it->first, retVal)); 
     
    192193     if (this->isDomainAxisChecked) return; 
    193194 
     195     this->solveAxisRef(areAttributesChecked); 
    194196     this->solveDomainRef(areAttributesChecked); 
    195      this->solveAxisRef(areAttributesChecked); 
    196197 
    197198     this->isDomainAxisChecked = areAttributesChecked; 
     
    337338                                                            client->intraComm); 
    338339 
    339      clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 
    340                                                  clientDistribution_->getLocalDataIndexSendToServerOnClient()); 
    341  
     340     clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex()); 
    342341     const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    343      std::vector<int> connectedServerRank; 
    344      for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 
    345        connectedServerRank.push_back(it->first); 
    346      } 
    347      nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 
     342     const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
     343 
     344     std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
     345     itbGlobalMap = itGlobalMap = globalIndexOnServer.begin(); 
     346     iteGlobalMap = globalIndexOnServer.end(); 
     347 
     348     int nbGlobalIndex = globalIndexSendToServer.numElements(); 
     349    for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
     350    { 
     351      int serverRank = itGlobalMap->first; 
     352      std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), itVecGlobal, 
     353                                          iteVecGlobal = (itGlobalMap->second).end(); 
     354      for (int i = 0; i < nbGlobalIndex; ++i) 
     355      { 
     356        if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i))) 
     357        { 
     358          if (connectedDataSize_.end() == connectedDataSize_.find(serverRank)) 
     359            connectedDataSize_[serverRank] = 0; 
     360          else 
     361            ++connectedDataSize_[serverRank]; 
     362        } 
     363      } 
     364    } 
     365 
     366   connectedServerRank_.clear(); 
     367   for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 
     368     connectedServerRank_.push_back(it->first); 
     369   } 
     370   if (!connectedDataSize_.empty()) 
     371   { 
     372     connectedServerRank_.clear(); 
     373     for (std::map<int,size_t>::const_iterator it = connectedDataSize_.begin(); it != connectedDataSize_.end(); ++it) 
     374       connectedServerRank_.push_back(it->first); 
     375   } 
     376 
     377    nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    348378 
    349379     // Get local data index on client 
     
    443473    list< CArray<size_t,1>* > listOutIndex; 
    444474    const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    445     const std::map<int, std::vector<int> >& localIndexSendToServer  = clientServerMap_->getLocalIndexSendToServer(); 
    446  
    447     std::map<int, std::vector<size_t> >::const_iterator iteMap, itbMap, itGlobal; 
    448     std::map<int, std::vector<int> >::const_iterator itLocal; 
    449     itbMap = itGlobal = globalIndexOnServer.begin(); 
    450     iteMap = globalIndexOnServer.end(); 
    451     itLocal = localIndexSendToServer.begin(); 
     475    const CArray<int,1>& localIndexSendToServer = clientDistribution_->getLocalDataIndexSendToServer(); 
     476    const CArray<size_t,1>& globalIndexSendToServer = clientDistribution_->getGlobalDataIndexSendToServer(); 
     477 
     478    std::map<int, std::vector<size_t> >::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
     479    itbGlobalMap = itGlobalMap = globalIndexOnServer.begin(); 
     480    iteGlobalMap = globalIndexOnServer.end(); 
     481 
     482    int nbGlobalIndex = globalIndexSendToServer.numElements(); 
     483    std::map<int,std::vector<int> >localIndexTmp; 
     484    std::map<int,std::vector<size_t> > globalIndexTmp; 
     485    for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
     486    { 
     487      int serverRank = itGlobalMap->first; 
     488      std::vector<size_t>::const_iterator itbVecGlobal = (itGlobalMap->second).begin(), 
     489                                          iteVecGlobal = (itGlobalMap->second).end(); 
     490      for (int i = 0; i < nbGlobalIndex; ++i) 
     491      { 
     492        if (iteVecGlobal != std::find(itbVecGlobal, iteVecGlobal, globalIndexSendToServer(i))) 
     493        { 
     494          globalIndexTmp[serverRank].push_back(globalIndexSendToServer(i)); 
     495          localIndexTmp[serverRank].push_back(localIndexSendToServer(i)); 
     496        } 
     497      } 
     498    } 
     499 
    452500 
    453501    if (!doGridHaveDataDistributed()) 
    454502    { 
    455       if (0 == client->clientRank) 
    456       { 
    457        for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 
    458         { 
    459           rank = itGlobal->first; 
    460           int nb = (itGlobal->second).size(); 
    461  
    462           CArray<size_t, 1> outGlobalIndexOnServer(nb); 
    463           CArray<int, 1> outLocalIndexToServer(nb); 
    464           for (int k = 0; k < nb; ++k) 
    465           { 
    466             outGlobalIndexOnServer(k) = itGlobal->second.at(k); 
    467             outLocalIndexToServer(k)  = itLocal->second.at(k); 
    468           } 
    469  
    470           storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 
    471           listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 
    472  
    473           list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
    474           *list_msg.back()<<getId()<<*listOutIndex.back(); 
    475           event.push(rank, 1, *list_msg.back()); 
    476         } 
    477         client->sendEvent(event); 
    478       } else client->sendEvent(event); 
     503//      if (0 == client->clientRank) 
     504//      { 
     505//       for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 
     506//        { 
     507//          rank = itGlobal->first; 
     508//          int nb = (itGlobal->second).size(); 
     509// 
     510//          CArray<size_t, 1> outGlobalIndexOnServer(nb); 
     511//          CArray<int, 1> outLocalIndexToServer(nb); 
     512//          for (int k = 0; k < nb; ++k) 
     513//          { 
     514//            outGlobalIndexOnServer(k) = itGlobal->second.at(k); 
     515//            outLocalIndexToServer(k)  = itLocal->second.at(k); 
     516//          } 
     517// 
     518//          storeIndex_toSrv.insert( pair<int,CArray<int,1>* >(rank,new CArray<int,1>(outLocalIndexToServer) )); 
     519//          listOutIndex.push_back(new CArray<size_t,1>(outGlobalIndexOnServer)); 
     520// 
     521//          list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
     522//          *list_msg.back()<<getId()<<*listOutIndex.back(); 
     523//          event.push(rank, 1, *list_msg.back()); 
     524//        } 
     525//        client->sendEvent(event); 
     526//      } else client->sendEvent(event); 
    479527    } 
    480528    else 
    481529    { 
    482       for (int ns = 0; itGlobal != iteMap; ++itGlobal, ++itLocal, ++ns) 
    483       { 
    484         rank = itGlobal->first; 
    485         int nb = (itGlobal->second).size(); 
     530      for (int ns = 0; ns < connectedServerRank_.size(); ++ns) 
     531      { 
     532        rank = connectedServerRank_[ns]; 
     533        int nb = 0; 
     534        if (globalIndexTmp.end() != globalIndexTmp.find(rank)) 
     535          nb = globalIndexTmp[rank].size(); 
    486536 
    487537        CArray<size_t, 1> outGlobalIndexOnServer(nb); 
     
    489539        for (int k = 0; k < nb; ++k) 
    490540        { 
    491           outGlobalIndexOnServer(k) = itGlobal->second.at(k); 
    492           outLocalIndexToServer(k)  = itLocal->second.at(k); 
     541          outGlobalIndexOnServer(k) = globalIndexTmp[rank].at(k); 
     542          outLocalIndexToServer(k)  = localIndexTmp[rank].at(k); 
    493543        } 
    494544 
     
    498548        list_msg.push_back(shared_ptr<CMessage>(new CMessage)); 
    499549        *list_msg.back()<<getId()<<*listOutIndex.back(); 
     550 
    500551        event.push(rank, nbSenders[rank], *list_msg.back()); 
    501552      } 
     553 
    502554      client->sendEvent(event); 
    503555    } 
     
    555607  bool CGrid::doGridHaveDataToWrite() 
    556608  { 
    557     return (0 != serverDistribution_); 
     609//    return (0 != serverDistribution_); 
     610    return (0 != writtenDataSize_); 
    558611  } 
    559612 
  • XIOS/trunk/src/node/grid.hpp

    r568 r584  
    223223        CClientServerMapping* clientServerMap_; 
    224224        size_t writtenDataSize_; 
     225        std::map<int,size_t> connectedDataSize_; 
     226        std::vector<int> connectedServerRank_; 
    225227   }; // class CGrid 
    226228 
  • XIOS/trunk/src/utils.hpp

    r571 r584  
    131131  }; 
    132132 
     133  template <int v> 
     134  struct Int2Type 
     135  { 
     136  enum { value = v }; 
     137  }; 
     138 
     139  template<typename T> 
     140  union TypeToBytes { 
     141    T value; 
     142    unsigned char bytes[sizeof(value)]; 
     143  }; 
     144 
     145  template<typename T> 
     146  struct HashAlgorithm 
     147  { 
     148    /*! 
     149      Adapted version of one-at-a-time hash by Bob Jenkins, 
     150      which is an expanded version of his Dr. Dobbs article. 
     151    */ 
     152    static inline size_t jenkins_hash(const T& value) 
     153    { 
     154      TypeToBytes<T> u; 
     155      (u.value) = value; 
     156 
     157      size_t hash = 0; 
     158      size_t length = sizeof(value); 
     159 
     160      for (size_t i = 0; i < length; ++i) 
     161      { 
     162          hash += u.bytes[i]; 
     163          hash += (hash << 10); 
     164          hash ^= (hash >> 6); 
     165      } 
     166      hash += (hash << 3); 
     167      hash ^= (hash >> 11); 
     168      hash += (hash << 15); 
     169 
     170      return hash; 
     171    } 
     172  }; 
     173 
     174  template<typename T, typename Algo = Int2Type<0> > 
     175  struct HashXIOS 
     176  { 
     177    std::size_t operator()(const T& val) 
     178    { 
     179      Algo al; 
     180      return hash_value(val, al); 
     181    } 
     182 
     183  private: 
     184    size_t hash_value(const T& val, Int2Type<0>) 
     185    { 
     186      return HashAlgorithm<T>::jenkins_hash(val); 
     187    } 
     188  }; 
    133189} 
    134190 
Note: See TracChangeset for help on using the changeset viewer.