Changeset 1642 for XIOS/dev/branch_openmp/src/node/axis.cpp
- Timestamp:
- 01/23/19 10:31:44 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/node/axis.cpp
r1545 r1642 14 14 #include "distribution_client.hpp" 15 15 16 using namespace ep_lib;17 18 16 namespace xios { 19 17 … … 28 26 , transformationMap_(), hasValue(false), hasLabel(false) 29 27 , computedWrittenIndex_(false) 30 28 , clients() 31 29 { 32 30 } … … 40 38 , transformationMap_(), hasValue(false), hasLabel(false) 41 39 , computedWrittenIndex_(false) 42 40 , clients() 43 41 { 44 42 } … … 47 45 { /* Ne rien faire de plus */ } 48 46 49 std::map<StdString, ETranformationType> *CAxis::transformationMapList_ptr = 0;50 47 std::map<StdString, ETranformationType> CAxis::transformationMapList_ = std::map<StdString, ETranformationType>(); 48 bool CAxis::dummyTransformationMapList_ = CAxis::initializeTransformationMap(CAxis::transformationMapList_); 51 49 bool CAxis::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 50 TRY 52 51 { 53 52 m["zoom_axis"] = TRANS_ZOOM_AXIS; 54 53 m["interpolate_axis"] = TRANS_INTERPOLATE_AXIS; 54 m["extract_axis"] = TRANS_EXTRACT_AXIS; 55 55 m["inverse_axis"] = TRANS_INVERSE_AXIS; 56 56 m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS; … … 59 59 m["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 60 60 m["duplicate_scalar"] = TRANS_DUPLICATE_SCALAR_TO_AXIS; 61 } 62 63 bool CAxis::initializeTransformationMap() 64 { 65 if(CAxis::transformationMapList_ptr == 0) CAxis::transformationMapList_ptr = new std::map<StdString, ETranformationType>(); 66 (*CAxis::transformationMapList_ptr)["zoom_axis"] = TRANS_ZOOM_AXIS; 67 (*CAxis::transformationMapList_ptr)["interpolate_axis"] = TRANS_INTERPOLATE_AXIS; 68 (*CAxis::transformationMapList_ptr)["inverse_axis"] = TRANS_INVERSE_AXIS; 69 (*CAxis::transformationMapList_ptr)["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_AXIS; 70 (*CAxis::transformationMapList_ptr)["extract_domain"] = TRANS_EXTRACT_DOMAIN_TO_AXIS; 71 (*CAxis::transformationMapList_ptr)["reduce_axis"] = TRANS_REDUCE_AXIS_TO_AXIS; 72 (*CAxis::transformationMapList_ptr)["temporal_splitting"] = TRANS_TEMPORAL_SPLITTING; 73 (*CAxis::transformationMapList_ptr)["duplicate_scalar"] = TRANS_DUPLICATE_SCALAR_TO_AXIS; 74 } 61 62 } 63 CATCH 75 64 76 65 ///--------------------------------------------------------------- 77 66 78 67 const std::set<StdString> & CAxis::getRelFiles(void) const 68 TRY 79 69 { 80 70 return (this->relFiles); 81 71 } 72 CATCH 82 73 83 74 bool CAxis::IsWritten(const StdString & filename) const 75 TRY 84 76 { 85 77 return (this->relFiles.find(filename) != this->relFiles.end()); 86 78 } 79 CATCH 87 80 88 81 bool CAxis::isWrittenCompressed(const StdString& filename) const 82 TRY 89 83 { 90 84 return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); 91 85 } 86 CATCH 92 87 93 88 bool CAxis::isDistributed(void) const 89 TRY 94 90 { 95 91 bool distributed = (!this->begin.isEmpty() && !this->n.isEmpty() && (this->begin + this->n < this->n_glo)) || 96 92 (!this->n.isEmpty() && (this->n != this->n_glo)); 97 // A same stupidcondition to make sure that if there is only one client, axis93 // A condition to make sure that if there is only one client, axis 98 94 // should be considered to be distributed. This should be a temporary solution 99 95 distributed |= (1 == CContext::getCurrent()->client->clientSize); 100 96 return distributed; 101 97 } 98 CATCH 102 99 103 100 /*! … … 107 104 */ 108 105 bool CAxis::isCompressible(void) const 106 TRY 109 107 { 110 108 return isCompressible_; 111 109 } 110 CATCH 112 111 113 112 void CAxis::addRelFile(const StdString & filename) 113 TRY 114 114 { 115 115 this->relFiles.insert(filename); 116 116 } 117 CATCH_DUMP_ATTR 117 118 118 119 void CAxis::addRelFileCompressed(const StdString& filename) 120 TRY 119 121 { 120 122 this->relFilesCompressed.insert(filename); 121 123 } 124 CATCH_DUMP_ATTR 122 125 123 126 //---------------------------------------------------------------- … … 128 131 */ 129 132 int CAxis::getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 133 TRY 130 134 { 131 135 int writtenSize; … … 133 137 return numberWrittenIndexes_[writtenSize]; 134 138 } 139 CATCH_DUMP_ATTR 135 140 136 141 /*! … … 139 144 */ 140 145 int CAxis::getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom) 146 TRY 141 147 { 142 148 int writtenSize; … … 144 150 return totalNumberWrittenIndexes_[writtenSize]; 145 151 } 152 CATCH_DUMP_ATTR 146 153 147 154 /*! … … 150 157 */ 151 158 int CAxis::getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom) 159 TRY 152 160 { 153 161 int writtenSize; … … 155 163 return offsetWrittenIndexes_[writtenSize]; 156 164 } 165 CATCH_DUMP_ATTR 157 166 158 167 CArray<int, 1>& CAxis::getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom) 168 TRY 159 169 { 160 170 int writtenSize; … … 162 172 return compressedIndexToWriteOnServer[writtenSize]; 163 173 } 174 CATCH_DUMP_ATTR 175 164 176 //---------------------------------------------------------------- 165 177 … … 171 183 std::map<int, StdSize> CAxis::getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 172 184 CServerDistributionDescription::ServerDistributionType distType) 185 TRY 173 186 { 174 187 … … 234 247 } 235 248 } 236 237 249 return attributesSizes; 238 250 } 251 CATCH_DUMP_ATTR 239 252 240 253 //---------------------------------------------------------------- … … 247 260 248 261 CAxis* CAxis::createAxis() 262 TRY 249 263 { 250 264 CAxis* axis = CAxisGroup::get("axis_definition")->createChild(); 251 265 return axis; 252 266 } 267 CATCH 253 268 254 269 /*! … … 257 272 */ 258 273 void CAxis::checkAttributes(void) 259 { 260 if (this->n_glo.isEmpty()) 274 TRY 275 { 276 CContext* context=CContext::getCurrent(); 277 278 if (this->n_glo.isEmpty()) 261 279 ERROR("CAxis::checkAttributes(void)", 262 280 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " … … 298 316 } 299 317 300 // Remove this check because it doen't make sense in case of a hole or overlapping axes301 318 if (!this->value.isEmpty()) 302 319 { 303 // StdSize true_size = value.numElements(); 304 // if (this->n.getValue() != true_size) 305 // ERROR("CAxis::checkAttributes(void)", 306 // << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 307 // << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 320 // Avoid this check at writing because it fails in case of a hole 321 if (context->hasClient) 322 { 323 StdSize true_size = value.numElements(); 324 if (this->n.getValue() != true_size) 325 ERROR("CAxis::checkAttributes(void)", 326 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 327 << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size 328 << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 329 } 308 330 this->hasValue = true; 309 331 } … … 311 333 this->checkBounds(); 312 334 313 CContext* context=CContext::getCurrent();314 335 if (context->hasClient) 315 336 { 337 this->checkMask(); 316 338 this->checkData(); 317 this->checkZoom();318 this->checkMask();319 339 this->checkLabel(); 320 340 } 321 341 } 342 CATCH_DUMP_ATTR 322 343 323 344 /*! 324 Check the validity of data and fill in values if any.345 Check the validity of data, fill in values if any, and apply mask. 325 346 */ 326 347 void CAxis::checkData() 348 TRY 327 349 { 328 350 if (data_begin.isEmpty()) data_begin.setValue(0); … … 342 364 { 343 365 data_index.resize(data_n); 344 for (int i = 0; i < data_n; ++i) data_index(i) = i; 345 } 346 } 347 348 /*! 349 Check validity of zoom info and fill in values if any. 350 */ 351 void CAxis::checkZoom(void) 352 { 353 if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 354 if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 355 if (zoom_index.isEmpty()) 356 { 357 zoom_index.setValue(index.getValue()); 358 } 359 if (zoom_n.isEmpty()) zoom_n.setValue(n); 360 if (zoom_begin.isEmpty()) zoom_begin.setValue(begin); 361 } 366 for (int i = 0; i < data_n; ++i) 367 { 368 if ((i+data_begin) >= 0 && (i+data_begin<n)) 369 { 370 if (mask(i+data_begin)) 371 data_index(i) = i+data_begin; 372 else 373 data_index(i) = -1; 374 } 375 else 376 data_index(i) = -1; 377 } 378 } 379 else 380 { 381 if (data_index.numElements() != data_n) 382 { 383 ERROR("CAxis::checkData(void)", 384 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 385 << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 386 } 387 for (int i = 0; i < data_n; ++i) 388 { 389 if ((i+data_begin) >= 0 && (i+data_begin<n) && !mask(i+data_begin)) 390 data_index(i) = -1; 391 } 392 } 393 394 } 395 CATCH_DUMP_ATTR 362 396 363 397 size_t CAxis::getGlobalWrittenSize(void) 364 398 { 365 if (zoomByIndex()) return global_zoom_index.numElements(); 366 else return global_zoom_n ; 399 return n_glo ; 367 400 } 368 401 … … 371 404 */ 372 405 void CAxis::checkMask() 406 TRY 373 407 { 374 408 if (!mask.isEmpty()) 375 409 { 376 377 ERROR("CAxis::checkMask(void)",378 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] "379 << "The mask does not have the same size as the local domain." << std::endl380 << "Local size is " << n.getValue() << "." << std::endl381 << "Mask size is " << mask.extent(0) << ".");382 }383 else // (mask.isEmpty())384 { // If no mask was defined, we create a default one without any masked point.385 mask.resize(n);386 for (int i = 0; i < n; ++i)387 {388 mask(i)= true;389 390 391 }410 if (mask.extent(0) != n) 411 { 412 ERROR("CAxis::checkMask(void)", 413 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 414 << "The mask does not have the same size as the local domain." << std::endl 415 << "Local size is " << n.getValue() << "." << std::endl 416 << "Mask size is " << mask.extent(0) << "."); 417 } 418 } 419 else 420 { 421 mask.resize(n); 422 mask = true; 423 } 424 } 425 CATCH_DUMP_ATTR 392 426 393 427 /*! … … 395 429 */ 396 430 void CAxis::checkBounds() 431 TRY 397 432 { 398 433 if (!bounds.isEmpty()) … … 407 442 else hasBounds = false; 408 443 } 444 CATCH_DUMP_ATTR 409 445 410 446 void CAxis::checkLabel() 447 TRY 411 448 { 412 449 if (!label.isEmpty()) … … 421 458 else hasLabel = false; 422 459 } 460 CATCH_DUMP_ATTR 423 461 424 462 /*! … … 426 464 */ 427 465 void CAxis::checkEligibilityForCompressedOutput() 466 TRY 428 467 { 429 468 // We don't check if the mask is valid here, just if a mask has been defined at this point. 430 469 isCompressible_ = !mask.isEmpty(); 431 470 } 432 433 /* 434 Check whether we do zooming by indexing 435 return true if do zooming by index 436 */ 437 bool CAxis::zoomByIndex() 438 { 439 return (!global_zoom_index.isEmpty() && (0 != global_zoom_index.numElements())); 440 } 471 CATCH_DUMP_ATTR 441 472 442 473 /*! … … 444 475 */ 445 476 bool CAxis::dispatchEvent(CEventServer& event) 477 TRY 446 478 { 447 479 if (SuperClass::dispatchEvent(event)) return true; … … 469 501 } 470 502 } 503 CATCH 471 504 472 505 /*! … … 474 507 */ 475 508 void CAxis::checkAttributesOnClient() 509 TRY 476 510 { 477 511 if (this->areClientAttributesChecked_) return; … … 482 516 this->areClientAttributesChecked_ = true; 483 517 } 518 CATCH_DUMP_ATTR 484 519 485 520 /* … … 489 524 void CAxis::checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, 490 525 CServerDistributionDescription::ServerDistributionType distType) 526 TRY 491 527 { 492 528 CContext* context=CContext::getCurrent() ; … … 502 538 this->isClientAfterTransformationChecked = true; 503 539 } 540 CATCH_DUMP_ATTR 504 541 505 542 /* … … 512 549 void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 513 550 CServerDistributionDescription::ServerDistributionType distType) 551 TRY 514 552 { 515 553 if (!this->areClientAttributesChecked_) checkAttributesOnClient(); … … 522 560 this->isChecked = true; 523 561 } 562 CATCH_DUMP_ATTR 524 563 525 564 /*! … … 530 569 void CAxis::sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 531 570 CServerDistributionDescription::ServerDistributionType distType) 571 TRY 532 572 { 533 573 sendDistributionAttribute(globalDim, orderPositionInGrid, distType); … … 544 584 } 545 585 } 586 CATCH_DUMP_ATTR 546 587 547 588 /* … … 555 596 void CAxis::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 556 597 CServerDistributionDescription::ServerDistributionType distType) 598 TRY 557 599 { 558 600 CContext* context = CContext::getCurrent(); … … 574 616 size_t ni = this->n.getValue(); 575 617 size_t ibegin = this->begin.getValue(); 576 size_t global_zoom_end = global_zoom_begin+global_zoom_n-1;577 size_t nZoomCount = 0;578 618 size_t nbIndex = index.numElements(); 579 619 … … 588 628 589 629 // Calculate the compressed index if any 590 std::set<int> writtenInd; 591 if (isCompressible_) 592 { 593 for (int idx = 0; idx < data_index.numElements(); ++idx) 594 { 595 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 596 597 if (ind >= 0 && ind < ni && mask(ind)) 598 { 599 ind += ibegin; 600 if (ind >= global_zoom_begin && ind <= global_zoom_end) 601 writtenInd.insert(ind); 602 } 603 } 604 } 630 // std::set<int> writtenInd; 631 // if (isCompressible_) 632 // { 633 // for (int idx = 0; idx < data_index.numElements(); ++idx) 634 // { 635 // int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 636 // 637 // if (ind >= 0 && ind < ni && mask(ind)) 638 // { 639 // ind += ibegin; 640 // writtenInd.insert(ind); 641 // } 642 // } 643 // } 605 644 606 645 // Compute the global index of the current client (process) hold … … 635 674 636 675 CServerDistributionDescription serverDescription(nGlobAxis, nbServer, distType); 637 676 638 677 std::vector<int> serverZeroIndex; 639 678 serverZeroIndex = serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t&,size_t&>(indexBegin, indexEnd), 0); … … 654 693 if (distType==CServerDistributionDescription::ROOT_DISTRIBUTION) 655 694 { 656 for(int i=1; i<nbServer; ++i) 657 { 658 indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 659 } 660 695 for(int i=1; i<nbServer; ++i) indSrv_[nbServer].insert(pair<int, vector<size_t> >(i,indSrv_[nbServer][0]) ) ; 661 696 serverZeroIndexLeader.clear() ; 662 697 } 663 698 664 699 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_[nbServer].begin(), 665 700 ite = indSrv_[nbServer].end(); … … 675 710 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 676 711 677 712 nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 678 713 679 714 delete clientServerMap; … … 681 716 } 682 717 } 718 CATCH_DUMP_ATTR 683 719 684 720 /* … … 688 724 */ 689 725 void CAxis::computeWrittenIndex() 726 TRY 690 727 { 691 728 if (computedWrittenIndex_) return; … … 697 734 // We describe the distribution of client (server) on which data are written 698 735 std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 699 nBegin[0] = zoom_begin;700 nSize[0] = zoom_n;736 nBegin[0] = begin; 737 nSize[0] = n; 701 738 nBeginGlobal[0] = 0; 702 739 nGlob[0] = n_glo; … … 711 748 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 712 749 itSrve = writtenGlobalIndex.end(), itSrv; 713 if (!zoomByIndex()) 714 { 715 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 716 { 717 indGlo = *itSrv; 718 if (ite != globalLocalIndexMap_.find(indGlo)) 719 { 720 ++nbWritten; 721 } 722 } 723 724 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 725 // localIndexToWriteOnServer.resize(nbWritten); 726 727 nbWritten = 0; 728 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 729 { 730 indGlo = *itSrv; 731 if (ite != globalLocalIndexMap_.find(indGlo)) 732 { 733 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 734 ++nbWritten; 735 } 736 } 737 } 738 else 739 { 740 nbWritten = 0; 741 std::unordered_map<size_t,size_t>::const_iterator itb = globalLocalIndexMap_.begin(), 742 ite = globalLocalIndexMap_.end(), it; 743 for (int i = 0; i < zoom_index.numElements(); ++i) 744 { 745 if (ite != globalLocalIndexMap_.find(zoom_index(i))) 746 ++nbWritten; 747 } 748 749 localIndexToWriteOnServer.resize(nbWritten); 750 751 nbWritten = 0; 752 for (int i = 0; i < zoom_index.numElements(); ++i) 753 { 754 if (ite != globalLocalIndexMap_.find(zoom_index(i))) 755 { 756 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[zoom_index(i)]; 757 ++nbWritten; 758 } 759 } 760 } 761 762 } 750 751 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 752 nbWritten = 0; 753 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 754 { 755 indGlo = *itSrv; 756 if (ite != globalLocalIndexMap_.find(indGlo)) 757 { 758 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 759 } 760 else 761 { 762 localIndexToWriteOnServer(nbWritten) = -1; 763 } 764 ++nbWritten; 765 } 766 767 } 768 CATCH_DUMP_ATTR 763 769 764 770 void CAxis::computeWrittenCompressedIndex(ep_lib::MPI_Comm writtenComm) 771 TRY 765 772 { 766 773 int writtenCommSize; … … 777 784 // We describe the distribution of client (server) on which data are written 778 785 std::vector<int> nBegin(1), nSize(1), nBeginGlobal(1), nGlob(1); 779 nBegin[0] = zoom_begin;780 nSize[0] = zoom_n;786 nBegin[0] = 0; 787 nSize[0] = n; 781 788 nBeginGlobal[0] = 0; 782 789 nGlob[0] = n_glo; … … 798 805 } 799 806 } 807 // 808 // nbWritten = 0; 809 // for (int idx = 0; idx < data_index.numElements(); ++idx) 810 // { 811 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 812 // { 813 // ++nbWritten; 814 // } 815 // } 816 // 817 // compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 818 // nbWritten = 0; 819 // for (int idx = 0; idx < data_index.numElements(); ++idx) 820 // { 821 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 822 // { 823 // compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 824 // ++nbWritten; 825 // } 826 // } 800 827 801 828 nbWritten = 0; … … 823 850 { 824 851 825 ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);826 ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, MPI_INT, MPI_SUM, writtenComm);852 ep_lib::MPI_Allreduce(&numberWrittenIndexes_[writtenCommSize], &totalNumberWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 853 ep_lib::MPI_Scan(&numberWrittenIndexes_[writtenCommSize], &offsetWrittenIndexes_[writtenCommSize], 1, EP_INT, EP_SUM, writtenComm); 827 854 offsetWrittenIndexes_[writtenCommSize] -= numberWrittenIndexes_[writtenCommSize]; 828 855 } … … 831 858 } 832 859 } 860 CATCH_DUMP_ATTR 833 861 834 862 /*! … … 841 869 void CAxis::sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, 842 870 CServerDistributionDescription::ServerDistributionType distType) 871 TRY 843 872 { 844 873 std::list<CContextClient*>::iterator it; … … 865 894 const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 866 895 const int ni = serverDimensionSizes[*itRank][orderPositionInGrid]; 867 const int end = begin + ni - 1;868 896 869 897 msgs.push_back(CMessage()); 870 898 CMessage& msg = msgs.back(); 871 899 msg << this->getId(); 872 msg << ni << begin << end;900 msg << ni << begin; 873 901 msg << isCompressible_; 874 902 … … 880 908 } 881 909 } 910 CATCH_DUMP_ATTR 882 911 883 912 /* … … 886 915 */ 887 916 void CAxis::recvDistributionAttribute(CEventServer& event) 917 TRY 888 918 { 889 919 CBufferIn* buffer = event.subEvents.begin()->buffer; … … 892 922 get(axisId)->recvDistributionAttribute(*buffer); 893 923 } 924 CATCH 894 925 895 926 /* … … 898 929 */ 899 930 void CAxis::recvDistributionAttribute(CBufferIn& buffer) 900 { 901 int ni_srv, begin_srv, end_srv; 902 int global_zoom_end, zoom_end; 903 bool zoomIndex = zoomByIndex(); 904 905 std::vector<int> zoom_index_tmp; 906 std::vector<int>::iterator itZoomBegin, itZoomEnd, itZoom; 907 908 buffer >> ni_srv >> begin_srv >> end_srv; 931 TRY 932 { 933 int ni_srv, begin_srv; 934 buffer >> ni_srv >> begin_srv; 909 935 buffer >> isCompressible_; 910 936 … … 912 938 n.setValue(ni_srv); 913 939 begin.setValue(begin_srv); 914 915 // If we have zoom by index then process it 916 if (zoomIndex) 917 { 918 zoom_index_tmp.resize(global_zoom_index.numElements()); 919 std::copy(global_zoom_index.begin(), global_zoom_index.end(), zoom_index_tmp.begin()); 920 std::sort(zoom_index_tmp.begin(), zoom_index_tmp.end()); 921 itZoomBegin = std::lower_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), begin_srv); 922 itZoomEnd = std::upper_bound(zoom_index_tmp.begin(), zoom_index_tmp.end(), end_srv); 923 int sz = std::distance(itZoomBegin, itZoomEnd); 924 zoom_index.resize(sz); 925 itZoom = itZoomBegin; 926 for (int i = 0; i < sz; ++i, ++itZoom) 927 { 928 zoom_index(i) = *(itZoom); 929 } 930 } 931 932 global_zoom_begin = zoomIndex ? 0 : global_zoom_begin ; 933 global_zoom_n = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 934 global_zoom_end = global_zoom_begin + global_zoom_n - 1; 935 936 zoom_begin = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomBegin) 937 : global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 938 zoom_end = zoomIndex ? std::distance(zoom_index_tmp.begin(), itZoomEnd) - 1 939 : global_zoom_end < end_srv ? global_zoom_end : end_srv ; 940 zoom_n = zoom_end - zoom_begin + 1; 941 942 if (zoom_n<=0) 943 { 944 zoom_n = 0; zoom_begin=global_zoom_begin; //0; zoom_begin = 0; 945 } 946 947 if (n_glo == n) 948 { 949 zoom_begin = zoomIndex ? std::distance(itZoomBegin, zoom_index_tmp.begin()) 950 : global_zoom_begin; 951 zoom_n = zoomIndex ? zoom_index_tmp.size() : global_zoom_n; 952 } 953 } 940 } 941 CATCH_DUMP_ATTR 954 942 955 943 /* … … 959 947 */ 960 948 void CAxis::sendNonDistributedAttributes() 949 TRY 961 950 { 962 951 std::list<CContextClient*>::iterator it; 963 952 for (it=clients.begin(); it!=clients.end(); ++it) 964 965 953 { 954 CContextClient* client = *it; 966 955 967 956 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); … … 1012 1001 } 1013 1002 } 1003 CATCH_DUMP_ATTR 1014 1004 1015 1005 /* … … 1018 1008 */ 1019 1009 void CAxis::recvNonDistributedAttributes(CEventServer& event) 1010 TRY 1020 1011 { 1021 1012 list<CEventServer::SSubEvent>::iterator it; … … 1028 1019 } 1029 1020 } 1021 CATCH 1030 1022 1031 1023 /* … … 1035 1027 */ 1036 1028 void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 1029 TRY 1037 1030 { 1038 CArray<int,1> tmp_index, tmp_data_index , tmp_zoom_index;1031 CArray<int,1> tmp_index, tmp_data_index; 1039 1032 CArray<bool,1> tmp_mask; 1040 1033 CArray<double,1> tmp_val; … … 1076 1069 for (int idx = 0; idx < index.numElements(); ++idx) globalLocalIndexMap_[index(idx)] = idx; 1077 1070 } 1071 CATCH_DUMP_ATTR 1078 1072 1079 1073 /* 1080 Send a ttributes of axis from a group of client to other group of clients/servers1081 onsupposing that these attributes are distributed among the clients of the sending group1082 In thefuture, if new attributes are added, they should also be processed in this function1074 Send axis attributes from a group of clients to another group of clients/servers 1075 supposing that these attributes are distributed among the clients of the sending group 1076 In future, if new attributes are added, they should also be processed in this function 1083 1077 */ 1084 1078 void CAxis::sendDistributedAttributes(void) 1085 { 1086 int ns, n, i, j, ind, nv, idx; 1079 TRY 1080 { 1081 int ind, idx; 1087 1082 std::list<CContextClient*>::iterator it; 1088 1083 … … 1095 1090 1096 1091 list<CMessage> listData; 1097 list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 1098 list<CArray<bool,1> > list_mask; 1092 list<CArray<int,1> > list_indi, list_dataInd; 1099 1093 list<CArray<double,1> > list_val; 1100 1094 list<CArray<double,2> > list_bounds; 1101 1095 list<CArray<string,1> > list_label; 1102 1096 1097 // Cut off the ghost points 1103 1098 int nbIndex = index.numElements(); 1104 1099 CArray<int,1> dataIndex(nbIndex); … … 1107 1102 { 1108 1103 if (0 <= data_index(idx) && data_index(idx) < nbIndex) 1109 dataIndex( idx) = 1;1104 dataIndex(data_index(idx)) = 1; 1110 1105 } 1111 1106 … … 1114 1109 for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 1115 1110 { 1116 int nbData = 0 ;1111 int nbData = 0, nbDataCount = 0; 1117 1112 int rank = connectedServerRank_[nbServer][k]; 1118 1113 it = indSrv_[nbServer].find(rank); … … 1121 1116 1122 1117 list_indi.push_back(CArray<int,1>(nbData)); 1123 list_dataInd.push_back(CArray<int,1>(nbData)); 1124 list_mask.push_back(CArray<bool,1>(nbData)); 1118 list_dataInd.push_back(CArray<int,1>(nbData)); 1125 1119 1126 1120 if (hasValue) … … 1134 1128 1135 1129 CArray<int,1>& indi = list_indi.back(); 1136 CArray<int,1>& dataIndi = list_dataInd.back(); 1137 CArray<bool,1>& maskIndi = list_mask.back();1138 1139 for ( n = 0; n < nbData; ++n)1130 CArray<int,1>& dataIndi = list_dataInd.back(); 1131 dataIndi = -1; 1132 1133 for (int n = 0; n < nbData; ++n) 1140 1134 { 1141 1135 idx = static_cast<int>(it->second[n]); … … 1144 1138 ind = globalLocalIndexMap_[idx]; 1145 1139 dataIndi(n) = dataIndex(ind); 1146 maskIndi(n) = mask(ind);1147 1140 1148 1141 if (hasValue) … … 1168 1161 listData.push_back(CMessage()); 1169 1162 listData.back() << this->getId() 1170 << list_indi.back() << list_dataInd.back() << list_mask.back();1163 << list_indi.back() << list_dataInd.back(); 1171 1164 1172 1165 listData.back() << hasValue; … … 1188 1181 } 1189 1182 } 1183 CATCH_DUMP_ATTR 1190 1184 1191 1185 /* … … 1194 1188 */ 1195 1189 void CAxis::recvDistributedAttributes(CEventServer& event) 1190 TRY 1196 1191 { 1197 1192 string axisId; … … 1209 1204 get(axisId)->recvDistributedAttributes(ranks, buffers); 1210 1205 } 1206 CATCH 1211 1207 1212 1208 /* … … 1216 1212 */ 1217 1213 void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) 1214 TRY 1218 1215 { 1219 1216 int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 1220 vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived); 1221 vector<CArray<bool,1> > vec_mask(nbReceived); 1217 vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 1222 1218 vector<CArray<double,1> > vec_val(nbReceived); 1223 1219 vector<CArray<double,2> > vec_bounds(nbReceived); … … 1229 1225 buffer >> vec_indi[idx]; 1230 1226 buffer >> vec_dataInd[idx]; 1231 buffer >> vec_mask[idx];1232 1227 1233 1228 buffer >> hasValue; … … 1256 1251 globalLocalIndexMap_.rehash(std::ceil(index.numElements()/globalLocalIndexMap_.max_load_factor())); 1257 1252 nbIndexGlob = 0; 1253 int nbIndLoc = 0; 1258 1254 for (idx = 0; idx < nbReceived; ++idx) 1259 1255 { … … 1262 1258 { 1263 1259 gloInd = tmp(ind); 1260 nbIndLoc = (gloInd % n_glo)-begin; 1264 1261 if (0 == globalLocalIndexMap_.count(gloInd)) 1265 1262 { 1266 index(nbIndexGlob) = gloInd % n_glo; 1267 globalLocalIndexMap_[gloInd] = nbIndexGlob; 1263 index(nbIndexGlob) = gloInd % n_glo; 1264 globalLocalIndexMap_[gloInd] = nbIndexGlob; 1268 1265 ++nbIndexGlob; 1269 1266 } … … 1278 1275 CArray<int,1> nonCompressedData(nbData); 1279 1276 nonCompressedData = -1; 1280 mask.resize(nbData); 1277 // Mask is incorporated into data_index and is not sent/received anymore 1278 mask.resize(0); 1281 1279 if (hasValue) 1282 1280 value.resize(nbData); … … 1291 1289 CArray<int,1>& indi = vec_indi[idx]; 1292 1290 CArray<int,1>& dataIndi = vec_dataInd[idx]; 1293 CArray<bool,1>& maskIndi = vec_mask[idx];1294 1291 int nb = indi.numElements(); 1295 1292 for (int n = 0; n < nb; ++n) … … 1299 1296 nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd); 1300 1297 1301 if (!mask(locInd)) // Only rewrite mask if it's not true1302 mask(locInd) = maskIndi(n);1303 1304 1298 if (hasValue) 1305 1299 value(locInd) = vec_val[idx](n); … … 1316 1310 } 1317 1311 1318 int nbCompressedData = 0; 1312 int nbCompressedData = 0; 1319 1313 for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 1320 1314 { 1321 1315 if (0 <= nonCompressedData(idx)) 1322 ++nbCompressedData; 1316 ++nbCompressedData; 1323 1317 } 1324 1318 … … 1330 1324 { 1331 1325 data_index(nbCompressedData) = idx % n; 1332 ++nbCompressedData; 1326 ++nbCompressedData; 1333 1327 } 1334 1328 } 1335 1329 1336 1330 data_begin.setValue(0); 1337 } 1331 data_n.setValue(data_index.numElements()); 1332 } 1333 CATCH_DUMP_ATTR 1338 1334 1339 1335 /*! … … 1345 1341 */ 1346 1342 bool CAxis::isEqual(CAxis* obj) 1343 TRY 1347 1344 { 1348 1345 vector<StdString> excludedAttr; … … 1368 1365 return objEqual; 1369 1366 } 1367 CATCH_DUMP_ATTR 1370 1368 1371 1369 /* … … 1375 1373 */ 1376 1374 CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) 1375 TRY 1377 1376 { 1378 1377 transformationMap_.push_back(std::make_pair(transType, CTransformation<CAxis>::createTransformation(transType,id))); 1379 1378 return transformationMap_.back().second; 1380 1379 } 1380 CATCH_DUMP_ATTR 1381 1381 1382 1382 /* … … 1384 1384 */ 1385 1385 bool CAxis::hasTransformation() 1386 TRY 1386 1387 { 1387 1388 return (!transformationMap_.empty()); 1388 1389 } 1390 CATCH_DUMP_ATTR 1389 1391 1390 1392 /* … … 1393 1395 */ 1394 1396 void CAxis::setTransformations(const TransMapTypes& axisTrans) 1397 TRY 1395 1398 { 1396 1399 transformationMap_ = axisTrans; 1397 1400 } 1401 CATCH_DUMP_ATTR 1398 1402 1399 1403 /* … … 1402 1406 */ 1403 1407 CAxis::TransMapTypes CAxis::getAllTransformations(void) 1408 TRY 1404 1409 { 1405 1410 return transformationMap_; 1406 1411 } 1412 CATCH_DUMP_ATTR 1407 1413 1408 1414 /* … … 1411 1417 */ 1412 1418 void CAxis::duplicateTransformation(CAxis* src) 1419 TRY 1413 1420 { 1414 1421 if (src->hasTransformation()) … … 1417 1424 } 1418 1425 } 1426 CATCH_DUMP_ATTR 1419 1427 1420 1428 /*! … … 1422 1430 */ 1423 1431 void CAxis::solveInheritanceTransformation() 1432 TRY 1424 1433 { 1425 1434 if (hasTransformation() || !hasDirectAxisReference()) … … 1438 1447 refAxis[i]->setTransformations(axis->getAllTransformations()); 1439 1448 } 1449 CATCH_DUMP_ATTR 1440 1450 1441 1451 void CAxis::setContextClient(CContextClient* contextClient) 1452 TRY 1442 1453 { 1443 1454 if (clientsSet.find(contextClient)==clientsSet.end()) … … 1446 1457 clientsSet.insert(contextClient); 1447 1458 } 1448 } 1459 } 1460 CATCH_DUMP_ATTR 1449 1461 1450 1462 void CAxis::parse(xml::CXMLNode & node) 1463 TRY 1451 1464 { 1452 1465 SuperClass::parse(node); … … 1462 1475 1463 1476 nodeElementName = node.getElementName(); 1464 1465 if(transformationMapList_ptr == 0) initializeTransformationMap(); 1466 std::map<StdString, ETranformationType>::const_iterator ite = (*CAxis::transformationMapList_ptr).end(), it; 1467 it = (*CAxis::transformationMapList_ptr).find(nodeElementName); 1477 std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it; 1478 it = transformationMapList_.find(nodeElementName); 1468 1479 if (ite != it) 1469 1480 { … … 1481 1492 } 1482 1493 } 1494 CATCH_DUMP_ATTR 1483 1495 1484 1496 DEFINE_REF_FUNC(Axis,axis)
Note: See TracChangeset
for help on using the changeset viewer.