Ignore:
Timestamp:
05/30/21 23:30:01 (3 years ago)
Author:
yushan
Message:

temporal commit for merging graph into XIOS_coupling

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  
    451451 
    452452    } 
    453    
     453 
    454454  string CAxis::getCouplingAlias(const string& fieldId, int posInGrid) 
    455455  { 
  • XIOS/dev/dev_trunk_graph/src/node/axis.hpp

    r2027 r2137  
    176176         void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
    177177         string getCouplingAlias(const string& fieldId, int posInGrid) ; 
    178  
    179178 
    180179      private: 
  • XIOS/dev/dev_trunk_graph/src/node/context.cpp

    r2027 r2137  
    7373 
    7474   //---------------------------------------------------------------- 
    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() ; 
    8182  
    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  } 
    9090   /*! 
    9191   \brief Get context group (context root) 
     
    291291   ///--------------------------------------------------------------- 
    292292 
    293  
    294    void CContext::setClientServerBuffer(vector<CField*>& fields, bool bufferForWriting) 
    295    TRY 
    296    { 
    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 buffers 
    300      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_NODE 
    307 #undef DECLARE_NODE_PAR 
    308  
    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 buffers 
    339        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_ATTR 
    351  
    352  
    353     /*! 
    354     Sets client buffers. 
    355     \param [in] contextClient 
    356     \param [in] bufferForWriting True if buffers are used for sending data for writing 
    357     This flag is only true for client and server-1 for communication with server-2 
    358   */ 
    359   // ym obsolete to be removed 
    360    void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting) 
    361    TRY 
    362    { 
    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 buffers 
    367       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_NODE 
    374 #undef DECLARE_NODE_PAR 
    375  
    376      // Compute the buffer sizes needed to send the attributes and data corresponding to fields 
    377      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 size 
    386      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 buffers 
    395      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_ATTR 
    410293 
    411294 /*! 
     
    716599  CATCH_DUMP_ATTR 
    717600 
    718     
    719   bool CContext::eventLoop(bool enableEventsProcessing) 
     601  void CContext::globalEventLoop(void) 
    720602  { 
    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;  
    723612    size_t timeLine=timeLine_ ; 
    724613    if (serviceType_==CServicesManager::CLIENT) 
     
    730619    do 
    731620    {  
    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) ; 
    754622      if (serviceType_==CServicesManager::CLIENT) out = eventScheduler_->queryEvent(timeLine,hashId_) ; 
    755623      else out=true ; 
    756624    }  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()) ; 
    757658    return finalized && finished ; 
    758659  } 
     
    784685        couplerOutClient_[fullContextId] = client ; 
    785686        couplerOutServer_[fullContextId] = server ; 
    786  
    787 /* 
    788       // for now, we don't now which beffer size must be used for client coupler 
    789       // It will be evaluated later. Fix a constant size for now... 
    790       // set to 10Mb for development 
    791        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 */ 
    800687      } 
    801688    } 
     
    819706       MPI_Comm_free(&interComm) ; 
    820707 
    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);     
    829708       couplerInClient_[fullContextId] = client ; 
    830709       couplerInServer_[fullContextId] = server ;         
     
    832711  } 
    833712   
    834   void CContext::globalEventLoop(void) 
    835   { 
    836     CXios::getDaemonsManager()->eventLoop() ; 
    837     setCurrent(getId()) ; 
    838   } 
    839  
    840  
    841713   void CContext::finalize(void) 
    842714   TRY 
     
    1023895 
    1024896    bool workflowGraphIsCompleted ; 
    1025  
     897     
    1026898    bool first=true ; 
     899    
    1027900    do 
    1028901    { 
     
    1032905        workflowGraphIsCompleted &= endWorkflowField->buildWorkflowGraph(garbageCollector) ; 
    1033906      } 
    1034  
     907    
    1035908      for(auto couplerIn : enabledCouplerIn) couplerIn->assignContext() ; 
    1036909      for(auto field : couplerInField) field->makeGridAliasForCoupling(); 
     
    1045918        // connect to couplerOut -> to do 
    1046919      } 
    1047       if (first) setClientServerBuffer(couplerOutField, true) ; // set buffer context --> to check 
    1048     
     920 
    1049921      bool couplersReady ; 
    1050922      do  
     
    1057929          couplersReady &= ready ; 
    1058930        } 
    1059         this->eventLoop() ; 
     931        this->scheduledEventLoop() ; 
     932 
    1060933      } while (!couplersReady) ; 
    1061  
     934       
    1062935      first=false ; 
    1063       this->eventLoop() ; 
     936      this->scheduledEventLoop() ; 
     937 
    1064938    } while (!workflowGraphIsCompleted) ; 
     939 
    1065940 
    1066941    for( auto field : couplerInField) couplerInFields_.push_back(field) ; 
     
    1087962        field->connectToFileServer(garbageCollector) ; // connect the field to server filter 
    1088963      } 
    1089       setClientServerBuffer(fileOutField, true) ; // set buffer context --> to review 
    1090964      for(auto field : fileOutField) field->sendFieldToFileServer() ; 
    1091965    } 
     
    11931067      ok = true ; 
    11941068      for(auto& couplerOutClient : couplerOutClient_) ok &= isCouplerInCloseDefinition(couplerOutClient.second) ; 
    1195       this->eventLoop() ;  
     1069      this->scheduledEventLoop() ; 
    11961070    } 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 
    11971081 
    11981082     CTimer::get("Context : close definition").suspend() ; 
  • XIOS/dev/dev_trunk_graph/src/node/context.hpp

    r2027 r2137  
    1515#include "server_context.hpp" 
    1616#include "event_scheduler.hpp" 
     17 
    1718 
    1819namespace xios 
     
    108109         // Put sever or client into loop state 
    109110         bool eventLoop(bool enableEventsProcessing=true); 
     111         bool scheduledEventLoop(bool enableEventsProcessing=true) ;  
    110112         void globalEventLoop(void); 
    111113 
     
    148150         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 
    149151         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 removed 
    151          void setClientServerBuffer(vector<CField*>& fields, bool bufferForWriting) ;  
    152152 
    153153         // Distribute files (in write mode) among secondary-server pools according to the estimated data flux 
     
    355355         string contextId_ ; //!< context client id for the servers. For clients this is same as getId()  
    356356         bool isProcessingEvent_ ; 
     357    private:      
    357358         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_;} 
    359367      public: // Some function maybe removed in the near future 
    360368        // virtual void toBinary  (StdOStream & os) const; 
  • XIOS/dev/dev_trunk_graph/src/node/domain.cpp

    r2027 r2137  
    805805        nj = 1; 
    806806        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 
    813816     } 
    814817 
     
    17801783   } 
    17811784 
     1785 
    17821786  string CDomain::getCouplingAlias(const string& fieldId, int posInGrid) 
    17831787  { 
     
    18081812  void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) 
    18091813  { 
    1810      const string domainId = getCouplingAlias(fieldId, posInGrid); 
     1814    const string domainId = getCouplingAlias(fieldId, posInGrid); 
    18111815    this->createAlias(domainId) ; 
    18121816  } 
  • XIOS/dev/dev_trunk_graph/src/node/domain.hpp

    r2027 r2137  
    241241        void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
    242242        string getCouplingAlias(const string& fieldId, int posInGrid) ; 
    243  
    244243       private: 
    245244 
  • XIOS/dev/dev_trunk_graph/src/node/extract_domain_to_axis.cpp

    r2019 r2137  
    6767    { 
    6868      case direction_attr::jDir: 
    69         if (axis_n_glo != domain_ni_glo) 
     69        if (axis_n_glo != domain_nj_glo) 
    7070          ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
    71             << "Extract domain along j, axis destination should have n_glo equal to ni_glo of domain source" 
    72             << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_ni_glo << std::endl 
     71            << "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 
    7373            << "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)) 
    7575        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 nj_glo " << domain_ni_glo << std::endl 
     76          << "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 
    7878          << "Axis destination " << axisDst->getId() << std::endl 
    7979          << "Position " << position); 
     
    8181 
    8282      case direction_attr::iDir: 
    83         if (axis_n_glo != domain_nj_glo) 
     83        if (axis_n_glo != domain_ni_glo) 
    8484          ERROR("CExtractDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", 
    85             << "Extract domain along i, axis destination should have n_glo equal to nj_glo of domain source" 
    86             << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl 
     85            << "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 
    8787            << "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)) 
    8989        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_ni_glo << std::endl 
     90          << "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 
    9292          << "Axis destination " << axisDst->getId() << std::endl 
    9393          << "Position " << position); 
  • XIOS/dev/dev_trunk_graph/src/node/field.cpp

    r2027 r2137  
    383383  CATCH_DUMP_ATTR 
    384384 
     385   
    385386  //---------------------------------------------------------------- 
    386387 
     
    497498  CATCH_DUMP_ATTR 
    498499 
     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  }   
    499538 
    500539 
     
    550589    bool buildGraph_ = !build_workflow_graph.isEmpty() && build_workflow_graph == true ; 
    551590    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));  
    564592      
    565593    if (hasDirectFieldReference()) 
    566594    { 
    567        
    568595      CField* fieldRef = getDirectFieldReference(); 
     596 
     597      //------ build_workflow_graph start 
    569598      if(buildGraph_) 
    570599      { 
     
    580609       
    581610      if(buildGraph_) this->build_workflow_graph.set(build_workflow_graph); 
     611      //------ build_workflow_graph end 
     612 
    582613      bool ret=fieldRef->buildWorkflowGraph(gc);  
    583614      if (!ret) return false ; // workflow graph cannot be built at this stage 
     
    612643      { 
    613644        grid->solveElementsRefInheritance() ; 
    614         
    615         // new 
    616          
    617645        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid->buildTransformationGraph(gc, false,  gridSrc, detectMissingValues, defaultValue, newGrid, buildGraph_, this) ; 
    618646        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         }*/ 
    626647        lastFilter = filters.second; 
    627648        gridSrc = newGrid ; 
    628  
    629         // end new 
    630649      } 
    631650 
     
    658677         grid_ = newGrid ; 
    659678         grid_ref=grid_->getId() ; // for server  
     679         //grid_->completeGrid(); // grid generation, to be checked 
    660680         if (fileIn_->isClientSide()) fileIn_->readFieldAttributesValues(this); 
    661681         grid_->checkElementsAttributes() ; 
     682//         grid_->solveDomainAxisBaseRef(); 
    662683         // probably in future tag grid incomplete if coming from a reading 
    663684         instantDataFilter=inputFilter ; 
     
    927948   * \return the output pin corresponding to a self reference 
    928949   */ 
     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*/ 
    929998  std::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 
    930999  TRY 
     
    10301099  CATCH_DUMP_ATTR 
    10311100 
     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*/ 
    10321136 
    10331137  //---------------------------------------------------------------- 
     
    13551459   CATCH_DUMP_ATTR 
    13561460 
    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 
    13681470 
    13691471  void CField::sendAddAllVariables(CContextClient* client) 
  • XIOS/dev/dev_trunk_graph/src/node/field.hpp

    r2028 r2137  
    110110         // Grid data buffer size for each connection of contextclient 
    111111         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) ; 
    113115       public: 
    114116          void makeGridAliasForCoupling(void) ; 
     
    236238          bool isGridCompleted_ = true ; 
    237239      public: 
    238           bool isGridCompleted() ;  
     240          bool isGridCompleted()  ;  
    239241          void setGridCompleted(void) { isGridCompleted_= true; } 
    240242          void unsetGridCompleted(void) { isGridCompleted_ = false ;} 
  • XIOS/dev/dev_trunk_graph/src/node/grid.cpp

    r2027 r2137  
    12101210  } 
    12111211 
     1212 
    12121213  void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId) 
    12131214  { 
     
    12171218    distributeGridToServer(client,fieldId) ; 
    12181219  } 
     1220 
    12191221 
    12201222  void CGrid::distributeGridToServer(CContextClient* client, const string& fieldId) 
     
    13121314    CMessage message ; 
    13131315    if (isCoupling) message<<getCouplingAlias(fieldId) ; 
    1314     else message<<getId() ; 
     1316    else message<<getId() ;  
    13151317    gridScattererConnector.transfer(maskOut, client, event, message) ; 
    13161318    for(auto& it : scattererConnectors) delete it ; 
     
    13421344    clientFromServerConnector_[client] = new CGridGathererConnector(clientFromServerConnectors) ; 
    13431345 
    1344  
    1345   } 
     1346  } 
     1347 
    13461348 
    13471349  void CGrid::recvMask(CEventServer& event) 
     
    13941396  } 
    13951397 
    1396  
    13971398  string CGrid::getCouplingAlias(const string& fieldId) 
    13981399  { 
    13991400    return "_grid_of_"+fieldId; 
    14001401  } 
    1401  
    14021402 
    14031403  void CGrid::makeAliasForCoupling(const string& fieldId) 
     
    16501650    std::shared_ptr<CFilter> inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc)); 
    16511651    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 
    16571654    string newId ; 
    16581655    if (gridSrc!=nullptr) newId = gridSrc->getId() + " --> " + this->getId()  ; 
     
    16671664    else   
    16681665    { 
    1669       StdString role = CXios::isClient? "Client ": "Server "; 
    1670       cout<<role<<"Create new grid : "<<newId<<endl ; 
     1666      cout<<"Create new grid : "<<newId<<endl ; 
    16711667      newGrid = CGrid::create(newId) ; 
    16721668      isNewGrid = true ; 
     
    17151711        else if (srcElement.type==TYPE_AXIS)   tmpGridSrc->addAxis(srcElement.axis->getId()) ; 
    17161712        else if (srcElement.type==TYPE_SCALAR) tmpGridSrc->addScalar(srcElement.scalar->getId()) ; 
    1717         tmpGridSrc->checkElementsAttributes() ; 
     1713        // WARNING -> suppress checkElement attribute ? What append ? 
     1714        // tmpGridSrc->checkElementsAttributes() ; 
    17181715        CGrid* tmpGridDst=CGrid::create(); // destination Grid 
    17191716        map<int,int> posInGrid={{0,0}} ; 
     
    19561953          auxField->getInstantDataFilter()->connectOutput(transformFilter,i) ; 
    19571954          i++ ; 
    1958            
    19591955        } 
    19601956        outputFilter = transformFilter ; 
  • XIOS/dev/dev_trunk_graph/src/node/grid.hpp

    r2027 r2137  
    336336 
    337337      private: 
    338         CGridLocalConnector* workflowToModelConnector_ ; 
     338        CGridLocalConnector* workflowToModelConnector_ = nullptr; 
    339339      public: 
    340340        void computeWorkflowToModelConnector(void) ; 
  • XIOS/dev/dev_trunk_graph/src/node/interpolate_axis.cpp

    r2019 r2137  
    6060    } 
    6161 
     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    } 
    6268 
    6369    if (!this->coordinate.isEmpty()) 
    6470    { 
    65       StdString coordinate = this->coordinate.getValue(); 
    6671      if (!CField::has(coordinate)) 
    6772        ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", 
    6873               << "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 " 
    6990               << "Please define one"); 
    7091    } 
     
    7495  { 
    7596    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 
    76105    if (!this->coordinate.isEmpty()) 
    77106    { 
    78107      StdString coordinate = this->coordinate.getValue(); 
    79108      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_()", 
    81130               << "Coordinate field whose id " << coordinate << "does not exist " 
    82131               << "Please define one"); 
     
    97146                                                        std::map<int, int>& elementPositionInGridDst2DomainPosition) 
    98147  { 
    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     
    102153    else return CAxisAlgorithmInterpolate::create(isSource, gridDst,  gridSrc, this, elementPositionInGrid,  
    103154                elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, 
  • XIOS/dev/dev_trunk_graph/src/node/scalar.cpp

    r2027 r2137  
    201201    this->sendAllAttributesToServer(client, scalarId); 
    202202  }   
    203    
     203 
    204204  string CScalar::getCouplingAlias(const string& fieldId, int posInGrid) 
    205205  { 
Note: See TracChangeset for help on using the changeset viewer.