kfdtest: Replace pthread with std::thread (#1448)

* kfdtest: Replace pthread with std::thread

Modify concurrent kfdtest to use std::thread
instead of pthread, eventually modify KFDTestLaunch
to take in a member function of test instance
instead of static function.

Convert KFDQMTest to pass in member function for
multi-gpu kfdtest.

* kfdtest: Convert KFDPerfCountersTest to use std::thread

Convert KFDPerfCountersTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDGraphicsInterop to use std::thread

Convert KFDGraphicsInterop to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDGWSTest to use std::thread

Convert KFDGWSTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDCWSRTest to use std::thread

Convert KFDCWSRTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDEventTest to use std::thread

Convert KFDEventTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDExceptionTest to use std::thread

Convert KFDExceptionTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDLocalMemoryTest to use std::thread

Convert KFDLocalMemoryTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDMemoryTest to use std::thread

Convert KFDMemoryTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDSVMRangeTest to use std::thread

Convert KFDSVMRangeTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Convert KFDHWSTest to use std::thread

Convert KFDHWSTest to use std::thread for
multi-gpu kfdtest.

* kfdtest: Remove pthread multigpu test structure

Remove older multi-gpu test framework which
uses pthread.
This commit is contained in:
Alysa Liu
2025-12-02 10:25:21 -05:00
committed by GitHub
parent 81df45d896
commit 3a7b5571c0
24 changed files with 851 additions and 833 deletions
@@ -44,7 +44,7 @@ void KFDLocalMemoryTest::TearDown() {
ROUTINE_END
}
static void AccessLocalMem(KFDTEST_PARAMETERS* pTestParamters) {
void KFDLocalMemoryTest::AccessLocalMem(int gpuNode) {
/* Skip test if not on dGPU path, which the test depends on */
if (!hsakmt_is_dgpu()) {
@@ -52,8 +52,6 @@ static void AccessLocalMem(KFDTEST_PARAMETERS* pTestParamters) {
return;
}
int gpuNode = pTestParamters->gpuNode;
//local memory
HsaMemoryBuffer destBuf(PAGE_SIZE, gpuNode, false, true);
HsaEvent *event;
@@ -75,23 +73,22 @@ static void AccessLocalMem(KFDTEST_PARAMETERS* pTestParamters) {
TEST_F(KFDLocalMemoryTest, AccessLocalMem) {
TEST_START(TESTPROFILE_RUNALL)
ASSERT_SUCCESS(KFDTest_Launch(AccessLocalMem));
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->AccessLocalMem(gpuNode);
}));
TEST_END
}
static void BasicTest(KFDTEST_PARAMETERS* pTestParamters) {
void KFDLocalMemoryTest::BasicTest(int gpuNode) {
PM4Queue queue;
HSAuint64 AlternateVAGPU;
unsigned int BufferSize = PAGE_SIZE;
HsaMemMapFlags mapFlags = {0};
int gpuNode = pTestParamters->gpuNode;
KFDLocalMemoryTest* pKFDLocalMemoryTest = (KFDLocalMemoryTest*)pTestParamters->pTestObject;
Assembler* m_pAsm;
m_pAsm = pKFDLocalMemoryTest->GetAssemblerFromNodeId(gpuNode);
m_pAsm = GetAssemblerFromNodeId(gpuNode);
ASSERT_NOTNULL_GPU(m_pAsm, gpuNode);
HsaMemoryBuffer isaBuffer(PAGE_SIZE, gpuNode, true/*zero*/, false/*local*/, true/*exec*/);
@@ -138,23 +135,22 @@ TEST_F(KFDLocalMemoryTest, BasicTest) {
TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX);
TEST_START(TESTPROFILE_RUNALL);
ASSERT_SUCCESS(KFDTest_Launch(BasicTest));
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->BasicTest(gpuNode);
}));
TEST_END
}
static void VerifyContentsAfterUnmapAndMap(KFDTEST_PARAMETERS* pTestParamters)
void KFDLocalMemoryTest::VerifyContentsAfterUnmapAndMap(int gpuNode)
{
PM4Queue queue;
HSAuint64 AlternateVAGPU;
unsigned int BufferSize = PAGE_SIZE;
HsaMemMapFlags mapFlags = {0};
int gpuNode = pTestParamters->gpuNode;
KFDLocalMemoryTest* pKFDLocalMemoryTest = (KFDLocalMemoryTest*)pTestParamters->pTestObject;
Assembler* m_pAsm;
m_pAsm = pKFDLocalMemoryTest->GetAssemblerFromNodeId(gpuNode);
m_pAsm = GetAssemblerFromNodeId(gpuNode);
ASSERT_NOTNULL_GPU(m_pAsm, gpuNode);
HsaMemoryBuffer isaBuffer(PAGE_SIZE, gpuNode, true/*zero*/, false/*local*/, true/*exec*/);
@@ -197,7 +193,9 @@ TEST_F(KFDLocalMemoryTest, VerifyContentsAfterUnmapAndMap) {
TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX);
TEST_START(TESTPROFILE_RUNALL);
ASSERT_SUCCESS(KFDTest_Launch(VerifyContentsAfterUnmapAndMap));
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->VerifyContentsAfterUnmapAndMap(gpuNode);
}));
TEST_END
}
@@ -271,14 +269,11 @@ TEST_F(KFDLocalMemoryTest, VerifyContentsAfterUnmapAndMap) {
* 20 | 1M | 4G | 10G | 40G | 10
*/
static void Fragmentation(KFDTEST_PARAMETERS* pTestParamters){
int gpuNode = pTestParamters->gpuNode;
KFDLocalMemoryTest* pKFDLocalMemoryTest = (KFDLocalMemoryTest*)pTestParamters->pTestObject;
void KFDLocalMemoryTest::Fragmentation(int gpuNode){
HSAuint64 fbSize;
fbSize = pKFDLocalMemoryTest->GetVramSize(gpuNode);
fbSize = GetVramSize(gpuNode);
if (!fbSize) {
LOG() << "Skipping test: No VRAM found." << std::endl;
@@ -311,7 +306,7 @@ static void Fragmentation(KFDTEST_PARAMETERS* pTestParamters){
HsaMemoryBuffer isaBuffer(PAGE_SIZE, gpuNode, true/*zero*/, false/*local*/, true/*exec*/);
/* instantiate Assembler for gpuNode */
HsaNodeInfo* m_NodeInfo = pKFDLocalMemoryTest->Get_NodeInfo();
HsaNodeInfo* m_NodeInfo = Get_NodeInfo();
const HsaNodeProperties *nodeProperties = m_NodeInfo->GetNodeProperties(gpuNode);
Assembler* m_pAsm = new Assembler(GetGfxVersion(nodeProperties));
@@ -439,18 +434,17 @@ TEST_F(KFDLocalMemoryTest, DISABLED_Fragmentation) {
TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX);
TEST_START(TESTPROFILE_RUNALL);
ASSERT_SUCCESS(KFDTest_Launch(Fragmentation));
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->Fragmentation(gpuNode);
}));
TEST_END
}
static void CheckZeroInitializationVram(KFDTEST_PARAMETERS* pTestParamters){
int gpuNode = pTestParamters->gpuNode;
KFDLocalMemoryTest* pKFDLocalMemoryTest = (KFDLocalMemoryTest*)pTestParamters->pTestObject;
void KFDLocalMemoryTest::CheckZeroInitializationVram(int gpuNode){
/* Testing VRAM */
HSAuint64 vramSizeMB = pKFDLocalMemoryTest->GetVramSize(gpuNode) >> 20;
HSAuint64 vramSizeMB = GetVramSize(gpuNode) >> 20;
if (!vramSizeMB) {
LOG() << "Skipping test: No VRAM found." << std::endl;
@@ -501,7 +495,9 @@ TEST_F(KFDLocalMemoryTest, CheckZeroInitializationVram) {
TEST_REQUIRE_ENV_CAPABILITIES(ENVCAPS_64BITLINUX);
TEST_START(TESTPROFILE_RUNALL);
ASSERT_SUCCESS(KFDTest_Launch(CheckZeroInitializationVram));
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->CheckZeroInitializationVram(gpuNode);
}));
TEST_END
}