Changeset 1027 for XIOS/dev/dev_olga/src/node/domain.cpp
- Timestamp:
- 01/11/17 16:50:27 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/domain.cpp
r1025 r1027 1495 1495 { 1496 1496 CContext* context=CContext::getCurrent() ; 1497 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1498 int nbServer=client->serverSize; 1499 int rank = client->clientRank; 1500 bool doComputeGlobalIndexServer = true; 1501 1502 int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 1503 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 1504 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 1505 1506 // Precompute number of index 1507 int globalIndexCountZoom = 0; 1508 nbIndex = i_index.numElements(); 1509 // for (i = 0; i < nbIndex; ++i) 1510 // { 1511 // i_ind=i_index(i); 1512 // j_ind=j_index(i); 1513 1514 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1515 // { 1516 // ++globalIndexCountZoom; 1517 // } 1518 // } 1519 1520 // int globalIndexWrittenCount = 0; 1521 // if (isCompressible_) 1522 // { 1523 // for (i = 0; i < data_i_index.numElements(); ++i) 1524 // { 1525 // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1526 // data_ibegin, data_jbegin, data_dim, ni, 1527 // j_ind); 1528 // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1529 // { 1530 // i_ind += ibegin; 1531 // j_ind += jbegin; 1532 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1533 // ++globalIndexWrittenCount; 1534 // } 1535 // } 1536 // } 1537 1538 // Fill in index 1539 1540 CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 1541 CArray<size_t,1> globalIndexDomain(nbIndex); 1542 size_t globalIndex; 1543 int globalIndexCount = 0; 1544 1545 1546 for (i = 0; i < nbIndex; ++i) 1547 { 1548 i_ind=i_index(i); 1549 j_ind=j_index(i); 1550 globalIndex = i_ind + j_ind * ni_glo; 1551 globalIndexDomain(globalIndexCount) = globalIndex; 1552 globalLocalIndexMap_[globalIndex] = i; 1553 ++globalIndexCount; 1554 } 1555 1556 nbIndexZoom = zoom_i_index.numElements(); 1557 CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 1558 globalIndexCountZoom = 0; 1559 for (i = 0; i < nbIndexZoom; ++i) 1560 { 1561 i_ind=zoom_i_index(i); 1562 j_ind=zoom_j_index(i); 1563 globalIndex = i_ind + j_ind * ni_glo; 1564 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1565 1566 ++globalIndexCountZoom; 1567 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1497 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1498 for (int i = 0; i < nbSrvPools; ++i) 1499 { 1500 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 1501 int nbServer=client->serverSize; 1502 int rank = client->clientRank; 1503 bool doComputeGlobalIndexServer = true; 1504 1505 int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 1506 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 1507 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 1508 1509 // Precompute number of index 1510 int globalIndexCountZoom = 0; 1511 nbIndex = i_index.numElements(); 1512 // for (i = 0; i < nbIndex; ++i) 1568 1513 // { 1569 // globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1570 // localIndexDomainZoom(globalIndexCountZoom) = i; 1571 // ++globalIndexCountZoom; 1514 // i_ind=i_index(i); 1515 // j_ind=j_index(i); 1516 1517 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1518 // { 1519 // ++globalIndexCountZoom; 1520 // } 1572 1521 // } 1573 } 1574 1575 // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 1576 // if (isCompressible_) 1577 // { 1578 // globalIndexWrittenCount = 0; 1579 // for (i = 0; i < data_i_index.numElements(); ++i) 1580 // { 1581 // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1582 // data_ibegin, data_jbegin, data_dim, ni, 1583 // j_ind); 1584 // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1585 // { 1586 // i_ind += ibegin; 1587 // j_ind += jbegin; 1588 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1589 // { 1590 // globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 1591 // ++globalIndexWrittenCount; 1592 // } 1593 // } 1594 // } 1595 // } 1596 1597 size_t globalSizeIndex = 1, indexBegin, indexEnd; 1598 int range, clientSize = client->clientSize; 1599 std::vector<int> nGlobDomain(2); 1600 nGlobDomain[0] = this->ni_glo; 1601 nGlobDomain[1] = this->nj_glo; 1602 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 1603 indexBegin = 0; 1604 if (globalSizeIndex <= clientSize) 1605 { 1606 indexBegin = rank%globalSizeIndex; 1607 indexEnd = indexBegin; 1608 } 1609 else 1610 { 1611 for (int i = 0; i < clientSize; ++i) 1612 { 1613 range = globalSizeIndex / clientSize; 1614 if (i < (globalSizeIndex%clientSize)) ++range; 1615 if (i == client->clientRank) break; 1616 indexBegin += range; 1617 } 1618 indexEnd = indexBegin + range - 1; 1619 } 1620 1621 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1622 if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 1623 else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 1624 1625 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 1626 client->intraComm); 1627 clientServerMap->computeServerIndexMapping(globalIndexDomain); 1628 CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 1629 1630 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), 1631 ite = globalIndexDomainOnServer.end(); 1632 // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 1633 // std::vector<int>::iterator itVec; 1634 1635 // indSrv_.clear(); 1636 // indWrittenSrv_.clear(); 1637 // for (; it != ite; ++it) 1638 // { 1639 // int rank = it->first; 1640 // int indexSize = it->second.size(); 1641 // std::vector<int> permutIndex(indexSize); 1642 // XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 1643 // XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 1644 // BinarySearch binSearch(it->second); 1645 // int nb = globalIndexDomainZoom.numElements(); 1646 // for (int i = 0; i < nb; ++i) 1647 // { 1648 // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 1649 // { 1650 // indSrv_[rank].push_back(localIndexDomainZoom(i)); 1651 // } 1652 // } 1653 // for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 1654 // { 1655 // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 1656 // { 1657 // indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 1658 // } 1659 // } 1660 // } 1661 1662 connectedServerRank_.clear(); 1663 for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 1664 connectedServerRank_.push_back(it->first); 1665 } 1666 1667 indSrv_.swap(globalIndexDomainOnServer); 1668 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 1669 1670 clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 1671 CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1672 indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1673 std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 1674 for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1675 connectedServerZoomRank.push_back(it->first); 1676 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank); 1677 1678 delete clientServerMap; 1522 1523 // int globalIndexWrittenCount = 0; 1524 // if (isCompressible_) 1525 // { 1526 // for (i = 0; i < data_i_index.numElements(); ++i) 1527 // { 1528 // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1529 // data_ibegin, data_jbegin, data_dim, ni, 1530 // j_ind); 1531 // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1532 // { 1533 // i_ind += ibegin; 1534 // j_ind += jbegin; 1535 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1536 // ++globalIndexWrittenCount; 1537 // } 1538 // } 1539 // } 1540 1541 // Fill in index 1542 1543 CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 1544 CArray<size_t,1> globalIndexDomain(nbIndex); 1545 size_t globalIndex; 1546 int globalIndexCount = 0; 1547 1548 1549 for (i = 0; i < nbIndex; ++i) 1550 { 1551 i_ind=i_index(i); 1552 j_ind=j_index(i); 1553 globalIndex = i_ind + j_ind * ni_glo; 1554 globalIndexDomain(globalIndexCount) = globalIndex; 1555 globalLocalIndexMap_[globalIndex] = i; 1556 ++globalIndexCount; 1557 } 1558 1559 nbIndexZoom = zoom_i_index.numElements(); 1560 CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 1561 globalIndexCountZoom = 0; 1562 for (i = 0; i < nbIndexZoom; ++i) 1563 { 1564 i_ind=zoom_i_index(i); 1565 j_ind=zoom_j_index(i); 1566 globalIndex = i_ind + j_ind * ni_glo; 1567 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1568 1569 ++globalIndexCountZoom; 1570 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1571 // { 1572 // globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1573 // localIndexDomainZoom(globalIndexCountZoom) = i; 1574 // ++globalIndexCountZoom; 1575 // } 1576 } 1577 1578 // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 1579 // if (isCompressible_) 1580 // { 1581 // globalIndexWrittenCount = 0; 1582 // for (i = 0; i < data_i_index.numElements(); ++i) 1583 // { 1584 // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1585 // data_ibegin, data_jbegin, data_dim, ni, 1586 // j_ind); 1587 // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1588 // { 1589 // i_ind += ibegin; 1590 // j_ind += jbegin; 1591 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1592 // { 1593 // globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 1594 // ++globalIndexWrittenCount; 1595 // } 1596 // } 1597 // } 1598 // } 1599 1600 size_t globalSizeIndex = 1, indexBegin, indexEnd; 1601 int range, clientSize = client->clientSize; 1602 std::vector<int> nGlobDomain(2); 1603 nGlobDomain[0] = this->ni_glo; 1604 nGlobDomain[1] = this->nj_glo; 1605 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 1606 indexBegin = 0; 1607 if (globalSizeIndex <= clientSize) 1608 { 1609 indexBegin = rank%globalSizeIndex; 1610 indexEnd = indexBegin; 1611 } 1612 else 1613 { 1614 for (int i = 0; i < clientSize; ++i) 1615 { 1616 range = globalSizeIndex / clientSize; 1617 if (i < (globalSizeIndex%clientSize)) ++range; 1618 if (i == client->clientRank) break; 1619 indexBegin += range; 1620 } 1621 indexEnd = indexBegin + range - 1; 1622 } 1623 1624 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1625 if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 1626 else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 1627 1628 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 1629 client->intraComm); 1630 clientServerMap->computeServerIndexMapping(globalIndexDomain); 1631 CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 1632 1633 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), 1634 ite = globalIndexDomainOnServer.end(); 1635 // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 1636 // std::vector<int>::iterator itVec; 1637 1638 // indSrv_.clear(); 1639 // indWrittenSrv_.clear(); 1640 // for (; it != ite; ++it) 1641 // { 1642 // int rank = it->first; 1643 // int indexSize = it->second.size(); 1644 // std::vector<int> permutIndex(indexSize); 1645 // XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 1646 // XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 1647 // BinarySearch binSearch(it->second); 1648 // int nb = globalIndexDomainZoom.numElements(); 1649 // for (int i = 0; i < nb; ++i) 1650 // { 1651 // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 1652 // { 1653 // indSrv_[rank].push_back(localIndexDomainZoom(i)); 1654 // } 1655 // } 1656 // for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 1657 // { 1658 // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 1659 // { 1660 // indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 1661 // } 1662 // } 1663 // } 1664 1665 connectedServerRank_.clear(); 1666 for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 1667 connectedServerRank_.push_back(it->first); 1668 } 1669 1670 indSrv_.swap(globalIndexDomainOnServer); 1671 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 1672 1673 clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 1674 CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1675 indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1676 std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 1677 for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1678 connectedServerZoomRank.push_back(it->first); 1679 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank); 1680 1681 delete clientServerMap; 1682 } 1679 1683 } 1680 1684 … … 1706 1710 int ns, n, i, j, ind, nv, idx; 1707 1711 CContext* context = CContext::getCurrent(); 1708 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1709 1710 CEventClient eventIndex(getType(), EVENT_ID_INDEX); 1711 1712 list<CMessage> list_msgsIndex; 1713 list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 1714 1715 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex, itZoom, iteZoom; 1716 iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end(); 1717 for (int k = 0; k < connectedServerRank_.size(); ++k) 1718 { 1719 int nbIndGlob = 0; 1720 int rank = connectedServerRank_[k]; 1721 itIndex = indSrv_.find(rank); 1722 if (iteIndex != itIndex) 1723 nbIndGlob = itIndex->second.size(); 1724 int nbIndZoom = 0; 1725 itZoom = indZoomSrv_.find(rank); 1726 if (iteZoom != itZoom) 1727 nbIndZoom = itZoom->second.size(); 1728 1729 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1730 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1731 1732 CArray<int,1>& indZoom = list_indZoom.back(); 1733 CArray<int,1>& indGlob = list_indGlob.back(); 1734 for (n = 0; n < nbIndGlob; ++n) 1735 { 1736 indGlob(n) = static_cast<int>(itIndex->second[n]); 1737 } 1738 1739 for (n = 0; n < nbIndZoom; ++n) 1740 { 1741 indZoom(n) = static_cast<int>(itZoom->second[n]); 1742 } 1743 1744 list_msgsIndex.push_back(CMessage()); 1745 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1746 list_msgsIndex.back() << isCurvilinear; 1747 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 1748 1749 // if (isCompressible_) 1750 // { 1751 // std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 1752 // list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 1753 // CArray<int,1>& writtenInd = list_writtenInd.back(); 1754 1755 // for (n = 0; n < writtenInd.numElements(); ++n) 1756 // writtenInd(n) = writtenIndSrc[n]; 1757 1758 // list_msgsIndex.back() << writtenInd; 1759 // } 1760 1761 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 1762 } 1763 1764 client->sendEvent(eventIndex); 1712 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1713 for (int i = 0; i < nbSrvPools; ++i) 1714 { 1715 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 1716 1717 CEventClient eventIndex(getType(), EVENT_ID_INDEX); 1718 1719 list<CMessage> list_msgsIndex; 1720 list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 1721 1722 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex, itZoom, iteZoom; 1723 iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end(); 1724 for (int k = 0; k < connectedServerRank_.size(); ++k) 1725 { 1726 int nbIndGlob = 0; 1727 int rank = connectedServerRank_[k]; 1728 itIndex = indSrv_.find(rank); 1729 if (iteIndex != itIndex) 1730 nbIndGlob = itIndex->second.size(); 1731 int nbIndZoom = 0; 1732 itZoom = indZoomSrv_.find(rank); 1733 if (iteZoom != itZoom) 1734 nbIndZoom = itZoom->second.size(); 1735 1736 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1737 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1738 1739 CArray<int,1>& indZoom = list_indZoom.back(); 1740 CArray<int,1>& indGlob = list_indGlob.back(); 1741 for (n = 0; n < nbIndGlob; ++n) 1742 { 1743 indGlob(n) = static_cast<int>(itIndex->second[n]); 1744 } 1745 1746 for (n = 0; n < nbIndZoom; ++n) 1747 { 1748 indZoom(n) = static_cast<int>(itZoom->second[n]); 1749 } 1750 1751 list_msgsIndex.push_back(CMessage()); 1752 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1753 list_msgsIndex.back() << isCurvilinear; 1754 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 1755 1756 // if (isCompressible_) 1757 // { 1758 // std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 1759 // list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 1760 // CArray<int,1>& writtenInd = list_writtenInd.back(); 1761 1762 // for (n = 0; n < writtenInd.numElements(); ++n) 1763 // writtenInd(n) = writtenIndSrc[n]; 1764 1765 // list_msgsIndex.back() << writtenInd; 1766 // } 1767 1768 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 1769 } 1770 1771 client->sendEvent(eventIndex); 1772 } 1765 1773 } 1766 1774 … … 1772 1780 int ns, n, i, j, ind, nv, idx; 1773 1781 CContext* context = CContext::getCurrent(); 1774 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1775 1776 // send area for each connected server 1777 CEventClient eventMask(getType(), EVENT_ID_MASK); 1778 1779 list<CMessage> list_msgsMask; 1780 list<CArray<bool,1> > list_mask; 1781 1782 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1783 iteMap = indSrv_.end(); 1784 for (int k = 0; k < connectedServerRank_.size(); ++k) 1785 { 1786 int nbData = 0; 1787 int rank = connectedServerRank_[k]; 1788 it = indSrv_.find(rank); 1789 if (iteMap != it) 1790 nbData = it->second.size(); 1791 list_mask.push_back(CArray<bool,1>(nbData)); 1792 1793 const std::vector<size_t>& temp = it->second; 1794 for (n = 0; n < nbData; ++n) 1795 { 1796 idx = static_cast<int>(it->second[n]); 1797 list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]); 1798 } 1799 1800 list_msgsMask.push_back(CMessage()); 1801 list_msgsMask.back() << this->getId() << list_mask.back(); 1802 eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 1803 } 1804 client->sendEvent(eventMask); 1782 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1783 for (int i = 0; i < nbSrvPools; ++i) 1784 { 1785 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 1786 1787 // send area for each connected server 1788 CEventClient eventMask(getType(), EVENT_ID_MASK); 1789 1790 list<CMessage> list_msgsMask; 1791 list<CArray<bool,1> > list_mask; 1792 1793 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1794 iteMap = indSrv_.end(); 1795 for (int k = 0; k < connectedServerRank_.size(); ++k) 1796 { 1797 int nbData = 0; 1798 int rank = connectedServerRank_[k]; 1799 it = indSrv_.find(rank); 1800 if (iteMap != it) 1801 nbData = it->second.size(); 1802 list_mask.push_back(CArray<bool,1>(nbData)); 1803 1804 const std::vector<size_t>& temp = it->second; 1805 for (n = 0; n < nbData; ++n) 1806 { 1807 idx = static_cast<int>(it->second[n]); 1808 list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]); 1809 } 1810 1811 list_msgsMask.push_back(CMessage()); 1812 list_msgsMask.back() << this->getId() << list_mask.back(); 1813 eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 1814 } 1815 client->sendEvent(eventMask); 1816 } 1805 1817 } 1806 1818 … … 1814 1826 int ns, n, i, j, ind, nv, idx; 1815 1827 CContext* context = CContext::getCurrent(); 1816 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1817 1818 // send area for each connected server 1819 CEventClient eventArea(getType(), EVENT_ID_AREA); 1820 1821 list<CMessage> list_msgsArea; 1822 list<CArray<double,1> > list_area; 1823 1824 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1825 iteMap = indSrv_.end(); 1826 for (int k = 0; k < connectedServerRank_.size(); ++k) 1827 { 1828 int nbData = 0; 1829 int rank = connectedServerRank_[k]; 1830 it = indSrv_.find(rank); 1831 if (iteMap != it) 1832 nbData = it->second.size(); 1833 list_area.push_back(CArray<double,1>(nbData)); 1834 1835 const std::vector<size_t>& temp = it->second; 1836 for (n = 0; n < nbData; ++n) 1837 { 1838 idx = static_cast<int>(it->second[n]); 1839 list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); 1840 } 1841 1842 list_msgsArea.push_back(CMessage()); 1843 list_msgsArea.back() << this->getId() << hasArea; 1844 list_msgsArea.back() << list_area.back(); 1845 eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 1846 } 1847 client->sendEvent(eventArea); 1828 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1829 for (int i = 0; i < nbSrvPools; ++i) 1830 { 1831 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 1832 1833 // send area for each connected server 1834 CEventClient eventArea(getType(), EVENT_ID_AREA); 1835 1836 list<CMessage> list_msgsArea; 1837 list<CArray<double,1> > list_area; 1838 1839 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1840 iteMap = indSrv_.end(); 1841 for (int k = 0; k < connectedServerRank_.size(); ++k) 1842 { 1843 int nbData = 0; 1844 int rank = connectedServerRank_[k]; 1845 it = indSrv_.find(rank); 1846 if (iteMap != it) 1847 nbData = it->second.size(); 1848 list_area.push_back(CArray<double,1>(nbData)); 1849 1850 const std::vector<size_t>& temp = it->second; 1851 for (n = 0; n < nbData; ++n) 1852 { 1853 idx = static_cast<int>(it->second[n]); 1854 list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); 1855 } 1856 1857 list_msgsArea.push_back(CMessage()); 1858 list_msgsArea.back() << this->getId() << hasArea; 1859 list_msgsArea.back() << list_area.back(); 1860 eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 1861 } 1862 client->sendEvent(eventArea); 1863 } 1848 1864 } 1849 1865 … … 1859 1875 int ns, n, i, j, ind, nv, idx; 1860 1876 CContext* context = CContext::getCurrent(); 1861 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1862 1863 // send lon lat for each connected server 1864 CEventClient eventLon(getType(), EVENT_ID_LON); 1865 CEventClient eventLat(getType(), EVENT_ID_LAT); 1866 1867 list<CMessage> list_msgsLon, list_msgsLat; 1868 list<CArray<double,1> > list_lon, list_lat; 1869 list<CArray<double,2> > list_boundslon, list_boundslat; 1870 1871 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1872 iteMap = indSrv_.end(); 1873 for (int k = 0; k < connectedServerRank_.size(); ++k) 1874 { 1875 int nbData = 0; 1876 int rank = connectedServerRank_[k]; 1877 it = indSrv_.find(rank); 1878 if (iteMap != it) 1879 nbData = it->second.size(); 1880 1881 list_lon.push_back(CArray<double,1>(nbData)); 1882 list_lat.push_back(CArray<double,1>(nbData)); 1883 1884 if (hasBounds) 1885 { 1886 list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 1887 list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 1888 } 1889 1890 CArray<double,1>& lon = list_lon.back(); 1891 CArray<double,1>& lat = list_lat.back(); 1892 const std::vector<size_t>& temp = it->second; 1893 for (n = 0; n < nbData; ++n) 1894 { 1895 idx = static_cast<int>(it->second[n]); 1896 int localInd = globalLocalIndexMap_[idx]; 1897 lon(n) = lonvalue(localInd); 1898 lat(n) = latvalue(localInd); 1877 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1878 for (int i = 0; i < nbSrvPools; ++i) 1879 { 1880 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 1881 1882 // send lon lat for each connected server 1883 CEventClient eventLon(getType(), EVENT_ID_LON); 1884 CEventClient eventLat(getType(), EVENT_ID_LAT); 1885 1886 list<CMessage> list_msgsLon, list_msgsLat; 1887 list<CArray<double,1> > list_lon, list_lat; 1888 list<CArray<double,2> > list_boundslon, list_boundslat; 1889 1890 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1891 iteMap = indSrv_.end(); 1892 for (int k = 0; k < connectedServerRank_.size(); ++k) 1893 { 1894 int nbData = 0; 1895 int rank = connectedServerRank_[k]; 1896 it = indSrv_.find(rank); 1897 if (iteMap != it) 1898 nbData = it->second.size(); 1899 1900 list_lon.push_back(CArray<double,1>(nbData)); 1901 list_lat.push_back(CArray<double,1>(nbData)); 1899 1902 1900 1903 if (hasBounds) 1901 1904 { 1902 CArray<double,2>& boundslon = list_boundslon.back(); 1903 CArray<double,2>& boundslat = list_boundslat.back(); 1904 1905 for (nv = 0; nv < nvertex; ++nv) 1905 list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 1906 list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 1907 } 1908 1909 CArray<double,1>& lon = list_lon.back(); 1910 CArray<double,1>& lat = list_lat.back(); 1911 const std::vector<size_t>& temp = it->second; 1912 for (n = 0; n < nbData; ++n) 1913 { 1914 idx = static_cast<int>(it->second[n]); 1915 int localInd = globalLocalIndexMap_[idx]; 1916 lon(n) = lonvalue(localInd); 1917 lat(n) = latvalue(localInd); 1918 1919 if (hasBounds) 1906 1920 { 1907 boundslon(nv, n) = bounds_lonvalue(nv, localInd); 1908 boundslat(nv, n) = bounds_latvalue(nv, localInd); 1921 CArray<double,2>& boundslon = list_boundslon.back(); 1922 CArray<double,2>& boundslat = list_boundslat.back(); 1923 1924 for (nv = 0; nv < nvertex; ++nv) 1925 { 1926 boundslon(nv, n) = bounds_lonvalue(nv, localInd); 1927 boundslat(nv, n) = bounds_latvalue(nv, localInd); 1928 } 1909 1929 } 1910 1930 } 1911 } 1912 1913 list_msgsLon.push_back(CMessage());1914 list_msgsLat.push_back(CMessage()); 1915 1916 list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds;1917 list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 1918 1919 if (hasBounds)1920 {1921 list_msgsLon.back() << list_boundslon.back();1922 list_msgsLat.back() << list_boundslat.back();1923 } 1924 1925 eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back());1926 eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back());1927 } 1928 1929 client->sendEvent(eventLon);1930 client->sendEvent(eventLat);1931 1932 list_msgsLon.push_back(CMessage()); 1933 list_msgsLat.push_back(CMessage()); 1934 1935 list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 1936 list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 1937 1938 if (hasBounds) 1939 { 1940 list_msgsLon.back() << list_boundslon.back(); 1941 list_msgsLat.back() << list_boundslat.back(); 1942 } 1943 1944 eventLon.push(rank, nbConnectedClients_[rank], list_msgsLon.back()); 1945 eventLat.push(rank, nbConnectedClients_[rank], list_msgsLat.back()); 1946 } 1947 1948 client->sendEvent(eventLon); 1949 client->sendEvent(eventLat); 1950 } 1931 1951 } 1932 1952 … … 1940 1960 int ns, n, i, j, ind, nv, idx; 1941 1961 CContext* context = CContext::getCurrent(); 1942 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1943 1944 // send area for each connected server 1945 CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 1946 1947 list<CMessage> list_msgsDataIndex; 1948 list<CArray<int,1> > list_data_i_index, list_data_j_index; 1949 1950 int nbIndex = i_index.numElements(); 1951 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 1952 dataIIndex = -1; dataJIndex = -1, ind = 0; 1953 for (idx = 0; idx < data_i_index.numElements(); ++idx) 1954 { 1955 if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 1956 { 1957 dataIIndex(ind) = data_i_index(idx); 1958 dataJIndex(ind) = data_j_index(idx); 1959 ++ind; 1960 } 1961 } 1962 1963 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1964 iteMap = indSrv_.end(); 1965 for (int k = 0; k < connectedServerRank_.size(); ++k) 1966 { 1967 int nbData = 0; 1968 int rank = connectedServerRank_[k]; 1969 it = indSrv_.find(rank); 1970 if (iteMap != it) 1971 nbData = it->second.size(); 1972 list_data_i_index.push_back(CArray<int,1>(nbData)); 1973 list_data_j_index.push_back(CArray<int,1>(nbData)); 1974 1975 const std::vector<size_t>& temp = it->second; 1976 for (n = 0; n < nbData; ++n) 1977 { 1978 idx = static_cast<int>(it->second[n]); 1979 i = globalLocalIndexMap_[idx]; 1980 list_data_i_index.back()(n) = dataIIndex(i); 1981 list_data_j_index.back()(n) = dataJIndex(i); 1982 } 1983 1984 list_msgsDataIndex.push_back(CMessage()); 1985 list_msgsDataIndex.back() << this->getId(); 1986 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 1987 eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 1988 } 1989 client->sendEvent(eventDataIndex); 1962 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1963 for (int i = 0; i < nbSrvPools; ++i) 1964 { 1965 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[i] : context->client; 1966 1967 // send area for each connected server 1968 CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 1969 1970 list<CMessage> list_msgsDataIndex; 1971 list<CArray<int,1> > list_data_i_index, list_data_j_index; 1972 1973 int nbIndex = i_index.numElements(); 1974 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 1975 dataIIndex = -1; dataJIndex = -1, ind = 0; 1976 for (idx = 0; idx < data_i_index.numElements(); ++idx) 1977 { 1978 if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 1979 { 1980 dataIIndex(ind) = data_i_index(idx); 1981 dataJIndex(ind) = data_j_index(idx); 1982 ++ind; 1983 } 1984 } 1985 1986 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1987 iteMap = indSrv_.end(); 1988 for (int k = 0; k < connectedServerRank_.size(); ++k) 1989 { 1990 int nbData = 0; 1991 int rank = connectedServerRank_[k]; 1992 it = indSrv_.find(rank); 1993 if (iteMap != it) 1994 nbData = it->second.size(); 1995 list_data_i_index.push_back(CArray<int,1>(nbData)); 1996 list_data_j_index.push_back(CArray<int,1>(nbData)); 1997 1998 const std::vector<size_t>& temp = it->second; 1999 for (n = 0; n < nbData; ++n) 2000 { 2001 idx = static_cast<int>(it->second[n]); 2002 i = globalLocalIndexMap_[idx]; 2003 list_data_i_index.back()(n) = dataIIndex(i); 2004 list_data_j_index.back()(n) = dataJIndex(i); 2005 } 2006 2007 list_msgsDataIndex.push_back(CMessage()); 2008 list_msgsDataIndex.back() << this->getId(); 2009 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 2010 eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 2011 } 2012 client->sendEvent(eventDataIndex); 2013 } 1990 2014 } 1991 2015
Note: See TracChangeset
for help on using the changeset viewer.