Skip to content

Commit

Permalink
Update initialization and error handling based on PR feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
neon60 committed Nov 11, 2024
1 parent 693a7b7 commit 0d23a51
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 12 additions & 4 deletions docs/how-to/hip_runtime_api/error_handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ HIP runtime function, apart from launching kernels, has :cpp:type:`hipError_t`
as return type. :cpp:func:`hipGetLastError()` and :cpp:func:`hipPeekAtLastError()`
can be used for catching errors from kernel launches, as kernel launches don't
return an error directly. HIP maintains an internal state, that includes the
last error code. hipGetLastError returns and resets that error to hipSuccess,
while :cpp:func:`hipPeekAtLastError` just returns the error without changing it.
To get a human readable version of the errors, :cpp:func:`hipGetErrorString()`
and :cpp:func:`hipGetErrorName()` can be used.
last error code. :cpp:func:`hipGetLastError` returns and resets that error to
hipSuccess, while :cpp:func:`hipPeekAtLastError` just returns the error without
changing it. To get a human readable version of the errors,
:cpp:func:`hipGetErrorString()` and :cpp:func:`hipGetErrorName()` can be used.

.. note::

:cpp:func:`hipGetLastError` returns the returned error code of the last HIP
runtime API call even if it's hipSuccess, while ``cudaGetLastError`` returns
the error returned by any of the preceding CUDA APIs in the same host thread.
:cpp:func:`hipGetLastError` behavior will be matched with
``cudaGetLastError`` in ROCm release 7.0.

Best practices of HIP error handling:

Expand Down
7 changes: 5 additions & 2 deletions docs/how-to/hip_runtime_api/initialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ using GPUs. The following steps are covered with the initialization:

- Setting up the HIP runtime

This includes loading necessary libraries and setting up internal data
structures.
This includes reading the environment variables set during init, setting up
the active or visible devices, loading necessary libraries, setting up
internal buffers for memory copies or cooperative launches, initialize the
compiler as well as HSA runtime and checks any errors due to lack of resources
or no active devices.

- Querying and setting GPUs

Expand Down

0 comments on commit 0d23a51

Please sign in to comment.