refactor: stop using DEFAULT_TEST_FAMILY_NAME

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-09-26 13:13:07 +00:00
committed by Compute-Runtime-Automation
parent aaa9342141
commit 39f10f9c5e
7 changed files with 138 additions and 137 deletions

View File

@@ -772,12 +772,12 @@ HWTEST_P(CommandQueueIndirectHeapTest, WhenAskedForNewHeapThenOldHeapIsStoredFor
*commandStreamReceiver.getTagAddress() = 2u;
}
TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithoutHeapAllocationWhenAskedForNewHeapThenNewAllocationIsAcquiredWithoutStoring) {
HWTEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithoutHeapAllocationWhenAskedForNewHeapThenNewAllocationIsAcquiredWithoutStoring) {
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
MockCommandQueue cmdQ(context.get(), pClDevice, props, false);
auto memoryManager = pDevice->getMemoryManager();
auto &csr = pDevice->getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_TRUE(pDevice->getDefaultEngine().commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
const auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), 100);
@@ -807,7 +807,7 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWithResourceCachingActiveW
EXPECT_TRUE(pDevice->getDefaultEngine().commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
}
TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapAllocatedWhenIndirectHeapIsReleasedThenHeapAllocationAndHeapBufferIsSetToNullptr) {
HWTEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapAllocatedWhenIndirectHeapIsReleasedThenHeapAllocationAndHeapBufferIsSetToNullptr) {
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
MockCommandQueue cmdQ(context.get(), pClDevice, props, false);
@@ -822,7 +822,7 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapAllocatedWhenIndir
EXPECT_NE(nullptr, graphicsAllocation);
cmdQ.releaseIndirectHeap(this->GetParam());
auto &csr = pDevice->getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(nullptr, csr.indirectHeap[this->GetParam()]->getGraphicsAllocation());
@@ -830,17 +830,17 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapAllocatedWhenIndir
EXPECT_EQ(0u, indirectHeap.getMaxAvailableSpace());
}
TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithoutHeapAllocatedWhenIndirectHeapIsReleasedThenIndirectHeapAllocationStaysNull) {
HWTEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithoutHeapAllocatedWhenIndirectHeapIsReleasedThenIndirectHeapAllocationStaysNull) {
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
MockCommandQueue cmdQ(context.get(), pClDevice, props, false);
cmdQ.releaseIndirectHeap(this->GetParam());
auto &csr = pDevice->getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(nullptr, csr.indirectHeap[this->GetParam()]);
}
TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapWhenGraphicAllocationIsNullThenNothingOnReuseList) {
HWTEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapWhenGraphicAllocationIsNullThenNothingOnReuseList) {
DebugManagerStateRestore restorer;
debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.set(0);
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
@@ -849,7 +849,7 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapWhenGraphicAllocat
auto &ih = cmdQ.getIndirectHeap(this->GetParam(), 0u);
auto allocation = ih.getGraphicsAllocation();
EXPECT_NE(nullptr, allocation);
auto &csr = pDevice->getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
csr.indirectHeap[this->GetParam()]->replaceGraphicsAllocation(nullptr);
csr.indirectHeap[this->GetParam()]->replaceBuffer(nullptr, 0);

View File

@@ -1424,7 +1424,7 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampsPacketContainerWithOneEleme
ev->timeStampNode = nullptr;
}
TEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCalcProfilingDataIsCalledThenCorrectedValuesAreReturned) {
HWTEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCalcProfilingDataIsCalledThenCorrectedValuesAreReturned) {
uint32_t globalStart[16] = {0};
uint32_t globalEnd[16] = {0};
uint32_t contextStart[16] = {0};
@@ -1432,7 +1432,7 @@ TEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCal
initTimestampNodeMultiOsContextData(globalStart, globalEnd, 16u);
addTimestampNodeMultiOsContext(globalStart, globalEnd, contextStart, contextEnd, 16u);
auto &device = reinterpret_cast<MockDevice &>(cmdQ->getDevice());
auto &csr = device.getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = device.getUltCommandStreamReceiver<FamilyType>();
csr.multiOsContextCapable = true;
ev->calcProfilingData();
@@ -1440,7 +1440,7 @@ TEST_F(ProfilingTimestampPacketsTest, givenMultiOsContextCapableSetToTrueWhenCal
EXPECT_EQ(350u, ev->endTimeStamp.gpuTimeStamp);
}
TEST_F(ProfilingTimestampPacketsTest, givenTimestampPacketWithoutProfilingDataWhenCalculatingThenDontUseThatPacket) {
HWTEST_F(ProfilingTimestampPacketsTest, givenTimestampPacketWithoutProfilingDataWhenCalculatingThenDontUseThatPacket) {
uint32_t globalStart0 = 20;
uint32_t globalEnd0 = 51;
uint32_t contextStart0 = 21;
@@ -1454,7 +1454,7 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampPacketWithoutProfilingDataWh
addTimestampNodeMultiOsContext(&globalStart0, &globalEnd0, &contextStart0, &contextEnd0, 1);
addTimestampNodeMultiOsContext(&globalStart1, &globalEnd1, &contextStart1, &contextEnd1, 1);
auto &device = reinterpret_cast<MockDevice &>(cmdQ->getDevice());
auto &csr = device.getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = device.getUltCommandStreamReceiver<FamilyType>();
csr.multiOsContextCapable = true;
ev->timestampPacketContainer->peekNodes()[1]->setProfilingCapable(false);
@@ -1464,14 +1464,14 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampPacketWithoutProfilingDataWh
EXPECT_EQ(static_cast<uint64_t>(globalEnd0), ev->endTimeStamp.gpuTimeStamp);
}
TEST_F(ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCalcProfilingDataThenTimeStampsArePrinted) {
HWTEST_F(ProfilingTimestampPacketsTest, givenPrintTimestampPacketContentsSetWhenCalcProfilingDataThenTimeStampsArePrinted) {
DebugManagerStateRestore restorer;
debugManager.flags.PrintTimestampPacketContents.set(true);
StreamCapture capture;
capture.captureStdout();
auto &device = reinterpret_cast<MockDevice &>(cmdQ->getDevice());
auto &csr = device.getUltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>();
auto &csr = device.getUltCommandStreamReceiver<FamilyType>();
csr.multiOsContextCapable = true;
uint32_t globalStart[16] = {0};

View File

@@ -289,23 +289,3 @@ if(DEFAULT_TESTED_PLATFORM)
else()
set(NEO_SKIP_UNIT_TESTS TRUE)
endif()
if(NOT DEFAULT_TESTED_FAMILY_NAME)
if(DEFINED PREFERRED_FAMILY_NAME)
list(FIND ALL_TESTED_FAMILY_NAME ${PREFERRED_FAMILY_NAME} CORE_IDX)
if(${CORE_IDX} GREATER -1)
set(DEFAULT_TESTED_FAMILY_NAME ${PREFERRED_FAMILY_NAME})
endif()
endif()
if(NOT DEFINED DEFAULT_TESTED_FAMILY_NAME)
foreach(CORE_TYPE ${ALL_CORE_TYPES_REVERSED})
FIND_IDX_FOR_CORE_TYPE(${CORE_TYPE} CORE_IDX)
list(GET ALL_TESTED_FAMILY_NAME ${CORE_IDX} CORE_FAMILY_NAME)
if(NOT CORE_FAMILY_NAME STREQUAL " ")
set(DEFAULT_TESTED_FAMILY_NAME ${CORE_FAMILY_NAME})
break()
endif()
endforeach()
endif()
endif()
message(STATUS "Default tested family name: ${DEFAULT_TESTED_FAMILY_NAME}")

View File

@@ -18,7 +18,7 @@ function(generate_shared_lib LIB_NAME MOCKABLE)
${CORE_SOURCES}
)
if(${MOCKABLE})
target_compile_definitions(${LIB_NAME} PUBLIC MOCKABLE_VIRTUAL=virtual MOCKABLE= DEFAULT_TEST_PLATFORM=${DEFAULT_TESTED_PLATFORM} DEFAULT_TEST_FAMILY_NAME=${DEFAULT_TESTED_FAMILY_NAME} ${TESTED_CORE_FLAGS_DEFINITONS})
target_compile_definitions(${LIB_NAME} PUBLIC MOCKABLE_VIRTUAL=virtual MOCKABLE= DEFAULT_TEST_PLATFORM=${DEFAULT_TESTED_PLATFORM} ${TESTED_CORE_FLAGS_DEFINITONS})
else()
target_compile_definitions(${LIB_NAME} PUBLIC MOCKABLE_VIRTUAL=)
endif()

View File

@@ -34,27 +34,24 @@
using namespace NEO;
struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
MyMockCsr(ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield)
: UltCommandStreamReceiver(executionEnvironment, rootDeviceIndex, deviceBitfield) {
}
template <typename GfxFamily>
struct MyMockCsr : UltCommandStreamReceiver<GfxFamily> {
using UltCommandStreamReceiver<GfxFamily>::UltCommandStreamReceiver;
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
flushParametrization.wasCalled = true;
flushParametrization.receivedBatchBuffer = &batchBuffer;
flushParametrization.receivedEngine = osContext->getEngineType();
flushParametrization.receivedEngine = this->osContext->getEngineType();
flushParametrization.receivedAllocationsForResidency = &allocationsForResidency;
processResidency(allocationsForResidency, 0u);
flushStamp->setStamp(flushParametrization.flushStampToReturn);
this->flushStamp->setStamp(flushParametrization.flushStampToReturn);
return SubmissionStatus::success;
}
void makeResident(GraphicsAllocation &gfxAllocation) override {
makeResidentParameterization.wasCalled = true;
makeResidentParameterization.receivedGfxAllocation = &gfxAllocation;
gfxAllocation.updateResidencyTaskCount(1, osContext->getContextId());
gfxAllocation.updateResidencyTaskCount(1, this->osContext->getContextId());
}
SubmissionStatus processResidency(ResidencyContainer &allocationsForResidency, uint32_t handleId) override {
@@ -124,22 +121,23 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
} expectMemoryParameterization;
};
template <typename BaseCSR>
template <typename GfxFamily, typename BaseCSR>
struct MyMockCsrWithAubDump : CommandStreamReceiverWithAUBDump<BaseCSR> {
MyMockCsrWithAubDump(bool createAubCSR,
ExecutionEnvironment &executionEnvironment,
const DeviceBitfield deviceBitfield)
: CommandStreamReceiverWithAUBDump<BaseCSR>("aubfile", executionEnvironment, 0, deviceBitfield) {
this->aubCSR.reset(createAubCSR ? new MyMockCsr(executionEnvironment, 0, deviceBitfield) : nullptr);
this->aubCSR.reset(createAubCSR ? new MyMockCsr<GfxFamily>(executionEnvironment, 0, deviceBitfield) : nullptr);
}
MyMockCsr &getAubMockCsr() const {
return static_cast<MyMockCsr &>(*this->aubCSR);
MyMockCsr<GfxFamily> &getAubMockCsr() const {
return static_cast<MyMockCsr<GfxFamily> &>(*this->aubCSR);
}
};
struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bool /*createAubCSR*/>, MockAubCenterFixture, DeviceFixture {
void SetUp() override {
template <typename GfxFamily>
void setUpT() {
DeviceFixture::setUp();
MockAubCenterFixture::setUp();
setMockAubCenter(pDevice->getRootDeviceEnvironmentRef());
@@ -149,27 +147,32 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bo
ASSERT_NE(nullptr, memoryManager);
createAubCSR = GetParam();
DeviceBitfield deviceBitfield(1);
csrWithAubDump = new MyMockCsrWithAubDump<MyMockCsr>(createAubCSR, *executionEnvironment, deviceBitfield);
csrWithAubDump = new MyMockCsrWithAubDump<GfxFamily, MyMockCsr<GfxFamily>>(createAubCSR, *executionEnvironment, deviceBitfield);
ASSERT_NE(nullptr, csrWithAubDump);
auto engineDescriptor = EngineDescriptorHelper::getDefaultDescriptor({getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo), EngineUsage::regular},
PreemptionHelper::getDefaultPreemptionMode(DEFAULT_TEST_PLATFORM::hwInfo));
pDevice->getExecutionEnvironment()->memoryManager->reInitLatestContextId();
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csrWithAubDump, engineDescriptor);
csrWithAubDump->setupContext(*osContext);
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(getCsrWithAubDump<GfxFamily>(), engineDescriptor);
getCsrWithAubDump<GfxFamily>()->setupContext(*osContext);
}
void TearDown() override {
template <typename GfxFamily>
void tearDownT() {
delete csrWithAubDump;
MockAubCenterFixture::tearDown();
DeviceFixture::tearDown();
}
template <typename GfxFamily>
MyMockCsrWithAubDump<GfxFamily, MyMockCsr<GfxFamily>> *getCsrWithAubDump() const {
return static_cast<MyMockCsrWithAubDump<GfxFamily, MyMockCsr<GfxFamily>> *>(csrWithAubDump);
}
ExecutionEnvironment *executionEnvironment;
MyMockCsrWithAubDump<MyMockCsr> *csrWithAubDump;
MemoryManager *memoryManager;
bool createAubCSR;
ExecutionEnvironment *executionEnvironment = nullptr;
CommandStreamReceiver *csrWithAubDump = nullptr;
MemoryManager *memoryManager = nullptr;
bool createAubCSR{};
};
struct CommandStreamReceiverWithAubDumpSimpleTest : Test<MockAubCenterFixture>, DeviceFixture {
@@ -302,11 +305,13 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenPoll
EXPECT_TRUE(mockAubCsr->pollForCompletionCalled);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenExpectMemoryIsCalledThenBothCommandStreamReceiversAreCalled) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenExpectMemoryIsCalledThenBothCommandStreamReceiversAreCalled) {
uint32_t compareOperation = AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual;
uint8_t buffer[0x10000]{};
size_t length = sizeof(buffer);
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), false, length}, buffer);
ASSERT_NE(nullptr, gfxAllocation);
@@ -330,9 +335,10 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenWriteMemoryIsCalledThenBothCommandStreamReceiversAreCalled) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenWriteMemoryIsCalledThenBothCommandStreamReceiversAreCalled) {
MockGraphicsAllocation mockAllocation;
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
EXPECT_EQ(0u, csrWithAubDump->writeMemoryParams.totalCallCount);
if (createAubCSR) {
EXPECT_EQ(0u, csrWithAubDump->getAubMockCsr().writeMemoryParams.totalCallCount);
@@ -541,7 +547,8 @@ HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenAubManagerNotAvailable
ASSERT_NE(nullptr, csrWithAubDump.aubCSR);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCtorIsCalledThenAubCsrIsInitialized) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCtorIsCalledThenAubCsrIsInitialized) {
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
if (createAubCSR) {
EXPECT_NE(nullptr, csrWithAubDump->aubCSR);
} else {
@@ -549,7 +556,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
}
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenBaseCsrFlushStampIsReturned) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenBaseCsrFlushStampIsReturned) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -558,6 +565,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
auto engineType = csrWithAubDump->getOsContext().getEngineType();
ResidencyContainer allocationsForResidency;
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
csrWithAubDump->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(csrWithAubDump->obtainCurrentFlushStamp(), csrWithAubDump->flushParametrization.flushStampToReturn);
@@ -576,10 +584,11 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
memoryManager->freeGraphicsMemoryImpl(commandBuffer);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeResidentIsCalledThenBaseCsrMakeResidentIsCalled) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeResidentIsCalledThenBaseCsrMakeResidentIsCalled) {
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, gfxAllocation);
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
csrWithAubDump->makeResident(*gfxAllocation);
EXPECT_TRUE(csrWithAubDump->makeResidentParameterization.wasCalled);
@@ -593,7 +602,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenBothBaseAndAubCsrProcessResidencyIsCalled) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenBothBaseAndAubCsrProcessResidencyIsCalled) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -603,6 +612,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
ASSERT_NE(nullptr, gfxAllocation);
ResidencyContainer allocationsForResidency = {gfxAllocation};
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
csrWithAubDump->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(csrWithAubDump->obtainCurrentFlushStamp(), csrWithAubDump->flushParametrization.flushStampToReturn);
@@ -618,7 +628,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
memoryManager->freeGraphicsMemoryImpl(commandBuffer);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenLatestSentTaskCountShouldBeUpdatedForAubCsr) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenLatestSentTaskCountShouldBeUpdatedForAubCsr) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -626,6 +636,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
ResidencyContainer allocationsForResidency;
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
EXPECT_EQ(0u, csrWithAubDump->peekLatestSentTaskCount());
if (createAubCSR) {
EXPECT_EQ(0u, csrWithAubDump->getAubMockCsr().peekLatestSentTaskCount());
@@ -643,9 +654,10 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
memoryManager->freeGraphicsMemoryImpl(commandBuffer);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeNonResidentIsCalledThenBothBaseAndAubCsrMakeNonResidentIsCalled) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeNonResidentIsCalledThenBothBaseAndAubCsrMakeNonResidentIsCalled) {
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, gfxAllocation);
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
csrWithAubDump->makeResident(*gfxAllocation);
csrWithAubDump->makeNonResident(*gfxAllocation);
@@ -662,8 +674,9 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCheckAndActivateAubSubCaptureIsCalledThenBaseCsrCommandStreamReceiverIsCalled) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCheckAndActivateAubSubCaptureIsCalledThenBaseCsrCommandStreamReceiverIsCalled) {
std::string kernelName = "";
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
csrWithAubDump->checkAndActivateAubSubCapture(kernelName);
EXPECT_TRUE(csrWithAubDump->checkAndActivateAubSubCaptureParameterization.wasCalled);
@@ -675,18 +688,15 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
}
}
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCreateMemoryManagerIsCalledThenItIsUsedByBothBaseAndAubCsr) {
HWTEST_TEMPLATED_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCreateMemoryManagerIsCalledThenItIsUsedByBothBaseAndAubCsr) {
auto csrWithAubDump = getCsrWithAubDump<FamilyType>();
EXPECT_EQ(memoryManager, csrWithAubDump->getMemoryManager());
if (createAubCSR) {
EXPECT_EQ(memoryManager, csrWithAubDump->aubCSR->getMemoryManager());
}
}
static bool createAubCSR[] = {
false,
true};
INSTANTIATE_TEST_SUITE_P(
CommandStreamReceiverWithAubDumpTest_Create,
,
CommandStreamReceiverWithAubDumpTest,
testing::ValuesIn(createAubCSR));
testing::Bool());

