Skip to content

Commit ce0fb74

Browse files
authored
Fix host / device sync bug in PODVector (AMReX-Codes#2890)
1 parent 06753e6 commit ce0fb74

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Src/Base/AMReX_PODVector.H

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,10 @@ namespace amrex
608608
void AllocateBuffer (size_type a_capacity) noexcept
609609
{
610610
pointer new_data = allocate(a_capacity);
611-
if (m_data) detail::memCopyImpl<Allocator>(new_data, m_data, size() * sizeof(T), *this);
611+
if (m_data) {
612+
detail::memCopyImpl<Allocator>(new_data, m_data, size() * sizeof(T), *this);
613+
amrex::Gpu::streamSynchronize();
614+
}
612615
deallocate(m_data, capacity());
613616
m_data = new_data;
614617
m_capacity = a_capacity;
@@ -621,9 +624,10 @@ namespace amrex
621624
pointer new_data = allocate(a_capacity);
622625
if (m_data)
623626
{
624-
memCopyImpl<Allocator>(new_data, m_data, a_index * sizeof(T), *this);
627+
memCopyImpl<Allocator>(new_data, m_data, a_index * sizeof(T), *this);
625628
memCopyImpl<Allocator>(new_data + a_index + a_count, m_data + a_index,
626629
(size() - a_index)*sizeof(T), *this);
630+
amrex::Gpu::streamSynchronize();
627631
}
628632
deallocate(m_data, capacity());
629633
m_data = new_data;

0 commit comments

Comments
 (0)