Changeset 1646 for XIOS/dev/dev_trunk_omp/src/node/domain.cpp
- Timestamp:
- 01/31/19 12:12:52 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_omp/src/node/domain.cpp
r1601 r1646 19 19 #include "client_server_mapping_distributed.hpp" 20 20 21 #ifdef _usingEP 21 22 using namespace ep_lib; 23 #endif 22 24 23 25 #include <algorithm> … … 60 62 61 63 void CDomain::assignMesh(const StdString meshName, const int nvertex) 64 TRY 62 65 { 63 66 mesh = CMesh::getMesh(meshName, nvertex); 64 67 } 68 CATCH_DUMP_ATTR 65 69 66 70 CDomain* CDomain::createDomain() 71 TRY 67 72 { 68 73 CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); 69 74 return domain; 70 75 } 76 CATCH 71 77 72 78 std::map<StdString, ETranformationType> *CDomain::transformationMapList_ptr = 0; 73 79 74 80 bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 81 TRY 75 82 { 76 83 m["zoom_domain"] = TRANS_ZOOM_DOMAIN; … … 82 89 m["extract_domain"] = TRANS_EXTRACT_DOMAIN; 83 90 } 91 CATCH 84 92 85 93 bool CDomain::initializeTransformationMap() 94 TRY 86 95 { 87 96 CDomain::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); … … 94 103 (*CDomain::transformationMapList_ptr)["extract_domain"] = TRANS_EXTRACT_DOMAIN; 95 104 } 105 CATCH 96 106 97 107 const std::set<StdString> & CDomain::getRelFiles(void) const 108 TRY 98 109 { 99 110 return (this->relFiles); 100 111 } 101 112 CATCH 102 113 103 114 /*! … … 106 117 */ 107 118 int CDomain::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 119 TRY 108 120 { 109 121 int writtenSize; … … 111 123 return numberWrittenIndexes_[writtenSize]; 112 124 } 125 CATCH_DUMP_ATTR 113 126 114 127 /*! … … 117 130 */ 118 131 int CDomain::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 132 TRY 119 133 { 120 134 int writtenSize; … … 122 136 return totalNumberWrittenIndexes_[writtenSize]; 123 137 } 138 CATCH_DUMP_ATTR 124 139 125 140 /*! … … 128 143 */ 129 144 int CDomain::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 145 TRY 130 146 { 131 147 int writtenSize; … … 133 149 return offsetWrittenIndexes_[writtenSize]; 134 150 } 151 CATCH_DUMP_ATTR 135 152 136 153 CArray<int, 1>& CDomain::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 154 TRY 137 155 { 138 156 int writtenSize; … … 140 158 return compressedIndexToWriteOnServer[writtenSize]; 141 159 } 160 CATCH_DUMP_ATTR 142 161 143 162 //---------------------------------------------------------------- … … 149 168 */ 150 169 std::map<int, StdSize> CDomain::getAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= false*/) 170 TRY 151 171 { 152 172 … … 176 196 // size estimation for sendIndex (and sendArea which is always smaller or equal) 177 197 size_t sizeIndexEvent = 2 * sizeof(size_t) + 2 * CArray<int,1>::size(idxCount); 178 // if (isCompressible_)179 // {180 // std::map<int, std::vector<int> >::const_iterator itWritten = indWrittenSrv_.find(rank);181 // size_t writtenIdxCount = (itWritten != itWrittenIndexEnd) ? itWritten->second.size() : 0;182 // sizeIndexEvent += CArray<int,1>::size(writtenIdxCount);183 // }184 198 185 199 // size estimation for sendLonLat … … 195 209 return attributesSizes; 196 210 } 211 CATCH_DUMP_ATTR 197 212 198 213 //---------------------------------------------------------------- 199 214 200 215 bool CDomain::isEmpty(void) const 216 TRY 201 217 { 202 218 return ((this->i_index.isEmpty()) || (0 == this->i_index.numElements())); 203 219 } 220 CATCH 204 221 205 222 //---------------------------------------------------------------- 206 223 207 224 bool CDomain::IsWritten(const StdString & filename) const 225 TRY 208 226 { 209 227 return (this->relFiles.find(filename) != this->relFiles.end()); 210 228 } 229 CATCH 211 230 212 231 bool CDomain::isWrittenCompressed(const StdString& filename) const 232 TRY 213 233 { 214 234 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 215 235 } 236 CATCH 216 237 217 238 //---------------------------------------------------------------- 218 239 219 240 bool CDomain::isDistributed(void) const 241 TRY 220 242 { 221 243 bool distributed = !((!ni.isEmpty() && (ni == ni_glo) && !nj.isEmpty() && (nj == nj_glo)) || … … 225 247 return distributed; 226 248 } 249 CATCH 227 250 228 251 //---------------------------------------------------------------- … … 234 257 */ 235 258 bool CDomain::isCompressible(void) const 259 TRY 236 260 { 237 261 return isCompressible_; 238 262 } 263 CATCH 239 264 240 265 void CDomain::addRelFile(const StdString & filename) 266 TRY 241 267 { 242 268 this->relFiles.insert(filename); 243 269 } 270 CATCH_DUMP_ATTR 244 271 245 272 void CDomain::addRelFileCompressed(const StdString& filename) 273 TRY 246 274 { 247 275 this->relFilesCompressed.insert(filename); 248 276 } 277 CATCH_DUMP_ATTR 249 278 250 279 StdString CDomain::GetName(void) { return (StdString("domain")); } … … 259 288 */ 260 289 bool CDomain::distributionAttributesHaveValue() const 290 TRY 261 291 { 262 292 bool hasValues = true; … … 270 300 return hasValues; 271 301 } 302 CATCH 272 303 273 304 /*! … … 279 310 */ 280 311 void CDomain::redistribute(int nbLocalDomain) 312 TRY 281 313 { 282 314 if (this->isRedistributed_) return; … … 441 473 checkDomain(); 442 474 } 475 CATCH_DUMP_ATTR 443 476 444 477 /*! … … 446 479 */ 447 480 void CDomain::fillInLonLat() 481 TRY 448 482 { 449 483 switch (type) … … 463 497 } 464 498 completeLonLatClient() ; 465 466 }499 } 500 CATCH_DUMP_ATTR 467 501 468 502 /*! … … 472 506 */ 473 507 void CDomain::fillInRectilinearLonLat() 508 TRY 474 509 { 475 510 if (!lonvalue_rectilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) … … 540 575 } 541 576 } 577 CATCH_DUMP_ATTR 542 578 543 579 /* … … 546 582 */ 547 583 void CDomain::fillInCurvilinearLonLat() 584 TRY 548 585 { 549 586 if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty() && lonvalue_1d.isEmpty()) … … 588 625 bounds_latvalue_curvilinear_read_from_file.free(); 589 626 } 590 591 }627 } 628 CATCH_DUMP_ATTR 592 629 593 630 /* … … 596 633 */ 597 634 void CDomain::fillInUnstructuredLonLat() 635 TRY 598 636 { 599 637 if (i_index.isEmpty()) … … 647 685 } 648 686 } 687 CATCH_DUMP_ATTR 649 688 650 689 /* … … 652 691 */ 653 692 void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) 693 TRY 654 694 { 655 695 CContext* context = CContext::getCurrent(); … … 683 723 delete[] nj_g ; 684 724 } 725 CATCH_DUMP_ATTR 685 726 686 727 void CDomain::fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 687 728 CArray<double,2>& boundsLon, CArray<double,2>& boundsLat) 688 { 729 TRY 730 { 689 731 int i,j,k; 690 732 … … 785 827 } 786 828 } 829 CATCH_DUMP_ATTR 787 830 788 831 /* … … 790 833 */ 791 834 void CDomain::checkDomain(void) 835 TRY 792 836 { 793 837 if (type.isEmpty()) … … 881 925 } 882 926 } 927 CATCH_DUMP_ATTR 883 928 884 929 size_t CDomain::getGlobalWrittenSize(void) … … 890 935 // Check validity of local domain on using the combination of 3 parameters: ibegin, ni and i_index 891 936 void CDomain::checkLocalIDomain(void) 937 TRY 892 938 { 893 939 // If ibegin and ni are provided then we use them to check the validity of local domain … … 948 994 } 949 995 } 996 CATCH_DUMP_ATTR 950 997 951 998 // Check validity of local domain on using the combination of 3 parameters: jbegin, nj and j_index 952 999 void CDomain::checkLocalJDomain(void) 1000 TRY 953 1001 { 954 1002 // If jbegin and nj are provided then we use them to check the validity of local domain … … 999 1047 } 1000 1048 } 1049 CATCH_DUMP_ATTR 1001 1050 1002 1051 //---------------------------------------------------------------- 1003 1052 1004 1053 void CDomain::checkMask(void) 1054 TRY 1005 1055 { 1006 1056 if (!mask_1d.isEmpty() && !mask_2d.isEmpty()) … … 1048 1098 } 1049 1099 } 1100 CATCH_DUMP_ATTR 1050 1101 1051 1102 //---------------------------------------------------------------- 1052 1103 1053 1104 void CDomain::checkDomainData(void) 1105 TRY 1054 1106 { 1055 1107 if (data_dim.isEmpty()) … … 1091 1143 } 1092 1144 } 1145 CATCH_DUMP_ATTR 1093 1146 1094 1147 //---------------------------------------------------------------- 1095 1148 1096 1149 void CDomain::checkCompression(void) 1097 { 1150 TRY 1151 { 1152 int i,j,ind; 1098 1153 if (!data_i_index.isEmpty()) 1099 1154 { … … 1116 1171 << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); 1117 1172 } 1173 for (int k=0; k<data_i_index.numElements(); ++k) 1174 { 1175 i = data_i_index(k)+data_ibegin ; 1176 j = data_j_index(k)+data_jbegin ; 1177 if (i>=0 && i<ni && j>=0 && j<nj) 1178 { 1179 ind=j*ni+i ; 1180 if (!domainMask(ind)) 1181 { 1182 data_i_index(k) = -1; 1183 data_j_index(k) = -1; 1184 } 1185 } 1186 else 1187 { 1188 data_i_index(k) = -1; 1189 data_j_index(k) = -1; 1190 } 1191 } 1118 1192 } 1119 1193 else // (1 == data_dim) … … 1122 1196 { 1123 1197 data_j_index.resize(data_ni); 1124 for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; 1198 data_j_index = 0; 1199 } 1200 for (int k=0; k<data_i_index.numElements(); ++k) 1201 { 1202 i=data_i_index(k)+data_ibegin ; 1203 if (i>=0 && i < domainMask.size()) 1204 { 1205 if (!domainMask(i)) data_i_index(k) = -1; 1206 } 1207 else 1208 data_i_index(k) = -1; 1209 1210 if (!domainMask(i)) data_i_index(k) = -1; 1125 1211 } 1126 1212 } … … 1137 1223 data_i_index.resize(data_ni); 1138 1224 data_j_index.resize(data_ni); 1139 1140 for (int i = 0; i < data_ni; ++i) 1225 data_j_index = 0; 1226 1227 for (int k = 0; k < data_ni; ++k) 1141 1228 { 1142 data_i_index(i) = i; 1143 data_j_index(i) = 0; 1229 i=k+data_ibegin ; 1230 if (i>=0 && i < domainMask.size()) 1231 { 1232 if (domainMask(i)) 1233 data_i_index(k) = k; 1234 else 1235 data_i_index(k) = -1; 1236 } 1237 else 1238 data_i_index(k) = -1; 1144 1239 } 1145 1240 } … … 1150 1245 data_j_index.resize(dsize); 1151 1246 1152 for(int count = 0, j = 0; j < data_nj; ++j)1247 for(int count = 0, kj = 0; kj < data_nj; ++kj) 1153 1248 { 1154 for(int i = 0; i < data_ni; ++i, ++count)1249 for(int ki = 0; ki < data_ni; ++ki, ++count) 1155 1250 { 1156 data_i_index(count) = i; 1157 data_j_index(count) = j; 1251 i = ki + data_ibegin; 1252 j = kj + data_jbegin; 1253 ind=j*ni+i ; 1254 if (i>=0 && i<ni && j>=0 && j<nj) 1255 { 1256 if (domainMask(ind)) 1257 { 1258 data_i_index(count) = ki; 1259 data_j_index(count) = kj; 1260 } 1261 else 1262 { 1263 data_i_index(count) = -1; 1264 data_j_index(count) = -1; 1265 } 1266 } 1267 else 1268 { 1269 data_i_index(count) = -1; 1270 data_j_index(count) = -1; 1271 } 1158 1272 } 1159 1273 } … … 1161 1275 } 1162 1276 } 1277 CATCH_DUMP_ATTR 1163 1278 1164 1279 //---------------------------------------------------------------- 1165 1280 void CDomain::computeLocalMask(void) 1281 TRY 1166 1282 { 1167 1283 localMask.resize(i_index.numElements()) ; … … 1195 1311 } 1196 1312 } 1313 CATCH_DUMP_ATTR 1197 1314 1198 1315 void CDomain::checkEligibilityForCompressedOutput(void) 1316 TRY 1199 1317 { 1200 1318 // We don't check if the mask or the indexes are valid here, just if they have been defined at this point. 1201 1319 isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !data_i_index.isEmpty(); 1202 1320 } 1321 CATCH_DUMP_ATTR 1203 1322 1204 1323 //---------------------------------------------------------------- … … 1209 1328 */ 1210 1329 void CDomain::completeLonLatClient(void) 1330 TRY 1211 1331 { 1212 1332 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); … … 1322 1442 } 1323 1443 } 1444 CATCH_DUMP_ATTR 1324 1445 1325 1446 /* … … 1327 1448 */ 1328 1449 void CDomain::convertLonLatValue(void) 1450 TRY 1329 1451 { 1330 1452 bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); … … 1424 1546 } 1425 1547 } 1426 1548 CATCH_DUMP_ATTR 1427 1549 1428 1550 void CDomain::checkBounds(void) 1551 TRY 1429 1552 { 1430 1553 bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); … … 1518 1641 } 1519 1642 } 1643 CATCH_DUMP_ATTR 1520 1644 1521 1645 void CDomain::checkArea(void) 1646 TRY 1522 1647 { 1523 1648 bool hasAreaValue = (!areavalue.isEmpty() && 0 != areavalue.numElements()); … … 1547 1672 } 1548 1673 } 1674 CATCH_DUMP_ATTR 1549 1675 1550 1676 void CDomain::checkLonLat() 1677 TRY 1551 1678 { 1552 1679 if (!hasLonLat) hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || … … 1608 1735 } 1609 1736 } 1737 CATCH_DUMP_ATTR 1610 1738 1611 1739 void CDomain::checkAttributesOnClientAfterTransformation() 1740 TRY 1612 1741 { 1613 1742 CContext* context=CContext::getCurrent() ; … … 1624 1753 this->isClientAfterTransformationChecked = true; 1625 1754 } 1755 CATCH_DUMP_ATTR 1626 1756 1627 1757 //---------------------------------------------------------------- … … 1629 1759 // This function only checks all attributes of current domain 1630 1760 void CDomain::checkAttributesOnClient() 1761 TRY 1631 1762 { 1632 1763 if (this->isClientChecked) return; … … 1654 1785 this->isClientChecked = true; 1655 1786 } 1787 CATCH_DUMP_ATTR 1656 1788 1657 1789 // Send all checked attributes to server 1658 1790 void CDomain::sendCheckedAttributes() 1791 TRY 1659 1792 { 1660 1793 if (!this->isClientChecked) checkAttributesOnClient(); … … 1669 1802 this->isChecked = true; 1670 1803 } 1804 CATCH_DUMP_ATTR 1671 1805 1672 1806 void CDomain::checkAttributes(void) 1807 TRY 1673 1808 { 1674 1809 if (this->isChecked) return; … … 1700 1835 this->isChecked = true; 1701 1836 } 1837 CATCH_DUMP_ATTR 1702 1838 1703 1839 /*! … … 1708 1844 */ 1709 1845 void CDomain::computeConnectedClients() 1846 TRY 1710 1847 { 1711 1848 CContext* context=CContext::getCurrent() ; … … 1806 1943 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 1807 1944 1945 // Now check if all servers have data to receive. If not, master client will send empty data. 1946 // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 1947 std::vector<int> counts (clientSize); 1948 std::vector<int> displs (clientSize); 1949 displs[0] = 0; 1950 int localCount = connectedServerRank_[nbServer].size() ; 1951 ep_lib::MPI_Gather(&localCount, 1, MPI_INT, &counts[0], 1, MPI_INT, 0, client->intraComm) ; 1952 for (int i = 0; i < clientSize-1; ++i) 1953 { 1954 displs[i+1] = displs[i] + counts[i]; 1955 } 1956 std::vector<int> allConnectedServers(displs[clientSize-1]+counts[clientSize-1]); 1957 1958 ep_lib::MPI_Gatherv(&(connectedServerRank_[nbServer])[0], localCount, MPI_INT, &allConnectedServers[0], &counts[0], &displs[0], MPI_INT, 0, client->intraComm); 1959 1960 1961 if ((allConnectedServers.size() != nbServer) && (rank == 0)) 1962 { 1963 std::vector<bool> isSrvConnected (nbServer, false); 1964 for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 1965 for (int i = 0; i < nbServer; ++i) 1966 { 1967 if (!isSrvConnected[i]) connectedServerRank_[nbServer].push_back(i); 1968 } 1969 } 1808 1970 nbSenders[nbServer] = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 1809 1971 delete clientServerMap; … … 1812 1974 } 1813 1975 } 1976 CATCH_DUMP_ATTR 1814 1977 1815 1978 /*! … … 1819 1982 */ 1820 1983 void CDomain::computeWrittenIndex() 1984 TRY 1821 1985 { 1822 1986 if (computedWrittenIndex_) return; … … 1840 2004 itSrve = writtenGlobalIndex.end(), itSrv; 1841 2005 1842 // for (itSrv = itSrvb; itSrv != itSrve; ++itSrv)1843 // {1844 // indGlo = *itSrv;1845 // if (ite != globalLocalIndexMap_.find(indGlo))1846 // {1847 // ++nbWritten;1848 // }1849 // }1850 1851 // localIndexToWriteOnServer.resize(nbWritten);1852 2006 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 1853 1854 2007 nbWritten = 0; 1855 2008 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) … … 1859 2012 { 1860 2013 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 1861 ++nbWritten;1862 2014 } 1863 2015 else 1864 2016 { 1865 localIndexToWriteOnServer(nbWritten) = 0; 1866 ++nbWritten; 1867 } 1868 } 1869 1870 // if (isCompressible()) 1871 // { 1872 // nbWritten = 0; 1873 // std::unordered_map<size_t,size_t> localGlobalIndexMap; 1874 // for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 1875 // { 1876 // indGlo = *itSrv; 1877 // if (ite != globalLocalIndexMap_.find(indGlo)) 1878 // { 1879 // localGlobalIndexMap[localIndexToWriteOnServer(nbWritten)] = indGlo; 1880 // ++nbWritten; 1881 // } 1882 // } 1883 1884 // nbWritten = 0; 1885 // for (int idx = 0; idx < data_i_index.numElements(); ++idx) 1886 // { 1887 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) 1888 // { 1889 // ++nbWritten; 1890 // } 1891 // } 1892 1893 // compressedIndexToWriteOnServer.resize(nbWritten); 1894 // nbWritten = 0; 1895 // for (int idx = 0; idx < data_i_index.numElements(); ++idx) 1896 // { 1897 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_i_index(idx))) 1898 // { 1899 // compressedIndexToWriteOnServer(nbWritten) = localGlobalIndexMap[data_i_index(idx)]; 1900 // ++nbWritten; 1901 // } 1902 // } 1903 1904 // numberWrittenIndexes_ = nbWritten; 1905 // if (isDistributed()) 1906 // { 1907 // MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 1908 // MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 1909 // offsetWrittenIndexes_ -= numberWrittenIndexes_; 1910 // } 1911 // else 1912 // totalNumberWrittenIndexes_ = numberWrittenIndexes_; 1913 // } 1914 } 2017 localIndexToWriteOnServer(nbWritten) = -1; 2018 } 2019 ++nbWritten; 2020 } 2021 } 2022 CATCH_DUMP_ATTR 1915 2023 1916 2024 void CDomain::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 2025 TRY 1917 2026 { 1918 2027 int writtenCommSize; … … 1982 2091 } 1983 2092 } 2093 CATCH_DUMP_ATTR 1984 2094 1985 2095 /*! … … 1988 2098 */ 1989 2099 void CDomain::sendAttributes() 2100 TRY 1990 2101 { 1991 2102 sendDistributionAttributes(); 1992 2103 sendIndex(); 1993 sendMask();1994 2104 sendLonLat(); 1995 2105 sendArea(); 1996 2106 sendDataIndex(); 1997 2107 } 1998 2108 CATCH 1999 2109 /*! 2000 2110 Send global index from client to connected client(s) 2001 2111 */ 2002 2112 void CDomain::sendIndex() 2113 TRY 2003 2114 { 2004 2115 int ns, n, i, j, ind, nv, idx; … … 2043 2154 } 2044 2155 } 2156 CATCH_DUMP_ATTR 2045 2157 2046 2158 /*! … … 2050 2162 */ 2051 2163 void CDomain::sendDistributionAttributes(void) 2164 TRY 2052 2165 { 2053 2166 std::list<CContextClient*>::iterator it; … … 2096 2209 } 2097 2210 } 2098 2099 /*! 2100 Send mask index from client to connected(s) clients 2101 */ 2102 void CDomain::sendMask() 2103 { 2104 int ns, n, i, j, ind, nv, idx; 2105 std::list<CContextClient*>::iterator it; 2106 for (it=clients.begin(); it!=clients.end(); ++it) 2107 { 2108 CContextClient* client = *it; 2109 int serverSize = client->serverSize; 2110 2111 // send area for each connected server 2112 CEventClient eventMask(getType(), EVENT_ID_MASK); 2113 2114 list<CMessage> list_msgsMask; 2115 list<CArray<bool,1> > list_mask; 2116 2117 std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 2118 iteMap = indSrv_[serverSize].end(); 2119 for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 2120 { 2121 int nbData = 0; 2122 int rank = connectedServerRank_[serverSize][k]; 2123 it = indSrv_[serverSize].find(rank); 2124 if (iteMap != it) 2125 nbData = it->second.size(); 2126 list_mask.push_back(CArray<bool,1>(nbData)); 2127 2128 const std::vector<size_t>& temp = it->second; 2129 for (n = 0; n < nbData; ++n) 2130 { 2131 idx = static_cast<int>(it->second[n]); 2132 list_mask.back()(n) = domainMask(globalLocalIndexMap_[idx]); 2133 } 2134 2135 list_msgsMask.push_back(CMessage()); 2136 list_msgsMask.back() << this->getId() << list_mask.back(); 2137 eventMask.push(rank, nbSenders[serverSize][rank], list_msgsMask.back()); 2138 } 2139 client->sendEvent(eventMask); 2140 } 2141 } 2211 CATCH_DUMP_ATTR 2142 2212 2143 2213 /*! … … 2145 2215 */ 2146 2216 void CDomain::sendArea() 2217 TRY 2147 2218 { 2148 2219 if (!hasArea) return; … … 2188 2259 } 2189 2260 } 2261 CATCH_DUMP_ATTR 2190 2262 2191 2263 /*! … … 2195 2267 */ 2196 2268 void CDomain::sendLonLat() 2269 TRY 2197 2270 { 2198 2271 if (!hasLonLat) return; … … 2283 2356 } 2284 2357 } 2358 CATCH_DUMP_ATTR 2285 2359 2286 2360 /*! … … 2291 2365 */ 2292 2366 void CDomain::sendDataIndex() 2367 TRY 2293 2368 { 2294 2369 int ns, n, i, j, ind, nv, idx; … … 2359 2434 } 2360 2435 } 2436 CATCH 2361 2437 2362 2438 bool CDomain::dispatchEvent(CEventServer& event) 2439 TRY 2363 2440 { 2364 2441 if (SuperClass::dispatchEvent(event)) return true; … … 2373 2450 case EVENT_ID_INDEX: 2374 2451 recvIndex(event); 2375 return true;2376 break;2377 case EVENT_ID_MASK:2378 recvMask(event);2379 2452 return true; 2380 2453 break; … … 2402 2475 } 2403 2476 } 2477 CATCH 2404 2478 2405 2479 /*! … … 2408 2482 */ 2409 2483 void CDomain::recvIndex(CEventServer& event) 2484 TRY 2410 2485 { 2411 2486 string domainId; … … 2421 2496 get(domainId)->recvIndex(rankBuffers); 2422 2497 } 2498 CATCH 2423 2499 2424 2500 /*! … … 2428 2504 */ 2429 2505 void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 2506 TRY 2430 2507 { 2431 2508 int nbReceived = rankBuffers.size(), i, ind, index, type_int, iIndex, jIndex; … … 2466 2543 jIndex = (jIndex < 0) ? 0 : jIndex; 2467 2544 nbIndLoc = iIndex + ni * jIndex; 2468 if (nbIndLoc < nbIndexGlobMax) 2469 { 2470 i_index(nbIndLoc) = index % ni_glo; 2471 j_index(nbIndLoc) = index / ni_glo; 2472 globalLocalIndexMap_[index] = nbIndLoc; 2473 ++nbIndGlob; 2474 } 2475 // i_index(nbIndGlob) = index % ni_glo; 2476 // j_index(nbIndGlob) = index / ni_glo; 2477 // globalLocalIndexMap_[index] = nbIndGlob; 2478 // ++nbIndGlob; 2545 i_index(nbIndGlob) = index % ni_glo; 2546 j_index(nbIndGlob) = index / ni_glo; 2547 globalLocalIndexMap_[index] = nbIndGlob; 2548 ++nbIndGlob; 2479 2549 } 2480 2550 } … … 2491 2561 j_index.resizeAndPreserve(nbIndGlob); 2492 2562 } 2563 2564 domainMask.resize(0); // Mask is not defined anymore on servers 2493 2565 } 2566 CATCH 2494 2567 2495 2568 /*! … … 2498 2571 */ 2499 2572 void CDomain::recvDistributionAttributes(CEventServer& event) 2573 TRY 2500 2574 { 2501 2575 CBufferIn* buffer=event.subEvents.begin()->buffer; … … 2504 2578 get(domainId)->recvDistributionAttributes(*buffer); 2505 2579 } 2580 CATCH 2506 2581 2507 2582 /*! … … 2511 2586 */ 2512 2587 void CDomain::recvDistributionAttributes(CBufferIn& buffer) 2588 TRY 2513 2589 { 2514 2590 int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; … … 2526 2602 2527 2603 } 2528 2529 /*! 2530 Receive area event from clients(s) 2531 \param[in] event event contain info about rank and associated area 2532 */ 2533 void CDomain::recvMask(CEventServer& event) 2534 { 2535 string domainId; 2536 std::map<int, CBufferIn*> rankBuffers; 2537 2538 list<CEventServer::SSubEvent>::iterator it; 2539 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2540 { 2541 CBufferIn* buffer = it->buffer; 2542 *buffer >> domainId; 2543 rankBuffers[it->rank] = buffer; 2544 } 2545 get(domainId)->recvMask(rankBuffers); 2546 } 2547 2548 2549 /*! 2550 Receive mask information from client(s) 2551 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2552 */ 2553 void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 2554 { 2555 int nbReceived = rankBuffers.size(), i, ind, index, lInd; 2556 if (nbReceived != recvClientRanks_.size()) 2557 ERROR("void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers)", 2558 << "The number of sending clients is not correct." 2559 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2560 2561 vector<CArray<bool,1> > recvMaskValue(nbReceived); 2562 for (i = 0; i < recvClientRanks_.size(); ++i) 2563 { 2564 int rank = recvClientRanks_[i]; 2565 CBufferIn& buffer = *(rankBuffers[rank]); 2566 buffer >> recvMaskValue[i]; 2567 } 2568 2569 int nbMaskInd = 0; 2570 for (i = 0; i < nbReceived; ++i) 2571 { 2572 nbMaskInd += recvMaskValue[i].numElements(); 2573 } 2574 2575 if (nbMaskInd != globalLocalIndexMap_.size()) 2576 info (0) << "If domain " << this->getDomainOutputName() <<" does not have overlapped regions between processes " 2577 << "something must be wrong with mask index "<< std::endl; 2578 2579 nbMaskInd = globalLocalIndexMap_.size(); 2580 mask_1d.resize(nbMaskInd); 2581 domainMask.resize(nbMaskInd); 2582 mask_1d = false; 2583 2584 for (i = 0; i < nbReceived; ++i) 2585 { 2586 CArray<int,1>& tmpInd = indGlob_[recvClientRanks_[i]]; 2587 CArray<bool,1>& tmp = recvMaskValue[i]; 2588 for (ind = 0; ind < tmp.numElements(); ++ind) 2589 { 2590 lInd = globalLocalIndexMap_[size_t(tmpInd(ind))]; 2591 if (!mask_1d(lInd)) // Only rewrite mask_1d if it's not true 2592 mask_1d(lInd) = tmp(ind); 2593 } 2594 } 2595 domainMask=mask_1d ; 2596 } 2597 2604 CATCH_DUMP_ATTR 2598 2605 /*! 2599 2606 Receive longitude event from clients(s) … … 2601 2608 */ 2602 2609 void CDomain::recvLon(CEventServer& event) 2610 TRY 2603 2611 { 2604 2612 string domainId; … … 2614 2622 get(domainId)->recvLon(rankBuffers); 2615 2623 } 2624 CATCH 2616 2625 2617 2626 /*! … … 2620 2629 */ 2621 2630 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 2631 TRY 2622 2632 { 2623 2633 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; … … 2679 2689 } 2680 2690 } 2691 CATCH_DUMP_ATTR 2681 2692 2682 2693 /*! … … 2685 2696 */ 2686 2697 void CDomain::recvLat(CEventServer& event) 2698 TRY 2687 2699 { 2688 2700 string domainId; … … 2698 2710 get(domainId)->recvLat(rankBuffers); 2699 2711 } 2712 CATCH 2700 2713 2701 2714 /*! … … 2704 2717 */ 2705 2718 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 2719 TRY 2706 2720 { 2707 2721 int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex, lInd; … … 2765 2779 } 2766 2780 } 2781 CATCH_DUMP_ATTR 2767 2782 2768 2783 /*! … … 2771 2786 */ 2772 2787 void CDomain::recvArea(CEventServer& event) 2788 TRY 2773 2789 { 2774 2790 string domainId; … … 2784 2800 get(domainId)->recvArea(rankBuffers); 2785 2801 } 2802 CATCH 2786 2803 2787 2804 /*! … … 2790 2807 */ 2791 2808 void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 2809 TRY 2792 2810 { 2793 2811 int nbReceived = rankBuffers.size(), i, ind, index, lInd; … … 2835 2853 } 2836 2854 } 2855 CATCH_DUMP_ATTR 2837 2856 2838 2857 /*! … … 2844 2863 */ 2845 2864 bool CDomain::isEqual(CDomain* obj) 2865 TRY 2846 2866 { 2847 2867 vector<StdString> excludedAttr; … … 2866 2886 return objEqual; 2867 2887 } 2888 CATCH_DUMP_ATTR 2868 2889 2869 2890 /*! … … 2872 2893 */ 2873 2894 void CDomain::recvDataIndex(CEventServer& event) 2895 TRY 2874 2896 { 2875 2897 string domainId; … … 2885 2907 get(domainId)->recvDataIndex(rankBuffers); 2886 2908 } 2909 CATCH 2887 2910 2888 2911 /*! … … 2896 2919 */ 2897 2920 void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 2921 TRY 2898 2922 { 2899 2923 int nbReceived = rankBuffers.size(), i, ind, index, indexI, indexJ, type_int, lInd; … … 2932 2956 dataIIndex(lInd) = (-1 == dataIIndex(lInd)) ? tmpI(ind) : dataIIndex(lInd); // Only fill in dataIndex if there is no data 2933 2957 dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd); 2934 2935 if (!domainMask(lInd)) // Include mask info into data index on the RECEIVE getServerDimensionSizes2936 {2937 dataIIndex(lInd) = dataJIndex(lInd) = -1;2938 }2939 2958 } 2940 2959 } … … 2967 2986 data_jbegin.setValue(0); 2968 2987 } 2988 CATCH_DUMP_ATTR 2969 2989 2970 2990 CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 2991 TRY 2971 2992 { 2972 2993 transformationMap_.push_back(std::make_pair(transType, CTransformation<CDomain>::createTransformation(transType,id))); 2973 2994 return transformationMap_.back().second; 2974 2995 } 2996 CATCH_DUMP_ATTR 2975 2997 2976 2998 /*! … … 2979 3001 */ 2980 3002 bool CDomain::hasTransformation() 3003 TRY 2981 3004 { 2982 3005 return (!transformationMap_.empty()); 2983 3006 } 3007 CATCH_DUMP_ATTR 2984 3008 2985 3009 /*! … … 2988 3012 */ 2989 3013 void CDomain::setTransformations(const TransMapTypes& domTrans) 3014 TRY 2990 3015 { 2991 3016 transformationMap_ = domTrans; 2992 3017 } 3018 CATCH_DUMP_ATTR 2993 3019 2994 3020 /*! … … 2997 3023 */ 2998 3024 CDomain::TransMapTypes CDomain::getAllTransformations(void) 3025 TRY 2999 3026 { 3000 3027 return transformationMap_; 3001 3028 } 3029 CATCH_DUMP_ATTR 3002 3030 3003 3031 void CDomain::duplicateTransformation(CDomain* src) 3032 TRY 3004 3033 { 3005 3034 if (src->hasTransformation()) … … 3008 3037 } 3009 3038 } 3039 CATCH_DUMP_ATTR 3010 3040 3011 3041 /*! … … 3013 3043 */ 3014 3044 void CDomain::solveInheritanceTransformation() 3045 TRY 3015 3046 { 3016 3047 if (hasTransformation() || !hasDirectDomainReference()) … … 3029 3060 refDomains[i]->setTransformations(domain->getAllTransformations()); 3030 3061 } 3062 CATCH_DUMP_ATTR 3031 3063 3032 3064 void CDomain::setContextClient(CContextClient* contextClient) 3065 TRY 3033 3066 { 3034 3067 if (clientsSet.find(contextClient)==clientsSet.end()) … … 3038 3071 } 3039 3072 } 3073 CATCH_DUMP_ATTR 3040 3074 3041 3075 /*! … … 3045 3079 */ 3046 3080 void CDomain::parse(xml::CXMLNode & node) 3081 TRY 3047 3082 { 3048 3083 SuperClass::parse(node); … … 3076 3111 } 3077 3112 } 3113 CATCH_DUMP_ATTR 3078 3114 //---------------------------------------------------------------- 3079 3115
Note: See TracChangeset
for help on using the changeset viewer.