Files
rocm-systems/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDGWSTest.cpp
T
Alysa Liu 3a7b5571c0 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.
2025-12-02 10:25:21 -05:00

130 wiersze
4.0 KiB
C++

/*
* Copyright (C) 2014-2019 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "KFDGWSTest.hpp"
#include "PM4Queue.hpp"
#include "PM4Packet.hpp"
#include "Dispatch.hpp"
void KFDGWSTest::SetUp() {
ROUTINE_START
KFDBaseComponentTest::SetUp();
ROUTINE_END
}
void KFDGWSTest::TearDown() {
ROUTINE_START
KFDBaseComponentTest::TearDown();
ROUTINE_END
}
void KFDGWSTest::Allocate(int gpuNode) {
HSAuint32 firstGWS;
PM4Queue queue;
HsaNodeInfo* m_NodeInfo = Get_NodeInfo();
const HsaNodeProperties *pNodeProperties = m_NodeInfo->GetNodeProperties(gpuNode);
if (!pNodeProperties || !pNodeProperties->NumGws) {
LOG() << "Skip test: GPU node doesn't support GWS" << std::endl;
return;
}
ASSERT_SUCCESS_GPU(queue.Create(gpuNode), gpuNode);
ASSERT_SUCCESS_GPU(hsaKmtAllocQueueGWS(queue.GetResource()->QueueId,
pNodeProperties->NumGws,&firstGWS), gpuNode);
EXPECT_EQ_GPU(0, firstGWS, gpuNode);
EXPECT_SUCCESS_GPU(queue.Destroy(), gpuNode);
}
TEST_F(KFDGWSTest, Allocate) {
TEST_START(TESTPROFILE_RUNALL);
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->Allocate(gpuNode);
}));
TEST_END
}
void KFDGWSTest::Semaphore(int gpuNode) {
HsaNodeInfo* m_NodeInfo = Get_NodeInfo();
const HsaNodeProperties *pNodeProperties = m_NodeInfo->GetNodeProperties(gpuNode);
HSAuint32 firstGWS;
HSAuint32 numResources = 1;
PM4Queue queue;
if (!pNodeProperties || !pNodeProperties->NumGws) {
LOG() << "Skip test: GPU node doesn't support GWS" << std::endl;
return;
}
HsaMemoryBuffer isaBuffer(PAGE_SIZE, gpuNode, true/*zero*/, false/*local*/, true/*exec*/);
HsaMemoryBuffer buffer(PAGE_SIZE, gpuNode, true, false, false);
ASSERT_SUCCESS(queue.Create(gpuNode));
ASSERT_SUCCESS_GPU(hsaKmtAllocQueueGWS(queue.GetResource()->QueueId,
pNodeProperties->NumGws,&firstGWS), gpuNode);
EXPECT_EQ_GPU(0, firstGWS, gpuNode);
Assembler* m_pAsm;
m_pAsm = GetAssemblerFromNodeId(gpuNode);
ASSERT_NOTNULL_GPU(m_pAsm, gpuNode);
ASSERT_SUCCESS_GPU(m_pAsm->RunAssembleBuf(GwsInitIsa, isaBuffer.As<char*>()), gpuNode);
Dispatch dispatch0(isaBuffer);
buffer.Fill(numResources, 0, 4);
dispatch0.SetArgs(buffer.As<void*>(), NULL);
dispatch0.Submit(queue);
dispatch0.Sync();
ASSERT_SUCCESS_GPU(m_pAsm->RunAssembleBuf(GwsAtomicIncreaseIsa, isaBuffer.As<char*>()),gpuNode);
Dispatch dispatch(isaBuffer);
dispatch.SetArgs(buffer.As<void*>(), NULL);
dispatch.SetDim(1024, 16, 16);
dispatch.Submit(queue);
dispatch.Sync();
EXPECT_EQ_GPU(1024*16*16+1, *buffer.As<uint32_t *>(), gpuNode);
EXPECT_SUCCESS_GPU(queue.Destroy(),gpuNode);
}
TEST_F(KFDGWSTest, Semaphore) {
TEST_START(TESTPROFILE_RUNALL);
ASSERT_SUCCESS(KFDTestLaunch([this](int gpuNode) {
this->Semaphore(gpuNode);
}));
TEST_END
}