Ignore:
Timestamp:
03/10/15 10:49:09 (9 years ago)
Author:
mhnguyen
Message:

Implementing discovering algorithm of server index

+) Implement the algorithm with only one level
+) Remove some redundant functions, corrects some interface

Test
+) On Curie
+) Test passed and results are correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/grid.cpp

    r567 r568  
    1313#include "context_server.hpp" 
    1414#include "array_new.hpp" 
     15#include "client_server_mapping_distributed.hpp" 
    1516 
    1617namespace xios { 
     
    2223      , isChecked(false), isDomainAxisChecked(false), storeIndex(1) 
    2324      , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 
    24       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(), writtenDataSize_(0), globalDim_() 
     25      , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 
    2526   { 
    2627     setVirtualDomainGroup(); 
     
    3233      , isChecked(false), isDomainAxisChecked(false), storeIndex(1) 
    3334      , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false) 
    34       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(), writtenDataSize_(0), globalDim_() 
     35      , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_() 
    3536   { 
    3637     setVirtualDomainGroup(); 
     
    174175     StdSize retVal; 
    175176     std::map<int, StdSize> ret; 
    176      const std::map<int, std::vector<int> >& distribution = clientServerMap_.getLocalIndexSendToServer(); 
     177     const std::map<int, std::vector<int> >& distribution = clientServerMap_->getLocalIndexSendToServer(); 
    177178     std::map<int, std::vector<int> >::const_iterator it = distribution.begin(), itE = distribution.end(); 
    178179     for (; it != itE; ++it) 
     
    280281      { 
    281282        int idx = 0; 
     283        std::vector<int> axisPositionMap; 
     284        for (int i = 0; i < axisDomainOrder.numElements(); ++i) 
     285        { 
     286          if (false == axisDomainOrder(i)) 
     287          { 
     288            axisPositionMap.push_back(idx); 
     289            ++idx; 
     290          } 
     291          else idx += 2; 
     292        } 
     293 
    282294        computeGridGlobalDimension(getDomains(), getAxis(), axisDomainOrder); 
    283295        for (int i = 0; i < axisListP.size(); ++i) 
    284296        { 
    285           while (this->axisDomainOrder(idx)) idx += 2; 
    286297          if (sendAtt) 
    287             axisListP[i]->sendCheckedAttributes(globalDim_,idx); 
     298            axisListP[i]->sendCheckedAttributes(globalDim_,axisPositionMap[i]); 
    288299          else 
    289             axisListP[i]->checkAttributesOnClient(globalDim_,idx); 
     300            axisListP[i]->checkAttributesOnClient(globalDim_,axisPositionMap[i]); 
    290301          ++idx; 
    291302        } 
     
    303314     // First of all, compute distribution on client side 
    304315     clientDistribution_ = new CDistributionClient(client->clientRank, this); 
     316     size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     317     int range, clientSize = client->clientSize; 
     318     for (int i = 0; i < globalDim_.size(); ++i) globalSizeIndex *= globalDim_[i]; 
     319     indexBegin = 0; 
     320     for (int i = 0; i < clientSize; ++i) 
     321     { 
     322       range = globalSizeIndex / clientSize; 
     323       if (i < (globalSizeIndex%clientSize)) ++range; 
     324       if (i == client->clientRank) break; 
     325       indexBegin += range; 
     326     } 
     327     indexEnd = indexBegin + range - 1; 
    305328 
    306329     // Then compute distribution on server side 
    307330     serverDistributionDescription_ = new CServerDistributionDescription(clientDistribution_->getNGlob()); 
    308331     serverDistributionDescription_->computeServerDistribution(client->serverSize, true); 
     332     serverDistributionDescription_->computeServerGlobalIndexInRange(client->serverSize, 
     333                                                                     std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
    309334 
    310335     // Finally, compute index mapping between client(s) and server(s) 
    311      clientServerMap_.computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 
    312                                                 clientDistribution_->getLocalDataIndexSendToServerOnClient(), 
    313                                                 serverDistributionDescription_->getGlobalIndex()); 
    314      const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_.getGlobalIndexOnServer(); 
     336     clientServerMap_ = new CClientServerMappingDistributed(serverDistributionDescription_->getGlobalIndexRange(), 
     337                                                            client->intraComm); 
     338 
     339     clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 
     340                                                 clientDistribution_->getLocalDataIndexSendToServerOnClient()); 
     341 
     342//     clientServerMap_->computeServerIndexMapping(clientDistribution_->getGlobalIndex(), 
     343//                                                 clientDistribution_->getLocalDataIndexSendToServerOnClient(), 
     344//                                                 serverDistributionDescription_->getGlobalIndex()); 
     345     const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
    315346     std::vector<int> connectedServerRank; 
    316347     for (std::map<int, std::vector<size_t> >::const_iterator it = globalIndexOnServer.begin(); it != globalIndexOnServer.end(); ++it) { 
    317348       connectedServerRank.push_back(it->first); 
    318349     } 
    319      nbSenders = clientServerMap_.computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 
     350     nbSenders = clientServerMap_->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank); 
    320351 
    321352     // Get local data index on client 
     
    415446    list<shared_ptr<CMessage> > list_msg ; 
    416447    list< CArray<size_t,1>* > listOutIndex; 
    417     const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_.getGlobalIndexOnServer(); 
    418     const std::map<int, std::vector<int> >& localIndexSendToServer  = clientServerMap_.getLocalIndexSendToServer(); 
     448    const std::map<int, std::vector<size_t> >& globalIndexOnServer = clientServerMap_->getGlobalIndexOnServer(); 
     449    const std::map<int, std::vector<int> >& localIndexSendToServer  = clientServerMap_->getLocalIndexSendToServer(); 
    419450 
    420451    std::map<int, std::vector<size_t> >::const_iterator iteMap, itbMap, itGlobal; 
Note: See TracChangeset for help on using the changeset viewer.