-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6312df
commit cd24293
Showing
1 changed file
with
6 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,19 +61,19 @@ class d_vector | |
|
||
T* device_vector_setup() | ||
{ | ||
T* d = nullptr; | ||
T* d; | ||
if((hipMalloc)(&d, bytes) != hipSuccess) | ||
{ | ||
fmt::print(stderr, "Error allocating {} bytes ({} GB)\n", bytes, bytes >> 30); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jmachado-amd
Author
Collaborator
|
||
d = nullptr; | ||
} | ||
/* CHECK_HIP_ERROR((hipMemset)(d, 0, bytes)); // Why this doesn't work? */ | ||
if(d != nullptr) | ||
else | ||
{ | ||
auto error = (hipMemset)(d, 0, bytes); | ||
if(error != hipSuccess) | ||
auto status = (hipMemset)(d, 0, bytes); | ||
/* CHECK_HIP_ERROR(status); // Why this doesn't work? */ | ||
if(status != hipSuccess) | ||
{ | ||
fmt::print(stderr, "error: {} ({}) at {}:{}\n", hipGetErrorString(error), error, | ||
fmt::print(stderr, "error: {} ({}) at {}:{}\n", hipGetErrorString(status), status, | ||
__FILE__, __LINE__); | ||
rocblas_abort(); | ||
} | ||
|
Minor comment: Perhaps you would like to be consistent to capture the status from hipMalloc and generate a similar error message that contain hipGetErrorString(status)?
Personally, I prefer your original version in declaring "T * d = nullptr" to always set a known value to temporary variables, and to check value of "if (d != nullptr)" instead of using the "else". I find the logic easier to understand.
Just a minor suggestion.