Changeset 2397 for XIOS3/trunk/src/node


Ignore:
Timestamp:
08/31/22 17:23:56 (22 months ago)
Author:
ymipsl
Message:
  • Optimize remote connector computation in case of read (reverse way).
  • don't compute anymore clientFromServerConnector (and all intermediate computation) for non reading case.

YM

Location:
XIOS3/trunk/src/node
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/node/axis.cpp

    r2389 r2397  
    982982  } 
    983983  
    984   void CAxis::distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn,  
     984  void CAxis::distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn,  
    985985                                 shared_ptr<CScattererConnector> &scattererConnector, const string& axisId) 
    986986  { 
     
    10421042    // phase 3 : compute connector to receive from server 
    10431043    //////////// 
     1044    if (inOut) 
    10441045    { 
    10451046      auto scatteredElement = make_shared<CDistributedElement>(n_glo, globalIndexIn) ; 
     
    11281129//      gathererConnector_ -> computeConnector() ; 
    11291130    } 
    1130     else if (phasis==3) 
     1131    else if (phasis==3) // only for server -> client 
    11311132    { 
    11321133      elementTo_ = make_shared<CDistributedElement>(event) ; 
     
    11451146    serverFromClientConnector_ = make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ; 
    11461147    serverFromClientConnector_->computeConnector() ; 
    1147        
    1148     serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL), 
     1148    elementFrom_.reset() ; 
     1149 
     1150    if (elementTo_) 
     1151    { 
     1152      serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL), 
    11491153                                                                context->getIntraComm(), client->getRemoteSize()) ; 
    1150     serverToClientConnector_->computeConnector() ; 
     1154      serverToClientConnector_->computeConnector() ; 
     1155      elementTo_.reset() ; 
     1156    } 
    11511157  } 
    11521158  CATCH_DUMP_ATTR 
  • XIOS3/trunk/src/node/axis.hpp

    r2389 r2397  
    253253       public: 
    254254         void computeRemoteElement(CContextClient* client, EDistributionType) ; 
    255          void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn,  
     255         void distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn,  
    256256                                 shared_ptr<CScattererConnector>& scattererConnector, const string& axisId="") ; 
    257257 
  • XIOS3/trunk/src/node/context.cpp

    r2343 r2397  
    10121012      for(auto file : this->enabledReadModeFiles) file->setContextClient(client) ; 
    10131013    
     1014 
     1015    // workflow startpoint => data from server on client side 
     1016    // important : sendFieldToInputFileServer must be done prior sendFieldToFileServer because for the first case the grid remoteConnectorIn 
     1017    //             and grid remoteConnectorOut will be computed, and in the second case only the remoteConnectorOut. 
     1018    if (serviceType_==CServicesManager::CLIENT) 
     1019    { 
     1020      for(auto field : fileInField)  
     1021      { 
     1022        field->sendFieldToInputFileServer() ; 
     1023        field->connectToServerInput(garbageCollector) ; // connect the field to server filter 
     1024        fileInFields_.push_back(field) ; 
     1025      } 
     1026    } 
     1027 
    10141028    // workflow endpoint => sent to IO/SERVER 
    10151029    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) 
     
    10761090    { 
    10771091      field->connectToCouplerOut(garbageCollector) ; // for now the same kind of filter that for file server 
    1078     } 
    1079  
    1080      // workflow startpoint => data from server on client side 
    1081     if (serviceType_==CServicesManager::CLIENT) 
    1082     { 
    1083       for(auto field : fileInField)  
    1084       { 
    1085         field->sendFieldToInputFileServer() ; 
    1086         field->connectToServerInput(garbageCollector) ; // connect the field to server filter 
    1087         fileInFields_.push_back(field) ; 
    1088       } 
    10891092    } 
    10901093 
  • XIOS3/trunk/src/node/domain.cpp

    r2395 r2397  
    21132113  
    21142114 
    2115   void CDomain::distributeToServer(CContextClient* client, map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn, 
     2115  void CDomain::distributeToServer(CContextClient* client, bool inOut, map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn, 
    21162116                                   shared_ptr<CScattererConnector> &scattererConnector, const string& domainId) 
    21172117  TRY 
     
    21752175    // phase 3 : compute connector to receive from server 
    21762176    //////////// 
     2177    if (inOut) 
    21772178    { 
    21782179      auto scatteredElement = make_shared<CDistributedElement>(ni_glo*nj_glo, globalIndexIn) ; 
     
    22782279    serverFromClientConnector_ = make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ; 
    22792280    serverFromClientConnector_->computeConnector() ; 
     2281    elementFrom_.reset() ; 
    22802282       
    2281     serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL), 
     2283    if (elementTo_) 
     2284    { 
     2285      serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL), 
    22822286                                                                context->getIntraComm(), client->getRemoteSize()) ; 
    2283     serverToClientConnector_->computeConnector() ; 
     2287      serverToClientConnector_->computeConnector() ; 
     2288      elementTo_.reset() ; 
     2289    } 
     2290 
    22842291  } 
    22852292  CATCH_DUMP_ATTR 
  • XIOS3/trunk/src/node/domain.hpp

    r2389 r2397  
    309309       public: 
    310310         void computeRemoteElement(CContextClient* client, EDistributionType) ; 
    311          void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn,  
     311         void distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn,  
    312312                                 shared_ptr<CScattererConnector> &scattererConnector, const string& domainId="") ; 
    313313 
  • XIOS3/trunk/src/node/field.cpp

    r2326 r2397  
    14661466    getRelFile()->sendFileToFileServer(client); 
    14671467    sentGrid_ = grid_-> duplicateSentGrid() ; 
    1468     sentGrid_->sendGridToFileServer(client); 
     1468    sentGrid_->sendGridToFileServer(client, false); 
    14691469    name = getFieldOutputName() ; 
    14701470    this->sendAllAttributesToServer(client); 
     
    14771477    getRelFile()->sendFileToFileServer(client); 
    14781478    sentGrid_ = grid_-> duplicateSentGrid() ; 
    1479     sentGrid_->sendGridToFileServer(client); 
     1479    sentGrid_->sendGridToFileServer(client, true); 
    14801480    read_access=true ; // not the best solution, but on server side, the field must be a starting point of the workflow 
    14811481                       // must be replace by a better solution when implementing filters for reading and send to client 
  • XIOS3/trunk/src/node/grid.cpp

    r2351 r2397  
    14481448  
    14491449 
    1450   void CGrid::sendGridToFileServer(CContextClient* client) 
     1450  void CGrid::sendGridToFileServer(CContextClient* client, bool inOut) 
    14511451  { 
    14521452    if (sendGridToFileServer_done_.count(client)!=0) return ; 
     
    14571457    gridPtr->sendCreateChild(this->getId(),client); 
    14581458    this->sendAllAttributesToServer(client); 
    1459     distributeGridToServer(client) ; 
     1459    distributeGridToServer(client, inOut) ; 
    14601460  } 
    14611461 
     
    14661466    else sendGridToCouplerOut_done_.insert(client) ; 
    14671467    this->sendAllAttributesToServer(client, getCouplingAlias(fieldId)); 
    1468     distributeGridToServer(client, fieldId) ; 
    1469   } 
    1470  
    1471  
    1472   void CGrid::distributeGridToServer(CContextClient* client, const string& fieldId) 
     1468    distributeGridToServer(client, false, fieldId) ; 
     1469  } 
     1470 
     1471 
     1472  void CGrid::distributeGridToServer(CContextClient* client, bool inOut, const string& fieldId) 
    14731473  { 
    14741474    CContext* context = CContext::getCurrent(); 
     
    15201520    // CGridClientServerRemoteConnector : workflowView is added to avoid spurious optimisation with only the fullview 
    15211521    auto gridRemoteConnector = make_shared<CGridClientServerRemoteConnector>(localViews, workflowView, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
    1522     gridRemoteConnector->computeConnector(true) ; 
     1522    gridRemoteConnector->computeConnectorOut() ; 
    15231523     
    1524     auto gridRemoteConnectorIn = make_shared<CGridClientServerRemoteConnector>(localViews, workflowView, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
    1525     gridRemoteConnectorIn->computeConnector(false) ; 
    1526  
    1527      
     1524    shared_ptr<CGridClientServerRemoteConnector> gridRemoteConnectorIn ; 
     1525    if (inOut) 
     1526    { 
     1527      gridRemoteConnectorIn = make_shared<CGridClientServerRemoteConnector>(localViews, workflowView, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
     1528      gridRemoteConnectorIn->computeConnectorIn() ; 
     1529    } 
     1530    else gridRemoteConnectorIn = gridRemoteConnector ; 
     1531 
     1532 
    15281533    vector<shared_ptr<CScattererConnector>> scattererConnectors ; 
    15291534    shared_ptr<CScattererConnector> scattererConnector; 
     
    15331538      {  
    15341539        CDomain* domain = (CDomain*) elements[i].ptr ; 
    1535         if (isCoupling) domain->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), 
     1540        if (isCoupling) domain->distributeToServer(client, inOut, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), 
    15361541                                                   scattererConnector,  domain->getCouplingAlias(fieldId,i)) ; 
    15371542        else  
    15381543        { 
    15391544          sendAddDomain(domain->getId(),client) ; 
    1540           domain->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), scattererConnector) ; 
     1545          domain->distributeToServer(client, inOut, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), scattererConnector) ; 
    15411546        } 
    15421547        scattererConnectors.push_back(scattererConnector) ; 
     
    15451550      { 
    15461551        CAxis* axis = (CAxis*) elements[i].ptr ; 
    1547         if (isCoupling) axis->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), 
     1552        if (isCoupling) axis->distributeToServer(client, inOut, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), 
    15481553                                                 scattererConnector,  axis->getCouplingAlias(fieldId,i)) ; 
    15491554        else  
    15501555        { 
    15511556          sendAddAxis(axis->getId(),client) ; 
    1552           axis->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), scattererConnector) ; 
     1557          axis->distributeToServer(client, inOut, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), scattererConnector) ; 
    15531558        } 
    15541559        scattererConnectors.push_back(scattererConnector) ; 
     
    15571562      { 
    15581563        CScalar* scalar = (CScalar*) elements[i].ptr ; 
    1559         if (isCoupling) scalar->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), 
     1564        if (isCoupling) scalar->distributeToServer(client, inOut, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), 
    15601565                                                   scattererConnector,  scalar->getCouplingAlias(fieldId,i)) ; 
    15611566        else  
    15621567        { 
    15631568          sendAddScalar(scalar->getId(),client) ; 
    1564           scalar->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), scattererConnector) ; 
     1569          scalar->distributeToServer(client, inOut, gridRemoteConnector->getDistributedGlobalIndex(i), gridRemoteConnectorIn->getDistributedGlobalIndex(i), scattererConnector) ; 
    15651570        } 
    15661571        scattererConnectors.push_back(scattererConnector) ; 
     
    15881593      {  
    15891594         clientToServerConnectors.push_back(element.domain->getClientToServerConnector(client)) ; 
    1590          clientFromServerConnectors.push_back(element.domain->getClientFromServerConnector(client)) ; 
     1595         if (inOut) clientFromServerConnectors.push_back(element.domain->getClientFromServerConnector(client)) ; 
    15911596      } 
    15921597      else if (element.type==TYPE_AXIS) 
    15931598      { 
    15941599        clientToServerConnectors.push_back(element.axis->getClientToServerConnector(client)) ; 
    1595         clientFromServerConnectors.push_back(element.axis->getClientFromServerConnector(client)) ; 
     1600        if (inOut) clientFromServerConnectors.push_back(element.axis->getClientFromServerConnector(client)) ; 
    15961601 
    15971602      } 
     
    15991604      { 
    16001605        clientToServerConnectors.push_back(element.scalar->getClientToServerConnector(client)) ; 
    1601         clientFromServerConnectors.push_back(element.scalar->getClientFromServerConnector(client)) ; 
     1606        if (inOut) clientFromServerConnectors.push_back(element.scalar->getClientFromServerConnector(client)) ; 
    16021607      } 
    16031608    } 
     
    16051610    // compute the grid clientToServerConnector to send flux from client to servers 
    16061611    clientToServerConnector_[client] = make_shared<CGridScattererConnector>(clientToServerConnectors) ; 
    1607     clientFromServerConnector_[client] = make_shared<CGridGathererConnector>(clientFromServerConnectors) ; 
     1612    if (inOut) clientFromServerConnector_[client] = make_shared<CGridGathererConnector>(clientFromServerConnectors) ; 
    16081613 
    16091614  } 
  • XIOS3/trunk/src/node/grid.hpp

    r2326 r2397  
    172172 
    173173      public: 
    174          void sendGridToFileServer(CContextClient* client) ; 
     174         void sendGridToFileServer(CContextClient* client, bool inOut) ; 
    175175      private: 
    176176         std::set<CContextClient*> sendGridToFileServer_done_ ; 
     
    351351 
    352352      public: //?  
    353         void distributeGridToServer(CContextClient* client, const string& fieldId=""); 
     353        void distributeGridToServer(CContextClient* client, bool inOut, const string& fieldId=""); 
    354354       
    355355             
  • XIOS3/trunk/src/node/scalar.cpp

    r2343 r2397  
    420420  } 
    421421  
    422   void CScalar::distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndexOut,  std::map<int, CArray<size_t,1>>& globalIndexIn,  
     422  void CScalar::distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut,  std::map<int, CArray<size_t,1>>& globalIndexIn,  
    423423                                   shared_ptr<CScattererConnector> &scattererConnector, const string& scalarId) 
    424424  { 
     
    480480    // phase 3 : compute connector to receive from server 
    481481    //////////// 
     482    if (inOut) 
    482483    { 
    483484      auto scatteredElement = make_shared<CDistributedElement>(1, globalIndexIn) ; 
     
    567568    serverFromClientConnector_ = make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ; 
    568569    serverFromClientConnector_->computeConnector() ; 
     570    elementFrom_.reset() ; 
    569571       
    570     serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL), 
     572    if (elementTo_) 
     573    { 
     574      serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL), 
    571575                                                                context->getIntraComm(), client->getRemoteSize()) ; 
    572     serverToClientConnector_->computeConnector() ; 
     576      serverToClientConnector_->computeConnector() ; 
     577      elementTo_.reset() ; 
     578    } 
    573579  } 
    574580  CATCH_DUMP_ATTR 
  • XIOS3/trunk/src/node/scalar.hpp

    r2326 r2397  
    202202    public: 
    203203      void computeRemoteElement(CContextClient* client, EDistributionType) ; 
    204       void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn, 
     204      void distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn, 
    205205                              shared_ptr<CScattererConnector> &scattererConnector, const string& scalarId="") ; 
    206206 
Note: See TracChangeset for help on using the changeset viewer.