Ignore:
Timestamp:
01/26/16 18:18:58 (8 years ago)
Author:
mhnguyen
Message:

Fixing the bug in ticket 72

+) The distributed axis on client side send info to correct corresponding server
+) Improve serverdistributiondescription class to make it more flexible
+) Create new test_basic_2D only for test cases of 2-d grid

Test
+) On Curie
+) All tests pass

File:
1 edited

Legend:

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

    r786 r815  
    351351     { 
    352352       sendServerAttribut(globalDim, orderPositionInGrid, distType); 
    353        sendValue(); 
     353       sendValue(globalDim, orderPositionInGrid, distType); 
    354354     } 
    355355 
     
    357357   } 
    358358 
    359   void CAxis::sendValue() 
     359  void CAxis::sendValue(const std::vector<int>& globalDim, int orderPositionInGrid, 
     360                        CServerDistributionDescription::ServerDistributionType distType) 
    360361  { 
    361362     if (n.getValue() == n_glo.getValue()) 
     
    365366     else 
    366367     { 
    367        computeConnectedServer(); 
     368       computeConnectedServer(globalDim, orderPositionInGrid, distType); 
    368369       sendDistributedValue(); 
    369370     } 
    370371  } 
    371372 
    372   void CAxis::computeConnectedServer() 
     373  void CAxis::computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 
     374                                     CServerDistributionDescription::ServerDistributionType distType) 
    373375  { 
    374376    CContext* context = CContext::getCurrent(); 
     
    418420    } 
    419421 
    420     std::vector<int> nGlobDomain(1); 
    421     nGlobDomain[0] = n_glo.getValue(); 
    422  
    423     size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    424     for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
    425     indexBegin = 0; 
    426     for (int i = 0; i < clientSize; ++i) 
    427     { 
    428       range = globalSizeIndex / clientSize; 
    429       if (i < (globalSizeIndex%clientSize)) ++range; 
    430       if (i == client->clientRank) break; 
    431       indexBegin += range; 
    432     } 
    433     indexEnd = indexBegin + range - 1; 
    434  
    435     CServerDistributionDescription serverDescription(nGlobDomain); 
    436     serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 
    437     CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
    438     clientServerMap->computeServerIndexMapping(globalIndexAxis); 
    439     const std::map<int, std::vector<size_t> >& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
     422    CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 
     423    int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 
     424    std::map<int, std::vector<size_t> > globalIndexAxisOnServer; 
     425    if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 
     426    { 
     427      std::vector<int> nGlobAxis(1); 
     428      nGlobAxis[0] = n_glo.getValue(); 
     429 
     430      size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     431      for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 
     432      indexBegin = 0; 
     433      for (int i = 0; i < clientSize; ++i) 
     434      { 
     435        range = globalSizeIndex / clientSize; 
     436        if (i < (globalSizeIndex%clientSize)) ++range; 
     437        if (i == client->clientRank) break; 
     438        indexBegin += range; 
     439      } 
     440      indexEnd = indexBegin + range - 1; 
     441 
     442      CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 
     443      serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
     444      CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
     445      clientServerMap->computeServerIndexMapping(globalIndexAxis); 
     446      globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
     447      delete clientServerMap; 
     448    } 
     449    else 
     450    { 
     451      std::vector<size_t> globalIndexServer(n_glo.getValue()); 
     452      for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 
     453      { 
     454        globalIndexServer[idx] = idx; 
     455      } 
     456 
     457      for (int idx = 0; idx < nbServer; ++idx) 
     458      { 
     459        globalIndexAxisOnServer[idx] = globalIndexServer; 
     460      } 
     461    } 
    440462 
    441463    std::map<int, std::vector<size_t> >::const_iterator it = globalIndexAxisOnServer.begin(), 
     
    476498        connectedServerRank_.push_back(it->first); 
    477499    } 
    478     nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    479     delete clientServerMap; 
     500    nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    480501  } 
    481502 
     
    774795    CContext* context = CContext::getCurrent(); 
    775796    CContextClient* client = context->client; 
    776  
    777     CServerDistributionDescription serverDescription(globalDim); 
    778  
    779797    int nbServer = client->serverSize; 
    780798 
    781     serverDescription.computeServerDistribution(nbServer, false, distType); 
     799    CServerDistributionDescription serverDescription(globalDim, nbServer); 
     800    serverDescription.computeServerDistribution(); 
     801 
    782802    std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
    783803    std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
Note: See TracChangeset for help on using the changeset viewer.