Skip to content

Commit a14be4b

Browse files
[rocm-libraries] ROCm/rocm-libraries#8164 (commit 26278bf)
rocprim.device_merge_sort killed by host OOM during RocprimDeviceSortTests/21 (#8164) ## Motivation The RocPrimDeviceSortTests/21 is still running out of host memory on a small 16GB system (a VM.) ## Technical Details MEMCHECKs have been implemented in the test to skip the larger test sizes for low memory availability. ## Test Plan Re-run the test on the 16GB VM. ## Test Result Test should pass. ## Submission Checklist - [ ] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
1 parent a8028ac commit a14be4b

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

test/rocprim/test_device_merge_sort.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,23 +346,19 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
346346
{
347347
SCOPED_TRACE(testing::Message() << "with size = " << size);
348348

349-
bool is_apu = test_utils::is_apu(arch);
350-
if (is_apu && test_utils::get_total_system_memory(true) <= test_utils::minimum_memory_required_bytes
351-
&& size >= (1 << 20))
352-
{
353-
std::cout << "Insufficient APU system memory. Skipping test for size = " << size << std::endl;
354-
GTEST_SKIP();
355-
}
356-
357349
in_place = !in_place;
358350

351+
test_utils::MemCheck memcheck;
352+
359353
// Generate data
354+
MEMCHECK_OR_BREAK_ALLOC_HOST(key_type, size)
360355
std::vector<key_type> keys_input = test_utils::get_random_data_wrapped<key_type>(
361356
size,
362357
-100,
363358
100,
364359
seed_value); // float16 can't exceed 65504
365360

361+
MEMCHECK_OR_BREAK_ALLOC_HOST(value_type, size)
366362
std::vector<value_type> values_input(size);
367363
test_utils::iota(values_input.begin(), values_input.end(), 0);
368364

@@ -371,6 +367,11 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
371367
common::device_ptr<value_type> d_values_input;
372368
common::device_ptr<value_type> d_values_output_alloc;
373369

370+
MEMCHECK_OR_BREAK_ALLOC_DEVICE(key_type, size)
371+
MEMCHECK_OR_BREAK_ALLOC_DEVICE(key_type, in_place ? 0 : size)
372+
MEMCHECK_OR_BREAK_ALLOC_DEVICE(value_type, size)
373+
MEMCHECK_OR_BREAK_ALLOC_DEVICE(value_type, in_place ? 0 : size)
374+
374375
if(!d_keys_input.resize_with_memory_check(size)
375376
|| !d_keys_output_alloc.resize_with_memory_check(in_place ? 0 : size)
376377
|| !d_values_input.resize_with_memory_check(size)
@@ -393,6 +394,7 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
393394

394395
// Calculate expected results on host
395396
using key_value = std::pair<key_type, value_type>;
397+
MEMCHECK_OR_BREAK_ALLOC_HOST(key_value, size)
396398
std::vector<key_value> expected(size);
397399
for(size_t i = 0; i < size; i++)
398400
{
@@ -434,6 +436,7 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
434436
// allocate temporary storage
435437
common::device_ptr<void> d_temp_storage;
436438

439+
MEMCHECK_OR_BREAK_ALLOC_DEVICE_BYTES(temp_storage_size_bytes)
437440
if(!d_temp_storage.resize_with_memory_check(temp_storage_size_bytes))
438441
{
439442
std::cout << "Out of memory. Skipping test for size = " << size << std::endl;
@@ -467,7 +470,10 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
467470
HIP_CHECK(hipDeviceSynchronize());
468471

469472
// Check if output values are as expected
473+
MEMCHECK_OR_BREAK_ALLOC_HOST(key_type, expected.size())
470474
std::vector<key_type> expected_key(expected.size());
475+
476+
MEMCHECK_OR_BREAK_ALLOC_HOST(value_type, expected.size())
471477
std::vector<value_type> expected_value(expected.size());
472478
for(size_t i = 0; i < expected.size(); i++)
473479
{
@@ -479,11 +485,13 @@ TYPED_TEST(RocprimDeviceSortTests, SortKeyValue)
479485

480486
{
481487
// Copy output to host. This is scoped so keys_output is freed immediately.
488+
MEMCHECK_OR_BREAK_ALLOC_HOST(key_type, size)
482489
const auto keys_output = d_keys_output.load();
483490
ASSERT_NO_FATAL_FAILURE(test_utils::assert_eq(keys_output, expected_key));
484491
}
485492
{
486493
// Copy output to host. This is scoped so values_output is freed immediately.
494+
MEMCHECK_OR_BREAK_ALLOC_HOST(value_type, size)
487495
const auto values_output = d_values_output.load();
488496
ASSERT_NO_FATAL_FAILURE(test_utils::assert_eq(values_output, expected_value));
489497
}

0 commit comments

Comments
 (0)