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:
Milczarek, Slawomir
2018-06-12 20:33:03 +02:00
parent af65ee87e5
commit eb1b5ded9c
27 changed files with 1119 additions and 10 deletions

View File

@ -340,7 +340,7 @@ class CommandQueueHw : public CommandQueue {
std::unique_ptr<PrintfHandler> printfHandler);
protected:
MOCKABLE_VIRTUAL void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo);
MOCKABLE_VIRTUAL void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo){};
bool createAllocationForHostSurface(HostPtrSurface &surface);
size_t calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image);

View File

@ -63,9 +63,6 @@ inline bool isCommandWithoutKernel(uint32_t commandType) {
(commandType == CL_COMMAND_SVM_FREE));
}
template <typename GfxFamily>
void CommandQueueHw<GfxFamily>::enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo) {}
template <typename GfxFamily>
template <uint32_t commandType, size_t surfaceCount>
void CommandQueueHw<GfxFamily>::enqueueHandler(Surface *(&surfaces)[surfaceCount],
@ -197,10 +194,6 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
DBG_LOG(EventsDebugEnable, "blockQueue", blockQueue, "virtualEvent", virtualEvent, "taskLevel", taskLevel);
if (DebugManager.flags.MakeEachEnqueueBlocking.get()) {
blocking = true;
}
if (executionModelKernel && !blockQueue) {
while (!devQueueHw->isEMCriticalSectionFree())
;
@ -208,6 +201,14 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
enqueueHandlerHook(commandType, multiDispatchInfo);
if (DebugManager.flags.AUBDumpSubCaptureMode.get()) {
commandStreamReceiver.activateAubSubCapture(multiDispatchInfo);
}
if (DebugManager.flags.MakeEachEnqueueBlocking.get()) {
blocking = true;
}
if (multiDispatchInfo.empty() == false) {
HwPerfCounter *hwPerfCounter = nullptr;
DebugManager.dumpKernelArgs(&multiDispatchInfo);

View File

@ -24,6 +24,8 @@ set(RUNTIME_SRCS_COMMAND_STREAM
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver.h
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_hw.h
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_hw.inl
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture.h
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver.h
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw.h

View File

@ -29,6 +29,9 @@
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
namespace OCLRT {
class AubSubCaptureManager;
template <typename GfxFamily>
class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
typedef CommandStreamReceiverHw<GfxFamily> BaseClass;
@ -41,8 +44,11 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
void processResidency(ResidencyContainer *allocationsForResidency) override;
bool writeMemory(GraphicsAllocation &gfxAllocation);
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
// Family specific version
void submitLRCA(EngineType engineType, const MiContextDescriptorReg &contextDescriptor);
void pollForCompletion(EngineType engineType);
@ -81,6 +87,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
} engineInfoTable[EngineType::NUM_ENGINES];
std::unique_ptr<AUBCommandStreamReceiver::AubFileStream> stream;
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
uint32_t aubDeviceId;
bool standalone;

View File

@ -21,6 +21,7 @@
*/
#include "hw_cmds.h"
#include "runtime/command_stream/aub_subcapture.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/debug_helpers.h"
#include "runtime/helpers/ptr_math.h"
@ -37,11 +38,20 @@ template <typename GfxFamily>
AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, bool standalone)
: BaseClass(hwInfoIn),
stream(std::unique_ptr<AUBCommandStreamReceiver::AubFileStream>(new AUBCommandStreamReceiver::AubFileStream())),
subCaptureManager(std::unique_ptr<AubSubCaptureManager>(new AubSubCaptureManager())),
standalone(standalone) {
this->dispatchMode = DispatchMode::BatchedDispatch;
if (DebugManager.flags.CsrDispatchMode.get()) {
this->dispatchMode = (DispatchMode)DebugManager.flags.CsrDispatchMode.get();
}
if (DebugManager.flags.AUBDumpSubCaptureMode.get()) {
this->subCaptureManager->subCaptureMode = static_cast<AubSubCaptureManager::SubCaptureMode>(DebugManager.flags.AUBDumpSubCaptureMode.get());
this->subCaptureManager->subCaptureFilter.dumpKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelStartIdx.get());
this->subCaptureManager->subCaptureFilter.dumpKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelEndIdx.get());
if (DebugManager.flags.AUBDumpFilterKernelName.get() != "unk") {
this->subCaptureManager->subCaptureFilter.dumpKernelName = DebugManager.flags.AUBDumpFilterKernelName.get();
}
}
for (auto &engineInfo : engineInfoTable) {
engineInfo.pLRCA = nullptr;
engineInfo.ggttLRCA = 0u;
@ -225,6 +235,16 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
DEBUG_BREAK_IF(!engineInfo.pLRCA);
}
if (subCaptureManager->isSubCaptureMode()) {
if (!subCaptureManager->isSubCaptureEnabled()) {
if (this->standalone) {
*this->tagAddress = this->peekLatestSentTaskCount();
}
return 0;
}
subCaptureManager->deactivateSubCapture();
}
// Write our batch buffer
auto pBatchBuffer = ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset);
auto currentOffset = batchBuffer.usedSize;
@ -517,6 +537,15 @@ template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer *allocationsForResidency) {
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations();
if (subCaptureManager->isSubCaptureMode()) {
if (!subCaptureManager->isSubCaptureEnabled()) {
for (auto &gfxAllocation : residencyAllocations) {
gfxAllocation->clearTypeAubNonWritable();
}
return;
}
}
for (auto &gfxAllocation : residencyAllocations) {
if (!writeMemory(*gfxAllocation)) {
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || gfxAllocation->isTypeAubNonWritable()));
@ -533,6 +562,19 @@ void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &
}
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
subCaptureManager->activateSubCapture(dispatchInfo);
if (this->standalone) {
if (DebugManager.flags.ForceCsrFlushing.get()) {
this->flushBatchedSubmissions();
}
if (DebugManager.flags.ForceCsrReprogramming.get()) {
this->initProgrammingFlags();
}
}
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::addContextToken() {
// Some simulator versions don't support adding the context token.

View File

@ -0,0 +1,96 @@
/*
* 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 "runtime/kernel/kernel.h"
#include "runtime/utilities/debug_settings_reader.h"
namespace OCLRT {
void AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchInfo) {
if (dispatchInfo.empty()) {
return;
}
subCaptureWasActive = subCaptureIsActive;
subCaptureIsActive = false;
switch (subCaptureMode) {
case SubCaptureMode::Toggle:
subCaptureIsActive = isSubCaptureToggleActive();
break;
case SubCaptureMode::Filter:
subCaptureIsActive = isSubCaptureFilterActive(dispatchInfo, kernelCurrentIdx);
kernelCurrentIdx++;
break;
default:
DEBUG_BREAK_IF(false);
break;
}
setDebugManagerFlags();
}
void AubSubCaptureManager::deactivateSubCapture() {
subCaptureWasActive = false;
subCaptureIsActive = false;
}
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const {
return ((subCaptureFilter.dumpKernelStartIdx <= kernelIdx) &&
(kernelIdx <= subCaptureFilter.dumpKernelEndIdx));
}
bool AubSubCaptureManager::isSubCaptureToggleActive() const {
return DebugManager.readSetting("AUBDumpToggleCaptureOnOff", false);
}
bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const {
DEBUG_BREAK_IF(dispatchInfo.size() > 1);
auto kernelName = dispatchInfo.begin()->getKernel()->getKernelInfo().name;
auto subCaptureIsActive = false;
if (isKernelIndexInSubCaptureRange(kernelIdx)) {
if (subCaptureFilter.dumpKernelName.empty()) {
subCaptureIsActive = true;
} else {
if (0 == kernelName.compare(subCaptureFilter.dumpKernelName)) {
subCaptureIsActive = true;
}
}
}
return subCaptureIsActive;
}
void AubSubCaptureManager::setDebugManagerFlags() const {
DebugManager.flags.MakeEachEnqueueBlocking.set(!subCaptureIsActive);
DebugManager.flags.ForceCsrFlushing.set(false);
if (!subCaptureIsActive && subCaptureWasActive) {
DebugManager.flags.ForceCsrFlushing.set(true);
}
DebugManager.flags.ForceCsrReprogramming.set(false);
if (subCaptureIsActive && !subCaptureWasActive) {
DebugManager.flags.ForceCsrReprogramming.set(true);
}
}
} // namespace OCLRT

View File

@ -0,0 +1,66 @@
/*
* 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.
*/
#pragma once
#include <string>
namespace OCLRT {
struct MultiDispatchInfo;
class SettingsReader;
class AubSubCaptureManager {
public:
enum class SubCaptureMode {
Off = 0, //subcapture off
Filter, //subcapture kernel specified by filter (static regkey)
Toggle //toggle subcapture on/off (dynamic regkey)
} subCaptureMode = SubCaptureMode::Off;
struct SubCaptureFilter {
std::string dumpKernelName = "";
uint32_t dumpKernelStartIdx = 0;
uint32_t dumpKernelEndIdx = static_cast<uint32_t>(-1);
} subCaptureFilter;
inline bool isSubCaptureMode() const {
return subCaptureMode > SubCaptureMode::Off;
}
inline bool isSubCaptureEnabled() const {
return subCaptureIsActive || subCaptureWasActive;
}
void activateSubCapture(const MultiDispatchInfo &dispatchInfo);
void deactivateSubCapture();
virtual ~AubSubCaptureManager() = default;
protected:
MOCKABLE_VIRTUAL bool isSubCaptureToggleActive() const;
bool isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const;
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const;
void setDebugManagerFlags() const;
bool subCaptureIsActive = false;
bool subCaptureWasActive = false;
uint32_t kernelCurrentIdx = 0;
};
} // namespace OCLRT

View File

@ -239,6 +239,21 @@ void CommandStreamReceiver::setRequiredScratchSize(uint32_t newRequiredScratchSi
}
}
void CommandStreamReceiver::initProgrammingFlags() {
isPreambleSent = false;
GSBAFor32BitProgrammed = false;
mediaVfeStateDirty = true;
lastVmeSubslicesConfig = false;
lastSentL3Config = 0;
lastSentCoherencyRequest = -1;
lastMediaSamplerConfig = -1;
lastPreemptionMode = PreemptionMode::Initial;
latestSentStatelessMocsConfig = 0;
}
void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {}
GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {
UNRECOVERABLE_IF(debugSurface != nullptr);
debugSurface = memoryManager->allocateGraphicsMemory(size);

View File

@ -130,6 +130,9 @@ class CommandStreamReceiver {
FlatBatchBufferHelper &getFlatBatchBufferHelper() { return *flatBatchBufferHelper.get(); }
void overwriteFlatBatchBufferHelper(FlatBatchBufferHelper *newHelper) { flatBatchBufferHelper.reset(newHelper); }
MOCKABLE_VIRTUAL void initProgrammingFlags();
virtual void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo);
IndirectHeap &getIndirectHeap(IndirectHeap::Type heapType, size_t minRequiredSize);
void allocateHeapMemory(IndirectHeap::Type heapType, size_t minRequiredSize, IndirectHeap *&indirectHeap);
void releaseIndirectHeap(IndirectHeap::Type heapType);
@ -163,7 +166,7 @@ class CommandStreamReceiver {
int8_t lastSentCoherencyRequest = -1;
int8_t lastMediaSamplerConfig = -1;
PreemptionMode lastPreemptionMode = PreemptionMode::Initial;
uint32_t latestSentStatelessMocsConfig;
uint32_t latestSentStatelessMocsConfig = 0;
LinearStream commandStream;

View File

@ -149,6 +149,13 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
void *epiloguePipeControlLocation = nullptr;
Device *device = this->getMemoryManager()->device;
if (DebugManager.flags.ForceCsrFlushing.get()) {
flushBatchedSubmissions();
}
if (DebugManager.flags.ForceCsrReprogramming.get()) {
initProgrammingFlags();
}
if (dispatchFlags.blocking || dispatchFlags.dcFlush || dispatchFlags.guardCommandBufferWithPipeControl) {
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
//for ImmediateDispatch we will send this right away, therefore this pipe control will close the level

View File

@ -37,6 +37,8 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR {
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineOrdinal, ResidencyContainer *allocationsForResidency) override;
void processResidency(ResidencyContainer *allocationsForResidency) override;
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
MemoryManager *createMemoryManager(bool enable64kbPages) override;
CommandStreamReceiver *aubCSR = nullptr;

View File

@ -55,6 +55,14 @@ void CommandStreamReceiverWithAUBDump<BaseCSR>::processResidency(ResidencyContai
}
}
template <typename BaseCSR>
void CommandStreamReceiverWithAUBDump<BaseCSR>::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
BaseCSR::activateAubSubCapture(dispatchInfo);
if (aubCSR) {
aubCSR->activateAubSubCapture(dispatchInfo);
}
}
template <typename BaseCSR>
MemoryManager *CommandStreamReceiverWithAUBDump<BaseCSR>::createMemoryManager(bool enable64kbPages) {
auto memoryManager = BaseCSR::createMemoryManager(enable64kbPages);

View File

@ -22,6 +22,11 @@
/*SIMULATION FLAGS*/
DECLARE_DEBUG_VARIABLE(std::string, TbxServer, std::string("127.0.0.1"), "TCP-IP address of TBX server")
DECLARE_DEBUG_VARIABLE(std::string, ProductFamilyOverride, std::string("unk"), "Specify product for use in AUB/TBX")
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpFilterKernelName, std::string("unk"), "Name of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpSubCaptureMode, 0, "AUB dump subcapture mode (off, toggle, filter)")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelStartIdx, 0, "Start index of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelEndIdx, -1, "End index of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpToggleCaptureOnOff, 0, "Toggle AUB capture on/off")
DECLARE_DEBUG_VARIABLE(int32_t, SetCommandStreamReceiver, 0, "Set command stream receiver")
DECLARE_DEBUG_VARIABLE(int32_t, TbxPort, 4321, "TCP-IP port of TBX server")
DECLARE_DEBUG_VARIABLE(bool, FlattenBatchBufferForAUBDump, false, "Dump multi-level batch buffers to AUB as single, flat batch buffer")
@ -59,12 +64,15 @@ DECLARE_DEBUG_VARIABLE(bool, EnableNullHardware, false, "works on Windows only,
DECLARE_DEBUG_VARIABLE(bool, ForceLinearImages, false, "Force linear images. Default is Y-tiled.")
DECLARE_DEBUG_VARIABLE(bool, ForceSLML3Config, false, "Forces L3Config with SLM for all kernels")
DECLARE_DEBUG_VARIABLE(bool, Force32bitAddressing, false, "Forces 32 bit addresses to be used in 64 bit dll")
DECLARE_DEBUG_VARIABLE(bool, ForceCsrFlushing, false, "Forces flushing of command stream receiver")
DECLARE_DEBUG_VARIABLE(bool, ForceCsrReprogramming, false, "Forces reprogramming of command stream receiver")
DECLARE_DEBUG_VARIABLE(bool, DisableStatelessToStatefulOptimization, false, "Disables stateless to stateful optimization for buffers")
DECLARE_DEBUG_VARIABLE(bool, DisableConcurrentBlockExecution, 0, "disables concurrent block kernel execution")
DECLARE_DEBUG_VARIABLE(bool, UseNewHeapAllocator, true, "Custom 4GB heap allocator is used")
DECLARE_DEBUG_VARIABLE(bool, UseNoRingFlushesKmdMode, true, "Windows only, passes flag to KMD that informs KMD to not emit any ring buffer flushes.")
DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForUseHostPtr, false, "When active all buffer allocations created with CL_MEM_USE_HOST_PTR flag will not share memory with CPU.")
DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForBuffers, false, "When active all buffer allocations will not share memory with CPU.")
/*FEATURE FLAGS*/
DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension")
DECLARE_DEBUG_VARIABLE(bool, EnablePackedYuv, true, "Enables cl_packed_yuv extension")

View File

@ -227,6 +227,14 @@ void DebugSettingsManager<DebugLevel>::dumpKernelArgs(const MultiDispatchInfo *m
}
}
template <DebugFunctionalityLevel DebugLevel>
bool DebugSettingsManager<DebugLevel>::readSetting(const char *settingName, bool defaultValue) {
if (readerImpl) {
readerImpl->getSetting(settingName, defaultValue);
}
return defaultValue;
}
template class DebugSettingsManager<DebugFunctionalityLevel::None>;
template class DebugSettingsManager<DebugFunctionalityLevel::Full>;
template class DebugSettingsManager<DebugFunctionalityLevel::RegKeys>;

View File

@ -222,6 +222,8 @@ class DebugSettingsManager {
logFileName = filename;
}
bool readSetting(const char *settingName, bool defaultValue);
protected:
SettingsReader *readerImpl = nullptr;
std::mutex mtx;

View File

@ -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();
}

View File

@ -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

View File

@ -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

View 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());
}

View File

@ -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>();

View File

@ -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};

View File

@ -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) {

View File

@ -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;

View File

@ -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

View 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;
};

View File

@ -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));
}

View File

@ -67,3 +67,10 @@ SchedulerGWS = 0
DisableZeroCopyForBuffers = false
OverrideAubDeviceId = -1
ForceCompilerUsePlatform = unk
ForceCsrFlushing = false
ForceCsrReprogramming = false
AUBDumpSubCaptureMode = 0
AUBDumpToggleCaptureOnOff = 0
AUBDumpFilterKernelName = unk
AUBDumpFilterKernelStartIdx = 0
AUBDumpFilterKernelEndIdx = -1