Changeset 815 for XIOS/trunk/src/node/axis.cpp
- Timestamp:
- 01/26/16 18:18:58 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/axis.cpp
r786 r815 351 351 { 352 352 sendServerAttribut(globalDim, orderPositionInGrid, distType); 353 sendValue( );353 sendValue(globalDim, orderPositionInGrid, distType); 354 354 } 355 355 … … 357 357 } 358 358 359 void CAxis::sendValue() 359 void CAxis::sendValue(const std::vector<int>& globalDim, int orderPositionInGrid, 360 CServerDistributionDescription::ServerDistributionType distType) 360 361 { 361 362 if (n.getValue() == n_glo.getValue()) … … 365 366 else 366 367 { 367 computeConnectedServer( );368 computeConnectedServer(globalDim, orderPositionInGrid, distType); 368 369 sendDistributedValue(); 369 370 } 370 371 } 371 372 372 void CAxis::computeConnectedServer() 373 void CAxis::computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 374 CServerDistributionDescription::ServerDistributionType distType) 373 375 { 374 376 CContext* context = CContext::getCurrent(); … … 418 420 } 419 421 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 } 440 462 441 463 std::map<int, std::vector<size_t> >::const_iterator it = globalIndexAxisOnServer.begin(), … … 476 498 connectedServerRank_.push_back(it->first); 477 499 } 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_); 480 501 } 481 502 … … 774 795 CContext* context = CContext::getCurrent(); 775 796 CContextClient* client = context->client; 776 777 CServerDistributionDescription serverDescription(globalDim);778 779 797 int nbServer = client->serverSize; 780 798 781 serverDescription.computeServerDistribution(nbServer, false, distType); 799 CServerDistributionDescription serverDescription(globalDim, nbServer); 800 serverDescription.computeServerDistribution(); 801 782 802 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 783 803 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();
Note: See TracChangeset
for help on using the changeset viewer.