Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix host / device sync bug in PODVector #2890

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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