All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Add test for new hsaKmtAvailableMemory library call
@ 2022-01-11  2:14 Daniel Phillips
  2022-01-18  4:03 ` [PATCH v2 " Felix Kuehling
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Phillips @ 2022-01-11  2:14 UTC (permalink / raw)
  To: amd-gfx, dri-devel; +Cc: Daniel Phillips, Felix.Kuehling

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.

Signed-off-by: Daniel Phillips <daniel.phillips@amd.com>
Change-Id: I645006a89bd8d55ef7b1605611e8ef0c010dad1a
---
 tests/kfdtest/src/KFDMemoryTest.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp
index 9f62727..d9016de 100644
--- a/tests/kfdtest/src/KFDMemoryTest.cpp
+++ b/tests/kfdtest/src/KFDMemoryTest.cpp
@@ -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)
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v2 1/1] Add test for new hsaKmtAvailableMemory library call
  2022-01-11  2:14 [PATCH 1/1] Add test for new hsaKmtAvailableMemory library call Daniel Phillips
@ 2022-01-18  4:03 ` Felix Kuehling
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Kuehling @ 2022-01-18  4:03 UTC (permalink / raw)
  To: amd-gfx; +Cc: daniel.phillips

From: Daniel Phillips <daniel.phillips@amd.com>

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.

Signed-off-by: Daniel Phillips <daniel.phillips@amd.com>
Change-Id: I645006a89bd8d55ef7b1605611e8ef0c010dad1a
---
 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(-)

diff --git a/include/linux/kfd_ioctl.h b/include/linux/kfd_ioctl.h
index a81ae37..f9af830 100644
--- a/include/linux/kfd_ioctl.h
+++ b/include/linux/kfd_ioctl.h
@@ -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
diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp
index f7ac73f..b722ff8 100644
--- a/tests/kfdtest/src/KFDMemoryTest.cpp
+++ b/tests/kfdtest/src/KFDMemoryTest.cpp
@@ -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)
 
diff --git a/tests/kfdtest/src/KFDTestUtil.hpp b/tests/kfdtest/src/KFDTestUtil.hpp
index ee88ed3..420b7af 100644
--- a/tests/kfdtest/src/KFDTestUtil.hpp
+++ b/tests/kfdtest/src/KFDTestUtil.hpp
@@ -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();
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-18  4:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  2:14 [PATCH 1/1] Add test for new hsaKmtAvailableMemory library call Daniel Phillips
2022-01-18  4:03 ` [PATCH v2 " Felix Kuehling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.