From 65d1c056be23365a045bbcaebf4413378c4c977d Mon Sep 17 00:00:00 2001 From: WeiqunZhang Date: Tue, 8 Sep 2020 12:36:52 -0700 Subject: Remove ManagedVector from Particles/ (#1273) --- Source/Particles/RigidInjectedParticleContainer.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'Source/Particles/RigidInjectedParticleContainer.cpp') diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index 8b8237ceb..338a23675 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -246,7 +246,7 @@ RigidInjectedParticleContainer::PushPX (WarpXParIter& pti, auto& uzp = attribs[PIdx::uz]; // Save the position and momenta, making copies - Gpu::ManagedDeviceVector xp_save, yp_save, zp_save; + Gpu::DeviceVector xp_save, yp_save, zp_save; RealVector uxp_save, uyp_save, uzp_save; const auto GetPosition = GetParticlePosition(pti); @@ -453,9 +453,12 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, } // Save the position and momenta, making copies - auto uxp_save = uxp; - auto uyp_save = uyp; - auto uzp_save = uzp; + amrex::Gpu::DeviceVector uxp_save(np); + amrex::Gpu::DeviceVector uyp_save(np); + amrex::Gpu::DeviceVector uzp_save(np); + ParticleReal* const AMREX_RESTRICT ux_save = uxp_save.dataPtr(); + ParticleReal* const AMREX_RESTRICT uy_save = uyp_save.dataPtr(); + ParticleReal* const AMREX_RESTRICT uz_save = uzp_save.dataPtr(); // Loop over the particles and update their momentum const amrex::Real q = this->charge; @@ -466,6 +469,10 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (long ip) { + ux_save[ip] = uxpp[ip]; + uy_save[ip] = uypp[ip]; + uz_save[ip] = uzpp[ip]; + amrex::ParticleReal xp, yp, zp; getPosition(ip, xp, yp, zp); @@ -513,9 +520,6 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, // Undo the push for particles not injected yet. // It is assumed that PushP will only be called on the first and last steps // and that no particles will cross zinject_plane. - const ParticleReal* const AMREX_RESTRICT ux_save = uxp_save.dataPtr(); - const ParticleReal* const AMREX_RESTRICT uy_save = uyp_save.dataPtr(); - const ParticleReal* const AMREX_RESTRICT uz_save = uzp_save.dataPtr(); const ParticleReal zz = zinject_plane_levels[lev]; amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i) { @@ -527,6 +531,8 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, uzpp[i] = uz_save[i]; } }); + + amrex::Gpu::synchronize(); } } } -- cgit v1.2.3