Files
rocm-systems/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDGWSTest.cpp
T

忽略 .git-blame-ignore-revs 中的修訂。點擊 這裡 以繞過並查看正常的 Blame 視圖。

130 行
4.0 KiB
C++
原始文件 標準檢視 歷史記錄

2019-06-04 14:38:42 -05:00
/*
* 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) {
2019-06-04 14:38:42 -05:00
HSAuint32 firstGWS;
PM4Queue queue;
HsaNodeInfo* m_NodeInfo = Get_NodeInfo();
const HsaNodeProperties *pNodeProperties = m_NodeInfo->GetNodeProperties(gpuNode);
2019-06-04 14:38:42 -05:00
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);
}));
2019-06-04 14:38:42 -05:00
TEST_END
}
void KFDGWSTest::Semaphore(int gpuNode) {
HsaNodeInfo* m_NodeInfo = Get_NodeInfo();
const HsaNodeProperties *pNodeProperties = m_NodeInfo->GetNodeProperties(gpuNode);
2019-06-04 14:38:42 -05:00
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);
2019-06-04 14:38:42 -05:00
Assembler* m_pAsm;
m_pAsm = GetAssemblerFromNodeId(gpuNode);
ASSERT_NOTNULL_GPU(m_pAsm, gpuNode);
ASSERT_SUCCESS_GPU(m_pAsm->RunAssembleBuf(GwsInitIsa, isaBuffer.As<char*>()), gpuNode);
2021-09-24 18:47:58 -04:00
2019-06-04 14:38:42 -05:00
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);
2019-06-04 14:38:42 -05:00
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);
}));
2019-06-04 14:38:42 -05:00
TEST_END
}