diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp index b4cb37a5a6..5ee8537f37 100644 --- a/tests/kfdtest/src/KFDMemoryTest.cpp +++ b/tests/kfdtest/src/KFDMemoryTest.cpp @@ -39,6 +39,9 @@ #include "SDMAPacket.hpp" #include "linux/kfd_ioctl.h" +/* Captures user specified time (seconds) to sleep */ +extern unsigned int g_SleepTime; + void KFDMemoryTest::SetUp() { ROUTINE_START @@ -93,6 +96,15 @@ TEST_F(KFDMemoryTest, MMapLarge) { int i = 0; /* Allocate 1024GB, aka 1TB*/ for (; i < nObjects; i++) { + + /* Code snippet to allow CRIU checkpointing */ + if (i == (1 << 6)) { + if (g_SleepTime > 0) { + LOG() << "Pause for: " << g_SleepTime << " seconds" << std::endl; + sleep(g_SleepTime); + } + } + if (hsaKmtRegisterMemory(addr + i, s - i)) break; if (hsaKmtMapMemoryToGPUNodes(addr + i, s - i, @@ -633,6 +645,7 @@ void KFDMemoryTest::BinarySearchLargestBuffer(int allocNode, const HsaMemFlags & HSAuint64 highMB, int nodeToMap, HSAuint64 *lastSizeMB) { int ret; + int iter = 0; HsaMemMapFlags mapFlags = {0}; HSAuint64 granularityMB = highMB > 512 ? 128 : 16; @@ -656,6 +669,15 @@ void KFDMemoryTest::BinarySearchLargestBuffer(int allocNode, const HsaMemFlags & continue; } + /* Code snippet to allow CRIU checkpointing */ + iter++; + if (iter == 3) { + if (g_SleepTime > 0) { + LOG() << "Pause for: " << g_SleepTime << " seconds" << std::endl; + sleep(g_SleepTime); + } + } + ret = hsaKmtMapMemoryToGPUNodes(pDb, size, NULL, mapFlags, 1, reinterpret_cast(&nodeToMap)); if (ret) { @@ -908,6 +930,14 @@ TEST_F(KFDMemoryTest, MMBench) { HSAuint64 allocTime, map1Time, unmap1Time, mapAllTime, unmapAllTime, freeTime; HSAuint32 allocNode; + /* Code snippet to allow CRIU checkpointing */ + if (testIndex == 3) { + if (g_SleepTime > 0) { + LOG() << "Pause for: " << g_SleepTime << " seconds" << std::endl; + sleep(g_SleepTime); + } + } + if ((testIndex % nSizes) == 0) LOG() << "--------------------------------------------------------------------------" << std::endl; diff --git a/tests/kfdtest/src/KFDTestMain.cpp b/tests/kfdtest/src/KFDTestMain.cpp index 2b33ac153d..59c0dc806f 100644 --- a/tests/kfdtest/src/KFDTestMain.cpp +++ b/tests/kfdtest/src/KFDTestMain.cpp @@ -53,6 +53,7 @@ unsigned int g_TestTimeOut; int g_TestNodeId; int g_TestDstNodeId; bool g_IsChildProcess; +unsigned int g_SleepTime; unsigned int g_TestGPUFamilyId; class KFDBaseComponentTest *g_baseTest; @@ -80,12 +81,20 @@ GTEST_API_ int main(int argc, char **argv) { if ( args.TimeOut > 0 ) g_TestTimeOut = args.TimeOut; + g_SleepTime = 0x00; + if (args.SleepTime > 0) { + g_SleepTime = args.SleepTime; + } + // If --node is not specified, then args.NodeId == -1 g_TestNodeId = args.NodeId; g_TestDstNodeId = args.DstNodeId; LOG() << "Profile: " << (TESTPROFILE)g_TestRunProfile << std::endl; LOG() << "HW capabilities: 0x" << std::hex << g_TestENVCaps << std::endl; + if (g_SleepTime > 0) { + LOG() << "Sleep time in seconds as specified by user: " << std::dec << g_SleepTime << std::endl; + } return RUN_ALL_TESTS(); } diff --git a/tests/kfdtest/src/LinuxOSWrapper.cpp b/tests/kfdtest/src/LinuxOSWrapper.cpp index f5308249bf..b8855061d5 100644 --- a/tests/kfdtest/src/LinuxOSWrapper.cpp +++ b/tests/kfdtest/src/LinuxOSWrapper.cpp @@ -109,6 +109,7 @@ void ComandLineArgumentsUsage() { printf("\t--child arg\t - Child Process\n"); printf("\t--timeout arg\t - Time Out\n"); printf("\t--dst_node\t - For testing multiple nodes"); + printf("\t--sleep_time\t - For testing CRIU, etc"); } bool GetCommandLineArguments(int argc, char **argv, CommandLineArguments& rArgs) { @@ -123,6 +124,7 @@ bool GetCommandLineArguments(int argc, char **argv, CommandLineArguments& rArgs) { "timeout", required_argument, 0, 0}, { "node", required_argument, 0, 0 }, { "dst_node", required_argument, 0, 0 }, + { "sleep_time", required_argument, 0, 0 }, { 0, 0, 0, 0 } }; @@ -132,6 +134,7 @@ bool GetCommandLineArguments(int argc, char **argv, CommandLineArguments& rArgs) rArgs.TimeOut = 0; rArgs.NodeId = -1; rArgs.DstNodeId = -1; + rArgs.SleepTime = 0; while (true) { int c = getopt_long(argc, argv, "", long_options, &option_index); @@ -200,6 +203,14 @@ bool GetCommandLineArguments(int argc, char **argv, CommandLineArguments& rArgs) rArgs.DstNodeId = dstNodeId; } break; + /* Sleep time - used in testing CRIU */ + case 6: + { + int sleepTime = atoi(optarg); + if (sleepTime >= 0) + rArgs.SleepTime = sleepTime; + } + break; } } diff --git a/tests/kfdtest/src/OSWrapper.hpp b/tests/kfdtest/src/OSWrapper.hpp index 4ded18e0e0..d7d69b7f73 100644 --- a/tests/kfdtest/src/OSWrapper.hpp +++ b/tests/kfdtest/src/OSWrapper.hpp @@ -64,6 +64,8 @@ struct CommandLineArguments { unsigned int TimeOut; int NodeId; int DstNodeId; + /* Time in units of seconds */ + unsigned int SleepTime; }; // It is either MEM_NONE or the bitwise OR of one or more of the following flags