diff options
Diffstat (limited to 'Source/Particles/Sorting')
-rw-r--r-- | Source/Particles/Sorting/Partition.cpp | 11 | ||||
-rw-r--r-- | Source/Particles/Sorting/SortingUtils.H | 10 |
2 files changed, 14 insertions, 7 deletions
diff --git a/Source/Particles/Sorting/Partition.cpp b/Source/Particles/Sorting/Partition.cpp index 2b5d661e4..badd35f02 100644 --- a/Source/Particles/Sorting/Partition.cpp +++ b/Source/Particles/Sorting/Partition.cpp @@ -43,9 +43,9 @@ PhysicalParticleContainer::PartitionParticlesInBuffers( BL_PROFILE("PPC::Evolve::partition"); // Initialize temporary arrays - Gpu::ManagedDeviceVector<int> inexflag; + Gpu::DeviceVector<int> inexflag; inexflag.resize(np); - Gpu::ManagedDeviceVector<long> pid; + Gpu::DeviceVector<long> pid; pid.resize(np); // First, partition particles into the larger buffer @@ -138,5 +138,12 @@ PhysicalParticleContainer::PartitionParticlesInBuffers( std::swap(uyp, tmp); amrex::ParallelFor( np, copyAndReorder<Real>( uzp, tmp, pid ) ); std::swap(uzp, tmp); + + // Make sure that the temporary arrays are not destroyed before + // the GPU kernels finish running + Gpu::streamSynchronize(); } + // Make sure that the temporary arrays are not destroyed before + // the GPU kernels finish running + Gpu::streamSynchronize(); } diff --git a/Source/Particles/Sorting/SortingUtils.H b/Source/Particles/Sorting/SortingUtils.H index 76c143b09..1aaaf73a8 100644 --- a/Source/Particles/Sorting/SortingUtils.H +++ b/Source/Particles/Sorting/SortingUtils.H @@ -6,7 +6,7 @@ #include <AMReX_Gpu.H> // TODO: Add documentation -void fillWithConsecutiveIntegers( amrex::Gpu::ManagedDeviceVector<long>& v ) +void fillWithConsecutiveIntegers( amrex::Gpu::DeviceVector<long>& v ) { #ifdef AMREX_USE_GPU // On GPU: Use thrust @@ -21,7 +21,7 @@ void fillWithConsecutiveIntegers( amrex::Gpu::ManagedDeviceVector<long>& v ) template< typename ForwardIterator > ForwardIterator stablePartition(ForwardIterator index_begin, ForwardIterator index_end, - amrex::Gpu::ManagedDeviceVector<int>& predicate) + amrex::Gpu::DeviceVector<int>& predicate) { #ifdef AMREX_USE_GPU // On GPU: Use thrust @@ -59,7 +59,7 @@ class fillBufferFlag { public: fillBufferFlag( WarpXParIter& pti, const amrex::iMultiFab* bmasks, - amrex::Gpu::ManagedDeviceVector<int>& inexflag, + amrex::Gpu::DeviceVector<int>& inexflag, const amrex::Geometry& geom, long start_index=0 ) { // Extract simple structure that can be used directly on the GPU @@ -109,14 +109,14 @@ class copyAndReorder copyAndReorder( amrex::Gpu::ManagedDeviceVector<T>& src, amrex::Gpu::ManagedDeviceVector<T>& dst, - amrex::Gpu::ManagedDeviceVector<long>& indices ) { + amrex::Gpu::DeviceVector<long>& indices ) { // Extract simple structure that can be used directly on the GPU m_src_ptr = src.dataPtr(); m_dst_ptr = dst.dataPtr(); m_indices_ptr = indices.dataPtr(); }; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()( const long ip ) const { m_dst_ptr[ip] = m_src_ptr[ m_indices_ptr[ip] ]; }; |