Changeset 1871 for XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
- Timestamp:
- 04/21/20 16:46:20 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r1870 r1871 31 31 , vScalarGroup_(), scalarList_(), isScalarListSet(false) 32 32 , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0) 33 , writtenDataSize_(0),numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0)33 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 34 34 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 35 35 , isCompressible_(false) … … 52 52 , vScalarGroup_(), scalarList_(), isScalarListSet(false) 53 53 , clientDistribution_(0), isIndexSent(false) , serverDistribution_(0), clientServerMap_(0) 54 , writtenDataSize_(0),numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0)54 , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 55 55 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 56 56 , isCompressible_(false) … … 1665 1665 TRY 1666 1666 { 1667 CContextClient* client = server->getAssociatedClient(); 1668 connectedServerRankRead_ = ranks; 1669 for (int n = 0; n < ranks.size(); n++) 1670 { 1671 int rank = ranks[n]; 1672 CBufferIn& buffer = *buffers[n]; 1673 buffer >> isCompressible_; // probably to be removed later 1674 CArray<size_t,1> outIndex; 1675 buffer >> outIndex; 1676 outGlobalIndexFromClient_.insert(std::make_pair(rank, outIndex)); 1677 connectedDataSizeRead_[rank] = outIndex.numElements(); 1678 } 1679 1680 nbReadSenders_[client] = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, 1681 client->intraComm, ranks); 1682 } 1683 CATCH_DUMP_ATTR 1684 1685 1686 void CGrid::computeServerDistribution(void) 1687 TRY 1688 { 1689 if (computeServerDistribution_done_) return ; 1690 else computeServerDistribution_done_=true ; 1691 1692 CContext* context = CContext::getCurrent(); 1693 1694 int idx = 0, numElement = axis_domain_order.numElements(); 1695 int ssize = numElement; 1696 std::vector<int> indexMap(numElement); 1697 for (int i = 0; i < numElement; ++i) 1698 { 1699 indexMap[i] = idx; 1700 if (2 == axis_domain_order(i)) 1701 { 1702 ++ssize; 1703 idx += 2; 1704 } 1705 else 1706 ++idx; 1707 } 1708 1709 for (int n = 0; n < connectedServerRankRead_.size(); n++) 1710 { 1711 int rank = connectedServerRankRead_[n]; 1712 size_t dataSize = 0; 1713 1714 if (0 == serverDistribution_) 1715 { 1716 int axisId = 0, domainId = 0, scalarId = 0, globalSize = 1; 1717 std::vector<CDomain*> domainList = getDomains(); 1718 std::vector<CAxis*> axisList = getAxis(); 1719 std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement); 1720 std::vector<CArray<int,1> > globalIndex(numElement); 1721 for (int i = 0; i < numElement; ++i) 1722 { 1723 nGlobElement[i] = globalSize; 1724 if (2 == axis_domain_order(i)) //domain 1725 { 1726 nBegin[indexMap[i]] = domainList[domainId]->ibegin; 1727 nSize[indexMap[i]] = domainList[domainId]->ni; 1728 nBeginGlobal[indexMap[i]] = 0; 1729 nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 1730 1731 nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 1732 nSize[indexMap[i] + 1] = domainList[domainId]->nj; 1733 nBeginGlobal[indexMap[i] + 1] = 0; 1734 nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 1735 1736 { 1737 int count = 0; 1738 globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]); 1739 for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx) 1740 for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 1741 { 1742 globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 1743 ++count; 1744 } 1745 } 1746 1747 ++domainId; 1748 } 1749 else if (1 == axis_domain_order(i)) // axis 1750 { 1751 nBegin[indexMap[i]] = axisList[axisId]->begin; 1752 nSize[indexMap[i]] = axisList[axisId]->n; 1753 nBeginGlobal[indexMap[i]] = 0; 1754 nGlob[indexMap[i]] = axisList[axisId]->n_glo; 1755 globalIndex[i].resize(nSize[indexMap[i]]); 1756 for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 1757 globalIndex[i](idx) = nBegin[indexMap[i]] + idx; 1758 1759 ++axisId; 1760 } 1761 else // scalar 1762 { 1763 nBegin[indexMap[i]] = 0; 1764 nSize[indexMap[i]] = 1; 1765 nBeginGlobal[indexMap[i]] = 0; 1766 nGlob[indexMap[i]] = 1; 1767 globalIndex[i].resize(1); 1768 globalIndex[i](0) = 0; 1769 ++scalarId; 1770 } 1771 } 1772 dataSize = 1; 1773 1774 for (int i = 0; i < nSize.size(); ++i) 1775 dataSize *= nSize[i]; 1776 serverDistribution_ = new CDistributionServer(context->intraCommRank_, 1777 globalIndex, axis_domain_order, 1778 nBegin, nSize, nBeginGlobal, nGlob); 1779 } 1780 } 1781 } 1782 CATCH_DUMP_ATTR 1783 1784 1785 1786 1787 1788 1789 /* old interface => transform into compute receivedIndex 1790 void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers, CContextServer* server) 1791 TRY 1792 { 1667 1793 CContext* context = CContext::getCurrent(); 1668 1794 connectedServerRankRead_ = ranks; … … 1829 1955 } 1830 1956 CATCH_DUMP_ATTR 1957 */ 1958 1831 1959 1832 1960 /* … … 1922 2050 TRY 1923 2051 { 1924 return (0 != writtenDataSize_);2052 return (0 != getWrittenDataSize()); 1925 2053 } 1926 2054 CATCH_DUMP_ATTR … … 1932 2060 \return size of data written on server 1933 2061 */ 1934 size_t CGrid::getWrittenDataSize() const1935 TRY 1936 { 1937 return writtenDataSize_;2062 size_t CGrid::getWrittenDataSize() 2063 TRY 2064 { 2065 return getServerDistribution()->getGridSize(); 1938 2066 } 1939 2067 CATCH … … 1972 2100 CATCH 1973 2101 1974 CDistributionServer* CGrid::getDistributionServer() 1975 TRY 1976 { 1977 return serverDistribution_; 1978 } 1979 CATCH_DUMP_ATTR 1980 2102 1981 2103 CDistributionClient* CGrid::getClientDistribution() 1982 2104 TRY … … 2113 2235 gridPtr->sendCreateChild(this->getId(),client); 2114 2236 this->sendAllAttributesToServer(client); 2237 if (isScalarGrid()) sendIndexScalarGrid(); 2238 else sendIndex(); 2115 2239 this->sendAllDomains(client); 2116 2240 this->sendAllAxis(client);
Note: See TracChangeset
for help on using the changeset viewer.