From a69a3946c9bf7ce6cfc92362d8e9fcecd9bfe2ac Mon Sep 17 00:00:00 2001 From: Mengbing Wang Date: Fri, 26 Mar 2021 17:28:11 +0800 Subject: [PATCH] Add allocation size limit of 1/2 vram size in rocrtstPerf.Memory_Async_Copy test. Add the hard limit of allocation size to be 1/2 available vram to avoid allocation failure when allocation size equals to vram size. Add printing block size in each round to report progress for long running test Add the block size skip info in result form(if any tests skipped). Affected test: rocrtstPerf.Memory_Async_Copy Data Size Avg Time(us) Avg BW(GB/s) MinTime(us) Peak BW(GB/s) 128M 638759.570200 0.195692 637569.991000 0.196057 256M 1270058.822400 0.196841 1268425.758000 0.197095 Notice: Data Size larger than 512M is skipped due to hard limit of 1/2 vram size Signed-off-by: Mengbing Wang Change-Id: I4c4cea74a608272cc29d222b9399af26b34d7473 [ROCm/ROCR-Runtime commit: cf10c3bc350dcad8ef55174ca271389189038a97] --- .../suites/performance/memory_async_copy.cc | 56 +++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc index 8f929a860d..4f6c1123c7 100755 --- a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc +++ b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc @@ -227,24 +227,42 @@ void MemoryAsyncCopy::RunBenchmarkWithVerification(Transaction *t) { hsa_status_t err; void* ptr_src; void* ptr_dst; + size_t src_alloc_size; + size_t dst_alloc_size; + size_t max_alloc_size; + size_t size; - size_t size = t->max_size * 1024; + + size_t max_trans_size = t->max_size * 1024; hsa_amd_memory_pool_t src_pool = pool_info_[t->src]->pool_; hsa_agent_t dst_agent = pool_info_[t->dst]->owner_agent_info()->agent(); hsa_amd_memory_pool_t dst_pool = pool_info_[t->dst]->pool_; - hsa_agent_t src_agent = pool_info_[t->src]->owner_agent_info()->agent(); PrintTransactionType(t); - err = hsa_amd_memory_pool_allocate(src_pool, size, 0, &ptr_src); + err = hsa_amd_memory_pool_get_info(src_pool, HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE, + &src_alloc_size); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + + err = hsa_amd_memory_pool_get_info(dst_pool, HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE, + &dst_alloc_size); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + + max_alloc_size = (src_alloc_size < dst_alloc_size) ? src_alloc_size: dst_alloc_size; + + size = (max_alloc_size/2 <= max_trans_size) ? max_alloc_size/2: max_trans_size; + + err = hsa_amd_memory_pool_allocate(src_pool, size, 0, + &ptr_src); ASSERT_EQ(HSA_STATUS_SUCCESS, err); err = hsa_amd_memory_pool_allocate(dst_pool, size, 0, - &ptr_dst); + &ptr_dst); ASSERT_EQ(HSA_STATUS_SUCCESS, err); + // rocrtst::CommonCleanUp data void* host_ptr_src = NULL; void* host_ptr_dst = NULL; @@ -320,8 +338,10 @@ void MemoryAsyncCopy::RunBenchmarkWithVerification(Transaction *t) { for (int i = 0; i < kNumGranularity; i++) { if (Size[i] > size) { + printf("Skip test with block size %s\n", Str[i]); break; } + printf("Start test with block size %s\n",Str[i]); std::vector time; @@ -426,7 +446,28 @@ void MemoryAsyncCopy::DisplayResults(void) const { } void MemoryAsyncCopy::DisplayBenchmark(Transaction *t) const { - size_t size = t->max_size * 1024; + hsa_status_t err; + size_t src_alloc_size; + size_t dst_alloc_size; + size_t max_alloc_size; + size_t size; + + size_t max_trans_size = t->max_size * 1024; + hsa_amd_memory_pool_t src_pool = pool_info_[t->src]->pool_; + hsa_amd_memory_pool_t dst_pool = pool_info_[t->dst]->pool_; + + err = hsa_amd_memory_pool_get_info(src_pool, HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE, + &src_alloc_size); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + + err = hsa_amd_memory_pool_get_info(dst_pool, HSA_AMD_MEMORY_POOL_INFO_ALLOC_MAX_SIZE, + &dst_alloc_size); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + + max_alloc_size = (src_alloc_size < dst_alloc_size) ? src_alloc_size: dst_alloc_size; + + size = (max_alloc_size/2 <= max_trans_size) ? max_alloc_size/2: max_trans_size; + printf("=========================== PATH: From Pool %d To Pool %d (", t->src, t->dst); @@ -478,7 +519,12 @@ void MemoryAsyncCopy::DisplayBenchmark(Transaction *t) const { " Min Time(us) Peak BW(GB/s)\n"); for (int i = 0; i < kNumGranularity; i++) { + if (Size[i] > size) { + printf( + "Notice: Data Size >= %s is skipped due to hard limit of 1/2 vram size \n\n", + Str[i] + ); break; }