Changeset 1099 for XIOS/dev/dev_olga/src/node/domain.cpp
- Timestamp:
- 04/14/17 16:53:56 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/domain.cpp
r1054 r1099 33 33 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 34 34 , isClientAfterTransformationChecked(false), hasLonLat(false) 35 , isRedistributed_(false), hasPole(false) 35 , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 36 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 37 , globalLocalIndexMap_() 36 38 { 37 39 } … … 42 44 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 43 45 , isClientAfterTransformationChecked(false), hasLonLat(false) 44 , isRedistributed_(false), hasPole(false) 46 , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 47 , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 48 , globalLocalIndexMap_() 45 49 { 46 50 } … … 756 760 if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); 757 761 if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); 762 if (zoom_ibegin.isEmpty()) zoom_ibegin.setValue(ibegin); 763 if (zoom_ni.isEmpty()) zoom_ni.setValue(ni); 764 if (zoom_jbegin.isEmpty()) zoom_jbegin.setValue(jbegin); 765 if (zoom_nj.isEmpty()) zoom_nj.setValue(nj); 758 766 } 759 767 … … 1076 1084 void CDomain::completeLonLatClient(void) 1077 1085 { 1078 if (!lonvalue_2d.isEmpty()) 1086 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 1087 if (!lonvalue_2d.isEmpty() && !lonlatValueExisted) 1079 1088 { 1080 1089 lonvalue.resize(ni * nj); … … 1106 1115 } 1107 1116 } 1108 else if (!lonvalue_1d.isEmpty() )1117 else if (!lonvalue_1d.isEmpty() && !lonlatValueExisted) 1109 1118 { 1110 1119 if (type_attr::rectilinear == type) … … 1140 1149 } 1141 1150 } 1142 else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() )1151 else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements() && !lonlatValueExisted) 1143 1152 { 1144 1153 lonvalue.reference(lonvalue_1d); … … 1159 1168 << i_index.numElements() << " and " << j_index.numElements() << "."); 1160 1169 } 1161 else if (type == type_attr::curvilinear || type == type_attr::unstructured )1170 else if (type == type_attr::curvilinear || type == type_attr::unstructured && !lonlatValueExisted) 1162 1171 { 1163 1172 lonvalue.reference(lonvalue_1d); … … 1174 1183 void CDomain::checkBounds(void) 1175 1184 { 1176 if (!nvertex.isEmpty() && nvertex > 0) 1185 bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); 1186 if (!nvertex.isEmpty() && nvertex > 0 && !hasBoundValues) 1177 1187 { 1178 1188 if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) … … 1262 1272 void CDomain::checkArea(void) 1263 1273 { 1274 bool hasAreaValue = (0 != areavalue.numElements()); 1264 1275 hasArea = !area.isEmpty() || !areavalue.isEmpty(); 1265 1276 if (hasArea) … … 1292 1303 hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 1293 1304 (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); 1294 if (hasLonLat) 1305 bool hasLonLatValue = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 1306 if (hasLonLat && !hasLonLatValue) 1295 1307 { 1296 1308 if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) … … 1443 1455 } 1444 1456 1445 /*!1446 Send distribution from client to other clients1447 Because a client in a level knows correctly the grid distribution of client on the next level1448 it calculates this distribution then sends it to the corresponding clients on the next level1449 */1450 void CDomain::sendDistributionAttributes(void)1451 {1452 CContext* context = CContext::getCurrent();1453 // Use correct context client to send message1454 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;1455 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1;1456 for (int p = 0; p < nbSrvPools; ++p)1457 {1458 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[p]1459 : context->client;1460 1461 int nbServer = contextClientTmp->serverSize;1462 std::vector<int> nGlobDomain(2);1463 nGlobDomain[0] = this->ni_glo;1464 nGlobDomain[1] = this->nj_glo;1465 1466 CServerDistributionDescription serverDescription(nGlobDomain, nbServer);1467 if (isUnstructed_) serverDescription.computeServerDistribution(false, 0);1468 else serverDescription.computeServerDistribution(false, 1);1469 1470 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();1471 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();1472 1473 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT);1474 if (contextClientTmp->isServerLeader())1475 {1476 std::list<CMessage> msgs;1477 1478 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();1479 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1480 {1481 // Use const int to ensure CMessage holds a copy of the value instead of just a reference1482 const int ibegin_srv = serverIndexBegin[*itRank][0];1483 const int jbegin_srv = serverIndexBegin[*itRank][1];1484 const int ni_srv = serverDimensionSizes[*itRank][0];1485 const int nj_srv = serverDimensionSizes[*itRank][1];1486 1487 msgs.push_back(CMessage());1488 CMessage& msg = msgs.back();1489 msg << this->getId() ;1490 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv;1491 msg << isCompressible_;1492 1493 event.push(*itRank,1,msg);1494 }1495 contextClientTmp->sendEvent(event);1496 }1497 else contextClientTmp->sendEvent(event);1498 }1499 }1500 1457 1501 1458 // void CDomain::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, … … 1507 1464 { 1508 1465 CContext* context=CContext::getCurrent() ; 1466 1509 1467 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1510 1468 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; … … 1512 1470 { 1513 1471 CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; 1514 int nbServer =client->serverSize;1515 int rank = client->clientRank;1472 int nbServer = client->serverSize; 1473 int rank = client->clientRank; 1516 1474 bool doComputeGlobalIndexServer = true; 1517 1475 1518 1476 int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 1519 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 1520 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 1477 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 1478 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 1521 1479 1522 1480 // Precompute number of index 1523 1481 int globalIndexCountZoom = 0; 1524 1482 nbIndex = i_index.numElements(); 1483 1484 if (doZoomByIndex_) 1485 { 1486 globalIndexCountZoom = zoom_i_index.numElements(); 1487 } 1488 else 1489 { 1490 for (i = 0; i < nbIndex; ++i) 1491 { 1492 i_ind=i_index(i); 1493 j_ind=j_index(i); 1494 1495 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1496 { 1497 ++globalIndexCountZoom; 1498 } 1499 } 1500 } 1501 1525 1502 // for (i = 0; i < nbIndex; ++i) 1526 1503 // { … … 1554 1531 // Fill in index 1555 1532 1533 CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 1556 1534 CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 1557 1535 CArray<size_t,1> globalIndexDomain(nbIndex); … … 1559 1537 int globalIndexCount = 0; 1560 1538 1561 1562 1539 for (i = 0; i < nbIndex; ++i) 1563 1540 { … … 1565 1542 j_ind=j_index(i); 1566 1543 globalIndex = i_ind + j_ind * ni_glo; 1567 globalIndexDomain(globalIndexCount) = globalIndex; 1568 globalLocalIndexMap_[globalIndex] = i; 1569 ++globalIndexCount; 1570 } 1571 1572 nbIndexZoom = zoom_i_index.numElements(); 1573 CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 1544 globalIndexDomain(i) = globalIndex; 1545 } 1546 1547 if (globalLocalIndexMap_.empty()) 1548 { 1549 for (i = 0; i < nbIndex; ++i) 1550 globalLocalIndexMap_[globalIndexDomain(i)] = i; 1551 1552 } 1553 1574 1554 globalIndexCountZoom = 0; 1575 for (i = 0; i < nbIndexZoom; ++i) 1576 { 1577 i_ind=zoom_i_index(i); 1578 j_ind=zoom_j_index(i); 1579 globalIndex = i_ind + j_ind * ni_glo; 1580 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1581 1582 ++globalIndexCountZoom; 1583 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1584 // { 1585 // globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1586 // localIndexDomainZoom(globalIndexCountZoom) = i; 1587 // ++globalIndexCountZoom; 1588 // } 1589 } 1555 if (doZoomByIndex_) 1556 { 1557 int nbIndexZoom = zoom_i_index.numElements(); 1558 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 ++globalIndexCountZoom; 1566 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1567 // { 1568 // globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1569 // localIndexDomainZoom(globalIndexCountZoom) = i; 1570 // ++globalIndexCountZoom; 1571 // } 1572 } 1573 } 1574 else 1575 { 1576 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 1577 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 1578 for (i = 0; i < nbIndex; ++i) 1579 { 1580 i_ind=i_index(i); 1581 j_ind=j_index(i); 1582 globalIndex = i_ind + j_ind * ni_glo; 1583 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1584 { 1585 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1586 ++globalIndexCountZoom; 1587 } 1588 } 1589 1590 int iend = ibegin + ni -1; 1591 int jend = jbegin + nj -1; 1592 zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin; 1593 int zoom_iend = global_zoom_iend < iend ? zoom_iend : iend ; 1594 zoom_ni = zoom_iend-zoom_ibegin+1 ; 1595 1596 zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin ; 1597 int zoom_jend = global_zoom_jend < jend ? zoom_jend : jend; 1598 zoom_nj = zoom_jend-zoom_jbegin+1; 1599 } 1600 1590 1601 1591 1602 // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); … … 1679 1690 for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 1680 1691 connectedServerRank_.push_back(it->first); 1681 std::vector<size_t> vec = it->second;1682 std::sort(vec.begin(), vec.end());1683 indSrv_[it->first] = vec;1684 } 1685 1686 //indSrv_.swap(globalIndexDomainOnServer);1692 // std::vector<size_t> vec = it->second; 1693 // std::sort(vec.begin(), vec.end()); 1694 // indSrv_[it->first] = vec; 1695 } 1696 1697 indSrv_.swap(globalIndexDomainOnServer); 1687 1698 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 1688 1699 … … 1690 1701 CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1691 1702 // indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1692 std::vector<int> connectedServerZoomRank (indZoomSrv_.size());1703 std::vector<int> connectedServerZoomRank; //(indZoomSrv_.size()); 1693 1704 // for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1694 1705 // connectedServerZoomRank.push_back(it->first); … … 1719 1730 sendDistributionAttributes(); 1720 1731 sendIndex(); 1732 sendIndex(); 1721 1733 sendMask(); 1722 1734 sendLonLat(); … … 1733 1745 int ns, n, i, j, ind, nv, idx; 1734 1746 CContext* context = CContext::getCurrent(); 1747 1735 1748 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1736 1749 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; … … 1776 1789 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1777 1790 list_msgsIndex.back() << isCurvilinear; 1778 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 1779 1791 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back(); 1792 if (!doZoomByIndex_) 1793 { 1794 //list_msgsIndex.back() << zoom_ni.getValue() << zoom_ibegin.getValue() << zoom_nj.getValue() << zoom_jbegin.getValue(); 1795 } 1796 1780 1797 // if (isCompressible_) 1781 1798 // { … … 1798 1815 1799 1816 /*! 1817 Send distribution from client to other clients 1818 Because a client in a level knows correctly the grid distribution of client on the next level 1819 it calculates this distribution then sends it to the corresponding clients on the next level 1820 */ 1821 void CDomain::sendDistributionAttributes(void) 1822 { 1823 CContext* context = CContext::getCurrent(); 1824 // Use correct context client to send message 1825 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1826 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 1827 for (int i = 0; i < nbSrvPools; ++i) 1828 { 1829 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 1830 : context->client; 1831 int nbServer = contextClientTmp->serverSize; 1832 std::vector<int> nGlobDomain(2); 1833 nGlobDomain[0] = this->ni_glo; 1834 nGlobDomain[1] = this->nj_glo; 1835 1836 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1837 if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 1838 else serverDescription.computeServerDistribution(false, 1); 1839 1840 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 1841 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 1842 1843 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 1844 if (contextClientTmp->isServerLeader()) 1845 { 1846 std::list<CMessage> msgs; 1847 1848 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 1849 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1850 { 1851 // Use const int to ensure CMessage holds a copy of the value instead of just a reference 1852 const int ibegin_srv = serverIndexBegin[*itRank][0]; 1853 const int jbegin_srv = serverIndexBegin[*itRank][1]; 1854 const int ni_srv = serverDimensionSizes[*itRank][0]; 1855 const int nj_srv = serverDimensionSizes[*itRank][1]; 1856 1857 msgs.push_back(CMessage()); 1858 CMessage& msg = msgs.back(); 1859 msg << this->getId() ; 1860 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 1861 msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); 1862 msg << isCompressible_; 1863 1864 event.push(*itRank,1,msg); 1865 } 1866 contextClientTmp->sendEvent(event); 1867 } 1868 else contextClientTmp->sendEvent(event); 1869 } 1870 } 1871 1872 /*! 1800 1873 Send mask index from client to connected(s) 1801 1874 */ … … 1804 1877 int ns, n, i, j, ind, nv, idx; 1805 1878 CContext* context = CContext::getCurrent(); 1879 1806 1880 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1807 1881 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; … … 1851 1925 int ns, n, i, j, ind, nv, idx; 1852 1926 CContext* context = CContext::getCurrent(); 1927 1853 1928 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1854 1929 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; … … 1901 1976 int ns, n, i, j, ind, nv, idx; 1902 1977 CContext* context = CContext::getCurrent(); 1978 1903 1979 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1904 1980 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; … … 1986 2062 int ns, n, i, j, ind, nv, idx; 1987 2063 CContext* context = CContext::getCurrent(); 2064 1988 2065 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1989 2066 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; … … 2085 2162 2086 2163 /*! 2087 Receive attributes event from clients(s)2088 \param[in] event event contain info about rank and associated attributes2089 */2090 void CDomain::recvDistributionAttributes(CEventServer& event)2091 {2092 CBufferIn* buffer=event.subEvents.begin()->buffer;2093 string domainId ;2094 *buffer>>domainId ;2095 get(domainId)->recvDistributionAttributes(*buffer) ;2096 }2097 2098 /*!2099 Receive attributes from client(s): zoom info and begin and n of each server2100 \param[in] rank rank of client source2101 \param[in] buffer message containing attributes info2102 */2103 void CDomain::recvDistributionAttributes(CBufferIn& buffer)2104 {2105 int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp;2106 buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp2107 >> isCompressible_;2108 ni.setValue(ni_tmp);2109 ibegin.setValue(ibegin_tmp);2110 nj.setValue(nj_tmp);2111 jbegin.setValue(jbegin_tmp);2112 }2113 2114 /*!2115 2164 Receive index event from clients(s) 2116 2165 \param[in] event event contain info about rank and associated index … … 2151 2200 recvClientRanks_.resize(nbReceived); 2152 2201 vector<CArray<int,1> > recvZoomInd(nbReceived); 2202 int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 2153 2203 2154 2204 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); … … 2158 2208 recvClientRanks_[ind] = it->first; 2159 2209 CBufferIn& buffer = *(it->second); 2160 buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind]; //recvIndGlob[ind]; 2210 buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind] >> doZoomByIndex_; 2211 if (!doZoomByIndex_) 2212 { 2213 //buffer >> ni_zoom_tmp >> ibegin_zoom_tmp >> nj_zoom_tmp >> jbegin_zoom_tmp; 2214 } 2161 2215 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 2162 2216 } … … 2189 2243 } 2190 2244 2191 zoom_i_index.resize(nbZoomInd); 2192 zoom_j_index.resize(nbZoomInd); 2245 if (doZoomByIndex_) 2246 { 2247 zoom_i_index.resize(nbZoomInd); 2248 zoom_j_index.resize(nbZoomInd); 2249 2250 nbZoomInd = 0; 2251 for (i = 0; i < nbReceived; ++i) 2252 { 2253 CArray<int,1>& tmp = recvZoomInd[i]; 2254 for (ind = 0; ind < tmp.numElements(); ++ind) 2255 { 2256 index = tmp(ind); 2257 zoom_i_index(nbZoomInd) = index % ni_glo; 2258 zoom_j_index(nbZoomInd) = index / ni_glo; 2259 ++nbZoomInd; 2260 } 2261 } 2262 } 2263 else 2264 { 2265 // zoom_ni.setValue(ni_zoom_tmp); 2266 // zoom_ibegin.setValue(ibegin_zoom_tmp); 2267 // zoom_nj.setValue(nj_zoom_tmp); 2268 // zoom_jbegin.setValue(jbegin_zoom_tmp); 2269 // int nbZoom = ni_zoom_tmp * nj_zoom_tmp; 2270 // zoom_i_index.resize(nbZoom); 2271 // zoom_j_index.resize(nbZoom); 2272 // nbZoom = 0; 2273 // for (int j = 0; j < nj_zoom_tmp; ++j) 2274 // for (int i = 0; i < ni_zoom_tmp; ++i) 2275 // { 2276 // zoom_i_index(nbZoom) = ibegin_zoom_tmp + i; 2277 // zoom_j_index(nbZoom) = jbegin_zoom_tmp + j; 2278 // ++nbZoom; 2279 // } 2280 } 2281 2282 globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 2283 nbIndGlob = 0; 2284 for (int j = 0; j < nj; ++j) 2285 for (int i = 0; i < ni; ++i) 2286 { 2287 globalLocalIndexMap_[(i + ibegin) + (j + jbegin) * ni_glo] = nbIndGlob; 2288 ++nbIndGlob; 2289 } 2290 2291 2193 2292 2194 nbZoomInd = 0; 2195 for (i = 0; i < nbReceived; ++i) 2196 { 2197 CArray<int,1>& tmp = recvZoomInd[i]; 2198 for (ind = 0; ind < tmp.numElements(); ++ind) 2199 { 2200 index = tmp(ind); 2201 zoom_i_index(nbZoomInd) = index % ni_glo; 2202 zoom_j_index(nbZoomInd) = index / ni_glo; 2203 ++nbZoomInd; 2204 } 2205 } 2206 2207 { 2208 CContextServer* server = CContext::getCurrent()->server; 2209 count_write_index_.resize(2); 2210 start_write_index_.resize(2); 2211 local_write_size_.resize(2); 2212 global_write_size_.resize(2); 2213 if ((this->type) == CDomain::type_attr::unstructured) 2214 { 2215 count_write_index_[0] = zoom_i_index.numElements(); 2216 count_write_index_[1] = 0; 2217 } 2218 else 2219 { 2220 int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 2221 for (idx =0; idx < ni_zoom; ++idx) 2222 { 2223 if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 2224 ++nbIZoom; 2225 if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 2226 ++nbJZoom; 2227 } 2228 count_write_index_[0] = nbIZoom; 2229 count_write_index_[1] = nbJZoom; 2230 2231 // Reoder the zoom_index 2232 for (int j = 0; j < nbJZoom; ++j) 2233 for (int i = 0; i < nbIZoom; ++i) 2234 { 2235 idx = nbIZoom * j + i; 2236 if (idx < ni_zoom) 2237 { 2238 zoom_i_index(idx) = ibegin + i; 2239 zoom_j_index(idx) = jbegin + j; 2240 } 2241 } 2242 2243 // Reorder the global index 2244 for (int j = 0; j < nj; ++j) 2245 for (int i = 0; i < ni; ++i) 2246 { 2247 idx = ni * j + i; 2248 if (idx < nbIndGlob) 2249 { 2250 i_index(idx) = ibegin + i; 2251 j_index(idx) = jbegin + j; 2252 } 2253 } 2254 } 2293 // { 2294 // CContextServer* server = CContext::getCurrent()->server; 2295 // count_write_index_.resize(2); 2296 // start_write_index_.resize(2); 2297 // local_write_size_.resize(2); 2298 // global_write_size_.resize(2); 2299 // if ((this->type) == CDomain::type_attr::unstructured) 2300 // { 2301 // count_write_index_[0] = zoom_i_index.numElements(); 2302 // count_write_index_[1] = 0; 2303 // } 2304 // else 2305 // { 2306 // int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 2307 // for (idx =0; idx < ni_zoom; ++idx) 2308 // { 2309 // if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 2310 // ++nbIZoom; 2311 // if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 2312 // ++nbJZoom; 2313 // } 2314 // count_write_index_[0] = nbIZoom; 2315 // count_write_index_[1] = nbJZoom; 2316 2317 // // Reoder the zoom_index 2318 // for (int j = 0; j < nbJZoom; ++j) 2319 // for (int i = 0; i < nbIZoom; ++i) 2320 // { 2321 // idx = nbIZoom * j + i; 2322 // if (idx < ni_zoom) 2323 // { 2324 // zoom_i_index(idx) = ibegin + i; 2325 // zoom_j_index(idx) = jbegin + j; 2326 // } 2327 // } 2328 2329 // // Reorder the global index 2330 // for (int j = 0; j < nj; ++j) 2331 // for (int i = 0; i < ni; ++i) 2332 // { 2333 // idx = ni * j + i; 2334 // if (idx < nbIndGlob) 2335 // { 2336 // i_index(idx) = ibegin + i; 2337 // j_index(idx) = jbegin + j; 2338 // } 2339 // } 2340 // } 2341 2255 2342 2256 MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 2257 if ((this->type) != CDomain::type_attr::unstructured) 2258 { 2259 start_write_index_[0] = 0; 2260 start_write_index_[1] -= count_write_index_[1]; 2261 } 2262 else 2263 { 2264 start_write_index_[0] -= count_write_index_[0]; 2265 } 2266 local_write_size_[0] = count_write_index_[0]; 2267 local_write_size_[1] = count_write_index_[1]; 2268 MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 2269 if ((this->type) != CDomain::type_attr::unstructured) 2270 { 2271 global_write_size_[0] = count_write_index_[0]; 2272 global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 2273 } 2274 } 2343 // MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 2344 // start_write_index_[0] = 0; 2345 // start_write_index_[1] -= count_write_index_[1]; 2346 // local_write_size_[0] = count_write_index_[0]; 2347 // local_write_size_[1] = count_write_index_[1]; 2348 // MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 2349 // global_write_size_[0] = count_write_index_[0]; 2350 // global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 2351 2352 2353 // } 2275 2354 2276 2355 // int type_int; … … 2289 2368 2290 2369 /*! 2370 Receive attributes event from clients(s) 2371 \param[in] event event contain info about rank and associated attributes 2372 */ 2373 void CDomain::recvDistributionAttributes(CEventServer& event) 2374 { 2375 CBufferIn* buffer=event.subEvents.begin()->buffer; 2376 string domainId ; 2377 *buffer>>domainId ; 2378 get(domainId)->recvDistributionAttributes(*buffer); 2379 } 2380 2381 /*! 2382 Receive attributes from client(s): zoom info and begin and n of each server 2383 \param[in] rank rank of client source 2384 \param[in] buffer message containing attributes info 2385 */ 2386 void CDomain::recvDistributionAttributes(CBufferIn& buffer) 2387 { 2388 int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 2389 int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 2390 buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp 2391 >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp 2392 >> isCompressible_; 2393 ni.setValue(ni_tmp); 2394 ibegin.setValue(ibegin_tmp); 2395 nj.setValue(nj_tmp); 2396 jbegin.setValue(jbegin_tmp); 2397 2398 global_zoom_ni.setValue(global_zoom_ni_tmp); 2399 global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 2400 global_zoom_nj.setValue(global_zoom_nj_tmp); 2401 global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 2402 2403 int iend = ibegin + ni - 1; 2404 int jend = jbegin + nj - 1; 2405 int zoom_iend_glob = global_zoom_ibegin + global_zoom_ni - 1; 2406 int zoom_jend_glob = global_zoom_jbegin + global_zoom_nj - 1; 2407 2408 zoom_ibegin.setValue(global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin); 2409 int zoom_iend = zoom_iend_glob < iend ? zoom_iend_glob : iend ; 2410 zoom_ni.setValue(zoom_iend-zoom_ibegin+1); 2411 2412 zoom_jbegin.setValue(global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin); 2413 int zoom_jend = zoom_jend_glob < jend ? zoom_jend_glob : jend ; 2414 zoom_nj.setValue(zoom_jend-zoom_jbegin+1); 2415 2416 if (zoom_ni<=0 || zoom_nj<=0) 2417 { 2418 zoom_ibegin=0 ; zoom_iend=0 ; zoom_ni=0 ; 2419 zoom_jbegin=0 ; zoom_jend=0 ; zoom_nj=0 ; 2420 } 2421 2422 } 2423 2424 /*! 2291 2425 Receive area event from clients(s) 2292 2426 \param[in] event event contain info about rank and associated area … … 2372 2506 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 2373 2507 { 2374 int nbReceived = rankBuffers.size(), i, ind, index ;2508 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex; 2375 2509 if (nbReceived != recvClientRanks_.size()) 2376 2510 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", … … 2391 2525 } 2392 2526 2393 int nbLonInd = 0; 2527 lonvalue.resize(zoom_ni*zoom_nj); 2528 lonvalue = 0; 2529 2530 if (hasBounds) 2531 { 2532 bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); 2533 bounds_lonvalue = 0.; 2534 } 2535 2394 2536 for (i = 0; i < nbReceived; ++i) 2395 2537 { 2396 nbLonInd += recvLonValue[i].numElements(); 2397 } 2398 2399 lonvalue.resize(nbLonInd); 2400 if (hasBounds) 2401 { 2402 bounds_lonvalue.resize(nvertex, nbLonInd); 2403 } 2404 2405 nbLonInd = 0; 2406 for (i = 0; i < nbReceived; ++i) 2407 { 2408 CArray<double,1>& tmp = recvLonValue[i]; 2409 for (ind = 0; ind < tmp.numElements(); ++ind) 2410 { 2411 lonvalue(nbLonInd) = tmp(ind); 2538 int rank = recvClientRanks_[i]; 2539 CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2540 for (ind = 0; ind < indi.numElements(); ++ind) 2541 { 2542 iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2543 index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2544 lonvalue(index) = recvLonValue[i](ind); 2412 2545 if (hasBounds) 2413 { 2414 CArray<double,2>& tmpBnds = recvBoundsLonValue[i]; 2546 { 2415 2547 for (int nv = 0; nv < nvertex; ++nv) 2416 bounds_lonvalue(nv, nbLonInd) = tmpBnds(nv, ind); 2417 } 2418 ++nbLonInd; 2548 bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); 2549 } 2419 2550 } 2420 2551 } … … 2446 2577 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 2447 2578 { 2448 int nbReceived = rankBuffers.size(), i, ind, index ;2579 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex; 2449 2580 if (nbReceived != recvClientRanks_.size()) 2450 2581 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", … … 2465 2596 } 2466 2597 2467 int nbLatInd = 0; 2598 latvalue.resize(zoom_ni*zoom_nj); 2599 latvalue = 0; 2600 2601 if (hasBounds) 2602 { 2603 bounds_latvalue.resize(nvertex,zoom_ni*zoom_nj); 2604 bounds_latvalue = 0. ; 2605 } 2606 2468 2607 for (i = 0; i < nbReceived; ++i) 2469 2608 { 2470 nbLatInd += recvLatValue[i].numElements(); 2471 } 2472 2473 latvalue.resize(nbLatInd); 2474 if (hasBounds) 2475 { 2476 bounds_latvalue.resize(nvertex, nbLatInd); 2477 } 2478 2479 nbLatInd = 0; 2480 for (i = 0; i < nbReceived; ++i) 2481 { 2482 CArray<double,1>& tmp = recvLatValue[i]; 2483 for (ind = 0; ind < tmp.numElements(); ++ind) 2484 { 2485 latvalue(nbLatInd) = tmp(ind); 2609 int rank = recvClientRanks_[i]; 2610 CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 2611 CArray<double,1>& lat = recvLatValue[i]; 2612 for (ind = 0; ind < indi.numElements(); ++ind) 2613 { 2614 iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 2615 index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 2616 latvalue(index) = lat(ind); 2486 2617 if (hasBounds) 2487 2618 { 2488 CArray<double,2>& tmpBnds= recvBoundsLatValue[i];2619 CArray<double,2>& boundslat = recvBoundsLatValue[i]; 2489 2620 for (int nv = 0; nv < nvertex; ++nv) 2490 bounds_latvalue(nv, nbLatInd) = tmpBnds(nv, ind); 2491 } 2492 ++nbLatInd; 2621 bounds_latvalue(nv, index) = boundslat(nv, ind); 2622 } 2493 2623 } 2494 2624 }
Note: See TracChangeset
for help on using the changeset viewer.