From b6cefa7bda45325e84a2249750705ed4f384b893 Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Tue, 4 Jun 2019 15:36:42 -0400 Subject: [PATCH] kfdtest: Split BigBufferStressTest into two smaller tests The previous BigBufferStressTest has too much stuff and takes a long time to run. By separating largest*BufferTest out into other tests, we dramatically reduce the time to run BigBufferStressTest and therefore make reproducing issues much easier. Meanwhile, rename the test to BigSysBufferStressTest to express more information. Change-Id: I5911f113c0bd50627ee6d84bbb4f2972cbed8886 Signed-off-by: Yong Zhao --- tests/kfdtest/scripts/kfdtest.exclude | 5 +- tests/kfdtest/src/KFDMemoryTest.cpp | 69 ++++++++++++++++++++------- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/tests/kfdtest/scripts/kfdtest.exclude b/tests/kfdtest/scripts/kfdtest.exclude index 4d1b3b34e4..590cd3aa2b 100644 --- a/tests/kfdtest/scripts/kfdtest.exclude +++ b/tests/kfdtest/scripts/kfdtest.exclude @@ -110,12 +110,13 @@ FILTER[kaveri]=\ "KFDQMTest.CpuWriteCoherence" # KFDLocalMemoryTest.BasicTest is failing intermittently (KFD-368) -# KFDMemoryTest.BigBufferStressTest was failing intermittently on 4.9 and hangs when executed twice (KFD-312) +# KFDMemoryTest.BigSysBufferStressTest was failing intermittently on 4.9 +# and hangs when executed twice (KFD-312) # KFDQMTest.GPUDoorbellWrite fails on Hawaii. Could be HW-related (KFD-342) FILTER[hawaii]=\ "$BLACKLIST_ALL_ASICS:"\ "KFDLocalMemoryTest.BasicTest:"\ -"KFDMemoryTest.BigBufferStressTest:"\ +"KFDMemoryTest.BigSysBufferStressTest:"\ "KFDQMTest.GPUDoorbellWrite" FILTER[carrizo]=\ diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp index 05a3dbb318..9be43aa53f 100644 --- a/tests/kfdtest/src/KFDMemoryTest.cpp +++ b/tests/kfdtest/src/KFDMemoryTest.cpp @@ -862,20 +862,61 @@ void KFDMemoryTest::BigBufferVRAM(int defaultGPUNode, HSAuint64 granularityMB, << vramSizeMB * 15 / 16 << "MB" << std::endl; } -/* BigBufferStressTest allocs, maps/unmaps, and frees the biggest possible system - * buffers. Its size is found using binary search in the range (0, RAM SIZE) with - * a granularity of 128M. Repeat the similar logic on local buffers (VRAM). - * Finally, it allocs and maps 128M system buffers in a loop until it - * fails, then unmaps and frees them afterwards. - * Please note we limit the biggest possible system buffer to be smaller than +/* + * Largest*BufferTest allocates, maps/unmaps, and frees the largest possible + * buffers. Its size is found using binary search in the range + * (0, RAM SIZE) with a granularity of 128M. Also, the similar logic is + * repeated on local buffers (VRAM). + * Please note we limit the largest possible system buffer to be smaller than * the RAM size. The reason is that the system buffer can make use of virtual * memory so that a system buffer could be very large even though the RAM size - * is small. For example, on a typical Carrizo platform, the biggest allocated + * is small. For example, on a typical Carrizo platform, the largest allocated * system buffer could be more than 14G even though it only has 4G memory. - * In that situation, it will take too much time to finish the test, because of + * In that situation, it will take too much time to finish the test because of * the onerous memory swap operation. So we limit the buffer size that way. */ -TEST_F(KFDMemoryTest, BigBufferStressTest) { +TEST_F(KFDMemoryTest, LargestSysBufferTest) { + if (!is_dgpu()) { + LOG() << "Skipping test: Running on APU fails and locks the system." << std::endl; + return; + } + TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX); + TEST_START(TESTPROFILE_RUNALL); + + HSAuint64 granularityMB = 128; + + int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode(); + ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node"; + + BigBufferSystemMemory(defaultGPUNode, granularityMB, NULL); + + TEST_END +} + +TEST_F(KFDMemoryTest, LargestVramBufferTest) { + if (!is_dgpu()) { + LOG() << "Skipping test: Running on APU fails and locks the system." << std::endl; + return; + } + TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX); + TEST_START(TESTPROFILE_RUNALL); + + HSAuint64 granularityMB = 128; + + int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode(); + ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node"; + + BigBufferVRAM(defaultGPUNode, granularityMB, NULL); + + TEST_END +} + +/* + * BigSysBufferStressTest allocates and maps 128M system buffers in a loop until it + * fails, then unmaps and frees them afterwards. Meanwhile, a queue task is + * performed on each buffer. + */ +TEST_F(KFDMemoryTest, BigSysBufferStressTest) { if (!is_dgpu()) { LOG() << "Skipping test: Running on APU fails and locks the system." << std::endl; return; @@ -887,15 +928,9 @@ TEST_F(KFDMemoryTest, BigBufferStressTest) { HsaMemMapFlags mapFlags = {0}; int ret; - HSAuint64 granularityMB = 128; - int defaultGPUNode = m_NodeInfo.HsaDefaultGPUNode(); ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node"; - BigBufferSystemMemory(defaultGPUNode, granularityMB, NULL); - - BigBufferVRAM(defaultGPUNode, granularityMB, NULL); - /* Repeatedly allocate and map big buffers in system memory until it fails, * then unmap and free them. */ @@ -923,8 +958,8 @@ TEST_F(KFDMemoryTest, BigBufferStressTest) { } } - LOG() << "Allocated system buffers time " << std::dec << repeat << ": " << i << "x" - << block_size_mb << "MB" << std::endl; + LOG() << "Allocated system buffers time " << std::dec << repeat << ": " + << i << " * " << block_size_mb << "MB" << std::endl; if (allocationCount == 0) allocationCount = i;