Ignore:
Timestamp:
12/01/21 16:52:24 (3 years 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/grid.cpp

    r2264 r2267  
    14291429    if (posDistributed==elements.size()) posDistributed=0 ; // grid composed only of scalar 
    14301430     
    1431     vector<CLocalView*> localViews ; 
    1432     vector<CLocalView*> workflowView ; 
    1433     vector<CDistributedView*> remoteViews ; 
     1431    vector<shared_ptr<CLocalView>> localViews ; 
     1432    vector<shared_ptr<CLocalView>> workflowView ; 
     1433    vector<shared_ptr<CDistributedView>> remoteViews ; 
    14341434 
    14351435    for(int i=0 ; i<elements.size() ; i++) 
     
    14621462     
    14631463    // CGridClientServerRemoteConnector : workflowView is added to avoid spurious optimisation with only the fullview 
    1464     CGridClientServerRemoteConnector gridRemoteConnector(localViews, workflowView, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
    1465     gridRemoteConnector.computeConnector() ; 
     1464    auto gridRemoteConnector = make_shared<CGridClientServerRemoteConnector>(localViews, workflowView, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; 
     1465    gridRemoteConnector->computeConnector() ; 
    14661466     
    1467     vector<CScattererConnector*> scattererConnectors ; 
    1468     CScattererConnector* scattererConnector; 
     1467    vector<shared_ptr<CScattererConnector>> scattererConnectors ; 
     1468    shared_ptr<CScattererConnector> scattererConnector; 
    14691469    for(int i=0 ; i<elements.size() ; i++) 
    14701470    { 
     
    14721472      {  
    14731473        CDomain* domain = (CDomain*) elements[i].ptr ; 
    1474         if (isCoupling) domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector,  domain->getCouplingAlias(fieldId,i)) ; 
     1474        if (isCoupling) domain->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), scattererConnector,  domain->getCouplingAlias(fieldId,i)) ; 
    14751475        else  
    14761476        { 
    14771477          sendAddDomain(domain->getId(),client) ; 
    1478           domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1478          domain->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), scattererConnector) ; 
    14791479        } 
    14801480        scattererConnectors.push_back(scattererConnector) ; 
     
    14831483      { 
    14841484        CAxis* axis = (CAxis*) elements[i].ptr ; 
    1485         if (isCoupling) axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector,  axis->getCouplingAlias(fieldId,i)) ; 
     1485        if (isCoupling) axis->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), scattererConnector,  axis->getCouplingAlias(fieldId,i)) ; 
    14861486        else  
    14871487        { 
    14881488          sendAddAxis(axis->getId(),client) ; 
    1489           axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1489          axis->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), scattererConnector) ; 
    14901490        } 
    14911491        scattererConnectors.push_back(scattererConnector) ; 
     
    14941494      { 
    14951495        CScalar* scalar = (CScalar*) elements[i].ptr ; 
    1496         if (isCoupling) scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector,  scalar->getCouplingAlias(fieldId,i)) ; 
     1496        if (isCoupling) scalar->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), scattererConnector,  scalar->getCouplingAlias(fieldId,i)) ; 
    14971497        else  
    14981498        { 
    14991499          sendAddScalar(scalar->getId(),client) ; 
    1500           scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; 
     1500          scalar->distributeToServer(client, gridRemoteConnector->getDistributedGlobalIndex(i), scattererConnector) ; 
    15011501        } 
    15021502        scattererConnectors.push_back(scattererConnector) ; 
     
    15041504    } 
    15051505 
    1506     CGridScattererConnector gridScattererConnector(scattererConnectors) ; 
    1507     CGridLocalConnector* workflowToFull = getGridLocalElements()->getConnector(CElementView::WORKFLOW, CElementView::FULL) ; 
     1506    auto gridScattererConnector = make_shared<CGridScattererConnector>(scattererConnectors) ; 
     1507    shared_ptr<CGridLocalConnector> workflowToFull = getGridLocalElements()->getConnector(CElementView::WORKFLOW, CElementView::FULL) ; 
    15081508    CArray<bool,1> maskIn(workflowToFull->getSrcSize()) ; 
    15091509    CArray<bool,1> maskOut(workflowToFull->getDstSize()) ; 
     
    15151515    if (isCoupling) message<<getCouplingAlias(fieldId) ; 
    15161516    else message<<getId() ;  
    1517     gridScattererConnector.transfer(maskOut, client, event, message) ; 
    1518     for(auto& it : scattererConnectors) delete it ; 
    1519  
    1520     vector<CScattererConnector*> clientToServerConnectors ; 
    1521     vector<CGathererConnector*>  clientFromServerConnectors ; 
     1517    gridScattererConnector->transfer(maskOut, client, event, message) ; 
     1518    
     1519    vector<shared_ptr<CScattererConnector>> clientToServerConnectors ; 
     1520    vector<shared_ptr<CGathererConnector>>  clientFromServerConnectors ; 
    15221521    for(auto& element : elements) 
    15231522    { 
     
    15411540     
    15421541    // compute the grid clientToServerConnector to send flux from client to servers 
    1543     clientToServerConnector_[client] = new CGridScattererConnector(clientToServerConnectors) ; 
    1544     clientFromServerConnector_[client] = new CGridGathererConnector(clientFromServerConnectors) ; 
     1542    clientToServerConnector_[client] = make_shared<CGridScattererConnector>(clientToServerConnectors) ; 
     1543    clientFromServerConnector_[client] = make_shared<CGridGathererConnector>(clientFromServerConnectors) ; 
    15451544 
    15461545  } 
     
    15561555  void CGrid::receiveMask(CEventServer& event) 
    15571556  { 
    1558     vector<CGathererConnector*> gathererConnectors ; 
    1559     vector<CLocalView*> fullViews ; 
     1557    vector<shared_ptr<CGathererConnector>> gathererConnectors ; 
     1558    vector<shared_ptr<CLocalView>> fullViews ; 
    15601559 
    15611560    for(auto& element : getElements()) 
     
    15781577      } 
    15791578    } 
    1580     CGridGathererConnector gridGathererConnector(gathererConnectors) ; 
    1581     CGridMaskConnector gridMaskConnector(fullViews) ; 
     1579    auto gridGathererConnector = make_shared<CGridGathererConnector>(gathererConnectors) ; 
     1580    auto gridMaskConnector = make_shared<CGridMaskConnector>(fullViews) ; 
    15821581 
    15831582    CArray<bool,1> maskOut ; 
    1584     gridGathererConnector.transfer_or(event,maskOut) ; 
    1585     gridMaskConnector.computeConnector(maskOut) ; 
     1583    gridGathererConnector->transfer_or(event,maskOut) ; 
     1584    gridMaskConnector->computeConnector(maskOut) ; 
    15861585 
    15871586    CContextClient* client = event.getContextServer()->getAssociatedClient() ; 
     
    15891588    for(auto& element : getElements()) 
    15901589    { 
    1591       if (element.type==TYPE_DOMAIN) element.domain->setServerMask(gridMaskConnector.getElementMask(i),client); 
    1592       else if (element.type==TYPE_AXIS) element.axis->setServerMask(gridMaskConnector.getElementMask(i),client); 
    1593       else if (element.type==TYPE_SCALAR) element.scalar->setServerMask(gridMaskConnector.getElementMask(i),client); 
     1590      if (element.type==TYPE_DOMAIN) element.domain->setServerMask(gridMaskConnector->getElementMask(i),client); 
     1591      else if (element.type==TYPE_AXIS) element.axis->setServerMask(gridMaskConnector->getElementMask(i),client); 
     1592      else if (element.type==TYPE_SCALAR) element.scalar->setServerMask(gridMaskConnector->getElementMask(i),client); 
    15941593      i++ ; 
    15951594    } 
     
    23102309    auto axis=axisList.begin() ; 
    23112310    auto scalar=scalarList.begin() ; 
    2312     vector<CLocalElement*> elements; 
     2311    vector<shared_ptr<CLocalElement>> elements; 
    23132312    for(auto order : order_) 
    23142313    { 
     
    23322331    { 
    23332332      vector<bool> mask(getMask().getVector()) ; 
    2334       gridLocalElements_ = new CGridLocalElements(elements, mask) ;   
    2335     } 
    2336     else gridLocalElements_ = new CGridLocalElements(elements) ;   
     2333      gridLocalElements_ = make_shared<CGridLocalElements>(elements, mask) ;   
     2334    } 
     2335    else gridLocalElements_ = make_shared<CGridLocalElements>(elements) ;   
    23372336  } 
    23382337 
     
    23592358  void CGrid::computeServerFromClientConnector(void) 
    23602359  { 
    2361     vector<CGathererConnector*> connectors ; 
     2360    vector<shared_ptr<CGathererConnector>> connectors ; 
    23622361    for(auto& element : getElements()) 
    23632362    { 
     
    23662365      else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerFromClientConnector()) ;  
    23672366    } 
    2368     serverFromClientConnector_ = new CGridGathererConnector(connectors) ; 
     2367    serverFromClientConnector_ = make_shared<CGridGathererConnector>(connectors) ; 
    23692368  } 
    23702369 
    23712370  void CGrid::computeServerToClientConnector(void) 
    23722371  { 
    2373     vector<CScattererConnector*> connectors ; 
     2372    vector<shared_ptr<CScattererConnector>> connectors ; 
    23742373    for(auto& element : getElements()) 
    23752374    { 
     
    23782377      else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerToClientConnector()) ;  
    23792378    } 
    2380     serverToClientConnector_ = new CGridScattererConnector(connectors) ; 
     2379    serverToClientConnector_ = make_shared<CGridScattererConnector>(connectors) ; 
    23812380  } 
    23822381 
    23832382  void CGrid::computeClientFromClientConnector(void) 
    23842383  { 
    2385     vector<CGathererConnector*> connectors ; 
     2384    vector<shared_ptr<CGathererConnector>> connectors ; 
    23862385    for(auto& element : getElements()) 
    23872386    { 
     
    23902389      else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerFromClientConnector()) ;  
    23912390    } 
    2392     clientFromClientConnector_ = new CGridGathererConnector(connectors) ; 
     2391    clientFromClientConnector_ = make_shared<CGridGathererConnector>(connectors) ; 
    23932392  } 
    23942393 
Note: See TracChangeset for help on using the changeset viewer.