[RFC] Add KFD available memory ioctl thunk test
Daniel Phillips
daniel.phillips at amd.com
Tue Mar 22 17:33:43 UTC 2022
Hi all,
This patch adds at unit test to thunk for the new KFD memory availability
ioctl.
KFDMemoryTest.cpp | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
Regards,
Daniel
diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp
index f7ac73f..b23748b 100644
--- a/tests/kfdtest/src/KFDMemoryTest.cpp
+++ b/tests/kfdtest/src/KFDMemoryTest.cpp
@@ -595,6 +595,31 @@ 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};
+// memFlags.ui32.PageSize = HSA_PAGE_SIZE_4KB; // check if default
+// memFlags.ui32.HostAccess = 0;
+ memFlags.ui32.NonPaged = 1; // sys mem vs vram
+ m_MemoryFlags.ui32.NoNUMABind = 1;
+ HSAuint64 available;
+
+ EXPECT_SUCCESS(hsaKmtAvailableMemory(defaultGPUNode, &available));
+ fprintf(stderr, "=== available %x\n", available);
+ 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)
More information about the amd-gfx
mailing list