Skip to contentSkip to conversation

Add test for hsaKmtAvailableMemory available memory inquiry

PATCH In review Daniel Phillips 2 participants 2 messages Jan 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add test for hsaKmtAvailableMemory available memory inquiry

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.

Change-Id I738600d4b74cc5dba6b857e4c793f6b14b7d2283
---
 tests/kfdtest/src/KFDMemoryTest.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
tests/kfdtest/src/KFDMemoryTest.cpp +17 -0
index 9f62727..1f93928 100644
@@ -595,6 +595,23 @@ TEST_F(KFDMemoryTest, MemoryAlloc) {
     TEST_END
 }
 
+// Basic test for hsaKmtAllocMemory
+TEST_F(KFDMemoryTest, MemoryAllocAll) {
+    TEST_START(TESTPROFILE_RUNALL)
+
+    unsigned int* pBig = NULL;
+    unsigned int* pSmall = NULL;
+    m_MemoryFlags.ui32.NoNUMABind = 1;
+    HSAuint64 available;
+    EXPECT_SUCCESS(hsaKmtAvailableMemory(0 /* system */, &available));
+    EXPECT_SUCCESS(hsaKmtAllocMemory(0 /* system */, available, m_MemoryFlags, reinterpret_cast<void**>(&pBig)));
+    EXPECT_NE(HSAKMT_STATUS_SUCCESS, hsaKmtAllocMemory(0 /* system */, PAGE_SIZE, m_MemoryFlags, reinterpret_cast<void**>(&pSmall)));
+    EXPECT_SUCCESS(hsaKmtFreeMemory(pBig, available));
+    EXPECT_SUCCESS(hsaKmtAllocMemory(0 /* system */, PAGE_SIZE, m_MemoryFlags, reinterpret_cast<void**>(&pSmall)));
+
+    TEST_END
+}
+
 TEST_F(KFDMemoryTest, AccessPPRMem) {
     TEST_START(TESTPROFILE_RUNALL)
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 17 lines · Daniel Phillips

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.

Change-Id I738600d4b74cc5dba6b857e4c793f6b14b7d2283
---
  tests/kfdtest/src/KFDMemoryTest.cpp | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
tests/kfdtest/src/KFDMemoryTest.cpp +0 -0
index 9f62727..1f93928 100644
@@ -595,6 +595,23 @@ TEST_F(KFDMemoryTest, MemoryAlloc) {
      TEST_END
  }

tests/kfdtest/src/KFDMemoryTest.cpp TEST_F(KFDMemoryTest, MemoryAlloc) { · line 606

Quoted 10 lines
tests/kfdtest/src/KFDMemoryTest.cpp +9 -0
 
+// Basic test for hsaKmtAllocMemory
+TEST_F(KFDMemoryTest, MemoryAllocAll) {
+    TEST_START(TESTPROFILE_RUNALL)
+
+    unsigned int* pBig = NULL;
+    unsigned int* pSmall = NULL;
+    m_MemoryFlags.ui32.NoNUMABind = 1;
+    HSAuint64 available;
+    EXPECT_SUCCESS(hsaKmtAvailableMemory(0 /* system */, &available));

I don't think you've even implemented this API for system memory. The system memory node doesn't have a valid GPUID, so the ioctl will fail.

I'd expect this test to work only for VRAM.

tests/kfdtest/src/KFDMemoryTest.cpp TEST_F(KFDMemoryTest, MemoryAlloc) { · line 610

Quoted 4 lines
tests/kfdtest/src/KFDMemoryTest.cpp +4 -0
+    EXPECT_SUCCESS(hsaKmtAllocMemory(0 /* system */, available, m_MemoryFlags, reinterpret_cast<void**>(&pBig)));
+    EXPECT_NE(HSAKMT_STATUS_SUCCESS, hsaKmtAllocMemory(0 /* system */, PAGE_SIZE, m_MemoryFlags, reinterpret_cast<void**>(&pSmall)));
+    EXPECT_SUCCESS(hsaKmtFreeMemory(pBig, available));
+    EXPECT_SUCCESS(hsaKmtAllocMemory(0 /* system */, PAGE_SIZE, m_MemoryFlags, reinterpret_cast<void**>(&pSmall)));

You're leaking pSmall here.

Regards,
  Felix

Quoted 7 lines
tests/kfdtest/src/KFDMemoryTest.cpp +4 -0
+
+    TEST_END
+}
+
  TEST_F(KFDMemoryTest, AccessPPRMem) {
      TEST_START(TESTPROFILE_RUNALL)