mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add support for AUB subcapture (filter and toggle modes)
This commit adds a capability to selectively enable/disable AUB capture, i.e. by toggling the registry key from the outside or specifying the filter with a kernel name and/or kernel start index and kernel end index. Change-Id: Ib5d39c21863fbc4a95aa73c949b9779ff993de0f
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/command_stream/aub_subcapture.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
#include "unit_tests/fixtures/enqueue_handler_fixture.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
@ -304,3 +305,47 @@ HWTEST_F(EnqueueHandlerTest, givenExternallySynchronizedParentEventWhenRequestin
|
||||
ouputEvent->release();
|
||||
mockCmdQ->release();
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenSubCaptureIsOffThenActivateSubCaptureIsNotCalled) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Off));
|
||||
|
||||
MockKernelWithInternals kernelInternals(*pDevice, context);
|
||||
Kernel *kernel = kernelInternals.mockKernel;
|
||||
MockMultiDispatchInfo multiDispatchInfo(kernel);
|
||||
|
||||
auto mockCmdQ = new MockCommandQueueHw<FamilyType>(context, pDevice, 0);
|
||||
|
||||
mockCmdQ->template enqueueHandler<CL_COMMAND_NDRANGE_KERNEL>(nullptr,
|
||||
0,
|
||||
false,
|
||||
multiDispatchInfo,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_FALSE(pDevice->getUltCommandStreamReceiver<FamilyType>().activateAubSubCaptureCalled);
|
||||
|
||||
mockCmdQ->release();
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenSubCaptureIsOnThenActivateSubCaptureIsCalled) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter));
|
||||
|
||||
MockKernelWithInternals kernelInternals(*pDevice, context);
|
||||
Kernel *kernel = kernelInternals.mockKernel;
|
||||
MockMultiDispatchInfo multiDispatchInfo(kernel);
|
||||
|
||||
auto mockCmdQ = new MockCommandQueueHw<FamilyType>(context, pDevice, 0);
|
||||
|
||||
mockCmdQ->template enqueueHandler<CL_COMMAND_NDRANGE_KERNEL>(nullptr,
|
||||
0,
|
||||
false,
|
||||
multiDispatchInfo,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_TRUE(pDevice->getUltCommandStreamReceiver<FamilyType>().activateAubSubCaptureCalled);
|
||||
|
||||
mockCmdQ->release();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
set(IGDRCL_SRCS_tests_command_stream
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests.cpp
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
|
||||
#include "runtime/helpers/dispatch_info.h"
|
||||
#include "runtime/helpers/flat_batch_buffer_helper_hw.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
@ -28,11 +29,17 @@
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_aub_subcapture_manager.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_csr.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
|
||||
#endif
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
using ::testing::_;
|
||||
@ -56,6 +63,18 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
|
||||
void setLatestSentTaskCount(uint32_t latestSentTaskCount) {
|
||||
this->latestSentTaskCount = latestSentTaskCount;
|
||||
}
|
||||
|
||||
void flushBatchedSubmissions() override {
|
||||
flushBatchedSubmissionsCalled = true;
|
||||
}
|
||||
|
||||
void initProgrammingFlags() override {
|
||||
initProgrammingFlagsCalled = true;
|
||||
}
|
||||
|
||||
bool flushBatchedSubmissionsCalled = false;
|
||||
bool initProgrammingFlagsCalled = false;
|
||||
|
||||
MOCK_METHOD0(addPatchInfoComments, bool(void));
|
||||
};
|
||||
|
||||
@ -124,6 +143,27 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
|
||||
aubCsr->setMemoryManager(nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrInSubCaptureModeWhenItIsCreatedWithoutDebugFilterSettingsThenItInitializesSubCaptureFiltersWithDefaults) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter));
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
EXPECT_EQ(0u, aubCsr->subCaptureManager->subCaptureFilter.dumpKernelStartIdx);
|
||||
EXPECT_EQ(static_cast<uint32_t>(-1), aubCsr->subCaptureManager->subCaptureFilter.dumpKernelEndIdx);
|
||||
EXPECT_STREQ("", aubCsr->subCaptureManager->subCaptureFilter.dumpKernelName.c_str());
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrInSubCaptureModeWhenItIsCreatedWithDebugFilterSettingsThenItInitializesSubCaptureFiltersWithDebugFilterSettings) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter));
|
||||
DebugManager.flags.AUBDumpFilterKernelStartIdx.set(10);
|
||||
DebugManager.flags.AUBDumpFilterKernelEndIdx.set(100);
|
||||
DebugManager.flags.AUBDumpFilterKernelName.set("kernel_name");
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
EXPECT_EQ(static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelStartIdx.get()), aubCsr->subCaptureManager->subCaptureFilter.dumpKernelStartIdx);
|
||||
EXPECT_EQ(static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelEndIdx.get()), aubCsr->subCaptureManager->subCaptureFilter.dumpKernelEndIdx);
|
||||
EXPECT_STREQ(DebugManager.flags.AUBDumpFilterKernelName.get().c_str(), aubCsr->subCaptureManager->subCaptureFilter.dumpKernelName.c_str());
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentCalledMultipleTimesAffectsResidencyOnce) {
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
@ -185,6 +225,35 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneModeWhenFlushIsCalledThenItShouldNotUpdateHwTagWithLatestSentTaskCount) {
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {};
|
||||
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
|
||||
|
||||
aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1);
|
||||
|
||||
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
|
||||
|
||||
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
|
||||
|
||||
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
|
||||
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldUpdateHwTagWithLatestSentTaskCount) {
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
@ -213,6 +282,106 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldUpdateHwTagWithLatestSentTaskCount) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManagerMock->deactivateSubCapture();
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {};
|
||||
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
|
||||
|
||||
aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1);
|
||||
|
||||
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
|
||||
|
||||
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
|
||||
|
||||
EXPECT_EQ(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneAndSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldNotUpdateHwTagWithLatestSentTaskCount) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManagerMock->deactivateSubCapture();
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {};
|
||||
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
|
||||
|
||||
aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1);
|
||||
|
||||
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
|
||||
|
||||
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
|
||||
|
||||
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
|
||||
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenFlushIsCalledAndSubCaptureIsEnabledThenItShouldDeactivateSubCapture) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManagerMock->setSubCaptureToggleActive(true);
|
||||
aubSubCaptureManagerMock->activateSubCapture(dispatchInfo);
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
auto engineType = OCLRT::ENGINE_RCS;
|
||||
ResidencyContainer allocationsForResidency = {};
|
||||
|
||||
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
|
||||
|
||||
EXPECT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnCommandBufferAllocation) {
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
@ -379,6 +548,64 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
|
||||
memoryManager->freeGraphicsMemory(gfxImageAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModWhenProcessResidencyIsCalledWhileSubcaptureIsEnabledThenAllocationsTypesShouldBeMadeNonAubWritable) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
gfxBufferAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_BUFFER);
|
||||
|
||||
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
gfxImageAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_IMAGE);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManagerMock->setSubCaptureToggleActive(true);
|
||||
aubSubCaptureManagerMock->activateSubCapture(dispatchInfo);
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
|
||||
aubCsr->processResidency(&allocationsForResidency);
|
||||
|
||||
EXPECT_TRUE(gfxBufferAllocation->isTypeAubNonWritable());
|
||||
EXPECT_TRUE(gfxImageAllocation->isTypeAubNonWritable());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxBufferAllocation);
|
||||
memoryManager->freeGraphicsMemory(gfxImageAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenProcessResidencyIsCalledWhileSubcaptureIsDisabledThenAllocationsTypesShouldBeKeptAubWritable) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
gfxBufferAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_BUFFER | GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
|
||||
|
||||
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
gfxImageAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_IMAGE | GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
|
||||
|
||||
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManagerMock->deactivateSubCapture();
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
|
||||
aubCsr->processResidency(&allocationsForResidency);
|
||||
|
||||
EXPECT_FALSE(gfxBufferAllocation->isTypeAubNonWritable());
|
||||
EXPECT_FALSE(gfxImageAllocation->isTypeAubNonWritable());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxBufferAllocation);
|
||||
memoryManager->freeGraphicsMemory(gfxImageAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationTypeIsntNonAubWritableThenWriteMemoryIsAllowed) {
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
@ -411,6 +638,106 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
|
||||
EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation));
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenSubCaptureModeRemainsDeactivatedThenSubCaptureIsDisabled) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
|
||||
|
||||
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
subCaptureManagerMock->setSubCaptureIsActive(false);
|
||||
subCaptureManagerMock->setSubCaptureToggleActive(false);
|
||||
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
aubCsr->activateAubSubCapture(dispatchInfo);
|
||||
|
||||
EXPECT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenSubCaptureIsToggledOnThenSubCaptureGetsEnabled) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
|
||||
|
||||
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
subCaptureManagerMock->setSubCaptureIsActive(false);
|
||||
subCaptureManagerMock->setSubCaptureToggleActive(true);
|
||||
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
aubCsr->activateAubSubCapture(dispatchInfo);
|
||||
|
||||
EXPECT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureRemainsDeactivatedThenNeitherProgrammingFlagsAreInitializedNorCsrIsFlushed) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
|
||||
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
subCaptureManagerMock->setSubCaptureIsActive(false);
|
||||
subCaptureManagerMock->setSubCaptureToggleActive(false);
|
||||
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
aubCsr->activateAubSubCapture(dispatchInfo);
|
||||
|
||||
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
|
||||
EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureRemainsActivatedThenNeitherProgrammingFlagsAreInitializedNorCsrIsFlushed) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
|
||||
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
subCaptureManagerMock->setSubCaptureIsActive(true);
|
||||
subCaptureManagerMock->setSubCaptureToggleActive(true);
|
||||
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
aubCsr->activateAubSubCapture(dispatchInfo);
|
||||
|
||||
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
|
||||
EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureGetsActivatedThenProgrammingFlagsAreInitialized) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
|
||||
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
subCaptureManagerMock->setSubCaptureIsActive(false);
|
||||
subCaptureManagerMock->setSubCaptureToggleActive(true);
|
||||
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
aubCsr->activateAubSubCapture(dispatchInfo);
|
||||
|
||||
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
|
||||
EXPECT_TRUE(aubCsr->initProgrammingFlagsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureGetsDeactivatedThenCsrIsFlushed) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
|
||||
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
|
||||
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
subCaptureManagerMock->setSubCaptureIsActive(true);
|
||||
subCaptureManagerMock->setSubCaptureToggleActive(false);
|
||||
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
|
||||
|
||||
const DispatchInfo dispatchInfo;
|
||||
aubCsr->activateAubSubCapture(dispatchInfo);
|
||||
|
||||
EXPECT_TRUE(aubCsr->flushBatchedSubmissionsCalled);
|
||||
EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferFlatteningInImmediateDispatchModeThenNewCombinedBatchBufferIsCreated) {
|
||||
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
@ -1215,3 +1542,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenDbgDeviceIdFlagIsSetWhenAubCsrIsCre
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, true));
|
||||
EXPECT_EQ(9u, aubCsr->aubDeviceId);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
301
unit_tests/command_stream/aub_subcapture_tests.cpp
Normal file
301
unit_tests/command_stream/aub_subcapture_tests.cpp
Normal file
@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/aub_subcapture.h"
|
||||
#include "runtime/helpers/dispatch_info.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_aub_subcapture_manager.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
struct AubSubCaptureTest : public DeviceFixture,
|
||||
public ::testing::Test {
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
kernelInfo.name = "kernel_name";
|
||||
dbgRestore = new DebugManagerStateRestore();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
DeviceFixture::TearDown();
|
||||
delete dbgRestore;
|
||||
}
|
||||
|
||||
MockProgram program;
|
||||
KernelInfo kernelInfo;
|
||||
DebugManagerStateRestore *dbgRestore;
|
||||
};
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureToggleRegKeyIsUnspecifiedThenSubCaptureIsToggledOffByDefault) {
|
||||
struct AubSubCaptureManagerWithToggleActiveMock : public AubSubCaptureManager {
|
||||
using AubSubCaptureManager::isSubCaptureToggleActive;
|
||||
} aubSubCaptureManagerWithToggleActiveMock;
|
||||
|
||||
EXPECT_FALSE(aubSubCaptureManagerWithToggleActiveMock.isSubCaptureToggleActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenItIsCreatedThenItIsInitializedWithDefaults) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
EXPECT_EQ(AubSubCaptureManager::SubCaptureMode::Off, aubSubCaptureManager.subCaptureMode);
|
||||
EXPECT_STREQ("", aubSubCaptureManager.subCaptureFilter.dumpKernelName.c_str());
|
||||
EXPECT_EQ(0u, aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx);
|
||||
EXPECT_EQ(static_cast<uint32_t>(-1), aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureMode());
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
EXPECT_FALSE(aubSubCaptureManager.wasSubCaptureActive());
|
||||
EXPECT_EQ(0u, aubSubCaptureManager.getKernelCurrentIndex());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledWithEmptyDispatchInfoThenSubCaptureIsInactive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
MultiDispatchInfo dispatchInfo;
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledButSubCaptureModeIsOffThenSubCaptureIsInactive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Off;
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenActivateSubCaptureIsCalledAndSubCaptureIsToggledOnThenSubCaptureIsActive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManager.setSubCaptureToggleActive(true);
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenActivateSubCaptureIsCalledButSubCaptureIsToggledOffThenSubCaptureIsInactive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManager.setSubCaptureToggleActive(false);
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterIsDefaultThenSubCaptureIsActive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithValidKernelStartIndexIsSpecifiedThenSubCaptureIsActive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
||||
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 0;
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelStartIndexIsSpecifiedThenSubCaptureIsInactive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
||||
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 1;
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelEndIndexIsSpecifiedThenSubCaptureIsInactive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
||||
aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx = 0;
|
||||
aubSubCaptureManager.setKernelCurrentIndex(1);
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithValidKernelNameIsSpecifiedThenSubCaptureIsActive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
||||
aubSubCaptureManager.subCaptureFilter.dumpKernelName = "kernel_name";
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelNameIsSpecifiedThenSubCaptureIsInactive) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
|
||||
aubSubCaptureManager.subCaptureFilter.dumpKernelName = "invalid_kernel_name";
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenDeactivateSubCaptureIsCalledThenSubCaptureActiveStatesAreCleared) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
aubSubCaptureManager.setSubCaptureIsActive(true);
|
||||
aubSubCaptureManager.setSubCaptureWasActive(true);
|
||||
|
||||
aubSubCaptureManager.deactivateSubCapture();
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
|
||||
EXPECT_FALSE(aubSubCaptureManager.wasSubCaptureActive());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsInactiveThenMakeEachEnqueueBlocking) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.setSubCaptureIsActive(false);
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManager.setSubCaptureToggleActive(false);
|
||||
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_TRUE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
||||
EXPECT_FALSE(DebugManager.flags.ForceCsrFlushing.get());
|
||||
EXPECT_FALSE(DebugManager.flags.ForceCsrReprogramming.get());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsActiveThenDontMakeEachEnqueueBlockingAndForceCsrReprogramming) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.setSubCaptureIsActive(false);
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManager.setSubCaptureToggleActive(true);
|
||||
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(DebugManager.flags.ForceCsrFlushing.get());
|
||||
EXPECT_TRUE(DebugManager.flags.ForceCsrReprogramming.get());
|
||||
EXPECT_FALSE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsActiveThenDontMakeEachEnqueueBlocking) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.setSubCaptureIsActive(true);
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManager.setSubCaptureToggleActive(true);
|
||||
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_FALSE(DebugManager.flags.ForceCsrFlushing.get());
|
||||
EXPECT_FALSE(DebugManager.flags.ForceCsrReprogramming.get());
|
||||
EXPECT_FALSE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsInactiveThenMakeEachEnqueueBlockingAndForceCsrFlushing) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
DispatchInfo dispatchInfo;
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
dispatchInfo.setKernel(&kernel);
|
||||
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
aubSubCaptureManager.setSubCaptureIsActive(true);
|
||||
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
|
||||
aubSubCaptureManager.setSubCaptureToggleActive(false);
|
||||
|
||||
aubSubCaptureManager.activateSubCapture(dispatchInfo);
|
||||
EXPECT_TRUE(DebugManager.flags.ForceCsrFlushing.get());
|
||||
EXPECT_FALSE(DebugManager.flags.ForceCsrReprogramming.get());
|
||||
EXPECT_TRUE(DebugManager.flags.MakeEachEnqueueBlocking.get());
|
||||
}
|
||||
|
||||
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureActiveStatesAreDeterminedThenIsSubCaptureFunctionReturnCorrectValues) {
|
||||
AubSubCaptureManagerMock aubSubCaptureManager;
|
||||
|
||||
aubSubCaptureManager.setSubCaptureWasActive(false);
|
||||
aubSubCaptureManager.setSubCaptureIsActive(false);
|
||||
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureEnabled());
|
||||
|
||||
aubSubCaptureManager.setSubCaptureWasActive(false);
|
||||
aubSubCaptureManager.setSubCaptureIsActive(true);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
|
||||
|
||||
aubSubCaptureManager.setSubCaptureWasActive(true);
|
||||
aubSubCaptureManager.setSubCaptureIsActive(false);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
|
||||
|
||||
aubSubCaptureManager.setSubCaptureIsActive(true);
|
||||
aubSubCaptureManager.setSubCaptureWasActive(true);
|
||||
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
|
||||
}
|
@ -66,6 +66,28 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, shouldSeeCommandsOnFirstFlush) {
|
||||
EXPECT_GT(commandStreamReceiver.commandStream.getUsed(), 0u);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenForceCsrReprogrammingDebugVariableSetWhenFlushingThenInitProgrammingFlagsShouldBeCalled) {
|
||||
DebugManagerStateRestore restore;
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
|
||||
DebugManager.flags.ForceCsrReprogramming.set(true);
|
||||
|
||||
flushTask(commandStreamReceiver);
|
||||
|
||||
EXPECT_TRUE(commandStreamReceiver.initProgrammingFlagsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenForceCsrFlushingDebugVariableSetWhenFlushingThenFlushBatchedSubmissionsShouldBeCalled) {
|
||||
DebugManagerStateRestore restore;
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
|
||||
DebugManager.flags.ForceCsrFlushing.set(true);
|
||||
|
||||
flushTask(commandStreamReceiver);
|
||||
|
||||
EXPECT_TRUE(commandStreamReceiver.flushBatchedSubmissionsCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenOverrideThreadArbitrationPolicyDebugVariableSetWhenFlushingThenRequestRequiredMode) {
|
||||
DebugManagerStateRestore restore;
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
|
@ -63,6 +63,20 @@ HWTEST_F(CommandStreamReceiverTest, testCtor) {
|
||||
EXPECT_FALSE(csr.isPreambleSent);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, testInitProgrammingFlags) {
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
csr.initProgrammingFlags();
|
||||
EXPECT_FALSE(csr.isPreambleProgrammed());
|
||||
EXPECT_FALSE(csr.isGSBAFor32BitProgrammed());
|
||||
EXPECT_TRUE(csr.isMediaVfeStateDirty());
|
||||
EXPECT_FALSE(csr.isLastVmeSubslicesConfig());
|
||||
EXPECT_EQ(0u, csr.getLastSentL3Config());
|
||||
EXPECT_EQ(-1, csr.getLastSentCoherencyRequest());
|
||||
EXPECT_EQ(-1, csr.getLastMediaSamplerConfig());
|
||||
EXPECT_EQ(PreemptionMode::Initial, csr.getLastPreemptionMode());
|
||||
EXPECT_EQ(0u, csr.getLatestSentStatelessMocsConfig());
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, makeResident_setsBufferResidencyFlag) {
|
||||
MockContext context;
|
||||
float srcMemory[] = {1.0f};
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
||||
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.h"
|
||||
#include "runtime/command_stream/command_stream_receiver_with_aub_dump.inl"
|
||||
#include "runtime/helpers/dispatch_info.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
@ -55,6 +56,11 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
|
||||
makeNonResidentParameterization.receivedGfxAllocation = &gfxAllocation;
|
||||
}
|
||||
|
||||
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override {
|
||||
activateAubSubCaptureParameterization.wasCalled = true;
|
||||
activateAubSubCaptureParameterization.receivedDispatchInfo = &dispatchInfo;
|
||||
}
|
||||
|
||||
struct FlushParameterization {
|
||||
bool wasCalled = false;
|
||||
FlushStamp flushStampToReturn = 1;
|
||||
@ -77,6 +83,11 @@ struct MyMockCsr : UltCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> {
|
||||
bool wasCalled = false;
|
||||
GraphicsAllocation *receivedGfxAllocation = nullptr;
|
||||
} makeNonResidentParameterization;
|
||||
|
||||
struct ActivateAubSubCaptureParameterization {
|
||||
bool wasCalled = false;
|
||||
const MultiDispatchInfo *receivedDispatchInfo = nullptr;
|
||||
} activateAubSubCaptureParameterization;
|
||||
};
|
||||
|
||||
template <typename BaseCSR>
|
||||
@ -204,6 +215,21 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
|
||||
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
|
||||
}
|
||||
|
||||
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenActivateAubSubCaptureIsCalledThenBaseCsrCommandStreamReceiverIsCalled) {
|
||||
const DispatchInfo dispatchInfo;
|
||||
const MultiDispatchInfo multiDispatchInfo(dispatchInfo);
|
||||
|
||||
csrWithAubDump->activateAubSubCapture(multiDispatchInfo);
|
||||
|
||||
EXPECT_TRUE(csrWithAubDump->activateAubSubCaptureParameterization.wasCalled);
|
||||
EXPECT_EQ(&multiDispatchInfo, csrWithAubDump->activateAubSubCaptureParameterization.receivedDispatchInfo);
|
||||
|
||||
if (createAubCSR) {
|
||||
EXPECT_TRUE(csrWithAubDump->getAubMockCsr().activateAubSubCaptureParameterization.wasCalled);
|
||||
EXPECT_EQ(&multiDispatchInfo, csrWithAubDump->getAubMockCsr().activateAubSubCaptureParameterization.receivedDispatchInfo);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenCreateMemoryManagerIsCalledThenItIsUsedByBothBaseAndAubCsr) {
|
||||
EXPECT_EQ(memoryManager, csrWithAubDump->getMemoryManager());
|
||||
if (createAubCSR) {
|
||||
|
@ -79,6 +79,15 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
||||
}
|
||||
|
||||
void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; }
|
||||
bool isPreambleProgrammed() const { return this->isPreambleSent; }
|
||||
bool isGSBAFor32BitProgrammed() const { return this->GSBAFor32BitProgrammed; }
|
||||
bool isMediaVfeStateDirty() const { return this->mediaVfeStateDirty; }
|
||||
bool isLastVmeSubslicesConfig() const { return this->lastVmeSubslicesConfig; }
|
||||
uint32_t getLastSentL3Config() const { return this->lastSentL3Config; }
|
||||
int8_t getLastSentCoherencyRequest() const { return this->lastSentCoherencyRequest; }
|
||||
int8_t getLastMediaSamplerConfig() const { return this->lastMediaSamplerConfig; }
|
||||
PreemptionMode getLastPreemptionMode() const { return this->lastPreemptionMode; }
|
||||
uint32_t getLatestSentStatelessMocsConfig() const { return this->latestSentStatelessMocsConfig; }
|
||||
|
||||
virtual ~UltCommandStreamReceiver() override;
|
||||
GraphicsAllocation *getTagAllocation() { return tagAllocation; }
|
||||
@ -109,6 +118,23 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
||||
std::map<GraphicsAllocation *, uint32_t> makeResidentAllocations;
|
||||
bool storeMakeResidentAllocations;
|
||||
|
||||
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override {
|
||||
CommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(dispatchInfo);
|
||||
activateAubSubCaptureCalled = true;
|
||||
}
|
||||
void flushBatchedSubmissions() override {
|
||||
CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions();
|
||||
flushBatchedSubmissionsCalled = true;
|
||||
}
|
||||
void initProgrammingFlags() override {
|
||||
CommandStreamReceiverHw<GfxFamily>::initProgrammingFlags();
|
||||
initProgrammingFlagsCalled = true;
|
||||
}
|
||||
|
||||
bool activateAubSubCaptureCalled = false;
|
||||
bool flushBatchedSubmissionsCalled = false;
|
||||
bool initProgrammingFlagsCalled = false;
|
||||
|
||||
protected:
|
||||
using BaseClass::CommandStreamReceiver::memoryManager;
|
||||
using BaseClass::CommandStreamReceiver::tagAddress;
|
||||
|
@ -22,6 +22,7 @@ set(IGDRCL_SRCS_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_32bitAllocator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_async_event_handler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_subcapture_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_block_kernel_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_buffer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_builtins.h
|
||||
|
56
unit_tests/mocks/mock_aub_subcapture_manager.h
Normal file
56
unit_tests/mocks/mock_aub_subcapture_manager.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
#include "runtime/command_stream/aub_subcapture.h"
|
||||
|
||||
class AubSubCaptureManagerMock : public AubSubCaptureManager {
|
||||
public:
|
||||
void setSubCaptureIsActive(bool on) {
|
||||
subCaptureIsActive = on;
|
||||
}
|
||||
bool isSubCaptureActive() const {
|
||||
return subCaptureIsActive;
|
||||
}
|
||||
void setSubCaptureWasActive(bool on) {
|
||||
subCaptureWasActive = on;
|
||||
}
|
||||
bool wasSubCaptureActive() const {
|
||||
return subCaptureIsActive;
|
||||
}
|
||||
void setKernelCurrentIndex(uint32_t index) {
|
||||
kernelCurrentIdx = index;
|
||||
}
|
||||
uint32_t getKernelCurrentIndex() {
|
||||
return kernelCurrentIdx;
|
||||
}
|
||||
void setSubCaptureToggleActive(bool on) {
|
||||
isToggledOn = on;
|
||||
}
|
||||
bool isSubCaptureToggleActive() const override {
|
||||
return isToggledOn;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool isToggledOn = false;
|
||||
};
|
@ -900,3 +900,15 @@ TEST(DebugSettingsManager, whenOnlyRegKeysAreEnabledThenAllOtherDebugFunctionali
|
||||
static_assert(false == debugManager.kernelArgDumpingAvailable(), "");
|
||||
static_assert(debugManager.registryReadAvailable(), "");
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenDebugSettingsManagerWithDebugFunctionalityWhenReadSettingIsCalledOnInvalidSettingNameThenDefaultValueIsReturned) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
|
||||
EXPECT_EQ(true, debugManager.readSetting("invalid_setting_name", true));
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, givenDebugSettingsManagerWithoutDebugFunctionalityWhenReadSettingIsCalledOnInvalidSettingNameThenDefaultValueIsReturned) {
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
|
||||
EXPECT_EQ(true, debugManager.readSetting("invalid_setting_name", true));
|
||||
}
|
||||
|
@ -66,4 +66,11 @@ DisableZeroCopyForUseHostPtr = false
|
||||
SchedulerGWS = 0
|
||||
DisableZeroCopyForBuffers = false
|
||||
OverrideAubDeviceId = -1
|
||||
ForceCompilerUsePlatform = unk
|
||||
ForceCompilerUsePlatform = unk
|
||||
ForceCsrFlushing = false
|
||||
ForceCsrReprogramming = false
|
||||
AUBDumpSubCaptureMode = 0
|
||||
AUBDumpToggleCaptureOnOff = 0
|
||||
AUBDumpFilterKernelName = unk
|
||||
AUBDumpFilterKernelStartIdx = 0
|
||||
AUBDumpFilterKernelEndIdx = -1
|
Reference in New Issue
Block a user