From 892958903f96367df47242b4f6c63b20fa11221e Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 21 Feb 2023 09:03:05 -0800 Subject: GetExternalEBField: Use AMReX's CompileTimeOption ParallelFor (#3696) This greatly improves the performance on AMD and Intel GPUs when GetExternalEBField is not used. --- Source/Particles/RigidInjectedParticleContainer.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Source/Particles/RigidInjectedParticleContainer.cpp') diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index cc064538b..493b14e55 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -407,7 +407,14 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, const auto pusher_algo = WarpX::particle_pusher_algo; const auto do_crr = do_classical_radiation_reaction; - amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (long ip) + enum exteb_flags : int { no_exteb, has_exteb }; + + int exteb_runtime_flag = getExternalEB.isNoOp() ? no_exteb : has_exteb; + + amrex::ParallelFor(TypeList>{}, + {exteb_runtime_flag}, + np, [=,getExternalEB=getExternalEB] + AMREX_GPU_DEVICE (long ip, auto exteb_control) { ux_save[ip] = uxpp[ip]; uy_save[ip] = uypp[ip]; @@ -425,7 +432,10 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, ex_type, ey_type, ez_type, bx_type, by_type, bz_type, dx_arr, xyzmin_arr, lo, n_rz_azimuthal_modes, nox, galerkin_interpolation); - getExternalEB(ip, Exp, Eyp, Ezp, Bxp, Byp, Bzp); + + if constexpr (exteb_control == has_exteb) { + getExternalEB(ip, Exp, Eyp, Ezp, Bxp, Byp, Bzp); + } amrex::ParticleReal qp = q; if (ion_lev) { qp *= ion_lev[ip]; } -- cgit v1.2.3