Ignore:
Timestamp:
12/01/21 16:52:24 (7 months ago)
Author:
ymipsl
Message:

tracking memory leak
Elements, views, and connectors are now managed with shared pointer.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r2249 r2267  
    17401740      // testing ? 
    17411741     /* 
    1742       CLocalView* local = localElement_->getView(CElementView::WORKFLOW) ; 
    1743       CLocalView* model = localElement_->getView(CElementView::MODEL) ; 
     1742      shared_ptr<CLocalView> local = localElement_->getView(CElementView::WORKFLOW) ; 
     1743      shared_ptr<CLocalView> model = localElement_->getView(CElementView::MODEL) ; 
    17441744 
    17451745      CLocalConnector test1(model, local) ; 
     
    17731773      for(int ij=0; ij<nij ; ij++) ij_index(ij) = i_index(ij)+j_index(ij)*ni_glo ; 
    17741774      int rank = CContext::getCurrent()->getIntraCommRank() ; 
    1775       localElement_ = new CLocalElement(rank, ni_glo*nj_glo, ij_index) ; 
     1775      localElement_ = make_shared<CLocalElement>(rank, ni_glo*nj_glo, ij_index) ; 
    17761776   } 
    17771777 
     
    18301830   void CDomain::computeModelToWorkflowConnector(void) 
    18311831   {  
    1832      CLocalView* srcView=getLocalView(CElementView::MODEL) ; 
    1833      CLocalView* dstView=getLocalView(CElementView::WORKFLOW) ; 
    1834      modelToWorkflowConnector_ = new CLocalConnector(srcView, dstView);  
     1832     shared_ptr<CLocalView> srcView=getLocalView(CElementView::MODEL) ; 
     1833     shared_ptr<CLocalView> dstView=getLocalView(CElementView::WORKFLOW) ; 
     1834     modelToWorkflowConnector_ = make_shared<CLocalConnector>(srcView, dstView);  
    18351835     modelToWorkflowConnector_->computeConnector() ; 
    18361836   } 
     
    19891989      for (auto& rankServer : client->getRanksServerLeader()) globalIndex[rankServer] = indGlo ;  
    19901990    } 
    1991     remoteElement_[client] = new CDistributedElement(ni_glo*nj_glo, globalIndex) ; 
     1991    remoteElement_[client] = make_shared<CDistributedElement>(ni_glo*nj_glo, globalIndex) ; 
    19921992    remoteElement_[client]->addFullView() ; 
    19931993  } 
     
    19971997 
    19981998  void CDomain::distributeToServer(CContextClient* client, map<int, CArray<size_t,1>>& globalIndex, 
    1999                                    CScattererConnector* &scattererConnector, const string& domainId) 
     1999                                   shared_ptr<CScattererConnector> &scattererConnector, const string& domainId) 
    20002000  TRY 
    20012001  { 
     
    20052005    this->sendAllAttributesToServer(client, serverDomainId)  ; 
    20062006 
    2007     CDistributedElement scatteredElement(ni_glo*nj_glo, globalIndex) ; 
    2008     scatteredElement.addFullView() ; 
    2009     scattererConnector = new CScattererConnector(localElement_->getView(CElementView::FULL), scatteredElement.getView(CElementView::FULL),  
    2010                                            context->getIntraComm(), client->getRemoteSize()) ; 
     2007    auto scatteredElement = make_shared<CDistributedElement>(ni_glo*nj_glo, globalIndex) ; 
     2008    scatteredElement->addFullView() ; 
     2009    scattererConnector = make_shared<CScattererConnector>(localElement_->getView(CElementView::FULL), scatteredElement->getView(CElementView::FULL),  
     2010                                                          context->getIntraComm(), client->getRemoteSize()) ; 
    20112011    scattererConnector->computeConnector() ; 
    20122012 
     
    20252025    scattererConnector->transfer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event1,message1) ; 
    20262026     
    2027     sendDistributedAttributes(client, *scattererConnector, domainId) ; 
     2027    sendDistributedAttributes(client, scattererConnector, domainId) ; 
    20282028 
    20292029   
     
    20312031    CArray<bool,1> maskIn(localElement_->getView(CElementView::WORKFLOW)->getSize()); 
    20322032    CArray<bool,1> maskOut ; 
    2033     CLocalConnector workflowToFull(localElement_->getView(CElementView::WORKFLOW), localElement_->getView(CElementView::FULL)) ; 
    2034     workflowToFull.computeConnector() ; 
     2033    auto workflowToFull = make_shared<CLocalConnector>(localElement_->getView(CElementView::WORKFLOW), localElement_->getView(CElementView::FULL)) ; 
     2034    workflowToFull->computeConnector() ; 
    20352035    maskIn=true ; 
    2036     workflowToFull.transfer(maskIn,maskOut,false) ; 
     2036    workflowToFull->transfer(maskIn,maskOut,false) ; 
    20372037 
    20382038 
     
    20412041    map<int,CArray<bool,1>> maskOut2 ;  
    20422042    scattererConnector->transfer(maskOut, maskOut2, false) ; 
    2043     scatteredElement.addView(CElementView::WORKFLOW, maskOut2) ; 
    2044     scatteredElement.getView(CElementView::WORKFLOW)->getGlobalIndexView(workflowGlobalIndex) ; 
     2043    scatteredElement->addView(CElementView::WORKFLOW, maskOut2) ; 
     2044    scatteredElement->getView(CElementView::WORKFLOW)->getGlobalIndexView(workflowGlobalIndex) ; 
    20452045    // create new workflow view for scattered element 
    2046     CDistributedElement clientToServerElement(scatteredElement.getGlobalSize(), workflowGlobalIndex) ; 
    2047     clientToServerElement.addFullView() ; 
     2046    auto clientToServerElement = make_shared<CDistributedElement>(scatteredElement->getGlobalSize(), workflowGlobalIndex) ; 
     2047    clientToServerElement->addFullView() ; 
    20482048    CEventClient event2(getType(), EVENT_ID_DOMAIN_DISTRIBUTION); 
    20492049    CMessage message2 ; 
    20502050    message2<<serverDomainId<<2 ;  
    2051     clientToServerElement.sendToServer(client, event2, message2) ;  
    2052     clientToServerConnector_[client] = new CScattererConnector(localElement_->getView(CElementView::WORKFLOW), clientToServerElement.getView(CElementView::FULL), 
    2053                                                                context->getIntraComm(), client->getRemoteSize()) ; 
     2051    clientToServerElement->sendToServer(client, event2, message2) ;  
     2052    clientToServerConnector_[client] = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), clientToServerElement->getView(CElementView::FULL), 
     2053                                                                        context->getIntraComm(), client->getRemoteSize()) ; 
    20542054    clientToServerConnector_[client]->computeConnector() ; 
    20552055 
    2056     clientFromServerConnector_[client] = new CGathererConnector(clientToServerElement.getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)); 
     2056    clientFromServerConnector_[client] = make_shared<CGathererConnector>(clientToServerElement->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)); 
    20572057    clientFromServerConnector_[client]->computeConnector() ; 
    20582058 
     
    20762076    if (phasis==0) // receive the remote element to construct the full view 
    20772077    { 
    2078       localElement_ = new  CLocalElement(context->getIntraCommRank(),event) ; 
     2078      localElement_ = make_shared<CLocalElement>(context->getIntraCommRank(),event) ; 
    20792079      localElement_->addFullView() ; 
    20802080      // construct the local dimension and indexes 
     
    21022102    { 
    21032103      CContext* context = CContext::getCurrent(); 
    2104       CDistributedElement* elementFrom = new  CDistributedElement(event) ; 
     2104      shared_ptr<CDistributedElement> elementFrom = make_shared<CDistributedElement>(event) ; 
    21052105      elementFrom->addFullView() ; 
    2106       gathererConnector_ = new CGathererConnector(elementFrom->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ; 
     2106      gathererConnector_ = make_shared<CGathererConnector>(elementFrom->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ; 
    21072107      gathererConnector_->computeConnector() ;  
    21082108    } 
     
    21102110    { 
    21112111//      delete gathererConnector_ ; 
    2112       elementFrom_ = new  CDistributedElement(event) ; 
     2112      elementFrom_ = make_shared<CDistributedElement>(event) ; 
    21132113      elementFrom_->addFullView() ; 
    2114 //      gathererConnector_ =  new CGathererConnector(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ; 
     2114//      gathererConnector_ =  make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ; 
    21152115//      gathererConnector_ -> computeConnector() ; 
    21162116    } 
     
    21272127    mask_1d.reference(serverMask.copy()) ; 
    21282128  
    2129     serverFromClientConnector_ = new CGathererConnector(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ; 
     2129    serverFromClientConnector_ = make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ; 
    21302130    serverFromClientConnector_->computeConnector() ; 
    21312131       
    2132     serverToClientConnector_ = new CScattererConnector(localElement_->getView(CElementView::WORKFLOW), elementFrom_->getView(CElementView::FULL), 
    2133                                                        context->getIntraComm(), client->getRemoteSize()) ; 
     2132    serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementFrom_->getView(CElementView::FULL), 
     2133                                                                context->getIntraComm(), client->getRemoteSize()) ; 
    21342134    serverToClientConnector_->computeConnector() ; 
    21352135  } 
     
    21372137 
    21382138 
    2139   void CDomain::sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector,  const string& domainId) 
     2139  void CDomain::sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector,  const string& domainId) 
    21402140  { 
    21412141    string serverDomainId = domainId.empty() ? this->getId() : domainId ; 
     
    21482148        CMessage message ; 
    21492149        message<<serverDomainId<<string("lon") ;  
    2150         scattererConnector.transfer(lonvalue, client, event,message) ; 
     2150        scattererConnector->transfer(lonvalue, client, event,message) ; 
    21512151      } 
    21522152       
     
    21552155        CMessage message ; 
    21562156        message<<serverDomainId<<string("lat") ;  
    2157         scattererConnector.transfer(latvalue, client, event, message) ; 
     2157        scattererConnector->transfer(latvalue, client, event, message) ; 
    21582158      } 
    21592159    } 
     
    21652165        CMessage message ; 
    21662166        message<<serverDomainId<<string("boundslon") ;  
    2167         scattererConnector.transfer(nvertex, bounds_lonvalue, client, event, message ) ; 
     2167        scattererConnector->transfer(nvertex, bounds_lonvalue, client, event, message ) ; 
    21682168      } 
    21692169 
     
    21722172        CMessage message ; 
    21732173        message<<serverDomainId<<string("boundslat") ;  
    2174         scattererConnector.transfer(nvertex, bounds_latvalue, client, event, message ) ; 
     2174        scattererConnector->transfer(nvertex, bounds_latvalue, client, event, message ) ; 
    21752175      } 
    21762176    } 
     
    21812181      CMessage message ; 
    21822182      message<<serverDomainId<<string("area") ;  
    2183       scattererConnector.transfer(areavalue, client, event,message) ; 
     2183      scattererConnector->transfer(areavalue, client, event,message) ; 
    21842184    } 
    21852185  } 
Note: See TracChangeset for help on using the changeset viewer.