Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: randyh62 <42045079+randyh62@users.noreply.github.com>
  • Loading branch information
neon60 and randyh62 committed Nov 5, 2024
1 parent 6aea7c5 commit aa3584c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/how-to/hip_runtime_api/memory_management/virtual_memory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ the HIP ecosystem. Both allocating and copying memory can result in bottlenecks,
which can significantly impact performance.

Global memory allocation in HIP uses the C language style allocation function.
This works fine for simple cases but can cause problems if your memory needs
change. If you need to increase the size of your memory, you must allocate a
This works fine for simple cases but can cause problems if your application requires additional memory.
If you need to increase the size of your memory, you must allocate a
second larger buffer and copy the data to it before you can free the original
buffer. This increases overall memory usage and causes unnecessary ``memcpy``
calls. Another solution is to allocate a larger buffer than you initially need.
However, this isn't an efficient way to handle resources and doesn't solve the
issue of reallocation when the extra buffer runs out.

Virtual memory management solves these memory management problems. It helps to
reduce memory usage and unnecessary ``memcpy`` calls.
Virtual memory management solves these problems by reducing
memory usage and unnecessary ``memcpy`` calls.

.. _memory_allocation_virtual_memory:

Expand All @@ -48,7 +48,9 @@ contains the properties of the memory to be allocated, such as where the memory
is physically located and what kind of shareable handles are available. If the
allocation is successful, the function returns a value of
:cpp:enumerator:`hipSuccess`, with :cpp:type:`hipMemGenericAllocationHandle_t`
representing a valid physical memory allocation. The allocated memory size must
representing a valid physical memory allocation.

The allocated memory size must
be aligned with the granularity appropriate for the properties of the
allocation. You can use the :cpp:func:`hipMemGetAllocationGranularity` function
to determine the correct granularity.
Expand Down Expand Up @@ -138,7 +140,7 @@ Dynamically increase allocation size

The :cpp:func:`hipMemAddressReserve` function allows you to increase the amount
of pre-allocated memory. This function accepts a parameter representing the
requested starting address of the virtual memory. This allows you to have a
requested starting address of the virtual memory, and the amount of additional memory to reserve. This allows you to have a
continuous virtual address space without worrying about the underlying physical
allocation.

Expand Down

0 comments on commit aa3584c

Please sign in to comment.