Skip to content

Commit c9b1363

Browse files
umfranzwassistant-librarian[bot]
authored andcommitted
[rocm-libraries] ROCm/rocm-libraries#75 (commit 267d983)
[rocPRIM] Reset internal hip error for tests that run out of memory (#75) The behaviour of hipGetLastError is changing in HIP 7.0. Previously the error that was reported was cleared on each HIP API call. This means that hipGetLastError reported any error that occurred during the last HIP API call. Moving forward, the error that's reported will only be cleared on each call to hipGetLastError. This means that hipGetLastError will report any error that has occurred since the last call to hipGetError. Some of our tests rely on observing a return value of hipErrorOutOfMemory from hipMalloc when an allocation is too large for a given GPU architecture's memory system. This sets the internal HIP error, and it's not cleared before subsequent tests call hipGetLastError, causing them to fail. This change adds extra calls to hipGetLastError to clear the error (for future tests) in cases where tests run out of memory.
1 parent 0fd25ac commit c9b1363

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

common/utils_device_ptr.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class device_ptr
294294
= common::hipMallocHelper(&device_temp_ptr, new_number_of_ele * value_size);
295295
if(err == hipErrorOutOfMemory)
296296
{
297+
(void) hipGetLastError(); // reset internally recorded HIP error
297298
return false;
298299
}
299300
HIP_CHECK(err);

test/common_test_header.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
hipError_t error = condition; \
5151
if(error == hipErrorOutOfMemory) \
5252
{ \
53+
(void) hipGetLastError(); \
5354
std::cout << "Out of memory. Skipping size = " << size << std::endl; \
5455
break; \
5556
} \

test/rocprim/test_device_merge_sort.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ void testLargeIndices()
390390
hipError_t malloc_status = common::hipMallocHelper(&d_output, size * sizeof(*d_output));
391391
if(malloc_status == hipErrorOutOfMemory)
392392
{
393+
(void) hipGetLastError(); // reset internally recorded HIP error
393394
std::cout << "Out of memory. Skipping size = " << size << std::endl;
394395
break;
395396
}
@@ -418,6 +419,7 @@ void testLargeIndices()
418419
malloc_status = common::hipMallocHelper(&d_temp_storage, temp_storage_size_bytes);
419420
if(malloc_status == hipErrorOutOfMemory)
420421
{
422+
(void) hipGetLastError(); // reset internally recorded HIP error
421423
std::cout << "Out of memory. Skipping size = " << size << std::endl;
422424
HIP_CHECK(hipFree(d_output));
423425
break;

0 commit comments

Comments
 (0)