kfdtest: fix a regession on KFDEvictTest test case

The kfdtest multi-gpu extension only allows using the first gpu(in topology
order) as default gpu for KFDEvictTest test case. We should allow user
to select any gpu in system as default gpu to run KFDEvictTest test case.

Signed-off-by: Xiaogang Chen<Xiaogang.Chen@amd.com>
Change-Id: I8848771d92ae2812fbb96e917454ab3b4a71a2fa
此提交包含在:
Xiaogang Chen
2024-12-18 10:13:54 -06:00
父節點 699d0140be
當前提交 eafa929520
共有 3 個檔案被更改,包括 20 行新增19 行删除
+14 -11
查看文件
@@ -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<void *> &pBuffers) {
HSAuint64 totalMB;
@@ -110,7 +110,7 @@ void KFDEvictTest::FreeBuffers(std::vector<void *> &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<void *> 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<void *> 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<void **>();
unsigned int *result = resultBuffer.As<uint32_t *>();
@@ -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<void *> 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());
+2 -2
查看文件
@@ -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<void *> &pBuffers);
void FreeBuffers(std::vector<void *> &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);
+4 -6
查看文件
@@ -28,21 +28,19 @@
#include <vector>
#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<int> 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);
}