diff --git a/libhsakmt/tests/kfdtest/src/KFDEvictTest.cpp b/libhsakmt/tests/kfdtest/src/KFDEvictTest.cpp index c8b290ce5a..ccd4ae9439 100644 --- a/libhsakmt/tests/kfdtest/src/KFDEvictTest.cpp +++ b/libhsakmt/tests/kfdtest/src/KFDEvictTest.cpp @@ -53,7 +53,7 @@ void KFDEvictTest::TearDown() { ROUTINE_END } -void KFDEvictTest::AllocBuffers(HSAuint32 defaultGPUNode, HSAuint32 count, HSAuint64 vramBufSize, +void KFDEvictTest::AllocBuffers(bool m_IsParent, HSAuint32 defaultGPUNode, HSAuint32 count, HSAuint64 vramBufSize, std::vector &pBuffers) { HSAuint64 totalMB; @@ -110,7 +110,7 @@ void KFDEvictTest::FreeBuffers(std::vector &pBuffers, HSAuint64 vramBufS } } -void KFDEvictTest::AllocAmdgpuBo(int rn, HSAuint64 vramBufSize, amdgpu_bo_handle &handle) { +void KFDEvictTest::AllocAmdgpuBo(bool m_IsParent, int rn, HSAuint64 vramBufSize, amdgpu_bo_handle &handle) { struct amdgpu_bo_alloc_request alloc; alloc.alloc_size = vramBufSize / N_PROCESSES; @@ -314,6 +314,7 @@ TEST_F(KFDEvictTest, BasicTest) { HSAuint64 vramSize = GetVramSize(defaultGPUNode); HSAuint64 sysMemSize = GetSysMemSize(); + int gpuIndex = m_NodeInfo.HsaGPUindexFromGpuNode(defaultGPUNode); const HsaNodeProperties *pNodeProperties = m_NodeInfo.HsaDefaultGPUNodeProperties(); if (!vramSize) { @@ -349,17 +350,17 @@ TEST_F(KFDEvictTest, BasicTest) { } std::vector pBuffers; - AllocBuffers(defaultGPUNode, count, vramBufSize, pBuffers); + AllocBuffers(m_IsParent[gpuIndex], defaultGPUNode, count, vramBufSize, pBuffers); /* Allocate gfx vram size of at most one third system memory */ HSAuint64 size = sysMemSize / 3 < testSize / 2 ? sysMemSize / 3 : testSize / 2; amdgpu_bo_handle handle; - AllocAmdgpuBo(rn, size, handle); + AllocAmdgpuBo(m_IsParent[gpuIndex], rn, size, handle); AmdgpuCommandSubmissionSdmaNop(rn, handle); FreeAmdgpuBo(handle); - LOG() << m_psName << "free buffer" << std::endl; + LOG() << m_psName[gpuIndex] << "free buffer" << std::endl; FreeBuffers(pBuffers, vramBufSize); WaitChildProcesses(defaultGPUNode); @@ -392,6 +393,7 @@ TEST_F(KFDEvictTest, QueueTest) { ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node"; unsigned int count = MAX_WAVEFRONTS; + int gpuIndex = m_NodeInfo.HsaGPUindexFromGpuNode(defaultGPUNode); const HsaNodeProperties *pNodeProperties = m_NodeInfo.HsaDefaultGPUNodeProperties(); /* Skip test for chip if it doesn't have CWSR, which the test depends on */ @@ -453,15 +455,15 @@ TEST_F(KFDEvictTest, QueueTest) { Dispatch dispatch0(isaBuffer); std::vector pBuffers; - AllocBuffers(defaultGPUNode, count, vramBufSize, pBuffers); + AllocBuffers(m_IsParent[gpuIndex], defaultGPUNode, count, vramBufSize, pBuffers); /* Allocate gfx vram size of at most one third system memory */ HSAuint64 size = sysMemSize / 3 < testSize / 2 ? sysMemSize / 3 : testSize / 2; amdgpu_bo_handle handle; - AllocAmdgpuBo(rn, size, handle); + AllocAmdgpuBo(m_IsParent[gpuIndex], rn, size, handle); unsigned int wavefront_num = pBuffers.size(); - LOG() << m_psName << "wavefront number " << wavefront_num << std::endl; + LOG() << m_psName[gpuIndex] << "wavefront number " << wavefront_num << std::endl; void **localBufAddr = addrBuffer.As(); unsigned int *result = resultBuffer.As(); @@ -521,6 +523,7 @@ TEST_F(KFDEvictTest, BurstyTest) { ASSERT_GE(defaultGPUNode, 0) << "failed to get default GPU Node"; HSAuint64 vramBufSize = ALLOCATE_BUF_SIZE_MB * 1024 * 1024; + int gpuIndex = m_NodeInfo.HsaGPUindexFromGpuNode(defaultGPUNode); const HsaNodeProperties *pNodeProperties = m_NodeInfo.HsaDefaultGPUNodeProperties(); if (pNodeProperties->Integrated) { @@ -562,17 +565,17 @@ TEST_F(KFDEvictTest, BurstyTest) { ASSERT_SUCCESS(pm4Queue.Create(defaultGPUNode)); std::vector pBuffers; - AllocBuffers(defaultGPUNode, count, vramBufSize, pBuffers); + AllocBuffers(m_IsParent[gpuIndex], defaultGPUNode, count, vramBufSize, pBuffers); /* Allocate gfx vram size of at most one third system memory */ HSAuint64 size = sysMemSize / 3 < testSize / 2 ? sysMemSize / 3 : testSize / 2; amdgpu_bo_handle handle; - AllocAmdgpuBo(rn, size, handle); + AllocAmdgpuBo(m_IsParent[gpuIndex], rn, size, handle); AmdgpuCommandSubmissionSdmaNop(rn, handle, &pm4Queue); FreeAmdgpuBo(handle); - LOG() << m_psName << "free buffer" << std::endl; + LOG() << m_psName[gpuIndex] << "free buffer" << std::endl; FreeBuffers(pBuffers, vramBufSize); EXPECT_SUCCESS(pm4Queue.Destroy()); diff --git a/libhsakmt/tests/kfdtest/src/KFDEvictTest.hpp b/libhsakmt/tests/kfdtest/src/KFDEvictTest.hpp index 30f0a856be..3fc404125b 100644 --- a/libhsakmt/tests/kfdtest/src/KFDEvictTest.hpp +++ b/libhsakmt/tests/kfdtest/src/KFDEvictTest.hpp @@ -40,10 +40,10 @@ class KFDEvictTest : public KFDMultiProcessTest { virtual void SetUp(); virtual void TearDown(); - void AllocBuffers(HSAuint32 defaultGPUNode, HSAuint32 count, HSAuint64 vramBufSize, + void AllocBuffers(bool m_IsParent, HSAuint32 defaultGPUNode, HSAuint32 count, HSAuint64 vramBufSize, std::vector &pBuffers); void FreeBuffers(std::vector &pBuffers, HSAuint64 vramBufSize); - void AllocAmdgpuBo(int rn, HSAuint64 vramBufSize, amdgpu_bo_handle &handle); + void AllocAmdgpuBo(bool m_IsParent, int rn, HSAuint64 vramBufSize, amdgpu_bo_handle &handle); void FreeAmdgpuBo(amdgpu_bo_handle handle); void AmdgpuCommandSubmissionSdmaNop(int rn, amdgpu_bo_handle handle, PM4Queue *computeQueue); diff --git a/libhsakmt/tests/kfdtest/src/KFDMultiProcessTest.hpp b/libhsakmt/tests/kfdtest/src/KFDMultiProcessTest.hpp index f4449b28a8..a3173d307e 100644 --- a/libhsakmt/tests/kfdtest/src/KFDMultiProcessTest.hpp +++ b/libhsakmt/tests/kfdtest/src/KFDMultiProcessTest.hpp @@ -28,21 +28,19 @@ #include #include "KFDBaseComponentTest.hpp" -extern unsigned int g_TestGPUsNum; - // @class KFDMultiProcessTest // Base class for tests forking multiple child processes class KFDMultiProcessTest : public KFDBaseComponentTest { public: KFDMultiProcessTest(void) { - for ( int i = 0; i < g_TestGPUsNum; i++) { + for ( int i = 0; i < MAX_GPU; i++) { m_ChildStatus[i] = HSAKMT_STATUS_ERROR; m_IsParent[i] = true; } } ~KFDMultiProcessTest(void) { - for ( int i = 0; i < g_TestGPUsNum; i++) { + for (int i = 0; i < MAX_GPU; i++) { if (!m_IsParent[i]) { /* Child process has to exit * otherwise gtest will continue other tests @@ -53,9 +51,9 @@ class KFDMultiProcessTest : public KFDBaseComponentTest { try { const std::vector gpuNodes = m_NodeInfo.GetNodesWithGPU(); - unsigned gpu_num = gpuNodes.size(); int gpu_node; - for (int i = 0; i < g_TestGPUsNum; i++) { + /* parent porcess waits all its child processes on each gpu */ + for (int i = 0; i < std::min((int)gpuNodes.size(), MAX_GPU); i++) { gpu_node = gpuNodes.at(i); WaitChildProcesses(gpu_node); }