Changeset 1870 for XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
- Timestamp:
- 04/17/20 18:55:28 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r1869 r1870 33 33 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 34 34 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 35 , isDataDistributed_(true), isCompressible_(false)35 , isCompressible_(false) 36 36 , transformations_(0), isTransformed_(false) 37 37 , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) … … 54 54 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 55 55 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 56 , isDataDistributed_(true), isCompressible_(false)56 , isCompressible_(false) 57 57 , transformations_(0), isTransformed_(false) 58 58 , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) … … 96 96 if (!isScalarGrid()) 97 97 { 98 std::vector<int> dataNindex = get DistributionClient()->getDataNIndex();98 std::vector<int> dataNindex = getClientDistribution()->getDataNIndex(); 99 99 for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i]; 100 100 } … … 128 128 for (size_t i = 0; i < axisList.size(); ++i) 129 129 { 130 std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client, getGlobalDimension(), axisPositionInGrid_[i]);130 std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client, getGlobalDimension(),getAxisPositionInGrid()[i]); 131 131 for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it) 132 132 { … … 202 202 CATCH_DUMP_ATTR 203 203 204 205 void CGrid::computeAxisPositionInGrid(void) 206 { 207 axisPositionInGrid_.resize(0); 208 int idx = 0; 209 for (int i = 0; i < axis_domain_order.numElements(); ++i) 210 { 211 int elementDimension = axis_domain_order(i); 212 if (1 == elementDimension) 213 { 214 axisPositionInGrid_.push_back(idx); 215 ++idx; 216 } 217 else if (2 == elementDimension) idx += 2; 218 } 219 } 220 204 221 void CGrid::checkAttributesAfterTransformation() 205 222 TRY … … 207 224 setAxisList(); 208 225 std::vector<CAxis*> axisListP = this->getAxis(); 209 if (!axisListP.empty()) 210 { 211 int idx = 0; 212 axisPositionInGrid_.resize(0); 213 for (int i = 0; i < axis_domain_order.numElements(); ++i) 214 { 215 int elementDimension = axis_domain_order(i); 216 if (1 == elementDimension) 217 { 218 axisPositionInGrid_.push_back(idx); 219 ++idx; 220 } 221 else if (2 == elementDimension) idx += 2; 222 } 223 224 for (int i = 0; i < axisListP.size(); ++i) 225 { 226 axisListP[i]->checkAttributesOnClientAfterTransformation(getGlobalDimension(),axisPositionInGrid_[i]); 227 } 228 } 229 226 for (int i = 0; i < axisListP.size(); ++i) 227 axisListP[i]->checkAttributesOnClientAfterTransformation(getGlobalDimension(), getAxisPositionInGrid()[i]); 228 230 229 setDomainList(); 231 230 std::vector<CDomain*> domListP = this->getDomains(); … … 568 567 if (!axisListP.empty()) 569 568 { 570 int idx = 0;571 axisPositionInGrid_.resize(0);572 for (int i = 0; i < axis_domain_order.numElements(); ++i)573 {574 int elementDimension = axis_domain_order(i);575 if (1 == elementDimension)576 {577 axisPositionInGrid_.push_back(idx);578 ++idx;579 }580 else if (2 == elementDimension) idx += 2;581 }582 583 569 for (int i = 0; i < axisListP.size(); ++i) 584 570 { 585 571 if (sendAtt) 586 axisListP[i]->sendCheckedAttributes(getGlobalDimension(), axisPositionInGrid_[i]);572 axisListP[i]->sendCheckedAttributes(getGlobalDimension(),getAxisPositionInGrid()[i]); 587 573 else 588 574 axisListP[i]->checkAttributesOnClient(); … … 634 620 635 621 size_t nbWritten = 0, indGlo; 636 CDistributionClient::GlobalLocalDataMap& globalDataIndex = get DistributionClient()->getGlobalDataIndexOnClient();622 CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient(); 637 623 CDistributionClient::GlobalLocalDataMap::const_iterator itb = globalDataIndex.begin(), 638 624 ite = globalDataIndex.end(), it; … … 651 637 { 652 638 numberWrittenIndexes_ = nbWritten; 653 if (isDataDistributed _)639 if (isDataDistributed()) 654 640 { 655 641 CContext* context = CContext::getCurrent(); … … 688 674 void CGrid::computeGridIndexToFileServer(CContextClient* client) 689 675 { 690 if (isScalarGrid()) 691 { 692 computeClientIndexScalarGrid(); 693 computeConnectedClientsScalarGrid(client); 694 } 695 else 696 { 697 computeClientIndex(); 698 computeConnectedClients(client); 699 } 700 676 if (isScalarGrid()) computeConnectedClientsScalarGrid(client); 677 else computeConnectedClients(client); 678 701 679 // compute indices for client/server transfer for domain 702 680 for (const auto& domainId : domList_) CDomain::get(domainId)->computeConnectedClients(client); … … 705 683 // compute indices for client/server transfer for axis 706 684 std::vector<CAxis*> axisList = this->getAxis(); 707 std::vector<int> axisPosInGrid ; 708 // compute axis position in grid 709 int idx=0 ; 710 for (int i = 0 ; i < axis_domain_order.numElements(); ++i) 711 { 712 if (axis_domain_order(i) == 0) idx += 0 ; 713 else if (axis_domain_order(i) == 1) { axisPosInGrid.push_back(idx) ; ++idx; } 714 else if (axis_domain_order(i) == 2) idx += 2; 715 } 716 for(int i=0 ; i<axisList.size(); i++) axisList[i] -> computeConnectedClients(client, getGlobalDimension(),axisPositionInGrid_[i]) ; 685 for(int i=0 ; i<axisList.size(); i++) axisList[i] -> computeConnectedClients(client, getGlobalDimension(),getAxisPositionInGrid()[i]) ; 717 686 } 718 687 //--------------------------------------------------------------- … … 740 709 else 741 710 { 742 CDistributionClient* clientDistribution = get DistributionClient() ;711 CDistributionClient* clientDistribution = getClientDistribution() ; 743 712 const std::vector<int>& localDataIndex = clientDistribution->getLocalDataIndexOnClient() ; 744 713 int nbStoreIndex = localDataIndex.size() ; … … 759 728 else 760 729 { 761 CDistributionClient* clientDistribution = get DistributionClient() ;730 CDistributionClient* clientDistribution = getClientDistribution() ; 762 731 const std::vector<bool>& localMaskIndex = clientDistribution->getLocalMaskIndexOnClient() ; 763 732 int nbMaskIndex = localMaskIndex.size() ; … … 767 736 } 768 737 769 /* 770 Compute the global index and its local index taking account mask and data index. 771 These global indexes will be used to compute the connection of this client (sender) to its servers (receivers) 772 (via function computeConnectedClient) 773 These global indexes also correspond to data sent to servers (if any) 774 */ 775 void CGrid::computeClientIndex() 776 TRY 777 { 778 if (computeClientIndex_done_) return ; 779 780 CContext* context = CContext::getCurrent(); 781 int rank = context-> getIntraCommRank(); 782 783 auto clientDistribution = getDistributionClient(); 784 // Get local data index on client 785 int nbStoreIndex = clientDistribution->getLocalDataIndexOnClient().size(); 786 int nbStoreGridMask = clientDistribution->getLocalMaskIndexOnClient().size(); 787 // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 788 storeIndex_client_.resize(nbStoreIndex); 789 storeMask_client_.resize(nbStoreGridMask); 790 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client_(idx) = (clientDistribution->getLocalDataIndexOnClient())[idx]; 791 for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMask_client_(idx) = (clientDistribution->getLocalMaskIndexOnClient())[idx]; 792 793 if (0 == serverDistribution_) isDataDistributed_= clientDistribution->isDataDistributed(); 794 else 795 { 796 // Mapping global index received from clients to the storeIndex_client_ 797 CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistribution->getGlobalDataIndexOnClient(); 798 CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 799 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient_.begin(), 800 ite = outGlobalIndexFromClient_.end(), it; 801 802 for (it = itb; it != ite; ++it) 738 739 void CGrid::computeOutLocalIndexStoreOnClient(void) 740 { 741 if (computeOutLocalIndexStoreOnClient_done_) return ; 742 else computeOutLocalIndexStoreOnClient_done_=true ; 743 744 if (isScalarGrid()) 745 { 746 auto& outGlobalIndexFromClient = getOutGlobalIndexFromClient(); 747 auto itb = outGlobalIndexFromClient.begin(), ite = outGlobalIndexFromClient.end() ; 748 for (auto it = itb; it != ite; ++it) 803 749 { 804 750 int rank = it->first; 805 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient _[rank];751 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 806 752 outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 807 753 CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank]; 808 size_t nbIndex = 0; 809 810 // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance 811 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 812 { 813 if (itGloe != globalDataIndex.find(globalIndex(idx))) 814 { 815 ++nbIndex; 816 } 817 } 818 819 if (nbIndex != localIndex.numElements()) 820 ERROR("void CGrid::computeClientIndex()", 821 << "Number of local index on client is different from number of received global index" 822 << "Rank of sent client " << rank <<"." 823 << "Number of local index " << nbIndex << ". " 824 << "Number of received global index " << localIndex.numElements() << "."); 825 826 nbIndex = 0; 827 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 828 { 829 if (itGloe != globalDataIndex.find(globalIndex(idx))) 830 { 831 localIndex(idx) = globalDataIndex[globalIndex(idx)]; 832 } 833 } 754 if (1 != globalIndex.numElements()) 755 ERROR("void CGrid::computeClientIndexScalarGrid()", 756 << "Something wrong happened. " 757 << "Number of received global index on scalar grid should equal to 1" 758 << "Number of received global index " << globalIndex.numElements() << "."); 759 760 localIndex(0) = globalIndex(0); 834 761 } 835 } 836 computeClientIndex_done_ = true ; 837 } 838 CATCH_DUMP_ATTR 762 } 763 else 764 { 765 CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient(); 766 CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 767 auto& outGlobalIndexFromClient = getOutGlobalIndexFromClient(); 768 auto itb = outGlobalIndexFromClient.begin(), ite = outGlobalIndexFromClient.end() ; 769 770 for (auto it = itb; it != ite; ++it) 771 { 772 int rank = it->first; 773 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 774 outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 775 CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank]; 776 size_t nbIndex = 0; 777 778 // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance 779 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 780 if (itGloe != globalDataIndex.find(globalIndex(idx))) ++nbIndex; 781 782 if (nbIndex != localIndex.numElements()) 783 ERROR("void CGrid::computeClientIndex()", 784 << "Number of local index on client is different from number of received global index" 785 << "Rank of sent client " << rank <<"." 786 << "Number of local index " << nbIndex << ". " 787 << "Number of received global index " << localIndex.numElements() << "."); 788 789 nbIndex = 0; 790 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 791 if (itGloe != globalDataIndex.find(globalIndex(idx))) 792 localIndex(idx) = globalDataIndex[globalIndex(idx)]; 793 } 794 } 795 } 796 797 bool CGrid::isDataDistributed(void) 798 { 799 return getClientDistribution()->isDataDistributed() ; 800 } 839 801 840 802 /*! … … 845 807 { 846 808 if (computeConnectedClients_done_.count(client)!=0) return ; 809 else computeConnectedClients_done_.insert(client) ; 847 810 848 811 CContext* context = CContext::getCurrent(); … … 868 831 if (client->isServerLeader()) 869 832 { 870 size_t ssize = get DistributionClient()->getLocalDataIndexOnClient().size();833 size_t ssize = getClientDistribution()->getLocalDataIndexOnClient().size(); 871 834 const std::list<int>& ranks = client->getRanksServerLeader(); 872 835 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) … … 899 862 computeIndexByElement(indexServerOnElement, client, globalIndexOnServer_[receiverSize]); 900 863 901 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = get DistributionClient()->getGlobalLocalDataSendToServer();864 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 902 865 CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 903 866 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; … … 956 919 nbSenders_[receiverSize] = CClientServerMapping::computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 957 920 } 958 computeConnectedClients_done_.insert(client) ;959 921 } 960 922 CATCH_DUMP_ATTR … … 975 937 if (isScalarGrid()) 976 938 { 977 computeClientIndexScalarGrid();939 //computeClientIndexScalarGrid(); 978 940 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 979 941 { … … 983 945 else 984 946 { 985 computeClientIndex();947 //computeClientIndex(); 986 948 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 987 949 { … … 1430 1392 TRY 1431 1393 { 1432 const std::vector<int>& localMaskedDataIndex = get DistributionClient()->getLocalMaskedDataIndexOnClient();1394 const std::vector<int>& localMaskedDataIndex = getClientDistribution()->getLocalMaskedDataIndexOnClient(); 1433 1395 const int size = localMaskedDataIndex.size(); 1434 1396 for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; … … 1436 1398 CATCH 1437 1399 1438 void CGrid::computeClientIndexScalarGrid() 1439 TRY 1440 { 1441 if (computeClientIndexScalarGrid_done_) return ; 1442 1443 CContext* context = CContext::getCurrent(); 1444 { 1445 int rank = context->intraCommRank_; 1446 1447 auto clientDistribution = getDistributionClient(); 1448 1449 storeIndex_client_.resize(1); 1450 storeIndex_client_(0) = 0; 1451 1452 if (0 != serverDistribution_) 1453 { 1454 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient_.begin(), 1455 ite = outGlobalIndexFromClient_.end(), it; 1456 for (it = itb; it != ite; ++it) 1457 { 1458 int rank = it->first; 1459 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient_[rank]; 1460 outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 1461 CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank]; 1462 if (1 != globalIndex.numElements()) 1463 ERROR("void CGrid::computeClientIndexScalarGrid()", 1464 << "Something wrong happened. " 1465 << "Number of received global index on scalar grid should equal to 1" 1466 << "Number of received global index " << globalIndex.numElements() << "."); 1467 1468 localIndex(0) = globalIndex(0); 1469 } 1470 } 1471 } 1472 computeClientIndexScalarGrid_done_ = true ; 1473 } 1474 CATCH_DUMP_ATTR 1475 1400 1476 1401 void CGrid::computeConnectedClientsScalarGrid(CContextClient* client) 1477 1402 TRY … … 1523 1448 } 1524 1449 } 1525 isDataDistributed_ = false;1450 1526 1451 computeConnectedClientsScalarGrid_done_.insert(client) ; 1527 1452 } … … 1567 1492 1568 1493 listMsg.push_back(CMessage()); 1569 listMsg.back() << getId( )<< is DataDistributed_ << isCompressible_ << listOutIndex.back();1494 listMsg.back() << getId( )<< isCompressible_ << listOutIndex.back(); 1570 1495 1571 1496 event.push(rank, 1, listMsg.back()); … … 1611 1536 list<CMessage> listMsg; 1612 1537 list<CArray<size_t,1> > listOutIndex; 1613 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = get DistributionClient()->getGlobalLocalDataSendToServer();1538 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 1614 1539 CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex, 1615 1540 iteIndex = globalLocalIndexSendToServer.end(); … … 1639 1564 1640 1565 listMsg.push_back(CMessage()); 1641 listMsg.back() << getId() << is DataDistributed_ << isCompressible_ << listOutIndex.back();1566 listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 1642 1567 1643 1568 event.push(*itRank, 1, listMsg.back()); … … 1707 1632 storeIndex_fromSrv_.insert(make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1708 1633 listMsg.push_back(CMessage()); 1709 listMsg.back() << getId() << isDataDistributed_<< isCompressible_ << listOutIndex.back();1634 listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 1710 1635 1711 1636 event.push(rank, nbSenders_[receiverSize][rank], listMsg.back()); … … 1766 1691 CBufferIn& buffer = *buffers[n]; 1767 1692 1768 buffer >> isDataDistributed_ >>isCompressible_;1693 buffer >> isCompressible_; 1769 1694 size_t dataSize = 0; 1770 1695 … … 2054 1979 CATCH_DUMP_ATTR 2055 1980 2056 CDistributionClient* CGrid::get DistributionClient()1981 CDistributionClient* CGrid::getClientDistribution() 2057 1982 TRY 2058 1983 { … … 2071 1996 else if (0 != client) 2072 1997 { 2073 return (isDataDistributed _|| (1 != client->clientSize) || (1 != client->serverSize));1998 return (isDataDistributed() || (1 != client->clientSize) || (1 != client->serverSize)); 2074 1999 } 2075 2000 else 2076 return isDataDistributed _;2001 return isDataDistributed(); 2077 2002 } 2078 2003 CATCH_DUMP_ATTR … … 2178 2103 CATCH_DUMP_ATTR 2179 2104 2105 2106 void CGrid::sendGridToFileServer(CContextClient* client) 2107 { 2108 if (sendGridToFileServer_done_.count(client)!=0) return ; 2109 else sendGridToFileServer_done_.insert(client) ; 2110 2111 StdString gridDefRoot("grid_definition"); 2112 CGridGroup* gridPtr = CGridGroup::get(gridDefRoot); 2113 gridPtr->sendCreateChild(this->getId(),client); 2114 this->sendAllAttributesToServer(client); 2115 this->sendAllDomains(client); 2116 this->sendAllAxis(client); 2117 this->sendAllScalars(client); 2118 } 2119 2180 2120 /*! 2181 2121 \brief Send a message to create a domain on server side … … 2794 2734 { 2795 2735 std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); 2796 int dSize = domList.size(); 2797 for (int i = 0; i < dSize; ++i) 2798 { 2799 sendAddDomain(domList[i]->getId(),contextClient); 2800 domList[i]->sendAllAttributesToServer(contextClient); 2736 for (auto domain : domList) 2737 { 2738 sendAddDomain(domain->getId(),contextClient); 2739 domain->sendDomainToFileServer(contextClient); 2801 2740 } 2802 2741 } … … 2810 2749 { 2811 2750 std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); 2812 int aSize = aList.size(); 2813 2814 for (int i = 0; i < aSize; ++i) 2751 for (int i=0; i<aList.size() ; ++i) 2815 2752 { 2816 2753 sendAddAxis(aList[i]->getId(),contextClient); 2817 aList[i]->sendA llAttributesToServer(contextClient);2754 aList[i]->sendAxisToFileServer(contextClient, getGlobalDimension(), getAxisPositionInGrid()[i]); 2818 2755 } 2819 2756 } … … 2827 2764 { 2828 2765 std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren(); 2829 int sSize = sList.size(); 2830 2831 for (int i = 0; i < sSize; ++i) 2832 { 2833 sendAddScalar(sList[i]->getId(),contextClient); 2834 sList[i]->sendAllAttributesToServer(contextClient); 2766 for (auto scalar : sList) 2767 { 2768 sendAddScalar(scalar->getId(),contextClient); 2769 scalar->sendScalarToFileServer(contextClient); 2835 2770 } 2836 2771 }
Note: See TracChangeset
for help on using the changeset viewer.