diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index f599ece9a4..a0bb2900f3 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -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(); + auto &csr = pDevice->getUltCommandStreamReceiver(); 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(); + auto &csr = pDevice->getUltCommandStreamReceiver(); 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(); + auto &csr = pDevice->getUltCommandStreamReceiver(); 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(); + auto &csr = pDevice->getUltCommandStreamReceiver(); csr.indirectHeap[this->GetParam()]->replaceGraphicsAllocation(nullptr); csr.indirectHeap[this->GetParam()]->replaceBuffer(nullptr, 0); diff --git a/opencl/test/unit_test/profiling/profiling_tests.cpp b/opencl/test/unit_test/profiling/profiling_tests.cpp index 208a0cb0e1..e5e54daaba 100644 --- a/opencl/test/unit_test/profiling/profiling_tests.cpp +++ b/opencl/test/unit_test/profiling/profiling_tests.cpp @@ -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(cmdQ->getDevice()); - auto &csr = device.getUltCommandStreamReceiver(); + auto &csr = device.getUltCommandStreamReceiver(); 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(cmdQ->getDevice()); - auto &csr = device.getUltCommandStreamReceiver(); + auto &csr = device.getUltCommandStreamReceiver(); csr.multiOsContextCapable = true; ev->timestampPacketContainer->peekNodes()[1]->setProfilingCapable(false); @@ -1464,14 +1464,14 @@ TEST_F(ProfilingTimestampPacketsTest, givenTimestampPacketWithoutProfilingDataWh EXPECT_EQ(static_cast(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(cmdQ->getDevice()); - auto &csr = device.getUltCommandStreamReceiver(); + auto &csr = device.getUltCommandStreamReceiver(); csr.multiOsContextCapable = true; uint32_t globalStart[16] = {0}; diff --git a/platforms.cmake b/platforms.cmake index 830edf77b5..1989d682d7 100644 --- a/platforms.cmake +++ b/platforms.cmake @@ -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}") diff --git a/shared/source/CMakeLists.txt b/shared/source/CMakeLists.txt index c739d708fb..86b13b7e61 100644 --- a/shared/source/CMakeLists.txt +++ b/shared/source/CMakeLists.txt @@ -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() diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 79d34672bd..2f28806401 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -34,27 +34,24 @@ using namespace NEO; -struct MyMockCsr : UltCommandStreamReceiver { - MyMockCsr(ExecutionEnvironment &executionEnvironment, - uint32_t rootDeviceIndex, - const DeviceBitfield deviceBitfield) - : UltCommandStreamReceiver(executionEnvironment, rootDeviceIndex, deviceBitfield) { - } +template +struct MyMockCsr : UltCommandStreamReceiver { + using UltCommandStreamReceiver::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 { } expectMemoryParameterization; }; -template +template struct MyMockCsrWithAubDump : CommandStreamReceiverWithAUBDump { MyMockCsrWithAubDump(bool createAubCSR, ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield) : CommandStreamReceiverWithAUBDump("aubfile", executionEnvironment, 0, deviceBitfield) { - this->aubCSR.reset(createAubCSR ? new MyMockCsr(executionEnvironment, 0, deviceBitfield) : nullptr); + this->aubCSR.reset(createAubCSR ? new MyMockCsr(executionEnvironment, 0, deviceBitfield) : nullptr); } - MyMockCsr &getAubMockCsr() const { - return static_cast(*this->aubCSR); + MyMockCsr &getAubMockCsr() const { + return static_cast &>(*this->aubCSR); } }; struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam, MockAubCenterFixture, DeviceFixture { - void SetUp() override { + template + void setUpT() { DeviceFixture::setUp(); MockAubCenterFixture::setUp(); setMockAubCenter(pDevice->getRootDeviceEnvironmentRef()); @@ -149,27 +147,32 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam(createAubCSR, *executionEnvironment, deviceBitfield); + csrWithAubDump = new MyMockCsrWithAubDump>(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(), engineDescriptor); + getCsrWithAubDump()->setupContext(*osContext); } - void TearDown() override { + template + void tearDownT() { delete csrWithAubDump; MockAubCenterFixture::tearDown(); DeviceFixture::tearDown(); } + template + MyMockCsrWithAubDump> *getCsrWithAubDump() const { + return static_cast> *>(csrWithAubDump); + } - ExecutionEnvironment *executionEnvironment; - MyMockCsrWithAubDump *csrWithAubDump; - MemoryManager *memoryManager; - bool createAubCSR; + ExecutionEnvironment *executionEnvironment = nullptr; + CommandStreamReceiver *csrWithAubDump = nullptr; + MemoryManager *memoryManager = nullptr; + bool createAubCSR{}; }; struct CommandStreamReceiverWithAubDumpSimpleTest : Test, 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(); + 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(); 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(); 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(); 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(); 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(); 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(); 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(); 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(); 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(); 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()); diff --git a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 8989a8f0f7..e11402f095 100644 --- a/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -2648,7 +2648,7 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreate } HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferObjectWhenTheyAreMadeResidentThenOnlyOneBoIsPassedToExec) { - auto testedCsr = static_cast *>(device->getDefaultEngine().commandStreamReceiver); + auto testedCsr = static_cast *>(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 *>(device->getDefaultEngine().commandStreamReceiver); + auto testedCsr = static_cast *>(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); -} \ No newline at end of file +} diff --git a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index d5d7d67080..870893f2af 100644 --- a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -43,13 +43,14 @@ using namespace ::testing; class WddmCommandStreamFixture { public: std::unique_ptr device; - DeviceCommandStreamReceiver *csr; + CommandStreamReceiver *csr; MockWddmMemoryManager *memoryManager = nullptr; WddmMock *wddm = nullptr; DebugManagerStateRestore stateRestore; - void setUp() { + template + void setUpT() { HardwareInfo *hwInfo = nullptr; debugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::immediateDispatch)); debugManager.flags.SetAmountOfReusableAllocations.set(0); @@ -61,12 +62,13 @@ class WddmCommandStreamFixture { device.reset(MockDevice::create(executionEnvironment, 0u)); ASSERT_NE(nullptr, device); - csr = new WddmCommandStreamReceiver(*executionEnvironment, 0, device->getDeviceBitfield()); + csr = new WddmCommandStreamReceiver(*executionEnvironment, 0, device->getDeviceBitfield()); device->resetCommandStreamReceiver(csr); csr->getOsContext().ensureContextInitialized(false); } - void tearDown() { + template + void tearDownT() { } }; @@ -173,7 +175,7 @@ class WddmCommandStreamMockGdiTest : public ::testing::Test { } }; -using WddmCommandStreamTest = ::Test; +struct WddmCommandStreamTest : ::testing::Test, WddmCommandStreamFixture {}; using WddmDefaultTest = ::Test; struct DeviceCommandStreamTest : ::Test, DeviceFixture { void SetUp() override { @@ -187,33 +189,33 @@ struct DeviceCommandStreamTest : ::Test, 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(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(wddm)); executionEnvironment->initializeMemoryManager(); - std::unique_ptr> csr(static_cast *>(WddmCommandStreamReceiver::create(false, *executionEnvironment, 0, 1))); + std::unique_ptr> csr(static_cast *>(WddmCommandStreamReceiver::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(); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr(wddm)); executionEnvironment->initializeMemoryManager(); - std::unique_ptr> csr(static_cast *>(WddmCommandStreamReceiver::create(true, *executionEnvironment, 0, 1))); + std::unique_ptr> csr(static_cast *>(WddmCommandStreamReceiver::create(true, *executionEnvironment, 0, 1))); EXPECT_NE(nullptr, csr); auto wddmFromCsr = csr->peekWddm(); EXPECT_NE(nullptr, wddmFromCsr); - auto aubCSR = static_cast> *>(csr.get())->aubCSR.get(); + auto aubCSR = static_cast> *>(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; -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>(*executionEnvironment, 0, 1); + auto csr = std::make_unique>(*executionEnvironment, 0, 1); executionEnvironment->memoryManager.reset(new MemoryManagerCreate(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>(*executionEnvironment, 0, 1); + auto csr = std::make_unique>(*executionEnvironment, 0, 1); executionEnvironment->memoryManager.reset(new MemoryManagerCreate(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>(*executionEnvironment, 0, 1); + auto commandStreamReceiver = std::make_unique>(*executionEnvironment, 0, 1); auto commandHeader = commandStreamReceiver->commandBufferHeader; auto header = reinterpret_cast(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>(*executionEnvironment, 0, 1); + auto commandStreamReceiver = std::make_unique>(*executionEnvironment, 0, 1); auto commandHeader = commandStreamReceiver->commandBufferHeader; auto header = reinterpret_cast(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 { - using BaseClass = WddmCommandStreamReceiver; +template +struct MockWddmDirectSubmissionCsr : public WddmCommandStreamReceiver { + using BaseClass = WddmCommandStreamReceiver; MockWddmDirectSubmissionCsr(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield) : BaseClass(executionEnvironment, rootDeviceIndex, deviceBitfield) {} @@ -1303,13 +1306,14 @@ struct MockWddmDirectSubmissionCsr : public WddmCommandStreamReceiver + void setUpT() { + WddmCommandStreamTest::setUpT(); debugManager.flags.EnableDirectSubmissionController.set(1); auto executionEnvironment = device->getExecutionEnvironment(); - mockCsr = new MockWddmDirectSubmissionCsr(*executionEnvironment, 0, 1); + mockCsr = new MockWddmDirectSubmissionCsr(*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 + void tearDownT() { memoryManager->freeGraphicsMemory(buffer); memoryManager->freeGraphicsMemory(bufferHostMemory); memoryManager->freeGraphicsMemory(commandBuffer); - WddmCommandStreamTest::tearDown(); + WddmCommandStreamTest::tearDownT(); } + + template + MockWddmDirectSubmissionCsr *getCsr() { + return static_cast *>(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 directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true}; + VariableBackup directSubmissionAvailable{&getCsr()->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 directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true}; + VariableBackup directSubmissionAvailable{&getCsr()->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 directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true}; + VariableBackup directSubmissionAvailable{&getCsr()->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 directSubmissionAvailable{&mockCsr->directSubmissionAvailable, true}; + VariableBackup directSubmissionAvailable{&getCsr()->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); -} \ No newline at end of file +}