From 769dd04a5ceda609868e4675e84241278b1ea1eb Mon Sep 17 00:00:00 2001 From: acitrain <60715545+acitrain@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:13:22 +0200 Subject: [PATCH] feat: Add freeOnDevice calls on Wave Propagation Solvers (#2610) * Add freeOnDevice calls * Update LvArray submodule * Revert "Update LvArray submodule" This reverts commit bb15aaec4005844cea3f1f4afae9ed7a680decba. * Update LvArray submodule * add FreeOnDevice for Array * adding freeOnDevice for wavePropagation sovlers * add freeOnDevice function to AcousticFirstOrderWaveEquationSEM * udpate LvArray version * added freeOnDevice calls to all other wave solvers * uncrustify --------- Co-authored-by: Stefano Frambati Co-authored-by: Jie Meng Co-authored-by: j0405284 --- .../AcousticFirstOrderWaveEquationSEM.cpp | 14 +++++++++++++- .../anisotropic/AcousticVTIWaveEquationSEM.cpp | 13 +++++++++++++ .../isotropic/AcousticWaveEquationSEM.cpp | 13 +++++++++++++ .../isotropic/ElasticFirstOrderWaveEquationSEM.cpp | 13 +++++++++++++ .../isotropic/ElasticWaveEquationSEM.cpp | 13 +++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp index 304d89a43e1..39b2334d532 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/firstOrderEqn/isotropic/AcousticFirstOrderWaveEquationSEM.cpp @@ -251,8 +251,20 @@ void AcousticFirstOrderWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLev m_timeSourceDelay, m_rickerOrder ); } ); + elementSubRegion.faceList().freeOnDevice(); + baseMesh.getElemManager().getRegion( regionIndex ).getSubRegion< CellElementSubRegion >( esr ).nodeList().freeOnDevice(); + elementSubRegion.getElementCenter().freeOnDevice(); + elementSubRegion.ghostRank().freeOnDevice(); + elementSubRegion.localToGlobalMap().freeOnDevice(); } ); - + baseMesh.getNodeManager().localToGlobalMap().freeOnDevice(); + baseMesh.getNodeManager().elementList().toView().freeOnDevice(); + baseMesh.getFaceManager().nodeList().toView().freeOnDevice(); + baseMesh.getNodeManager().referencePosition().freeOnDevice(); + m_sourceCoordinates.freeOnDevice(); + m_receiverCoordinates.freeOnDevice(); + facesToNodes.freeOnDevice(); + nodesToElements.freeOnDevice(); } void AcousticFirstOrderWaveEquationSEM::initializePostInitialConditionsPreSubGroups() diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp index e3360243dc9..edf012c68d8 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/anisotropic/AcousticVTIWaveEquationSEM.cpp @@ -202,7 +202,20 @@ void AcousticVTIWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & ba m_timeSourceDelay, m_rickerOrder ); } ); + elementSubRegion.faceList().freeOnDevice(); + baseMesh.getElemManager().getRegion( er ).getSubRegion< CellElementSubRegion >( esr ).nodeList().freeOnDevice(); + elementSubRegion.getElementCenter().freeOnDevice(); + elementSubRegion.ghostRank().freeOnDevice(); + elementSubRegion.localToGlobalMap().freeOnDevice(); } ); + baseMesh.getNodeManager().localToGlobalMap().freeOnDevice(); + baseMesh.getNodeManager().elementList().toView().freeOnDevice(); + baseMesh.getFaceManager().nodeList().toView().freeOnDevice(); + baseMesh.getNodeManager().referencePosition().freeOnDevice(); + m_sourceCoordinates.freeOnDevice(); + m_receiverCoordinates.freeOnDevice(); + facesToNodes.freeOnDevice(); + nodesToElements.freeOnDevice(); } void AcousticVTIWaveEquationSEM::addSourceToRightHandSide( integer const & cycleNumber, arrayView1d< real32 > const rhs ) diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp index 26f30ddfbda..6e1852d0a55 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/acoustic/secondOrderEqn/isotropic/AcousticWaveEquationSEM.cpp @@ -211,7 +211,20 @@ void AcousticWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseM m_rickerOrder ); } } ); + elementSubRegion.faceList().freeOnDevice(); + baseMesh.getElemManager().getRegion( er ).getSubRegion< CellElementSubRegion >( esr ).nodeList().freeOnDevice(); + elementSubRegion.getElementCenter().freeOnDevice(); + elementSubRegion.ghostRank().freeOnDevice(); + elementSubRegion.localToGlobalMap().freeOnDevice(); } ); + baseMesh.getNodeManager().localToGlobalMap().freeOnDevice(); + baseMesh.getNodeManager().elementList().toView().freeOnDevice(); + baseMesh.getFaceManager().nodeList().toView().freeOnDevice(); + baseMesh.getNodeManager().referencePosition().freeOnDevice(); + m_sourceCoordinates.freeOnDevice(); + m_receiverCoordinates.freeOnDevice(); + facesToNodes.freeOnDevice(); + nodesToElements.freeOnDevice(); } void AcousticWaveEquationSEM::addSourceToRightHandSide( integer const & cycleNumber, arrayView1d< real32 > const rhs ) diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp index e4ba67351ce..ff99332815d 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/firstOrderEqn/isotropic/ElasticFirstOrderWaveEquationSEM.cpp @@ -303,7 +303,20 @@ void ElasticFirstOrderWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLeve m_timeSourceDelay, m_rickerOrder ); } ); + elementSubRegion.faceList().freeOnDevice(); + baseMesh.getElemManager().getRegion( regionIndex ).getSubRegion< CellElementSubRegion >( esr ).nodeList().freeOnDevice(); + elementSubRegion.getElementCenter().freeOnDevice(); + elementSubRegion.ghostRank().freeOnDevice(); + elementSubRegion.localToGlobalMap().freeOnDevice(); } ); + baseMesh.getNodeManager().localToGlobalMap().freeOnDevice(); + baseMesh.getNodeManager().elementList().toView().freeOnDevice(); + baseMesh.getFaceManager().nodeList().toView().freeOnDevice(); + baseMesh.getNodeManager().referencePosition().freeOnDevice(); + m_sourceCoordinates.freeOnDevice(); + m_receiverCoordinates.freeOnDevice(); + facesToNodes.freeOnDevice(); + nodesToElements.freeOnDevice(); } void ElasticFirstOrderWaveEquationSEM::initializePostInitialConditionsPreSubGroups() diff --git a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp index bdae31b1e26..b6e28c5f3d5 100644 --- a/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp +++ b/src/coreComponents/physicsSolvers/wavePropagation/sem/elastic/secondOrderEqn/isotropic/ElasticWaveEquationSEM.cpp @@ -326,7 +326,20 @@ void ElasticWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseMe m_sourceForce, m_sourceMoment ); } ); + elementSubRegion.faceList().freeOnDevice(); + baseMesh.getElemManager().getRegion( er ).getSubRegion< CellElementSubRegion >( esr ).nodeList().freeOnDevice(); + elementSubRegion.getElementCenter().freeOnDevice(); + elementSubRegion.ghostRank().freeOnDevice(); + elementSubRegion.localToGlobalMap().freeOnDevice(); } ); + baseMesh.getNodeManager().localToGlobalMap().freeOnDevice(); + baseMesh.getNodeManager().elementList().toView().freeOnDevice(); + baseMesh.getFaceManager().nodeList().toView().freeOnDevice(); + baseMesh.getNodeManager().referencePosition().freeOnDevice(); + m_sourceCoordinates.freeOnDevice(); + m_receiverCoordinates.freeOnDevice(); + facesToNodes.freeOnDevice(); + nodesToElements.freeOnDevice(); } void ElasticWaveEquationSEM::addSourceToRightHandSide( integer const & cycleNumber,