Changeset 1642 for XIOS/dev/branch_openmp/src/node/grid.cpp
- Timestamp:
- 01/23/19 10:31:44 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/node/grid.cpp
r1545 r1642 82 82 83 83 StdSize CGrid::getDimension(void) 84 TRY 84 85 { 85 86 return getGlobalDimension().size(); 86 87 } 88 CATCH_DUMP_ATTR 87 89 88 90 //--------------------------------------------------------------- 89 91 90 92 StdSize CGrid::getDataSize(void) const 93 TRY 91 94 { 92 95 StdSize retvalue = 1; … … 98 101 return retvalue; 99 102 } 103 CATCH 100 104 101 105 /*! … … 106 110 */ 107 111 std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting) 112 TRY 108 113 { 109 114 std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); … … 147 152 return attributesSizes; 148 153 } 154 CATCH_DUMP_ATTR 149 155 150 156 /*! … … 156 162 */ 157 163 std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/) 164 TRY 158 165 { 159 166 // The record index is sometimes sent along with the data but we always … … 180 187 return dataSizes; 181 188 } 189 CATCH_DUMP_ATTR 182 190 183 191 size_t CGrid::getGlobalWrittenSize(void) 192 TRY 184 193 { 185 194 std::vector<CDomain*> domainP = this->getDomains(); … … 191 200 return globalGridSize ; 192 201 } 193 202 CATCH_DUMP_ATTR 194 203 195 204 void CGrid::checkAttributesAfterTransformation() 205 TRY 196 206 { 197 207 setAxisList(); … … 228 238 } 229 239 } 240 CATCH_DUMP_ATTR 230 241 231 242 //--------------------------------------------------------------- … … 237 248 */ 238 249 bool CGrid::isCompressible(void) const 250 TRY 239 251 { 240 252 return isCompressible_; 241 253 } 254 CATCH 242 255 243 256 //--------------------------------------------------------------- 244 257 245 258 void CGrid::addRelFileCompressed(const StdString& filename) 259 TRY 246 260 { 247 261 this->relFilesCompressed.insert(filename); 248 262 } 263 CATCH_DUMP_ATTR 249 264 250 265 bool CGrid::isWrittenCompressed(const StdString& filename) const 266 TRY 251 267 { 252 268 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 253 269 } 270 CATCH 254 271 255 272 //--------------------------------------------------------------- … … 258 275 */ 259 276 void CGrid::solveDomainAxisRef(bool areAttributesChecked) 277 TRY 260 278 { 261 279 if (this->isDomainAxisChecked) return; … … 266 284 this->isDomainAxisChecked = areAttributesChecked; 267 285 } 286 CATCH_DUMP_ATTR 268 287 269 288 /* … … 272 291 */ 273 292 void CGrid::solveDomainAxisBaseRef() 293 TRY 274 294 { 275 295 if (this->hasDomainAxisBaseRef_) return; … … 297 317 this->hasDomainAxisBaseRef_ = true; 298 318 } 319 CATCH_DUMP_ATTR 299 320 300 321 void CGrid::checkEligibilityForCompressedOutput() 322 TRY 301 323 { 302 324 // We don't check if the mask is valid here, just if a mask has been defined at this point. 303 325 isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty(); 304 326 } 327 CATCH_DUMP_ATTR 305 328 306 329 void CGrid::checkMaskIndex(bool doSendingIndex) 330 TRY 307 331 { 308 332 CContext* context = CContext::getCurrent(); … … 339 363 this->isChecked = true; 340 364 } 365 CATCH_DUMP_ATTR 366 bool CGrid::hasMask() const 367 TRY 368 { 369 return (!mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty() || 370 !mask_4d.isEmpty() || !mask_5d.isEmpty() || !mask_6d.isEmpty() || !mask_7d.isEmpty()); 371 } 372 CATCH 341 373 342 374 /* … … 344 376 */ 345 377 void CGrid::createMask(void) 378 TRY 346 379 { 347 380 using namespace std; … … 381 414 } 382 415 } 416 CATCH_DUMP_ATTR 383 417 384 418 /* … … 386 420 */ 387 421 void CGrid::checkMask(void) 422 TRY 388 423 { 389 424 using namespace std; … … 423 458 } 424 459 } 425 426 427 /*! 428 A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 429 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 430 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 431 \param [in] multi-dimension array grid mask 432 */ 433 434 void CGrid::getLocalMask(CArray<bool,1>& localMask) 435 { 436 std::vector<CDomain*> domainP = this->getDomains(); 437 std::vector<CAxis*> axisP = this->getAxis(); 438 int dim = domainP.size() * 2 + axisP.size(); 439 440 switch (dim) 441 { 442 case 0: 443 getLocalMask(mask_0d, localMask); 444 break; 445 case 1: 446 getLocalMask(mask_1d, localMask); 447 break; 448 case 2: 449 getLocalMask(mask_2d, localMask); 450 break; 451 case 3: 452 getLocalMask(mask_3d, localMask); 453 break; 454 case 4: 455 getLocalMask(mask_4d, localMask); 456 break; 457 case 5: 458 getLocalMask(mask_5d, localMask); 459 break; 460 case 6: 461 getLocalMask(mask_6d, localMask); 462 break; 463 case 7: 464 getLocalMask(mask_7d, localMask); 465 break; 466 default: 467 break; 468 } 469 } 470 460 CATCH_DUMP_ATTR 461 471 462 /* 472 463 Modify value of mask in a certain index … … 476 467 */ 477 468 void CGrid::modifyMask(const CArray<int,1>& indexToModify, bool modifyValue) 469 TRY 478 470 { 479 471 using namespace std; … … 511 503 } 512 504 } 505 CATCH_DUMP_ATTR 513 506 514 507 /* … … 518 511 */ 519 512 void CGrid::modifyMaskSize(const std::vector<int>& newDimensionSize, bool newValue) 513 TRY 520 514 { 521 515 std::vector<CDomain*> domainP = this->getDomains(); … … 552 546 } 553 547 } 548 CATCH_DUMP_ATTR 554 549 555 550 //--------------------------------------------------------------- 556 551 557 552 void CGrid::solveDomainRef(bool sendAtt) 553 TRY 558 554 { 559 555 setDomainList(); … … 568 564 } 569 565 } 566 CATCH_DUMP_ATTR 570 567 571 568 //--------------------------------------------------------------- 572 569 573 570 void CGrid::solveAxisRef(bool sendAtt) 571 TRY 574 572 { 575 573 setAxisList(); … … 599 597 } 600 598 } 599 CATCH_DUMP_ATTR 601 600 602 601 //--------------------------------------------------------------- 603 602 604 603 void CGrid::solveScalarRef(bool sendAtt) 604 TRY 605 605 { 606 606 setScalarList(); … … 616 616 } 617 617 } 618 CATCH_DUMP_ATTR 618 619 619 620 /*! … … 621 622 */ 622 623 void CGrid::computeWrittenIndex() 624 TRY 623 625 { 624 626 if (computedWrittenIndex_) return; … … 659 661 { 660 662 CContextServer* server = CContext::getCurrent()->server; 661 MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);662 MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);663 ep_lib::MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, EP_INT, EP_SUM, server->intraComm); 664 ep_lib::MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, EP_INT, EP_SUM, server->intraComm); 663 665 offsetWrittenIndexes_ -= numberWrittenIndexes_; 664 666 } … … 680 682 } 681 683 } 684 CATCH_DUMP_ATTR 682 685 683 686 //--------------------------------------------------------------- … … 690 693 */ 691 694 void CGrid::computeClientIndex() 695 TRY 692 696 { 693 697 CContext* context = CContext::getCurrent(); 694 698 695 CContextClient* client = context->client; // Here it's not important which contextClient to recuperate699 CContextClient* client = context->client; 696 700 int rank = client->clientRank; 697 701 698 702 clientDistribution_ = new CDistributionClient(rank, this); 699 703 // Get local data index on client 700 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 701 int nbStoreIndex = storeIndex_client.numElements(); 704 int nbStoreIndex = clientDistribution_->getLocalDataIndexOnClient().size(); 705 int nbStoreGridMask = clientDistribution_->getLocalMaskIndexOnClient().size(); 706 // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 707 storeIndex_client.resize(nbStoreIndex); 708 storeMask_client.resize(nbStoreGridMask); 702 709 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 710 for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 703 711 704 712 if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); … … 746 754 } 747 755 } 756 CATCH_DUMP_ATTR 748 757 749 758 /*! … … 751 760 */ 752 761 void CGrid::computeConnectedClients() 762 TRY 753 763 { 754 764 CContext* context = CContext::getCurrent(); … … 840 850 connectedServerRank_[receiverSize].push_back(client->clientRank % client->serverSize); 841 851 852 // Now check if all servers have data to receive. If not, master client will send empty data. 853 // This ensures that all servers will participate in collective calls upon receiving even if they have no date to receive. 854 std::vector<int> counts (client->clientSize); 855 std::vector<int> displs (client->clientSize); 856 displs[0] = 0; 857 int localCount = connectedServerRank_[receiverSize].size() ; 858 ep_lib::MPI_Gather(&localCount, 1, EP_INT, &counts[0], 1, EP_INT, 0, client->intraComm) ; 859 for (int i = 0; i < client->clientSize-1; ++i) 860 { 861 displs[i+1] = displs[i] + counts[i]; 862 } 863 std::vector<int> allConnectedServers(displs[client->clientSize-1]+counts[client->clientSize-1]); 864 ep_lib::MPI_Gatherv(&(connectedServerRank_[receiverSize])[0], localCount, EP_INT, &allConnectedServers[0], &counts[0], &displs[0], EP_INT, 0, client->intraComm); 865 866 if ((allConnectedServers.size() != receiverSize) && (client->clientRank == 0)) 867 { 868 std::vector<bool> isSrvConnected (receiverSize, false); 869 for (int i = 0; i < allConnectedServers.size(); ++i) isSrvConnected[allConnectedServers[i]] = true; 870 for (int i = 0; i < receiverSize; ++i) 871 { 872 if (!isSrvConnected[i]) connectedServerRank_[receiverSize].push_back(i); 873 } 874 } 875 842 876 nbSenders[receiverSize] = clientServerMap_->computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 843 877 } 844 878 } 845 879 } 880 CATCH_DUMP_ATTR 846 881 847 882 /*! … … 853 888 */ 854 889 void CGrid::computeIndex(void) 890 TRY 855 891 { 856 892 CContext* context = CContext::getCurrent(); … … 879 915 } 880 916 } 917 CATCH_DUMP_ATTR 881 918 882 919 /*! … … 892 929 const CContextClient* client, 893 930 CClientServerMapping::GlobalIndexMap& globalIndexOnServer) 931 TRY 894 932 { 895 933 int serverSize = client->serverSize; … … 1058 1096 } 1059 1097 } 1060 //---------------------------------------------------------------- 1098 CATCH_DUMP_ATTR 1099 //---------------------------------------------------------------- 1061 1100 1062 1101 CGrid* CGrid::createGrid(CDomain* domain) 1102 TRY 1063 1103 { 1064 1104 std::vector<CDomain*> vecDom(1, domain); … … 1067 1107 return createGrid(vecDom, vecAxis); 1068 1108 } 1109 CATCH 1069 1110 1070 1111 CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis) 1071 { 1112 TRY 1113 { 1072 1114 std::vector<CDomain*> vecDom(1, domain); 1073 1115 std::vector<CAxis*> vecAxis(1, axis); … … 1075 1117 return createGrid(vecDom, vecAxis); 1076 1118 } 1119 CATCH 1077 1120 1078 1121 CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1079 1122 const CArray<int,1>& axisDomainOrder) 1123 TRY 1080 1124 { 1081 1125 std::vector<CScalar*> vecScalar; 1082 1126 return createGrid(generateId(domains, axis, vecScalar, axisDomainOrder), domains, axis, vecScalar, axisDomainOrder); 1083 1127 } 1128 CATCH 1084 1129 1085 1130 CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1086 1131 const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 1132 TRY 1087 1133 { 1088 1134 return createGrid(generateId(domains, axis, scalars, axisDomainOrder), domains, axis, scalars, axisDomainOrder); 1089 1135 } 1136 CATCH 1090 1137 1091 1138 CGrid* CGrid::createGrid(StdString id, const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1092 1139 const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 1140 TRY 1093 1141 { 1094 1142 if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) … … 1132 1180 return grid; 1133 1181 } 1182 CATCH 1134 1183 1135 1184 CGrid* CGrid::cloneGrid(const StdString& idNewGrid, CGrid* gridSrc) 1185 TRY 1136 1186 { 1137 1187 std::vector<CDomain*> domainSrcTmp = gridSrc->getDomains(), domainSrc; … … 1173 1223 return grid; 1174 1224 } 1225 CATCH 1175 1226 1176 1227 StdString CGrid::generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, 1177 1228 const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) 1229 TRY 1178 1230 { 1179 1231 if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) … … 1216 1268 return id.str(); 1217 1269 } 1270 CATCH 1218 1271 1219 1272 StdString CGrid::generateId(const CGrid* gridSrc, const CGrid* gridDest) 1273 TRY 1220 1274 { 1221 1275 StdString idSrc = gridSrc->getId(); … … 1227 1281 return id.str(); 1228 1282 } 1283 CATCH 1229 1284 1230 1285 //---------------------------------------------------------------- 1231 1286 1232 1287 CDomainGroup* CGrid::getVirtualDomainGroup() const 1288 TRY 1233 1289 { 1234 1290 return this->vDomainGroup_; 1235 1291 } 1292 CATCH 1236 1293 1237 1294 CAxisGroup* CGrid::getVirtualAxisGroup() const 1295 TRY 1238 1296 { 1239 1297 return this->vAxisGroup_; 1240 1298 } 1299 CATCH 1241 1300 1242 1301 CScalarGroup* CGrid::getVirtualScalarGroup() const 1302 TRY 1243 1303 { 1244 1304 return this->vScalarGroup_; 1245 1305 } 1306 CATCH 1246 1307 1247 1308 /* … … 1279 1340 1280 1341 void CGrid::storeField_arr(const double* const data, CArray<double, 1>& stored) const 1342 TRY 1281 1343 { 1282 1344 const StdSize size = storeIndex_client.numElements(); … … 1285 1347 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1286 1348 } 1349 CATCH 1287 1350 1288 1351 void CGrid::restoreField_arr(const CArray<double, 1>& stored, double* const data) const 1352 TRY 1289 1353 { 1290 1354 const StdSize size = storeIndex_client.numElements(); … … 1292 1356 for(StdSize i = 0; i < size; i++) data[storeIndex_client(i)] = stored(i); 1293 1357 } 1358 CATCH 1359 1360 void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 1361 { 1362 const StdSize size = storeIndex_client.numElements(); 1363 stored.resize(size); 1364 const double nanValue = std::numeric_limits<double>::quiet_NaN(); 1365 1366 if (storeMask_client.numElements() != 0) 1367 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 1368 else 1369 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1370 } 1294 1371 1295 1372 void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const 1373 TRY 1296 1374 { 1297 1375 const std::vector<int>& localMaskedDataIndex = clientDistribution_->getLocalMaskedDataIndexOnClient(); 1298 1376 const int size = localMaskedDataIndex.size(); 1299 1300 1377 for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; 1301 1378 } 1302 1379 CATCH 1303 1380 1304 1381 void CGrid::computeClientIndexScalarGrid() 1382 TRY 1305 1383 { 1306 1384 CContext* context = CContext::getCurrent(); 1307 // int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; // This should be changed soon 1308 // for (int p = 0; p < nbSrvPools; ++p) 1309 { 1310 // CContextClient* client = (context->hasServer) ? (context->hasClient ? context->clientPrimServer[p] : context->client) 1311 // : context->client; 1385 { 1312 1386 CContextClient* client = context->client; 1313 1387 … … 1340 1414 } 1341 1415 } 1416 CATCH_DUMP_ATTR 1342 1417 1343 1418 void CGrid::computeConnectedClientsScalarGrid() 1419 TRY 1344 1420 { 1345 1421 CContext* context = CContext::getCurrent(); … … 1386 1462 } 1387 1463 } 1464 CATCH_DUMP_ATTR 1388 1465 1389 1466 void CGrid::sendIndexScalarGrid() 1467 TRY 1390 1468 { 1391 1469 CContext* context = CContext::getCurrent(); … … 1451 1529 } 1452 1530 } 1531 CATCH_DUMP_ATTR 1453 1532 1454 1533 void CGrid::sendIndex(void) 1534 TRY 1455 1535 { 1456 1536 CContext* context = CContext::getCurrent(); … … 1572 1652 } 1573 1653 } 1654 CATCH_DUMP_ATTR 1574 1655 1575 1656 void CGrid::recvIndex(CEventServer& event) 1657 TRY 1576 1658 { 1577 1659 string gridId; … … 1589 1671 get(gridId)->recvIndex(ranks, buffers); 1590 1672 } 1673 CATCH 1591 1674 1592 1675 void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers) 1676 TRY 1593 1677 { 1594 1678 CContext* context = CContext::getCurrent(); … … 1631 1715 std::vector<CDomain*> domainList = getDomains(); 1632 1716 std::vector<CAxis*> axisList = getAxis(); 1633 std::vector<int> n ZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize), nGlobElement(numElement);1634 std::vector<CArray<int,1> > global ZoomIndex(numElement);1717 std::vector<int> nBegin(ssize), nSize(ssize), nGlob(ssize), nBeginGlobal(ssize), nGlobElement(numElement); 1718 std::vector<CArray<int,1> > globalIndex(numElement); 1635 1719 for (int i = 0; i < numElement; ++i) 1636 1720 { … … 1638 1722 if (2 == axis_domain_order(i)) //domain 1639 1723 { 1640 n ZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin;1641 n ZoomSize[indexMap[i]] = domainList[domainId]->zoom_ni;1642 n ZoomBeginGlobal[indexMap[i]] = domainList[domainId]->global_zoom_ibegin;1724 nBegin[indexMap[i]] = domainList[domainId]->ibegin; 1725 nSize[indexMap[i]] = domainList[domainId]->ni; 1726 nBeginGlobal[indexMap[i]] = 0; 1643 1727 nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 1644 1728 1645 n ZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin;1646 n ZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj;1647 n ZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->global_zoom_jbegin;1729 nBegin[indexMap[i] + 1] = domainList[domainId]->jbegin; 1730 nSize[indexMap[i] + 1] = domainList[domainId]->nj; 1731 nBeginGlobal[indexMap[i] + 1] = 0; 1648 1732 nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 1649 1733 1650 1734 { 1651 1735 int count = 0; 1652 global ZoomIndex[i].resize(nZoomSize[indexMap[i]]*nZoomSize[indexMap[i]+1]);1653 for (int jdx = 0; jdx < n ZoomSize[indexMap[i]+1]; ++jdx)1654 for (int idx = 0; idx < n ZoomSize[indexMap[i]]; ++idx)1736 globalIndex[i].resize(nSize[indexMap[i]]*nSize[indexMap[i]+1]); 1737 for (int jdx = 0; jdx < nSize[indexMap[i]+1]; ++jdx) 1738 for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 1655 1739 { 1656 global ZoomIndex[i](count) = (nZoomBegin[indexMap[i]] + idx) + (nZoomBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]];1740 globalIndex[i](count) = (nBegin[indexMap[i]] + idx) + (nBegin[indexMap[i]+1] + jdx) * nGlob[indexMap[i]]; 1657 1741 ++count; 1658 1742 } … … 1663 1747 else if (1 == axis_domain_order(i)) // axis 1664 1748 { 1665 n ZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin;1666 n ZoomSize[indexMap[i]] = axisList[axisId]->zoom_n;1667 n ZoomBeginGlobal[indexMap[i]] = axisList[axisId]->global_zoom_begin;1749 nBegin[indexMap[i]] = axisList[axisId]->begin; 1750 nSize[indexMap[i]] = axisList[axisId]->n; 1751 nBeginGlobal[indexMap[i]] = 0; 1668 1752 nGlob[indexMap[i]] = axisList[axisId]->n_glo; 1669 if (axisList[axisId]->zoomByIndex()) 1670 { 1671 globalZoomIndex[i].reference(axisList[axisId]->zoom_index); 1672 } 1673 else 1674 { 1675 globalZoomIndex[i].resize(nZoomSize[indexMap[i]]); 1676 for (int idx = 0; idx < nZoomSize[indexMap[i]]; ++idx) 1677 globalZoomIndex[i](idx) = nZoomBegin[indexMap[i]] + idx; 1678 } 1753 globalIndex[i].resize(nSize[indexMap[i]]); 1754 for (int idx = 0; idx < nSize[indexMap[i]]; ++idx) 1755 globalIndex[i](idx) = nBegin[indexMap[i]] + idx; 1679 1756 1680 1757 ++axisId; … … 1682 1759 else // scalar 1683 1760 { 1684 n ZoomBegin[indexMap[i]] = 0;1685 n ZoomSize[indexMap[i]] = 1;1686 n ZoomBeginGlobal[indexMap[i]] = 0;1761 nBegin[indexMap[i]] = 0; 1762 nSize[indexMap[i]] = 1; 1763 nBeginGlobal[indexMap[i]] = 0; 1687 1764 nGlob[indexMap[i]] = 1; 1688 global ZoomIndex[i].resize(1);1689 global ZoomIndex[i](0) = 0;1765 globalIndex[i].resize(1); 1766 globalIndex[i](0) = 0; 1690 1767 ++scalarId; 1691 1768 } … … 1693 1770 dataSize = 1; 1694 1771 1695 for (int i = 0; i < n ZoomSize.size(); ++i)1696 dataSize *= n ZoomSize[i];1772 for (int i = 0; i < nSize.size(); ++i) 1773 dataSize *= nSize[i]; 1697 1774 serverDistribution_ = new CDistributionServer(server->intraCommRank, 1698 global ZoomIndex, axis_domain_order,1699 n ZoomBegin, nZoomSize, nZoomBeginGlobal, nGlob);1775 globalIndex, axis_domain_order, 1776 nBegin, nSize, nBeginGlobal, nGlob); 1700 1777 } 1701 1778 … … 1760 1837 nGlob.push_back(1); 1761 1838 } 1762 1763 modifyMaskSize(nSize, false);1764 1765 // These below codes are reserved for future1766 CDistributionServer srvDist(server->intraCommRank, nBegin, nSize, nBeginGlobal, nGlob);1767 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient.begin(),1768 ite = outGlobalIndexFromClient.end(), it;1769 const CDistributionServer::GlobalLocalMap& globalLocalMask = srvDist.getGlobalLocalIndex();1770 CDistributionServer::GlobalLocalMap::const_iterator itSrv;1771 size_t nb = 0;1772 for (it = itb; it != ite; ++it)1773 {1774 CArray<size_t,1>& globalInd = it->second;1775 for (size_t idx = 0; idx < globalInd.numElements(); ++idx)1776 {1777 if (globalLocalMask.end() != globalLocalMask.find(globalInd(idx))) ++nb;1778 }1779 }1780 1781 CArray<int,1> indexToModify(nb);1782 nb = 0;1783 for (it = itb; it != ite; ++it)1784 {1785 CArray<size_t,1>& globalInd = it->second;1786 for (size_t idx = 0; idx < globalInd.numElements(); ++idx)1787 {1788 itSrv = globalLocalMask.find(globalInd(idx));1789 if (globalLocalMask.end() != itSrv)1790 {1791 indexToModify(nb) = itSrv->second;1792 ++nb;1793 }1794 }1795 }1796 1797 modifyMask(indexToModify, true);1798 1839 } 1799 1840 … … 1803 1844 } 1804 1845 } 1846 CATCH_DUMP_ATTR 1805 1847 1806 1848 /* … … 1818 1860 const std::vector<CScalar*> scalars, 1819 1861 const CArray<int,1>& axisDomainOrder) 1820 { 1862 TRY 1863 { 1821 1864 // globalDim.resize(domains.size()*2+axis.size()+scalars.size()); 1822 1865 globalDim.resize(domains.size()*2+axis.size()); … … 1858 1901 return positionDimensionDistributed; 1859 1902 } 1903 CATCH_DUMP_ATTR 1860 1904 1861 1905 // Retrieve the global dimension of grid 1862 1906 std::vector<int> CGrid::getGlobalDimension() 1907 TRY 1863 1908 { 1864 1909 std::vector<int> globalDim; … … 1867 1912 return globalDim; 1868 1913 } 1914 CATCH_DUMP_ATTR 1869 1915 1870 1916 // Retrieve dimension on which we do distribution (Very often, it should be 2nd dimension) 1871 1917 int CGrid::getDistributedDimension() 1918 TRY 1872 1919 { 1873 1920 std::vector<int> globalDim; 1874 1921 return computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order); 1875 1922 } 1923 CATCH_DUMP_ATTR 1876 1924 1877 1925 bool CGrid::isScalarGrid() const 1926 TRY 1878 1927 { 1879 1928 return (axisList_.empty() && domList_.empty()); 1880 1929 } 1930 CATCH 1881 1931 1882 1932 /*! … … 1886 1936 */ 1887 1937 bool CGrid::doGridHaveDataToWrite() 1938 TRY 1888 1939 { 1889 1940 return (0 != writtenDataSize_); 1890 1941 } 1942 CATCH_DUMP_ATTR 1891 1943 1892 1944 /*! … … 1897 1949 */ 1898 1950 size_t CGrid::getWrittenDataSize() const 1951 TRY 1899 1952 { 1900 1953 return writtenDataSize_; 1901 1954 } 1955 CATCH 1902 1956 1903 1957 /*! … … 1906 1960 */ 1907 1961 int CGrid::getNumberWrittenIndexes() const 1962 TRY 1908 1963 { 1909 1964 return numberWrittenIndexes_; 1910 1965 } 1966 CATCH 1911 1967 1912 1968 /*! … … 1915 1971 */ 1916 1972 int CGrid::getTotalNumberWrittenIndexes() const 1973 TRY 1917 1974 { 1918 1975 return totalNumberWrittenIndexes_; 1919 1976 } 1977 CATCH 1920 1978 1921 1979 /*! … … 1924 1982 */ 1925 1983 int CGrid::getOffsetWrittenIndexes() const 1984 TRY 1926 1985 { 1927 1986 return offsetWrittenIndexes_; 1928 1987 } 1988 CATCH 1929 1989 1930 1990 CDistributionServer* CGrid::getDistributionServer() 1991 TRY 1931 1992 { 1932 1993 return serverDistribution_; 1933 1994 } 1995 CATCH_DUMP_ATTR 1934 1996 1935 1997 CDistributionClient* CGrid::getDistributionClient() 1998 TRY 1936 1999 { 1937 2000 return clientDistribution_; 1938 2001 } 2002 CATCH_DUMP_ATTR 1939 2003 1940 2004 bool CGrid::doGridHaveDataDistributed(CContextClient* client) 2005 TRY 1941 2006 { 1942 2007 if (isScalarGrid()) return false; … … 1948 2013 return isDataDistributed_; 1949 2014 } 2015 CATCH_DUMP_ATTR 1950 2016 1951 2017 /*! … … 1957 2023 */ 1958 2024 bool CGrid::dispatchEvent(CEventServer& event) 2025 TRY 1959 2026 { 1960 2027 … … 1990 2057 } 1991 2058 } 2059 CATCH 1992 2060 1993 2061 ///--------------------------------------------------------------- 1994 2062 1995 2063 CDomain* CGrid::addDomain(const std::string& id) 2064 TRY 1996 2065 { 1997 2066 order_.push_back(2); … … 2000 2069 return vDomainGroup_->createChild(id); 2001 2070 } 2071 CATCH_DUMP_ATTR 2002 2072 2003 2073 CAxis* CGrid::addAxis(const std::string& id) 2074 TRY 2004 2075 { 2005 2076 order_.push_back(1); … … 2008 2079 return vAxisGroup_->createChild(id); 2009 2080 } 2081 CATCH_DUMP_ATTR 2010 2082 2011 2083 CScalar* CGrid::addScalar(const std::string& id) 2084 TRY 2012 2085 { 2013 2086 order_.push_back(0); … … 2016 2089 return vScalarGroup_->createChild(id); 2017 2090 } 2091 CATCH_DUMP_ATTR 2018 2092 2019 2093 //! Change virtual field group to a new one 2020 2094 void CGrid::setVirtualDomainGroup(CDomainGroup* newVDomainGroup) 2095 TRY 2021 2096 { 2022 2097 this->vDomainGroup_ = newVDomainGroup; 2023 2098 } 2099 CATCH_DUMP_ATTR 2024 2100 2025 2101 //! Change virtual variable group to new one 2026 2102 void CGrid::setVirtualAxisGroup(CAxisGroup* newVAxisGroup) 2103 TRY 2027 2104 { 2028 2105 this->vAxisGroup_ = newVAxisGroup; 2029 2106 } 2107 CATCH_DUMP_ATTR 2030 2108 2031 2109 //! Change virtual variable group to new one 2032 2110 void CGrid::setVirtualScalarGroup(CScalarGroup* newVScalarGroup) 2111 TRY 2033 2112 { 2034 2113 this->vScalarGroup_ = newVScalarGroup; 2035 2114 } 2115 CATCH_DUMP_ATTR 2036 2116 2037 2117 /*! … … 2040 2120 */ 2041 2121 void CGrid::sendAddDomain(const string& id) 2042 { 2122 TRY 2123 { 2043 2124 sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN); 2044 2125 } 2126 CATCH_DUMP_ATTR 2045 2127 2046 2128 /*! … … 2049 2131 */ 2050 2132 void CGrid::sendAddAxis(const string& id) 2133 TRY 2051 2134 { 2052 2135 sendAddItem(id, (int)EVENT_ID_ADD_AXIS); 2053 2136 } 2137 CATCH_DUMP_ATTR 2054 2138 2055 2139 /*! … … 2058 2142 */ 2059 2143 void CGrid::sendAddScalar(const string& id) 2144 TRY 2060 2145 { 2061 2146 sendAddItem(id, (int)EVENT_ID_ADD_SCALAR); 2062 2147 } 2148 CATCH_DUMP_ATTR 2063 2149 2064 2150 /*! … … 2067 2153 */ 2068 2154 void CGrid::recvAddDomain(CEventServer& event) 2155 TRY 2069 2156 { 2070 2157 … … 2074 2161 get(id)->recvAddDomain(*buffer); 2075 2162 } 2163 CATCH 2076 2164 2077 2165 /*! … … 2080 2168 */ 2081 2169 void CGrid::recvAddDomain(CBufferIn& buffer) 2170 TRY 2082 2171 { 2083 2172 string id; … … 2085 2174 addDomain(id); 2086 2175 } 2176 CATCH_DUMP_ATTR 2087 2177 2088 2178 /*! … … 2091 2181 */ 2092 2182 void CGrid::recvAddAxis(CEventServer& event) 2183 TRY 2093 2184 { 2094 2185 … … 2098 2189 get(id)->recvAddAxis(*buffer); 2099 2190 } 2191 CATCH 2100 2192 2101 2193 /*! … … 2104 2196 */ 2105 2197 void CGrid::recvAddAxis(CBufferIn& buffer) 2198 TRY 2106 2199 { 2107 2200 string id; … … 2109 2202 addAxis(id); 2110 2203 } 2204 CATCH_DUMP_ATTR 2111 2205 2112 2206 /*! … … 2115 2209 */ 2116 2210 void CGrid::recvAddScalar(CEventServer& event) 2211 TRY 2117 2212 { 2118 2213 … … 2122 2217 get(id)->recvAddScalar(*buffer); 2123 2218 } 2219 CATCH 2124 2220 2125 2221 /*! … … 2128 2224 */ 2129 2225 void CGrid::recvAddScalar(CBufferIn& buffer) 2226 TRY 2130 2227 { 2131 2228 string id; … … 2133 2230 addScalar(id); 2134 2231 } 2232 CATCH_DUMP_ATTR 2135 2233 2136 2234 /*! … … 2141 2239 */ 2142 2240 void CGrid::solveDomainAxisRefInheritance(bool apply) 2241 TRY 2143 2242 { 2144 2243 CContext* context = CContext::getCurrent(); … … 2181 2280 } 2182 2281 } 2282 CATCH_DUMP_ATTR 2183 2283 2184 2284 bool CGrid::isTransformed() 2285 TRY 2185 2286 { 2186 2287 return isTransformed_; 2187 2288 } 2289 CATCH_DUMP_ATTR 2188 2290 2189 2291 void CGrid::setTransformed() 2292 TRY 2190 2293 { 2191 2294 isTransformed_ = true; 2192 2295 } 2296 CATCH_DUMP_ATTR 2193 2297 2194 2298 CGridTransformation* CGrid::getTransformations() 2299 TRY 2195 2300 { 2196 2301 return transformations_; 2197 2302 } 2303 CATCH_DUMP_ATTR 2198 2304 2199 2305 void CGrid::addTransGridSource(CGrid* gridSrc) 2306 TRY 2200 2307 { 2201 2308 if (gridSrc_.end() == gridSrc_.find(gridSrc)) 2202 2309 gridSrc_.insert(make_pair(gridSrc,make_pair(false,""))); 2203 2310 } 2311 CATCH_DUMP_ATTR 2204 2312 2205 2313 std::map<CGrid*,std::pair<bool,StdString> >& CGrid::getTransGridSource() 2314 TRY 2206 2315 { 2207 2316 return gridSrc_; 2208 2317 } 2318 CATCH_DUMP_ATTR 2209 2319 2210 2320 /*! … … 2213 2323 */ 2214 2324 void CGrid::completeGrid(CGrid* transformGridSrc) 2325 TRY 2215 2326 { 2216 2327 if (0 != transformGridSrc) … … 2231 2342 gridGenerate.completeGrid(); 2232 2343 } 2344 CATCH_DUMP_ATTR 2233 2345 2234 2346 bool CGrid::isGenerated() 2347 TRY 2235 2348 { 2236 2349 return isGenerated_; 2237 2350 } 2351 CATCH 2238 2352 2239 2353 void CGrid::setGenerated() 2354 TRY 2240 2355 { 2241 2356 isGenerated_ = true; 2242 2357 } 2358 CATCH_DUMP_ATTR 2243 2359 2244 2360 void CGrid::transformGrid(CGrid* transformGridSrc) 2361 TRY 2245 2362 { 2246 2363 if (!transformGridSrc) … … 2268 2385 transformGridSrc->checkMaskIndex(false); 2269 2386 } 2387 CATCH_DUMP_ATTR 2270 2388 2271 2389 bool CGrid::hasTransform() 2390 TRY 2272 2391 { 2273 2392 if (hasTransform_) return hasTransform_; … … 2283 2402 return hasTransform_; 2284 2403 } 2404 CATCH_DUMP_ATTR 2285 2405 2286 2406 /*! … … 2289 2409 */ 2290 2410 std::vector<CDomain*> CGrid::getDomains() 2411 TRY 2291 2412 { 2292 2413 std::vector<CDomain*> domList; … … 2297 2418 return domList; 2298 2419 } 2420 CATCH_DUMP_ATTR 2299 2421 2300 2422 /*! … … 2303 2425 */ 2304 2426 std::vector<CAxis*> CGrid::getAxis() 2427 TRY 2305 2428 { 2306 2429 std::vector<CAxis*> aList; … … 2310 2433 return aList; 2311 2434 } 2435 CATCH_DUMP_ATTR 2312 2436 2313 2437 /*! … … 2316 2440 */ 2317 2441 std::vector<CScalar*> CGrid::getScalars() 2442 TRY 2318 2443 { 2319 2444 std::vector<CScalar*> sList; … … 2323 2448 return sList; 2324 2449 } 2450 CATCH_DUMP_ATTR 2325 2451 2326 2452 /*! … … 2329 2455 */ 2330 2456 CDomain* CGrid::getDomain(int domainIndex) 2457 TRY 2331 2458 { 2332 2459 std::vector<CDomain*> domainListP = this->getDomains(); … … 2346 2473 return domainListP[domainIndex]; 2347 2474 } 2475 CATCH_DUMP_ATTR 2348 2476 2349 2477 /*! … … 2352 2480 */ 2353 2481 CAxis* CGrid::getAxis(int axisIndex) 2482 TRY 2354 2483 { 2355 2484 std::vector<CAxis*> axisListP = this->getAxis(); … … 2369 2498 return axisListP[axisIndex]; 2370 2499 } 2500 CATCH_DUMP_ATTR 2371 2501 2372 2502 /*! … … 2375 2505 */ 2376 2506 CScalar* CGrid::getScalar(int scalarIndex) 2507 TRY 2377 2508 { 2378 2509 std::vector<CScalar*> scalarListP = this->getScalars(); … … 2392 2523 return scalarListP[scalarIndex]; 2393 2524 } 2525 CATCH_DUMP_ATTR 2394 2526 2395 2527 /*! … … 2398 2530 */ 2399 2531 void CGrid::setDomainList(const std::vector<CDomain*> domains) 2532 TRY 2400 2533 { 2401 2534 if (isDomListSet) return; … … 2418 2551 isDomListSet = true; 2419 2552 } 2420 2421 }2553 } 2554 CATCH_DUMP_ATTR 2422 2555 2423 2556 /*! … … 2426 2559 */ 2427 2560 void CGrid::setAxisList(const std::vector<CAxis*> axis) 2561 TRY 2428 2562 { 2429 2563 if (isAxisListSet) return; … … 2447 2581 } 2448 2582 } 2583 CATCH_DUMP_ATTR 2449 2584 2450 2585 /*! … … 2453 2588 */ 2454 2589 void CGrid::setScalarList(const std::vector<CScalar*> scalars) 2590 TRY 2455 2591 { 2456 2592 if (isScalarListSet) return; … … 2474 2610 } 2475 2611 } 2612 CATCH_DUMP_ATTR 2476 2613 2477 2614 /*! … … 2480 2617 */ 2481 2618 std::vector<StdString> CGrid::getDomainList() 2619 TRY 2482 2620 { 2483 2621 setDomainList(); 2484 2622 return domList_; 2485 2623 } 2624 CATCH 2486 2625 2487 2626 /*! … … 2490 2629 */ 2491 2630 std::vector<StdString> CGrid::getAxisList() 2631 TRY 2492 2632 { 2493 2633 setAxisList(); 2494 2634 return axisList_; 2495 2635 } 2636 CATCH 2496 2637 2497 2638 /*! … … 2500 2641 */ 2501 2642 std::vector<StdString> CGrid::getScalarList() 2643 TRY 2502 2644 { 2503 2645 setScalarList(); 2504 2646 return scalarList_; 2505 2647 } 2648 CATCH 2506 2649 2507 2650 /*! … … 2509 2652 */ 2510 2653 void CGrid::sendAllDomains() 2654 TRY 2511 2655 { 2512 2656 std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); … … 2518 2662 } 2519 2663 } 2664 CATCH_DUMP_ATTR 2520 2665 2521 2666 /*! … … 2523 2668 */ 2524 2669 void CGrid::sendAllAxis() 2670 TRY 2525 2671 { 2526 2672 std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); … … 2533 2679 } 2534 2680 } 2681 CATCH_DUMP_ATTR 2535 2682 2536 2683 /*! … … 2538 2685 */ 2539 2686 void CGrid::sendAllScalars() 2687 TRY 2540 2688 { 2541 2689 std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren(); … … 2548 2696 } 2549 2697 } 2698 CATCH_DUMP_ATTR 2550 2699 2551 2700 void CGrid::setContextClient(CContextClient* contextClient) 2701 TRY 2552 2702 { 2553 2703 if (clientsSet.find(contextClient)==clientsSet.end()) … … 2561 2711 this->getAxis()[i]->setContextClient(contextClient); 2562 2712 } 2713 CATCH_DUMP_ATTR 2563 2714 2564 2715 /*! … … 2566 2717 */ 2567 2718 void CGrid::parse(xml::CXMLNode& node) 2719 TRY 2568 2720 { 2569 2721 SuperClass::parse(node); … … 2606 2758 setScalarList(); 2607 2759 } 2760 CATCH_DUMP_ATTR 2761 2608 2762 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.