From 76ebee96eeabd7336c49c1250e255db59ec0d971 Mon Sep 17 00:00:00 2001 From: Michael E Rowan <38045958+mrowan137@users.noreply.github.com> Date: Tue, 16 Mar 2021 11:35:07 -0700 Subject: Add timers in routines that depend on cell-related work (#1692) * Add timers * eol * AtomicAdd * lev argument for getCosts * style * style * wip * eol * .ipynb * passing down lev * eol * passing lev * eol * Update Source/Particles/Collision/PairWiseCoulombCollision.cpp Co-authored-by: Axel Huebl * Add for QED and ionization routines * eol * remove unneeded * mfi-->pti * move cost * eol Co-authored-by: Axel Huebl --- .../FieldSolver/FiniteDifferenceSolver/EvolveE.cpp | 40 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp') diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp index 3762d3f71..cd1e3bdf9 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp @@ -5,6 +5,7 @@ * License: BSD-3-Clause-LBNL */ +#include "WarpX.H" #include "Utils/WarpXAlgorithmSelection.H" #include "FiniteDifferenceSolver.H" #ifdef WARPX_DIM_RZ @@ -28,27 +29,27 @@ void FiniteDifferenceSolver::EvolveE ( std::array< std::unique_ptr, 3 > const& Bfield, std::array< std::unique_ptr, 3 > const& Jfield, std::unique_ptr const& Ffield, - amrex::Real const dt ) { + int lev, amrex::Real const dt ) { // Select algorithm (The choice of algorithm is a runtime option, // but we compile code for each algorithm, using templates) #ifdef WARPX_DIM_RZ if (m_fdtd_algo == MaxwellSolverAlgo::Yee){ - EvolveECylindrical ( Efield, Bfield, Jfield, Ffield, dt ); + EvolveECylindrical ( Efield, Bfield, Jfield, Ffield, lev, dt ); #else if (m_do_nodal) { - EvolveECartesian ( Efield, Bfield, Jfield, Ffield, dt ); + EvolveECartesian ( Efield, Bfield, Jfield, Ffield, lev, dt ); } else if (m_fdtd_algo == MaxwellSolverAlgo::Yee) { - EvolveECartesian ( Efield, Bfield, Jfield, Ffield, dt ); + EvolveECartesian ( Efield, Bfield, Jfield, Ffield, lev, dt ); } else if (m_fdtd_algo == MaxwellSolverAlgo::CKC) { - EvolveECartesian ( Efield, Bfield, Jfield, Ffield, dt ); + EvolveECartesian ( Efield, Bfield, Jfield, Ffield, lev, dt ); #endif } else { @@ -66,8 +67,9 @@ void FiniteDifferenceSolver::EvolveECartesian ( std::array< std::unique_ptr, 3 > const& Bfield, std::array< std::unique_ptr, 3 > const& Jfield, std::unique_ptr const& Ffield, - amrex::Real const dt ) { + int lev, amrex::Real const dt ) { + amrex::LayoutData* cost = WarpX::getCosts(lev); Real constexpr c2 = PhysConst::c * PhysConst::c; // Loop through the grids, and over the tiles within each grid @@ -75,6 +77,11 @@ void FiniteDifferenceSolver::EvolveECartesian ( #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif for ( MFIter mfi(*Efield[0], TilingIfNotGPU()); mfi.isValid(); ++mfi ) { + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + } + Real wt = amrex::second(); // Extract field data for this grid/tile Array4 const& Ex = Efield[0]->array(mfi); @@ -150,6 +157,12 @@ void FiniteDifferenceSolver::EvolveECartesian ( } + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + wt = amrex::second() - wt; + amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); + } } } @@ -162,13 +175,20 @@ void FiniteDifferenceSolver::EvolveECylindrical ( std::array< std::unique_ptr, 3 > const& Bfield, std::array< std::unique_ptr, 3 > const& Jfield, std::unique_ptr const& Ffield, - amrex::Real const dt ) { + int lev, amrex::Real const dt ) { + + amrex::LayoutData* cost = WarpX::getCosts(lev); // Loop through the grids, and over the tiles within each grid #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif for ( MFIter mfi(*Efield[0], TilingIfNotGPU()); mfi.isValid(); ++mfi ) { + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + } + Real wt = amrex::second(); // Extract field data for this grid/tile Array4 const& Er = Efield[0]->array(mfi); @@ -339,6 +359,12 @@ void FiniteDifferenceSolver::EvolveECylindrical ( } // end of if condition for F + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + wt = amrex::second() - wt; + amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); + } } // end of loop over grid/tiles } -- cgit v1.2.3