View File

@@ -2648,7 +2648,7 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreate
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferObjectWhenTheyAreMadeResidentThenOnlyOneBoIsPassedToExec) {
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(device->getDefaultEngine().commandStreamReceiver);
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver);
mock->ioctlExpected.primeFdToHandle = 2;
mock->ioctlExpected.gemClose = 1;
mock->ioctlExpected.gemWait = 2;
@@ -2674,7 +2674,7 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareThe
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBufferObjectWhenTheyAreMadeResidentThenTwoBoIsPassedToExec) {
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(device->getDefaultEngine().commandStreamReceiver);
auto testedCsr = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver);
mock->ioctlExpected.primeFdToHandle = 2;
mock->ioctlExpected.gemClose = 2;
mock->ioctlExpected.gemWait = 2;
@@ -9299,4 +9299,4 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, given2MBAlignmentRequiredWhenUnalignedS
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(6 * MemoryConstants::megaByte, allocation->getReservedAddressSize());
memoryManager->freeGraphicsMemory(allocation);
}
}

View File

@@ -43,13 +43,14 @@ using namespace ::testing;
class WddmCommandStreamFixture {
public:
std::unique_ptr<MockDevice> device;
DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr;
CommandStreamReceiver *csr;
MockWddmMemoryManager *memoryManager = nullptr;
WddmMock *wddm = nullptr;
DebugManagerStateRestore stateRestore;
void setUp() {
template <typename GfxFamily>
void setUpT() {
HardwareInfo *hwInfo = nullptr;
debugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::immediateDispatch));
debugManager.flags.SetAmountOfReusableAllocations.set(0);
@@ -61,12 +62,13 @@ class WddmCommandStreamFixture {
device.reset(MockDevice::create<MockDevice>(executionEnvironment, 0u));
ASSERT_NE(nullptr, device);
csr = new WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment, 0, device->getDeviceBitfield());
csr = new WddmCommandStreamReceiver<GfxFamily>(*executionEnvironment, 0, device->getDeviceBitfield());
device->resetCommandStreamReceiver(csr);
csr->getOsContext().ensureContextInitialized(false);
}
void tearDown() {
template <typename GfxFamily>
void tearDownT() {
}
};
@@ -173,7 +175,7 @@ class WddmCommandStreamMockGdiTest : public ::testing::Test {
}
};
using WddmCommandStreamTest = ::Test<WddmCommandStreamFixture>;
struct WddmCommandStreamTest : ::testing::Test, WddmCommandStreamFixture {};
using WddmDefaultTest = ::Test<DeviceFixture>;
struct DeviceCommandStreamTest : ::Test<MockAubCenterFixture>, DeviceFixture {
void SetUp() override {
@@ -187,33 +189,33 @@ struct DeviceCommandStreamTest : ::Test<MockAubCenterFixture>, DeviceFixture {
}
};
TEST_F(DeviceCommandStreamTest, WhenCreatingWddmCsrThenWddmPointerIsSetCorrectly) {
HWTEST_F(DeviceCommandStreamTest, WhenCreatingWddmCsrThenWddmPointerIsSetCorrectly) {
ExecutionEnvironment *executionEnvironment = pDevice->getExecutionEnvironment();
auto wddm = Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get());
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
executionEnvironment->initializeMemoryManager();
std::unique_ptr<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> csr(static_cast<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>::create(false, *executionEnvironment, 0, 1)));
std::unique_ptr<WddmCommandStreamReceiver<FamilyType>> csr(static_cast<WddmCommandStreamReceiver<FamilyType> *>(WddmCommandStreamReceiver<FamilyType>::create(false, *executionEnvironment, 0, 1)));
EXPECT_NE(nullptr, csr);
auto wddmFromCsr = csr->peekWddm();
EXPECT_NE(nullptr, wddmFromCsr);
}
TEST_F(DeviceCommandStreamTest, WhenCreatingWddmCsrWithAubDumpThenAubCsrIsCreated) {
HWTEST_F(DeviceCommandStreamTest, WhenCreatingWddmCsrWithAubDumpThenAubCsrIsCreated) {
ExecutionEnvironment *executionEnvironment = pDevice->getExecutionEnvironment();
auto wddm = Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get());
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(wddm));
executionEnvironment->initializeMemoryManager();
std::unique_ptr<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> csr(static_cast<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>::create(true, *executionEnvironment, 0, 1)));
std::unique_ptr<WddmCommandStreamReceiver<FamilyType>> csr(static_cast<WddmCommandStreamReceiver<FamilyType> *>(WddmCommandStreamReceiver<FamilyType>::create(true, *executionEnvironment, 0, 1)));
EXPECT_NE(nullptr, csr);
auto wddmFromCsr = csr->peekWddm();
EXPECT_NE(nullptr, wddmFromCsr);
auto aubCSR = static_cast<CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> *>(csr.get())->aubCSR.get();
auto aubCSR = static_cast<CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<FamilyType>> *>(csr.get())->aubCSR.get();
EXPECT_NE(nullptr, aubCSR);
}
TEST_F(WddmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedMonitoredFence) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedMonitoredFence) {
uint64_t stampToWait = 123;
wddm->waitFromCpuResult.called = 0u;
csr->waitForFlushStamp(stampToWait);
@@ -222,7 +224,7 @@ TEST_F(WddmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedM
EXPECT_EQ(stampToWait, wddm->waitFromCpuResult.uint64ParamPassed);
}
TEST_F(WddmCommandStreamTest, WhenFlushingThenFlushIsSubmitted) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenFlushingThenFlushIsSubmitted) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -236,7 +238,7 @@ TEST_F(WddmCommandStreamTest, WhenFlushingThenFlushIsSubmitted) {
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPrintIndices) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPrintIndices) {
DebugManagerStateRestore restorer;
debugManager.flags.PrintDeviceAndEngineIdOnSubmission.set(true);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
@@ -263,7 +265,7 @@ TEST_F(WddmCommandStreamTest, givenPrintIndicesEnabledWhenFlushThenPrintIndices)
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThenCpuAddressWhenSubmitIsCalledThenGpuAddressIsUsed) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThenCpuAddressWhenSubmitIsCalledThenGpuAddressIsUsed) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
auto cpuAddress = commandBuffer->getUnderlyingBuffer();
@@ -277,7 +279,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, GivenOffsetWhenFlushingThenFlushIsSubmittedCorrectly) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, GivenOffsetWhenFlushingThenFlushIsSubmittedCorrectly) {
auto offset = 128u;
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize, mockDeviceBitfield});
ASSERT_NE(nullptr, commandBuffer);
@@ -293,7 +295,7 @@ TEST_F(WddmCommandStreamTest, GivenOffsetWhenFlushingThenFlushIsSubmittedCorrect
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFlagIsSetToFalse) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFlagIsSetToFalse) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -309,7 +311,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenFailureFromMakeResidentWhenFlushingThenOutOfMemoryIsReturned) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenFailureFromMakeResidentWhenFlushingThenOutOfMemoryIsReturned) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -343,12 +345,12 @@ struct WddmPreemptionHeaderFixture {
using WddmPreemptionHeaderTests = ::Test<WddmPreemptionHeaderFixture>;
TEST_F(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOffWhenWorkloadIsSubmittedThenHeaderDoesntHavePreemptionFieldSet) {
HWTEST_F(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOffWhenWorkloadIsSubmittedThenHeaderDoesntHavePreemptionFieldSet) {
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo);
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto csr = std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(*executionEnvironment, 0, 1);
auto csr = std::make_unique<MockWddmCsr<FamilyType>>(*executionEnvironment, 0, 1);
executionEnvironment->memoryManager.reset(new MemoryManagerCreate<WddmMemoryManager>(false, false, *executionEnvironment));
csr->overrideDispatchPolicy(DispatchMode::immediateDispatch);
@@ -370,12 +372,12 @@ TEST_F(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIs
executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) {
HWTEST_F(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) {
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo);
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto csr = std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(*executionEnvironment, 0, 1);
auto csr = std::make_unique<MockWddmCsr<FamilyType>>(*executionEnvironment, 0, 1);
executionEnvironment->memoryManager.reset(new MemoryManagerCreate<WddmMemoryManager>(false, false, *executionEnvironment));
csr->overrideDispatchPolicy(DispatchMode::immediateDispatch);
@@ -398,29 +400,29 @@ TEST_F(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIs
executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) {
HWTEST_F(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) {
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo);
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto commandStreamReceiver = std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(*executionEnvironment, 0, 1);
auto commandStreamReceiver = std::make_unique<MockWddmCsr<FamilyType>>(*executionEnvironment, 0, 1);
auto commandHeader = commandStreamReceiver->commandBufferHeader;
auto header = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
EXPECT_TRUE(header->NeedsMidBatchPreEmptionSupport);
}
TEST_F(WddmPreemptionHeaderTests, givenDevicenotSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderPreemptionFieldIsNotSet) {
HWTEST_F(WddmPreemptionHeaderTests, givenDevicenotSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderPreemptionFieldIsNotSet) {
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo);
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto commandStreamReceiver = std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(*executionEnvironment, 0, 1);
auto commandStreamReceiver = std::make_unique<MockWddmCsr<FamilyType>>(*executionEnvironment, 0, 1);
auto commandHeader = commandStreamReceiver->commandBufferHeader;
auto header = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
EXPECT_FALSE(header->NeedsMidBatchPreEmptionSupport);
}
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledWhenEUCountWouldBeOddThenRequestEvenEuCount) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledWhenEUCountWouldBeOddThenRequestEvenEuCount) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -442,7 +444,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledWhenEUCountWouldBeOddTh
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenSetHeaderFieldsProperly) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenSetHeaderFieldsProperly) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -461,7 +463,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenS
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumThenSetHeaderFieldsProperly) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumThenSetHeaderFieldsProperly) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -479,7 +481,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumTh
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThenSetHeaderFieldsProperly) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThenSetHeaderFieldsProperly) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -498,7 +500,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThen
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, WhenMakingResidentThenAllocationIsCorrectlySet) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenMakingResidentThenAllocationIsCorrectlySet) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -513,7 +515,7 @@ TEST_F(WddmCommandStreamTest, WhenMakingResidentThenAllocationIsCorrectlySet) {
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, WhenMakingNonResidentThenAllocationIsPlacedInEvictionAllocations) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenMakingNonResidentThenAllocationIsPlacedInEvictionAllocations) {
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@@ -534,7 +536,7 @@ TEST_F(WddmCommandStreamTest, WhenMakingNonResidentThenAllocationIsPlacedInEvict
memoryManager->freeGraphicsMemory(commandBuffer);
}
TEST_F(WddmCommandStreamTest, WhenProcesssingEvictionThenEvictionAllocationsListIsNotCleared) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenProcesssingEvictionThenEvictionAllocationsListIsNotCleared) {
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, allocation);
@@ -549,7 +551,7 @@ TEST_F(WddmCommandStreamTest, WhenProcesssingEvictionThenEvictionAllocationsList
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(WddmCommandStreamTest, WhenMakingResidentAndNonResidentThenAllocationIsMovedCorrectly) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenMakingResidentAndNonResidentThenAllocationIsMovedCorrectly) {
GraphicsAllocation *gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(gfxAllocation, nullptr);
@@ -566,7 +568,7 @@ TEST_F(WddmCommandStreamTest, WhenMakingResidentAndNonResidentThenAllocationIsMo
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocationIsInResidencyContainer) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocationIsInResidencyContainer) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
@@ -585,7 +587,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWhenMakeResidentThenAllocat
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenHostPtrAllocationWhenMapFailsThenFragmentsAreClearedAndNullptrIsReturned) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenHostPtrAllocationWhenMapFailsThenFragmentsAreClearedAndNullptrIsReturned) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
@@ -604,7 +606,7 @@ TEST_F(WddmCommandStreamTest, givenHostPtrAllocationWhenMapFailsThenFragmentsAre
EXPECT_EQ(nullptr, gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenAddressWithHighestBitSetWhenItIsMappedThenProperAddressIsPassed) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenAddressWithHighestBitSetWhenItIsMappedThenProperAddressIsPassed) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
@@ -625,7 +627,7 @@ TEST_F(WddmCommandStreamTest, givenAddressWithHighestBitSetWhenItIsMappedThenPro
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAllocationAndMakeResident) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAllocationAndMakeResident) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
@@ -647,7 +649,7 @@ TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAlloc
memoryManager->freeGraphicsMemory(gfxAllocation);
}
TEST_F(WddmCommandStreamTest, givenTwoTemporaryAllocationsWhenCleanTemporaryAllocationListThenDestoryOnlyCompletedAllocations) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenTwoTemporaryAllocationsWhenCleanTemporaryAllocationListThenDestoryOnlyCompletedAllocations) {
if (memoryManager->isLimitedGPU(0)) {
GTEST_SKIP();
}
@@ -1259,7 +1261,7 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnB
mockCsr->blitterDirectSubmission.reset();
}
TEST_F(WddmCommandStreamTest, givenResidencyLoggingAvailableWhenFlushingCommandBufferThenNotifiesResidencyLogger) {
HWTEST_TEMPLATED_F(WddmCommandStreamTest, givenResidencyLoggingAvailableWhenFlushingCommandBufferThenNotifiesResidencyLogger) {
if (!NEO::wddmResidencyLoggingAvailable) {
GTEST_SKIP();
}
@@ -1292,8 +1294,9 @@ TEST_F(WddmCommandStreamTest, givenResidencyLoggingAvailableWhenFlushingCommandB
memoryManager->freeGraphicsMemory(commandBuffer);
}
struct MockWddmDirectSubmissionCsr : public WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
using BaseClass = WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>;
template <typename GfxFamily>
struct MockWddmDirectSubmissionCsr : public WddmCommandStreamReceiver<GfxFamily> {
using BaseClass = WddmCommandStreamReceiver<GfxFamily>;
MockWddmDirectSubmissionCsr(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield) : BaseClass(executionEnvironment, rootDeviceIndex, deviceBitfield) {}
@@ -1303,13 +1306,14 @@ struct MockWddmDirectSubmissionCsr : public WddmCommandStreamReceiver<DEFAULT_TE
bool directSubmissionAvailable = false;
};
struct SemaphorWaitForResidencyTest : public WddmCommandStreamTest {
void SetUp() override {
WddmCommandStreamTest::setUp();
struct SemaphoreWaitForResidencyTest : public WddmCommandStreamTest {
template <typename GfxFamily>
void setUpT() {
WddmCommandStreamTest::setUpT<GfxFamily>();
debugManager.flags.EnableDirectSubmissionController.set(1);
auto executionEnvironment = device->getExecutionEnvironment();
mockCsr = new MockWddmDirectSubmissionCsr(*executionEnvironment, 0, 1);
mockCsr = new MockWddmDirectSubmissionCsr<GfxFamily>(*executionEnvironment, 0, 1);
device->resetCommandStreamReceiver(mockCsr);
mockCsr->getOsContext().ensureContextInitialized(false);
@@ -1317,20 +1321,27 @@ struct SemaphorWaitForResidencyTest : public WddmCommandStreamTest {
commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{mockCsr->getRootDeviceIndex(), MemoryConstants::pageSize});
bufferHostMemory = memoryManager->allocateGraphicsMemoryWithProperties({mockCsr->getRootDeviceIndex(), MemoryConstants::pageSize, AllocationType::bufferHostMemory, device->getDeviceBitfield()});
}
void TearDown() override {
template <typename GfxFamily>
void tearDownT() {
memoryManager->freeGraphicsMemory(buffer);
memoryManager->freeGraphicsMemory(bufferHostMemory);
memoryManager->freeGraphicsMemory(commandBuffer);
WddmCommandStreamTest::tearDown();
WddmCommandStreamTest::tearDownT<GfxFamily>();
}
template <typename GfxFamily>
MockWddmDirectSubmissionCsr<GfxFamily> *getCsr() {
return static_cast<MockWddmDirectSubmissionCsr<GfxFamily> *>(mockCsr);
}
DebugManagerStateRestore restorer{};
GraphicsAllocation *buffer;
GraphicsAllocation *commandBuffer;
GraphicsAllocation *bufferHostMemory;
MockWddmDirectSubmissionCsr *mockCsr;
CommandStreamReceiver *mockCsr;
};
TEST_F(SemaphorWaitForResidencyTest, givenCommandBufferToMakeResidentThenSignalFlag) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenCommandBufferToMakeResidentThenSignalFlag) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
@@ -1339,21 +1350,21 @@ TEST_F(SemaphorWaitForResidencyTest, givenCommandBufferToMakeResidentThenSignalF
EXPECT_TRUE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
}
TEST_F(SemaphorWaitForResidencyTest, givenPagingFenceNotUpdatedThenDontSignalFlag) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenPagingFenceNotUpdatedThenDontSignalFlag) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
auto controller = mockCsr->peekExecutionEnvironment().initializeDirectSubmissionController();
controller->stopThread();
VariableBackup<bool> directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true};
VariableBackup<bool> directSubmissionAvailable{&getCsr<FamilyType>()->directSubmissionAvailable, true};
mockCsr->getResidencyAllocations().push_back(buffer);
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
EXPECT_FALSE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
}
TEST_F(SemaphorWaitForResidencyTest, givenUllsControllerNotEnabledThenSignalFlag) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenUllsControllerNotEnabledThenSignalFlag) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
@@ -1365,7 +1376,7 @@ TEST_F(SemaphorWaitForResidencyTest, givenUllsControllerNotEnabledThenSignalFlag
EXPECT_TRUE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
}
TEST_F(SemaphorWaitForResidencyTest, givenBufferAllocationThenSignalFlagForPagingFenceSemWait) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenBufferAllocationThenSignalFlagForPagingFenceSemWait) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
@@ -1375,14 +1386,14 @@ TEST_F(SemaphorWaitForResidencyTest, givenBufferAllocationThenSignalFlagForPagin
wddm->currentPagingFenceValue = 100u;
auto controller = mockCsr->peekExecutionEnvironment().initializeDirectSubmissionController();
controller->stopThread();
VariableBackup<bool> directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true};
VariableBackup<bool> directSubmissionAvailable{&getCsr<FamilyType>()->directSubmissionAvailable, true};
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
EXPECT_FALSE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
EXPECT_EQ(100u, batchBuffer.pagingFenceSemInfo.pagingFenceValue);
}
TEST_F(SemaphorWaitForResidencyTest, givenBufferHostMemoryAllocationThenSignalFlagForPagingFenceSemWait) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenBufferHostMemoryAllocationThenSignalFlagForPagingFenceSemWait) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
@@ -1392,14 +1403,14 @@ TEST_F(SemaphorWaitForResidencyTest, givenBufferHostMemoryAllocationThenSignalFl
wddm->currentPagingFenceValue = 100u;
auto controller = mockCsr->peekExecutionEnvironment().initializeDirectSubmissionController();
controller->stopThread();
VariableBackup<bool> directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true};
VariableBackup<bool> directSubmissionAvailable{&getCsr<FamilyType>()->directSubmissionAvailable, true};
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
EXPECT_FALSE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
EXPECT_EQ(100u, batchBuffer.pagingFenceSemInfo.pagingFenceValue);
}
TEST_F(SemaphorWaitForResidencyTest, givenAnotherFlushWithSamePagingFenceValueThenDontProgramPagingFenceSemWaitAndDontBlock) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenAnotherFlushWithSamePagingFenceValueThenDontProgramPagingFenceSemWaitAndDontBlock) {
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
@@ -1409,7 +1420,7 @@ TEST_F(SemaphorWaitForResidencyTest, givenAnotherFlushWithSamePagingFenceValueTh
wddm->currentPagingFenceValue = 100u;
auto controller = mockCsr->peekExecutionEnvironment().initializeDirectSubmissionController();
controller->stopThread();
VariableBackup<bool> directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true};
VariableBackup<bool> directSubmissionAvailable{&getCsr<FamilyType>()->directSubmissionAvailable, true};
mockCsr->flush(batchBuffer, mockCsr->getResidencyAllocations());
EXPECT_FALSE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
@@ -1423,7 +1434,7 @@ TEST_F(SemaphorWaitForResidencyTest, givenAnotherFlushWithSamePagingFenceValueTh
EXPECT_FALSE(batchBuffer2.pagingFenceSemInfo.requiresProgrammingSemaphore());
}
TEST_F(SemaphorWaitForResidencyTest, givenDebugFlagDisabledThenDontSignalFlag) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenDebugFlagDisabledThenDontSignalFlag) {
debugManager.flags.WaitForPagingFenceInController.set(0);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
@@ -1439,7 +1450,7 @@ TEST_F(SemaphorWaitForResidencyTest, givenDebugFlagDisabledThenDontSignalFlag) {
EXPECT_TRUE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
}
TEST_F(SemaphorWaitForResidencyTest, givenIllegalAllocationTypeThenDontSignalFlag) {
HWTEST_TEMPLATED_F(SemaphoreWaitForResidencyTest, givenIllegalAllocationTypeThenDontSignalFlag) {
debugManager.flags.WaitForPagingFenceInController.set(0);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
@@ -1458,4 +1469,4 @@ TEST_F(SemaphorWaitForResidencyTest, givenIllegalAllocationTypeThenDontSignalFla
EXPECT_TRUE(batchBuffer.pagingFenceSemInfo.requiresBlockingResidencyHandling);
memoryManager->freeGraphicsMemory(cmdBuffer);
}
}