[rocRAND][hipRAND] Update error handling in rocRAND/hipRAND#1227
Merged
Conversation
In some files, rocRAND and hipRAND use a simplified definition of HIP_CHECK that calls GTest's ASSERT_EQ to compare the value it's passed with hipSuccess, and does not exit on error (just fails the test). As of ROCm 7.0, hipGetLastError's behaviour has changed such that the internal error state is not cleared with every HIP API call (only on calls to hipGetLastError). If we do not exit when HIP_CHECK fails, then the internal error state will persist, and the error will be caught the next time hipGetLastError is called in a subsequent test. This change replaces the simplified HIP_CHECK definitions with a version that exits on failure. hipRAND was also relying on the simplified HIP_CHECK to check both calls that return a hipError_t and hiprandStatus_t. With the new version of HIP_CHECK, this no longer works. This change adds a separate HIPRAND_CHECK macro to handle checks of type hiprandStatus_t. The version numbers for rocRAND and hipRAND have also been updated.
f9b5afa to
51a0f47
Compare
Contributor
Author
|
Converting this to a draft while I look into the reported CI issues. |
Calling HIP_CHECK(error) won't work, since HIP_CHECK declares a variable called error.
stanleytsang-amd
approved these changes
Aug 28, 2025
assistant-librarian Bot
pushed a commit
to ROCm/hipRAND
that referenced
this pull request
Aug 28, 2025
[rocRAND][hipRAND] Update error handling in rocRAND/hipRAND (#1227) ## Motivation In some files, rocRAND and hipRAND use a simplified definition of `HIP_CHECK` that calls GTest's `ASSERT_EQ` to compare the value it's passed with `hipSuccess`, and does not exit on error (just fails the test). As of ROCm 7.0, `hipGetLastError`'s behaviour has changed such that the internal error state is not cleared with every HIP API call (only on calls to `hipGetLastError`). If we do not exit when `HIP_CHECK` fails, then the internal error state will persist, and the error will be caught the next time `hipGetLastError` is called in a subsequent test. ## Technical Details This change replaces the simplified `HIP_CHECK` definitions with a version that exits on failure. hipRAND was also relying on the simplified `HIP_CHECK` to check both calls that return a `hipError_t` and `hiprandStatus_t`. With the new version of `HIP_CHECK`, this no longer works. This change adds a separate `HIPRAND_CHECK` macro to handle checks of type `hiprandStatus_t`. ## Test Plan Built and ran all tests for rocRAND and hipRAND in order to verify that they work correctly. ## Test Result All tests built and passed successfully. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
assistant-librarian Bot
pushed a commit
to ROCm/rocRAND
that referenced
this pull request
Aug 28, 2025
[rocRAND][hipRAND] Update error handling in rocRAND/hipRAND (#1227) ## Motivation In some files, rocRAND and hipRAND use a simplified definition of `HIP_CHECK` that calls GTest's `ASSERT_EQ` to compare the value it's passed with `hipSuccess`, and does not exit on error (just fails the test). As of ROCm 7.0, `hipGetLastError`'s behaviour has changed such that the internal error state is not cleared with every HIP API call (only on calls to `hipGetLastError`). If we do not exit when `HIP_CHECK` fails, then the internal error state will persist, and the error will be caught the next time `hipGetLastError` is called in a subsequent test. ## Technical Details This change replaces the simplified `HIP_CHECK` definitions with a version that exits on failure. hipRAND was also relying on the simplified `HIP_CHECK` to check both calls that return a `hipError_t` and `hiprandStatus_t`. With the new version of `HIP_CHECK`, this no longer works. This change adds a separate `HIPRAND_CHECK` macro to handle checks of type `hiprandStatus_t`. ## Test Plan Built and ran all tests for rocRAND and hipRAND in order to verify that they work correctly. ## Test Result All tests built and passed successfully. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In some files, rocRAND and hipRAND use a simplified definition of
HIP_CHECKthat calls GTest'sASSERT_EQto compare the value it's passed withhipSuccess, and does not exit on error (just fails the test).As of ROCm 7.0,
hipGetLastError's behaviour has changed such that the internal error state is not cleared with every HIP API call (only on calls tohipGetLastError). If we do not exit whenHIP_CHECKfails, then the internal error state will persist, and the error will be caught the next timehipGetLastErroris called in a subsequent test.Technical Details
This change replaces the simplified
HIP_CHECKdefinitions with a version that exits on failure.hipRAND was also relying on the simplified
HIP_CHECKto check both calls that return ahipError_tandhiprandStatus_t. With the new version ofHIP_CHECK, this no longer works. This change adds a separateHIPRAND_CHECKmacro to handle checks of typehiprandStatus_t.Test Plan
Built and ran all tests for rocRAND and hipRAND in order to verify that they work correctly.
Test Result
All tests built and passed successfully.
Submission Checklist