From 663b461512f94ad11d12072681415ab0fc2d06ab Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 23 Oct 2023 17:14:51 +0000 Subject: [PATCH] rocrtst: Speed-up Memory_Max_Mem test Skip Extended-scope memory pool as allocation is very close to fine-grain/coarse-grain but with just different PTE flags. Only test coarse grain on CPU agent other than the first CPU agent. Stop bisecting the max size once we are withing 5% to total size for these pool to speed this test on large memory pools. Change-Id: I77d1b45a1752ef092dda7c7f27723ea0a292a612 [ROCm/ROCR-Runtime commit: cb5a29955baf950948e5ab92f2082098e33c6d97] --- .../rocrtst/suites/functional/memory_basic.cc | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc b/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc index 37aafca575..eba05118fb 100755 --- a/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc +++ b/projects/rocr-runtime/rocrtst/suites/functional/memory_basic.cc @@ -163,6 +163,10 @@ void MemoryTest::MaxSingleAllocationTest(hsa_agent_t ag, err = hsa_agent_get_info(ag, HSA_AGENT_INFO_DEVICE, &ag_type); ASSERT_EQ(err, HSA_STATUS_SUCCESS); + uint32_t node_id; + err = hsa_agent_get_info(ag, HSA_AGENT_INFO_NODE, &node_id); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + if (verbosity() > 0) { std::cout << " Agent: " << ag_name << " ("; switch (ag_type) { @@ -186,14 +190,27 @@ void MemoryTest::MaxSingleAllocationTest(hsa_agent_t ag, rocrtst::DumpMemoryPoolInfo(&pool_i, 2); } - if (!pool_i.alloc_allowed || pool_i.alloc_granule == 0 || - pool_i.alloc_alignment == 0) { + if (!pool_i.alloc_allowed || pool_i.alloc_granule == 0 || pool_i.alloc_alignment == 0 || + (pool_i.global_flag & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_EXTENDED_SCOPE_FINE_GRAINED) + ) { if (verbosity() > 0) { std::cout << " Test not applicable. Skipping." << std::endl; std::cout << kSubTestSeparator << std::endl; } return; } + + // To speed-up test, test all pools on CPU-0, only test coare-grained on remaining CPU agents + if (ag_type == HSA_DEVICE_TYPE_CPU && node_id > 0 && + !(pool_i.global_flag & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED)) { + + if (verbosity() > 0) { + std::cout << " Test not applicable. Skipping." << std::endl; + std::cout << kSubTestSeparator << std::endl; + } + return; + } + // Do everything in "granule" units auto gran_sz = pool_i.alloc_granule; auto pool_sz = pool_i.aggregate_alloc_max / gran_sz; @@ -206,10 +223,12 @@ void MemoryTest::MaxSingleAllocationTest(hsa_agent_t ag, uint64_t upper_bound = pool_sz; uint64_t lower_bound = 0; + /* Stop bisecting once we have reached size diff within 5 % of total */ + size_t alloc_size_delta = max_alloc_size * 0.05; + while (true) { err = TestAllocate(pool, max_alloc_size * gran_sz); - ASSERT_TRUE(err == HSA_STATUS_SUCCESS || - err == HSA_STATUS_ERROR_OUT_OF_RESOURCES); + ASSERT_TRUE(err == HSA_STATUS_SUCCESS || err == HSA_STATUS_ERROR_OUT_OF_RESOURCES); if (err == HSA_STATUS_SUCCESS) { lower_bound = max_alloc_size; max_alloc_size += (upper_bound - lower_bound)/2; @@ -218,7 +237,7 @@ void MemoryTest::MaxSingleAllocationTest(hsa_agent_t ag, max_alloc_size -= (upper_bound - lower_bound)/2; } - if ((upper_bound - lower_bound) < 2) { + if ((upper_bound - lower_bound) < alloc_size_delta) { break; } ASSERT_GT(upper_bound, lower_bound);