Skip to content

Commit 3629de0

Browse files
committed
add docstring
1 parent 02a5b27 commit 3629de0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Src/Base/AMReX_GpuDevice.H

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ streamSynchronizeAll () noexcept
268268
Device::streamSynchronizeAll();
269269
}
270270

271+
/** Deallocate memory belonging to an arena asynchronously.
272+
* Memory deallocated in this way is held in a pool and will not be reused until
273+
* the next amrex::Gpu::streamSynchronize(). GPU kernels that were already launched on the
274+
* currently active stream can still continue to use the memory after this function is called.
275+
* There is no need to use this function for CPU-only memory or with The_Async_Arena.
276+
*
277+
* \param[in] arena the arena the memory belongs to
278+
* \param[in] mem pointer to the memory to be freed
279+
*/
271280
inline void
272281
streamFree (Arena* arena, void* mem) noexcept
273282
{

Src/Base/AMReX_PODVector.H

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,11 @@ namespace amrex
834834
std::swap(static_cast<Allocator&>(a_vector), static_cast<Allocator&>(*this));
835835
}
836836

837+
/** Deallocate the memory of the PODVector using amrex::Gpu::streamFree.
838+
* Memory deallocated in this way is held in a pool and will not be reused until the next
839+
* amrex::Gpu::streamSynchronize(). GPU kernels that were already launched on the currently
840+
* active stream can still continue to use the memory after this function is called.
841+
*/
837842
void stream_free () noexcept
838843
{
839844
if (m_data != nullptr) {
@@ -843,6 +848,8 @@ namespace amrex
843848
deallocate(m_data, capacity());
844849
}
845850
m_data = nullptr;
851+
m_size = 0;
852+
m_capacity = 0;
846853
}
847854
}
848855

Src/Particle/AMReX_ParticleUtil.H

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ partitionParticles (PTile& ptile, int num_left, ParFunc const& is_left)
632632
}
633633
});
634634

635-
Gpu::streamSynchronize(); // for index_left and index_right deallocation
635+
index_left.stream_free();
636+
index_right.stream_free();
636637
}
637638

638639
template <typename PTile>

0 commit comments

Comments
 (0)