Add test for new hsaKmtAvailableMemory library call
PATCH 1/1 Add test for new hsaKmtAvailableMemory library call
Using DefaultGPUNode now instead of system memory, usage similar to other tests. Also cleaned up pSmall, which I originally intended to just let float away on the mistaken assumption that it would be cleaned up automatically at the end of the test.
Basic test for the new hsaKmtAvailableMemory library call. This is a standalone test, does not modify any of the other tests just to be on the safe side. More elaborate tests coming soon.
--- tests/kfdtest/src/KFDMemoryTest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/kfdtest/src/KFDMemoryTest.cpp +20 -0
@@ -595,6 +595,26 @@ TEST_F(KFDMemoryTest, MemoryAlloc) { TEST_END } +// Basic test for hsaKmtAllocMemory +TEST_F(KFDMemoryTest, MemoryAllocAll) { + TEST_START(TESTPROFILE_RUNALL) + + int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode(); + unsigned int* pBig = NULL; + unsigned int* pSmall = NULL; + m_MemoryFlags.ui32.NoNUMABind = 1; + HSAuint64 available; + + EXPECT_SUCCESS(hsaKmtAvailableMemory(defaultGPUNode, &available)); + EXPECT_SUCCESS(hsaKmtAllocMemory(defaultGPUNode, available, m_MemoryFlags, reinterpret_cast<void**>(&pBig))); + EXPECT_NE(HSAKMT_STATUS_SUCCESS, hsaKmtAllocMemory(defaultGPUNode, PAGE_SIZE, m_MemoryFlags, reinterpret_cast<void**>(&pSmall))); + EXPECT_SUCCESS(hsaKmtFreeMemory(pBig, available)); + EXPECT_SUCCESS(hsaKmtAllocMemory(defaultGPUNode, PAGE_SIZE, m_MemoryFlags, reinterpret_cast<void**>(&pSmall))); + EXPECT_SUCCESS(hsaKmtFreeMemory(pSmall, PAGE_SIZE)); + + TEST_END +} + TEST_F(KFDMemoryTest, AccessPPRMem) { TEST_START(TESTPROFILE_RUNALL)
Signature · 1 line
2.34.1
PATCH v2 1/1 Add test for new hsaKmtAvailableMemory library call
From: Daniel Phillips <[email protected]>
Using DefaultGPUNode now instead of system memory, usage similar to other tests. Also cleaned up pSmall, which I originally intended to just let float away on the mistaken assumption that it would be cleaned up automatically at the end of the test.
Basic test for the new hsaKmtAvailableMemory library call. This is a standalone test, does not modify any of the other tests just to be on the safe side. More elaborate tests coming soon.
v2:
* Change ioctl to IOWR
* Allocate non-paged memory to actually get VRAM
* Align available memory to page size as required by hsaKmtAllocMemory Still doesn't pass on Fiji. Available is actually larger than the physically free memory on this GPU with only 4GB of memory. Needs more refinement in KFD.
--- include/linux/kfd_ioctl.h | 2 +- tests/kfdtest/src/KFDMemoryTest.cpp | 24 ++++++++++++++++++++++++ tests/kfdtest/src/KFDTestUtil.hpp | 1 + 3 files changed, 26 insertions(+), 1 deletion(-)
include/linux/kfd_ioctl.h +1 -1
@@ -1252,7 +1252,7 @@ struct kfd_ioctl_set_xnack_mode_args { AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args)#define AMDKFD_IOC_AVAILABLE_MEMORY \ - AMDKFD_IOR(0x22, struct kfd_ioctl_get_available_memory_args) + AMDKFD_IOWR(0x22, struct kfd_ioctl_get_available_memory_args)#define AMDKFD_COMMAND_START 0x01#define AMDKFD_COMMAND_END 0x23
tests/kfdtest/src/KFDMemoryTest.cpp +24 -0
@@ -595,6 +595,30 @@ TEST_F(KFDMemoryTest, MemoryAlloc) { TEST_END } +// Basic test for hsaKmtAllocMemory +TEST_F(KFDMemoryTest, MemoryAllocAll) { + TEST_START(TESTPROFILE_RUNALL) + + int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode(); + unsigned int* pBig = NULL; + unsigned int* pSmall = NULL; + HsaMemFlags memFlags = {0}; + HSAuint64 available; + + memFlags.ui32.NonPaged = 1; + + EXPECT_SUCCESS(hsaKmtAvailableMemory(defaultGPUNode, &available)); + available = ALIGN_DOWN(available, PAGE_SIZE); + + EXPECT_SUCCESS(hsaKmtAllocMemory(defaultGPUNode, available, memFlags, reinterpret_cast<void**>(&pBig))); + EXPECT_NE(HSAKMT_STATUS_SUCCESS, hsaKmtAllocMemory(defaultGPUNode, PAGE_SIZE, memFlags, reinterpret_cast<void**>(&pSmall))); + EXPECT_SUCCESS(hsaKmtFreeMemory(pBig, available)); + EXPECT_SUCCESS(hsaKmtAllocMemory(defaultGPUNode, PAGE_SIZE, memFlags, reinterpret_cast<void**>(&pSmall))); + EXPECT_SUCCESS(hsaKmtFreeMemory(pSmall, PAGE_SIZE)); + + TEST_END +} + TEST_F(KFDMemoryTest, AccessPPRMem) { TEST_START(TESTPROFILE_RUNALL)
tests/kfdtest/src/KFDTestUtil.hpp +1 -0
@@ -33,6 +33,7 @@ class BaseQueue; #define ARRAY_SIZE(_x) (sizeof(_x)/sizeof(_x[0])) #define ALIGN_UP(x, align) (((uint64_t)(x) + (align) - 1) & ~(uint64_t)((align)-1)) +#define ALIGN_DOWN(x, align) ((uint64_t)(x) & ~(uint64_t)((align)-1)) #define CounterToNanoSec(x) ((x) * 1000 / (is_dgpu() ? 27 : 100)) void WaitUntilInput();
Signature · 1 line
2.32.0