Changeset 1346 for XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp
- Timestamp:
- 11/25/17 00:19:11 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp
r1345 r1346 530 530 int rank = client->clientRank; 531 531 532 size_t ni = this->n.getValue(); 533 size_t ibegin = this->begin.getValue(); 534 size_t global_zoom_end = global_zoom_begin+global_zoom_n-1; 535 size_t nZoomCount = 0; 536 size_t nbIndex = index.numElements(); 537 538 // First of all, we should compute the mapping of the global index and local index of the current client 539 if (globalLocalIndexMap_.empty()) 540 { 541 for (size_t idx = 0; idx < nbIndex; ++idx) 542 { 543 globalLocalIndexMap_[index(idx)] = idx; 544 } 545 } 546 547 // Calculate the compressed index if any 548 std::set<int> writtenInd; 549 if (isCompressible_) 550 { 551 for (int idx = 0; idx < data_index.numElements(); ++idx) 552 { 553 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 554 555 if (ind >= 0 && ind < ni && mask(ind)) 532 if (connectedServerRank_.find(nbServer) == connectedServerRank_.end()) 533 { 534 size_t ni = this->n.getValue(); 535 size_t ibegin = this->begin.getValue(); 536 size_t global_zoom_end = global_zoom_begin+global_zoom_n-1; 537 size_t nZoomCount = 0; 538 size_t nbIndex = index.numElements(); 539 540 // First of all, we should compute the mapping of the global index and local index of the current client 541 if (globalLocalIndexMap_.empty()) 542 { 543 for (size_t idx = 0; idx < nbIndex; ++idx) 556 544 { 557 ind += ibegin; 558 if (ind >= global_zoom_begin && ind <= global_zoom_end) 559 writtenInd.insert(ind); 545 globalLocalIndexMap_[index(idx)] = idx; 560 546 } 561 547 } 562 } 563 564 // Compute the global index of the current client (process) hold 565 std::vector<int> nGlobAxis(1); 566 nGlobAxis[0] = n_glo.getValue(); 567 568 size_t globalSizeIndex = 1, indexBegin, indexEnd; 569 for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 570 indexBegin = 0; 571 if (globalSizeIndex <= clientSize) 572 { 573 indexBegin = rank%globalSizeIndex; 574 indexEnd = indexBegin; 575 } 576 else 577 { 578 for (int i = 0; i < clientSize; ++i) 579 { 580 range = globalSizeIndex / clientSize; 581 if (i < (globalSizeIndex%clientSize)) ++range; 582 if (i == client->clientRank) break; 583 indexBegin += range; 584 } 585 indexEnd = indexBegin + range - 1; 586 } 587 588 CArray<size_t,1> globalIndex(index.numElements()); 589 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 590 globalIndex(idx) = index(idx); 591 592 // Describe the distribution of server side 593 594 CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType); 548 549 // Calculate the compressed index if any 550 std::set<int> writtenInd; 551 if (isCompressible_) 552 { 553 for (int idx = 0; idx < data_index.numElements(); ++idx) 554 { 555 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 556 557 if (ind >= 0 && ind < ni && mask(ind)) 558 { 559 ind += ibegin; 560 if (ind >= global_zoom_begin && ind <= global_zoom_end) 561 writtenInd.insert(ind); 562 } 563 } 564 } 565 566 // Compute the global index of the current client (process) hold 567 std::vector<int> nGlobAxis(1); 568 nGlobAxis[0] = n_glo.getValue(); 569 570 size_t globalSizeIndex = 1, indexBegin, indexEnd; 571 for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 572 indexBegin = 0; 573 if (globalSizeIndex <= clientSize) 574 { 575 indexBegin = rank%globalSizeIndex; 576 indexEnd = indexBegin; 577 } 578 else 579 { 580 for (int i = 0; i < clientSize; ++i) 581 { 582 range = globalSizeIndex / clientSize; 583 if (i < (globalSizeIndex%clientSize)) ++range; 584 if (i == client->clientRank) break; 585 indexBegin += range; 586 } 587 indexEnd = indexBegin + range - 1; 588 } 589 590 CArray<size_t,1> globalIndex(index.numElements()); 591 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 592 globalIndex(idx) = index(idx); 593 594 // Describe the distribution of server side 595 596 CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType); 595 597 596 std::vector<int> serverZeroIndex; 597 serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 598 599 std::list<int> serverZeroIndexLeader; 600 std::list<int> serverZeroIndexNotLeader; 601 CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 602 for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 603 *it = serverZeroIndex[*it]; 604 605 // Find out the connection between client and server side 606 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 607 clientServerMap->computeServerIndexMapping(globalIndex, nbServer); 608 CClientServerMapping::GlobalIndexMap& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 609 610 611 indSrv_[nbServer].swap(globalIndexAxisOnServer); 612 613 if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION) 614 { 615 for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 616 serverZeroIndexLeader.clear() ; 617 } 598 std::vector<int> serverZeroIndex; 599 serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 600 601 std::list<int> serverZeroIndexLeader; 602 std::list<int> serverZeroIndexNotLeader; 603 CContextClient::computeLeader(client->clientRank, client->clientSize, serverZeroIndex.size(), serverZeroIndexLeader, serverZeroIndexNotLeader); 604 for (std::list<int>::iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 605 *it = serverZeroIndex[*it]; 606 607 // Find out the connection between client and server side 608 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 609 clientServerMap->computeServerIndexMapping(globalIndex, nbServer); 610 CClientServerMapping::GlobalIndexMap& globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 611 612 indSrv_[nbServer].swap(globalIndexAxisOnServer); 613 614 if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION) 615 { 616 for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 617 serverZeroIndexLeader.clear() ; 618 } 618 619 619 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_[nbServer].begin(),620 ite = indSrv_[nbServer].end();621 622 for (it = indSrv_[nbServer].begin(); it != ite; ++it) connectedServerRank_[nbServer].push_back(it->first);623 624 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it)625 connectedServerRank_[nbServer].push_back(*it);626 627 // Even if a client has no index, it must connect to at least one server and628 // send an "empty" data to this server629 if (connectedServerRank_[nbServer].empty())630 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize);631 632 // nbSenders[client] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[client]);633 nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 634 635 delete clientServerMap;620 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_[nbServer].begin(), 621 ite = indSrv_[nbServer].end(); 622 623 for (it = indSrv_[nbServer].begin(); it != ite; ++it) connectedServerRank_[nbServer].push_back(it->first); 624 625 for (std::list<int>::const_iterator it = serverZeroIndexLeader.begin(); it != serverZeroIndexLeader.end(); ++it) 626 connectedServerRank_[nbServer].push_back(*it); 627 628 // Even if a client has no index, it must connect to at least one server and 629 // send an "empty" data to this server 630 if (connectedServerRank_[nbServer].empty()) 631 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 632 633 nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 634 635 delete clientServerMap; 636 } 636 637 } 637 638 }
Note: See TracChangeset
for help on using the changeset viewer.