Skip to content

Commit

Permalink
Fix host / device sync bug in PODVector (AMReX-Codes#2890)
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Jul 26, 2022
1 parent 06753e6 commit ce0fb74
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Src/Base/AMReX_PODVector.H
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,10 @@ namespace amrex
void AllocateBuffer (size_type a_capacity) noexcept
{
pointer new_data = allocate(a_capacity);
if (m_data) detail::memCopyImpl<Allocator>(new_data, m_data, size() * sizeof(T), *this);
if (m_data) {
detail::memCopyImpl<Allocator>(new_data, m_data, size() * sizeof(T), *this);
amrex::Gpu::streamSynchronize();
}
deallocate(m_data, capacity());
m_data = new_data;
m_capacity = a_capacity;
Expand All @@ -621,9 +624,10 @@ namespace amrex
pointer new_data = allocate(a_capacity);
if (m_data)
{
memCopyImpl<Allocator>(new_data, m_data, a_index * sizeof(T), *this);
memCopyImpl<Allocator>(new_data, m_data, a_index * sizeof(T), *this);
memCopyImpl<Allocator>(new_data + a_index + a_count, m_data + a_index,
(size() - a_index)*sizeof(T), *this);
amrex::Gpu::streamSynchronize();
}
deallocate(m_data, capacity());
m_data = new_data;
Expand Down

0 comments on commit ce0fb74

Please sign in to comment.