From a7b0f541b7ea42ed0a820fbbae9ef200ed11a583 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 27 Aug 2024 20:42:46 +0000 Subject: [PATCH] rocrtst: Skip inaccessible agents when importing dmabuf If some agents cannot access the memory buffer directly, this will cause the hsa_amd_interop_map_buffer API call to fail Change-Id: If2f0e1735c2926440d657831de50775d7f304c8e [ROCm/ROCR-Runtime commit: 2360253b3b3ff3951e728081e7d0c40e8adf8cbf] --- .../rocrtst/suites/functional/memory_allocation.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/rocrtst/suites/functional/memory_allocation.cc b/projects/rocr-runtime/rocrtst/suites/functional/memory_allocation.cc index a842a78d2c..a2a69f58d0 100644 --- a/projects/rocr-runtime/rocrtst/suites/functional/memory_allocation.cc +++ b/projects/rocr-runtime/rocrtst/suites/functional/memory_allocation.cc @@ -522,10 +522,18 @@ void MemoryAllocationTest::MemoryAllocateContiguousTest(hsa_agent_t agent, uint64_t offset; ASSERT_SUCCESS(hsa_amd_portable_export_dmabuf(memoryPtr, alloc_size, &dmabuf, &offset)); + std::vector accessible_gpus; + for (auto gpuIter: gpus) { + hsa_amd_memory_pool_access_t access = HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED; + ASSERT_SUCCESS(hsa_amd_agent_memory_pool_get_info(gpuIter, pool, HSA_AMD_AGENT_MEMORY_POOL_INFO_ACCESS, &access)); + if (access != HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED) + accessible_gpus.push_back(gpuIter); + } + void* importedPtr; size_t importedSz; - ASSERT_SUCCESS(hsa_amd_interop_map_buffer(gpus.size(), gpus.data(), dmabuf, 0, &importedSz, + ASSERT_SUCCESS(hsa_amd_interop_map_buffer(accessible_gpus.size(), accessible_gpus.data(), dmabuf, 0, &importedSz, &importedPtr, 0, NULL)); ASSERT_NE((uint64_t)importedPtr, 0);