Changeset 2137 for XIOS/dev/dev_trunk_graph/src/node
- Timestamp:
- 05/30/21 23:30:01 (3 years ago)
- Location:
- XIOS/dev/dev_trunk_graph/src/node
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_graph/src/node/axis.cpp
r2027 r2137 451 451 452 452 } 453 453 454 454 string CAxis::getCouplingAlias(const string& fieldId, int posInGrid) 455 455 { -
XIOS/dev/dev_trunk_graph/src/node/axis.hpp
r2027 r2137 176 176 void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 177 177 string getCouplingAlias(const string& fieldId, int posInGrid) ; 178 179 178 180 179 private: -
XIOS/dev/dev_trunk_graph/src/node/context.cpp
r2027 r2137 73 73 74 74 //---------------------------------------------------------------- 75 void CContext::initEventScheduler(void) 76 { 77 SRegisterContextInfo contextInfo ; 78 CXios::getContextsManager()->getContextInfo(this->getId(), contextInfo, getIntraComm()) ; 79 80 eventScheduler_=CXios::getPoolRessource()->getService(contextInfo.serviceId,contextInfo.partitionId)->getEventScheduler() ; 75 76 void CContext::initEventScheduler(void) 77 { 78 SRegisterContextInfo contextInfo ; 79 CXios::getContextsManager()->getContextInfo(this->getId(), contextInfo, getIntraComm()) ; 80 81 eventScheduler_=CXios::getPoolRessource()->getService(contextInfo.serviceId,contextInfo.partitionId)->getEventScheduler() ; 81 82 82 // generate unique hash for server 83 auto time=chrono::system_clock::now().time_since_epoch().count() ; 84 std::default_random_engine rd(time); // not reproducible from a run to another 85 std::uniform_int_distribution<size_t> dist; 86 hashId_=dist(rd) ; 87 MPI_Bcast(&hashId_,1,MPI_SIZE_T,0,getIntraComm()) ; // Bcast to all server of the context 88 } 89 83 // generate unique hash for server 84 auto time=chrono::system_clock::now().time_since_epoch().count() ; 85 std::default_random_engine rd(time); // not reproducible from a run to another 86 std::uniform_int_distribution<size_t> dist; 87 hashId_=dist(rd) ; 88 MPI_Bcast(&hashId_,1,MPI_SIZE_T,0,getIntraComm()) ; // Bcast to all server of the context 89 } 90 90 /*! 91 91 \brief Get context group (context root) … … 291 291 ///--------------------------------------------------------------- 292 292 293 294 void CContext::setClientServerBuffer(vector<CField*>& fields, bool bufferForWriting)295 TRY296 {297 // Estimated minimum event size for small events (20 is an arbitrary constant just for safety)298 const size_t minEventSize = CEventClient::headerSize + 20 * sizeof(int);299 // Ensure there is at least some room for 20 of such events in the buffers300 size_t minBufferSize = std::max(CXios::minBufferSize, 20 * minEventSize);301 302 #define DECLARE_NODE(Name_, name_) \303 if (minBufferSize < sizeof(C##Name_##Definition)) minBufferSize = sizeof(C##Name_##Definition);304 #define DECLARE_NODE_PAR(Name_, name_)305 #include "node_type.conf"306 #undef DECLARE_NODE307 #undef DECLARE_NODE_PAR308 309 310 map<CContextClient*,map<int,size_t>> dataSize ;311 map<CContextClient*,map<int,size_t>> maxEventSize ;312 map<CContextClient*,map<int,size_t>> attributesSize ;313 314 for(auto field : fields)315 {316 field->setContextClientDataBufferSize(dataSize, maxEventSize, bufferForWriting) ;317 field->setContextClientAttributesBufferSize(attributesSize, maxEventSize, bufferForWriting) ;318 }319 320 321 for(auto& it : attributesSize)322 {323 auto contextClient = it.first ;324 auto& contextDataSize = dataSize[contextClient] ;325 auto& contextAttributesSize = attributesSize[contextClient] ;326 auto& contextMaxEventSize = maxEventSize[contextClient] ;327 328 for (auto& it : contextAttributesSize)329 {330 auto serverRank=it.first ;331 auto& buffer = contextAttributesSize[serverRank] ;332 if (contextDataSize[serverRank] > buffer) buffer=contextDataSize[serverRank] ;333 buffer *= CXios::bufferSizeFactor;334 if (buffer < minBufferSize) buffer = minBufferSize;335 if (buffer > CXios::maxBufferSize ) buffer = CXios::maxBufferSize;336 }337 338 // Leaders will have to send some control events so ensure there is some room for those in the buffers339 if (contextClient->isServerLeader())340 for(auto& rank : contextClient->getRanksServerLeader())341 if (!contextAttributesSize.count(rank))342 {343 contextAttributesSize[rank] = minBufferSize;344 contextMaxEventSize[rank] = minEventSize;345 }346 347 contextClient->setBufferSize(contextAttributesSize, contextMaxEventSize);348 }349 }350 CATCH_DUMP_ATTR351 352 353 /*!354 Sets client buffers.355 \param [in] contextClient356 \param [in] bufferForWriting True if buffers are used for sending data for writing357 This flag is only true for client and server-1 for communication with server-2358 */359 // ym obsolete to be removed360 void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting)361 TRY362 {363 // Estimated minimum event size for small events (20 is an arbitrary constant just for safety)364 const size_t minEventSize = CEventClient::headerSize + 20 * sizeof(int);365 366 // Ensure there is at least some room for 20 of such events in the buffers367 size_t minBufferSize = std::max(CXios::minBufferSize, 20 * minEventSize);368 369 #define DECLARE_NODE(Name_, name_) \370 if (minBufferSize < sizeof(C##Name_##Definition)) minBufferSize = sizeof(C##Name_##Definition);371 #define DECLARE_NODE_PAR(Name_, name_)372 #include "node_type.conf"373 #undef DECLARE_NODE374 #undef DECLARE_NODE_PAR375 376 // Compute the buffer sizes needed to send the attributes and data corresponding to fields377 std::map<int, StdSize> maxEventSize;378 std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize, contextClient, bufferForWriting);379 std::map<int, StdSize> dataBufferSize = getDataBufferSize(maxEventSize, contextClient, bufferForWriting);380 381 std::map<int, StdSize>::iterator it, ite = dataBufferSize.end();382 for (it = dataBufferSize.begin(); it != ite; ++it)383 if (it->second > bufferSize[it->first]) bufferSize[it->first] = it->second;384 385 // Apply the buffer size factor, check that we are above the minimum buffer size and below the maximum size386 ite = bufferSize.end();387 for (it = bufferSize.begin(); it != ite; ++it)388 {389 it->second *= CXios::bufferSizeFactor;390 if (it->second < minBufferSize) it->second = minBufferSize;391 if (it->second > CXios::maxBufferSize) it->second = CXios::maxBufferSize;392 }393 394 // Leaders will have to send some control events so ensure there is some room for those in the buffers395 if (contextClient->isServerLeader())396 {397 const std::list<int>& ranks = contextClient->getRanksServerLeader();398 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)399 {400 if (!bufferSize.count(*itRank))401 {402 bufferSize[*itRank] = minBufferSize;403 maxEventSize[*itRank] = minEventSize;404 }405 }406 }407 contextClient->setBufferSize(bufferSize, maxEventSize);408 }409 CATCH_DUMP_ATTR410 293 411 294 /*! … … 716 599 CATCH_DUMP_ATTR 717 600 718 719 bool CContext::eventLoop(bool enableEventsProcessing) 601 void CContext::globalEventLoop(void) 720 602 { 721 bool finished=true; 722 bool out; 603 lockContext() ; 604 CXios::getDaemonsManager()->eventLoop() ; 605 unlockContext() ; 606 setCurrent(getId()) ; 607 } 608 609 bool CContext::scheduledEventLoop(bool enableEventsProcessing) 610 { 611 bool out, finished; 723 612 size_t timeLine=timeLine_ ; 724 613 if (serviceType_==CServicesManager::CLIENT) … … 730 619 do 731 620 { 732 if (client!=nullptr && !finalized) client->checkBuffers(); 733 734 for (int i = 0; i < clientPrimServer.size(); ++i) 735 { 736 if (!finalized) clientPrimServer[i]->checkBuffers(); 737 if (!finalized) finished &= serverPrimServer[i]->eventLoop(enableEventsProcessing); 738 } 739 740 for (auto couplerOut : couplerOutClient_) 741 if (!finalized) couplerOut.second->checkBuffers(); 742 743 for (auto couplerIn : couplerInClient_) 744 if (!finalized) couplerIn.second->checkBuffers(); 745 746 for (auto couplerOut : couplerOutServer_) 747 if (!finalized) couplerOut.second->eventLoop(enableEventsProcessing); 748 749 for (auto couplerIn : couplerInServer_) 750 if (!finalized) couplerIn.second->eventLoop(enableEventsProcessing); 751 752 if (server!=nullptr) if (!finalized) finished &= server->eventLoop(enableEventsProcessing); 753 621 finished=eventLoop(enableEventsProcessing) ; 754 622 if (serviceType_==CServicesManager::CLIENT) out = eventScheduler_->queryEvent(timeLine,hashId_) ; 755 623 else out=true ; 756 624 } while(!out) ; 625 626 return finished ; 627 } 628 629 bool CContext::eventLoop(bool enableEventsProcessing) 630 { 631 bool finished; 632 if (isLockedContext()) return ; 633 634 setCurrent(getId()) ; 635 636 if (client!=nullptr && !finalized) client->checkBuffers(); 637 638 for (int i = 0; i < clientPrimServer.size(); ++i) 639 { 640 if (!finalized) clientPrimServer[i]->checkBuffers(); 641 if (!finalized) finished &= serverPrimServer[i]->eventLoop(enableEventsProcessing); 642 } 643 644 for (auto couplerOut : couplerOutClient_) 645 if (!finalized) couplerOut.second->checkBuffers(); 646 647 for (auto couplerIn : couplerInClient_) 648 if (!finalized) couplerIn.second->checkBuffers(); 649 650 for (auto couplerOut : couplerOutServer_) 651 if (!finalized) couplerOut.second->eventLoop(enableEventsProcessing); 652 653 for (auto couplerIn : couplerInServer_) 654 if (!finalized) couplerIn.second->eventLoop(enableEventsProcessing); 655 656 if (server!=nullptr) if (!finalized) finished &= server->eventLoop(enableEventsProcessing); 657 setCurrent(getId()) ; 757 658 return finalized && finished ; 758 659 } … … 784 685 couplerOutClient_[fullContextId] = client ; 785 686 couplerOutServer_[fullContextId] = server ; 786 787 /*788 // for now, we don't now which beffer size must be used for client coupler789 // It will be evaluated later. Fix a constant size for now...790 // set to 10Mb for development791 map<int,size_t> bufferSize, maxEventSize ;792 for(int i=0;i<client->getRemoteSize();i++)793 {794 bufferSize[i]=10000000 ;795 maxEventSize[i]=10000000 ;796 }797 798 client->setBufferSize(bufferSize, maxEventSize);799 */800 687 } 801 688 } … … 819 706 MPI_Comm_free(&interComm) ; 820 707 821 map<int,size_t> bufferSize, maxEventSize ;822 for(int i=0;i<client->getRemoteSize();i++)823 {824 bufferSize[i]=10000000 ;825 maxEventSize[i]=10000000 ;826 }827 828 client->setBufferSize(bufferSize, maxEventSize);829 708 couplerInClient_[fullContextId] = client ; 830 709 couplerInServer_[fullContextId] = server ; … … 832 711 } 833 712 834 void CContext::globalEventLoop(void)835 {836 CXios::getDaemonsManager()->eventLoop() ;837 setCurrent(getId()) ;838 }839 840 841 713 void CContext::finalize(void) 842 714 TRY … … 1023 895 1024 896 bool workflowGraphIsCompleted ; 1025 897 1026 898 bool first=true ; 899 1027 900 do 1028 901 { … … 1032 905 workflowGraphIsCompleted &= endWorkflowField->buildWorkflowGraph(garbageCollector) ; 1033 906 } 1034 907 1035 908 for(auto couplerIn : enabledCouplerIn) couplerIn->assignContext() ; 1036 909 for(auto field : couplerInField) field->makeGridAliasForCoupling(); … … 1045 918 // connect to couplerOut -> to do 1046 919 } 1047 if (first) setClientServerBuffer(couplerOutField, true) ; // set buffer context --> to check 1048 920 1049 921 bool couplersReady ; 1050 922 do … … 1057 929 couplersReady &= ready ; 1058 930 } 1059 this->eventLoop() ; 931 this->scheduledEventLoop() ; 932 1060 933 } while (!couplersReady) ; 1061 934 1062 935 first=false ; 1063 this->eventLoop() ; 936 this->scheduledEventLoop() ; 937 1064 938 } while (!workflowGraphIsCompleted) ; 939 1065 940 1066 941 for( auto field : couplerInField) couplerInFields_.push_back(field) ; … … 1087 962 field->connectToFileServer(garbageCollector) ; // connect the field to server filter 1088 963 } 1089 setClientServerBuffer(fileOutField, true) ; // set buffer context --> to review1090 964 for(auto field : fileOutField) field->sendFieldToFileServer() ; 1091 965 } … … 1193 1067 ok = true ; 1194 1068 for(auto& couplerOutClient : couplerOutClient_) ok &= isCouplerInCloseDefinition(couplerOutClient.second) ; 1195 this-> eventLoop() ;1069 this->scheduledEventLoop() ; 1196 1070 } while (!ok) ; 1071 1072 // Now evaluate the size of the context client buffers 1073 map<CContextClient*,map<int,size_t>> fieldBufferEvaluation ; 1074 for(auto field : fileOutField) field->evaluateBufferSize(fieldBufferEvaluation, CXios::isOptPerformance) ; // output to server 1075 for(auto field : couplerOutField) field->evaluateBufferSize(fieldBufferEvaluation, CXios::isOptPerformance) ; // output to coupler 1076 for(auto field : fieldModelIn) field->evaluateBufferSize(fieldBufferEvaluation, CXios::isOptPerformance) ; // server to client (for io servers) 1077 1078 // fix size for each context client 1079 for(auto& it : fieldBufferEvaluation) it.first->setBufferSize(it.second) ; 1080 1197 1081 1198 1082 CTimer::get("Context : close definition").suspend() ; -
XIOS/dev/dev_trunk_graph/src/node/context.hpp
r2027 r2137 15 15 #include "server_context.hpp" 16 16 #include "event_scheduler.hpp" 17 17 18 18 19 namespace xios … … 108 109 // Put sever or client into loop state 109 110 bool eventLoop(bool enableEventsProcessing=true); 111 bool scheduledEventLoop(bool enableEventsProcessing=true) ; 110 112 void globalEventLoop(void); 111 113 … … 148 150 std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 149 151 std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 150 void setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting = false); // old interface to be removed151 void setClientServerBuffer(vector<CField*>& fields, bool bufferForWriting) ;152 152 153 153 // Distribute files (in write mode) among secondary-server pools according to the estimated data flux … … 355 355 string contextId_ ; //!< context client id for the servers. For clients this is same as getId() 356 356 bool isProcessingEvent_ ; 357 private: 357 358 CServerContext* parentServerContext_ ; 358 359 public: 360 CServerContext* getParentServerContext(void) { return parentServerContext_; } 361 private: 362 bool lockedContext_=false; 363 public: 364 void lockContext(void) {lockedContext_=true; } 365 void unlockContext(void) {lockedContext_=true; } 366 bool isLockedContext(void) { return lockedContext_;} 359 367 public: // Some function maybe removed in the near future 360 368 // virtual void toBinary (StdOStream & os) const; -
XIOS/dev/dev_trunk_graph/src/node/domain.cpp
r2027 r2137 805 805 nj = 1; 806 806 jbegin = 0; 807 if (!i_index.isEmpty()) ni = i_index.numElements(); 808 j_index.resize(ni); 809 for(int i=0;i<ni;++i) j_index(i)=0; 810 811 if (!area.isEmpty()) 812 area.transposeSelf(1, 0); 807 if (!i_index.isEmpty()) 808 { 809 ni = i_index.numElements(); 810 j_index.resize(ni); 811 for(int i=0;i<ni;++i) j_index(i)=0; 812 } 813 814 815 if (!area.isEmpty()) area.transposeSelf(1, 0); // => to be checked why is it transposed 813 816 } 814 817 … … 1780 1783 } 1781 1784 1785 1782 1786 string CDomain::getCouplingAlias(const string& fieldId, int posInGrid) 1783 1787 { … … 1808 1812 void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) 1809 1813 { 1810 1814 const string domainId = getCouplingAlias(fieldId, posInGrid); 1811 1815 this->createAlias(domainId) ; 1812 1816 } -
XIOS/dev/dev_trunk_graph/src/node/domain.hpp
r2027 r2137 241 241 void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 242 242 string getCouplingAlias(const string& fieldId, int posInGrid) ; 243 244 243 private: 245 244 -
XIOS/dev/dev_trunk_graph/src/node/extract_domain_to_axis.cpp
r2019 r2137 67 67 { 68 68 case direction_attr::jDir: 69 if (axis_n_glo != domain_n i_glo)69 if (axis_n_glo != domain_nj_glo) 70 70 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 71 << "Extract domain along j, axis destination should have n_glo equal to n i_glo of domain source"72 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_n i_glo << std::endl71 << "Extract domain along j, axis destination should have n_glo equal to nj_glo of domain source" 72 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 73 73 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 74 if ((position < 0) || (position > domain_ni_glo))74 if ((position < 0) || (position >= domain_ni_glo)) 75 75 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 76 << "Extract domain along j, position should be inside 0 and ni_glo of domain source"77 << "Domain source " <<domainSrc->getId() << " has n j_glo " << domain_ni_glo << std::endl76 << "Extract domain along j, position should be inside 0 and ni_glo-1 of domain source" 77 << "Domain source " <<domainSrc->getId() << " has ni_glo " << domain_ni_glo << std::endl 78 78 << "Axis destination " << axisDst->getId() << std::endl 79 79 << "Position " << position); … … 81 81 82 82 case direction_attr::iDir: 83 if (axis_n_glo != domain_n j_glo)83 if (axis_n_glo != domain_ni_glo) 84 84 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 85 << "Extract domain along i, axis destination should have n_glo equal to n j_glo of domain source"86 << "Domain source " <<domainSrc->getId() << " has n j_glo " << domain_nj_glo << std::endl85 << "Extract domain along i, axis destination should have n_glo equal to ni_glo of domain source" 86 << "Domain source " <<domainSrc->getId() << " has ni_glo " << domain_ni_glo << std::endl 87 87 << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); 88 if ((position < 0) || (position > domain_nj_glo))88 if ((position < 0) || (position >= domain_nj_glo)) 89 89 ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 90 << "Extract domain along i, position should be inside 0 and nj_glo of domain source"91 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_n i_glo << std::endl90 << "Extract domain along i, position should be inside 0 and nj_glo-1 of domain source" 91 << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 92 92 << "Axis destination " << axisDst->getId() << std::endl 93 93 << "Position " << position); -
XIOS/dev/dev_trunk_graph/src/node/field.cpp
r2027 r2137 383 383 CATCH_DUMP_ATTR 384 384 385 385 386 //---------------------------------------------------------------- 386 387 … … 497 498 CATCH_DUMP_ATTR 498 499 500 bool CField::evaluateBufferSize(map<CContextClient*,map<int,size_t>>& evaluateBuffer, bool isOptPerformance) 501 { 502 CContextClient* client=nullptr ; 503 504 for(int i=0;i<2;i++) 505 { 506 map<int,int> dataSize ; 507 if (i==0 && clientToServerStoreFilter_) client = clientToServerStoreFilter_-> getTransferedDataSize(dataSize) ; 508 if (i==1 && serverToClientStoreFilter_) client = serverToClientStoreFilter_-> getTransferedDataSize(dataSize) ; 509 510 if (client!=nullptr) 511 { 512 map<int,size_t> bufferSize ; 513 514 if (evaluateBuffer.count(client)!=0) bufferSize = evaluateBuffer[client] ; 515 if (isOptPerformance) 516 { 517 for(auto& it : dataSize) 518 { 519 if (bufferSize.count(it.first)==0) bufferSize[it.first]=it.second ; 520 else bufferSize[it.first]+=it.second ; 521 } 522 } 523 else 524 { 525 for(auto& it : dataSize) 526 { 527 if (bufferSize.count(it.first)==0) bufferSize[it.first]=it.second ; 528 else bufferSize[it.first]=std::max(bufferSize[it.first],(size_t)it.second) ; 529 } 530 } 531 evaluateBuffer[client] = bufferSize ; 532 client=nullptr ; 533 } 534 } 535 if (client==nullptr) return false ; 536 else return true; 537 } 499 538 500 539 … … 550 589 bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 551 590 std::cout<<"field id="<<this->getId()<<" build_workflow_graph="<<buildGraph_<<std::endl; 552 553 if (!inputFilter) 554 { 555 inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc)); 556 /*if(buildGraph_) 557 { 558 std::cout<<"============== field "<<this->getId()<<" calls a pass through filter ============== "<<inputFilter<<" ***** "<<CXios::isClient<<std::endl; 559 inputFilter->graphEnabled = true; 560 inputFilter->graphPackage = new CGraphPackage; 561 inputFilter->graphPackage->inFields.push_back(this); 562 }*/ 563 } 591 if (!inputFilter) inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc)); 564 592 565 593 if (hasDirectFieldReference()) 566 594 { 567 568 595 CField* fieldRef = getDirectFieldReference(); 596 597 //------ build_workflow_graph start 569 598 if(buildGraph_) 570 599 { … … 580 609 581 610 if(buildGraph_) this->build_workflow_graph.set(build_workflow_graph); 611 //------ build_workflow_graph end 612 582 613 bool ret=fieldRef->buildWorkflowGraph(gc); 583 614 if (!ret) return false ; // workflow graph cannot be built at this stage … … 612 643 { 613 644 grid->solveElementsRefInheritance() ; 614 615 // new616 617 645 std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid->buildTransformationGraph(gc, false, gridSrc, detectMissingValues, defaultValue, newGrid, buildGraph_, this) ; 618 646 lastFilter->connectOutput(filters.first, 0); 619 /*if(buildGraph_)620 {621 std::cout<<"============== field "<<this->getId()<<" calls a transformation filter 1 ============== "<<lastFilter<<" _ "<<filters.first<<" ***** "<<CXios::isClient<<std::endl;622 filters.first->graphEnabled=true;623 filters.first->graphPackage = new CGraphPackage;624 filters.first->graphPackage->inFields.push_back(this);625 }*/626 647 lastFilter = filters.second; 627 648 gridSrc = newGrid ; 628 629 // end new630 649 } 631 650 … … 658 677 grid_ = newGrid ; 659 678 grid_ref=grid_->getId() ; // for server 679 //grid_->completeGrid(); // grid generation, to be checked 660 680 if (fileIn_->isClientSide()) fileIn_->readFieldAttributesValues(this); 661 681 grid_->checkElementsAttributes() ; 682 // grid_->solveDomainAxisBaseRef(); 662 683 // probably in future tag grid incomplete if coming from a reading 663 684 instantDataFilter=inputFilter ; … … 927 948 * \return the output pin corresponding to a self reference 928 949 */ 950 951 /* old version 952 std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 953 TRY 954 { 955 if (instantDataFilter || !hasExpression()) 956 ERROR("COutputPin* CField::getSelfReference(CGarbageCollector& gc)", 957 "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); 958 959 if (!selfReferenceFilter) 960 { 961 const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 962 const double defaultValue = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 963 964 if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 965 { 966 if (!serverSourceFilter) 967 { 968 checkTimeAttributes(); 969 serverSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, true, false, freq_offset, true, 970 detectMissingValues, defaultValue)); 971 } 972 973 selfReferenceFilter = serverSourceFilter; 974 } 975 else if (!field_ref.isEmpty()) 976 { 977 CField* fieldRef = CField::get(field_ref); 978 fieldRef->buildFilterGraph(gc, false); 979 selfReferenceFilter = fieldRef->getInstantDataFilter(); 980 } 981 else 982 { 983 if (!clientSourceFilter) 984 { 985 if (check_if_active.isEmpty()) check_if_active = false; 986 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, true, true, NoneDu, false, 987 detectMissingValues, defaultValue)); 988 } 989 990 selfReferenceFilter = clientSourceFilter; 991 } 992 } 993 994 return selfReferenceFilter; 995 } 996 CATCH_DUMP_ATTR 997 */ 929 998 std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 930 999 TRY … … 1030 1099 CATCH_DUMP_ATTR 1031 1100 1101 /* old version 1102 std::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 1103 TRY 1104 { 1105 if (instantDataFilter || !hasExpression()) 1106 ERROR("COutputPin* CField::getSelfTemporalDataFilter(CGarbageCollector& gc)", 1107 "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); 1108 1109 if (!selfReferenceFilter) getSelfReference(gc) ; 1110 1111 if (serverSourceFilter || clientSourceFilter) 1112 { 1113 if (operation.isEmpty()) 1114 ERROR("void CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq)", 1115 << "An operation must be defined for field \"" << getId() << "\"."); 1116 1117 checkTimeAttributes(&outFreq); 1118 1119 const bool detectMissingValues = (!detect_missing_value.isEmpty() && detect_missing_value == true); 1120 std::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation, 1121 CContext::getCurrent()->getCalendar()->getInitDate(), 1122 freq_op, freq_offset, outFreq, detectMissingValues)); 1123 1124 selfReferenceFilter->connectOutput(temporalFilter, 0); 1125 return temporalFilter ; 1126 } 1127 else if (!field_ref.isEmpty()) 1128 { 1129 CField* fieldRef = CField::get(field_ref); 1130 fieldRef->buildFilterGraph(gc, false); 1131 return fieldRef->getTemporalDataFilter(gc, outFreq) ; 1132 } 1133 } 1134 CATCH_DUMP_ATTR 1135 */ 1032 1136 1033 1137 //---------------------------------------------------------------- … … 1355 1459 CATCH_DUMP_ATTR 1356 1460 1357 1358 bool CField::isGridCompleted(void) 1359 TRY 1360 { 1361 bool isFullCompleted ; 1362 MPI_Allreduce(&isGridCompleted_,&isFullCompleted,1,MPI_C_BOOL, MPI_LAND, CContext::getCurrent()->getIntraComm() ) ; 1363 if ( (isGridCompleted_==false && isFullCompleted==true) ) ERROR("bool CField::isGridCompleted(void)",<< "incoherecy in MPI_AllReduce") ; 1364 return isFullCompleted ; 1365 } 1366 CATCH_DUMP_ATTR 1367 1461 bool CField::isGridCompleted(void) 1462 TRY 1463 { 1464 bool isFullCompleted ; 1465 MPI_Allreduce(&isGridCompleted_,&isFullCompleted,1,MPI_C_BOOL, MPI_LAND, CContext::getCurrent()->getIntraComm() ) ; 1466 if ( (isGridCompleted_==false && isFullCompleted==true) ) ERROR("bool CField::isGridCompleted(void)",<< "incoherecy in MPI_AllReduce") ; 1467 return isFullCompleted ; 1468 } 1469 CATCH_DUMP_ATTR 1368 1470 1369 1471 void CField::sendAddAllVariables(CContextClient* client) -
XIOS/dev/dev_trunk_graph/src/node/field.hpp
r2028 r2137 110 110 // Grid data buffer size for each connection of contextclient 111 111 std::map<int, StdSize> getGridDataBufferSize(CContextClient* client, bool bufferForWriting = false); 112 112 113 // evaluation the size of the buffer for the field 114 bool evaluateBufferSize(map<CContextClient*,map<int,size_t>>& evaluateBuffer, bool isOptPerformance) ; 113 115 public: 114 116 void makeGridAliasForCoupling(void) ; … … 236 238 bool isGridCompleted_ = true ; 237 239 public: 238 bool isGridCompleted() ;240 bool isGridCompleted() ; 239 241 void setGridCompleted(void) { isGridCompleted_= true; } 240 242 void unsetGridCompleted(void) { isGridCompleted_ = false ;} -
XIOS/dev/dev_trunk_graph/src/node/grid.cpp
r2027 r2137 1210 1210 } 1211 1211 1212 1212 1213 void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId) 1213 1214 { … … 1217 1218 distributeGridToServer(client,fieldId) ; 1218 1219 } 1220 1219 1221 1220 1222 void CGrid::distributeGridToServer(CContextClient* client, const string& fieldId) … … 1312 1314 CMessage message ; 1313 1315 if (isCoupling) message<<getCouplingAlias(fieldId) ; 1314 else message<<getId() ; 1316 else message<<getId() ; 1315 1317 gridScattererConnector.transfer(maskOut, client, event, message) ; 1316 1318 for(auto& it : scattererConnectors) delete it ; … … 1342 1344 clientFromServerConnector_[client] = new CGridGathererConnector(clientFromServerConnectors) ; 1343 1345 1344 1345 } 1346 } 1347 1346 1348 1347 1349 void CGrid::recvMask(CEventServer& event) … … 1394 1396 } 1395 1397 1396 1397 1398 string CGrid::getCouplingAlias(const string& fieldId) 1398 1399 { 1399 1400 return "_grid_of_"+fieldId; 1400 1401 } 1401 1402 1402 1403 1403 void CGrid::makeAliasForCoupling(const string& fieldId) … … 1650 1650 std::shared_ptr<CFilter> inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc)); 1651 1651 std::shared_ptr<CFilter> outputFilter = inputFilter ; 1652 cout<<"***************CGrid::buildTransformationGraph Pass through filter ***************"<<transformationGoing<<field->getId()<<endl; 1653 /*inputFilter->graphEnabled = true; 1654 inputFilter->graphPackage = new CGraphPackage; 1655 inputFilter->graphPackage->inFields.push_back(field); 1656 */ 1652 1653 1657 1654 string newId ; 1658 1655 if (gridSrc!=nullptr) newId = gridSrc->getId() + " --> " + this->getId() ; … … 1667 1664 else 1668 1665 { 1669 StdString role = CXios::isClient? "Client ": "Server "; 1670 cout<<role<<"Create new grid : "<<newId<<endl ; 1666 cout<<"Create new grid : "<<newId<<endl ; 1671 1667 newGrid = CGrid::create(newId) ; 1672 1668 isNewGrid = true ; … … 1715 1711 else if (srcElement.type==TYPE_AXIS) tmpGridSrc->addAxis(srcElement.axis->getId()) ; 1716 1712 else if (srcElement.type==TYPE_SCALAR) tmpGridSrc->addScalar(srcElement.scalar->getId()) ; 1717 tmpGridSrc->checkElementsAttributes() ; 1713 // WARNING -> suppress checkElement attribute ? What append ? 1714 // tmpGridSrc->checkElementsAttributes() ; 1718 1715 CGrid* tmpGridDst=CGrid::create(); // destination Grid 1719 1716 map<int,int> posInGrid={{0,0}} ; … … 1956 1953 auxField->getInstantDataFilter()->connectOutput(transformFilter,i) ; 1957 1954 i++ ; 1958 1959 1955 } 1960 1956 outputFilter = transformFilter ; -
XIOS/dev/dev_trunk_graph/src/node/grid.hpp
r2027 r2137 336 336 337 337 private: 338 CGridLocalConnector* workflowToModelConnector_ ;338 CGridLocalConnector* workflowToModelConnector_ = nullptr; 339 339 public: 340 340 void computeWorkflowToModelConnector(void) ; -
XIOS/dev/dev_trunk_graph/src/node/interpolate_axis.cpp
r2019 r2137 60 60 } 61 61 62 if (!this->coordinate.isEmpty() && (!this->coordinate_src.isEmpty() || !this->coordinate_dst.isEmpty())) 63 { 64 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 65 << "<coordinate> is incompatible with <coordinate_src> or <coordinate_dst> attributes. <coordinate> attribute is present only for backward" 66 << "compatibility and is now declared obsolete") ; 67 } 62 68 63 69 if (!this->coordinate.isEmpty()) 64 70 { 65 StdString coordinate = this->coordinate.getValue();66 71 if (!CField::has(coordinate)) 67 72 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 68 73 << "Coordinate field whose id " << coordinate << "does not exist " 74 << "Please define one"); 75 } 76 77 if (!this->coordinate_src.isEmpty()) 78 { 79 if (!CField::has(coordinate_src)) 80 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 81 << "Coordinate field whose id " << coordinate_src << "does not exist " 82 << "Please define one"); 83 } 84 85 if (!this->coordinate_dst.isEmpty()) 86 { 87 if (!CField::has(coordinate_dst)) 88 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 89 << "Coordinate field whose id " << coordinate_dst << "does not exist " 69 90 << "Please define one"); 70 91 } … … 74 95 { 75 96 std::vector<StdString> auxInputs; 97 98 if (!this->coordinate.isEmpty() && (!this->coordinate_src.isEmpty() || !this->coordinate_dst.isEmpty())) 99 { 100 ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", 101 << "<coordinate> is incompatible with <coordinate_src> or <coordinate_dst> attributes. <coordinate> attribute is present only for backward" 102 << "compatibility and is now declared obsolete") ; 103 } 104 76 105 if (!this->coordinate.isEmpty()) 77 106 { 78 107 StdString coordinate = this->coordinate.getValue(); 79 108 if (!CField::has(coordinate)) 80 ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 109 ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", 110 << "Coordinate field whose id " << coordinate << "does not exist " 111 << "Please define one"); 112 auxInputs.push_back(coordinate); 113 } 114 115 if (!this->coordinate_src.isEmpty()) 116 { 117 StdString coordinate = this->coordinate_src.getValue(); 118 if (!CField::has(coordinate)) 119 ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", 120 << "Coordinate field whose id " << coordinate << "does not exist " 121 << "Please define one"); 122 auxInputs.push_back(coordinate); 123 } 124 125 if (!this->coordinate_dst.isEmpty()) 126 { 127 StdString coordinate = this->coordinate_dst.getValue(); 128 if (!CField::has(coordinate)) 129 ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", 81 130 << "Coordinate field whose id " << coordinate << "does not exist " 82 131 << "Please define one"); … … 97 146 std::map<int, int>& elementPositionInGridDst2DomainPosition) 98 147 { 99 if (!coordinate.isEmpty()) return CAxisAlgorithmInterpolateCoordinate::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, 100 elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, 101 elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition); 148 if (!coordinate.isEmpty() || !coordinate_src.isEmpty() || !coordinate_dst.isEmpty()) 149 return CAxisAlgorithmInterpolateCoordinate::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, 150 elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, 151 elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition); 152 102 153 else return CAxisAlgorithmInterpolate::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, 103 154 elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, -
XIOS/dev/dev_trunk_graph/src/node/scalar.cpp
r2027 r2137 201 201 this->sendAllAttributesToServer(client, scalarId); 202 202 } 203 203 204 204 string CScalar::getCouplingAlias(const string& fieldId, int posInGrid) 205 205 {
Note: See TracChangeset
for help on using the changeset viewer.