AUB subcapture to read file name from outside and write into several files

Add a capability for AUB subcapture feature to dump into several files
and read file name from the outside (via regkey and env variable).

Change-Id: I2d5f7945cfbc740b0316fe23b8c5ae9fd698ac57
This commit is contained in:
Milczarek, Slawomir
2018-07-09 11:31:36 +02:00
parent 7bc1bc3c9c
commit 16d04fd276
12 changed files with 760 additions and 216 deletions

View File

@@ -142,12 +142,15 @@ struct AubFileStream : public AubStream {
void writeGTT(uint32_t offset, uint64_t entry) override;
void writeMMIO(uint32_t offset, uint32_t value) override;
void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override;
bool isOpen() const { return fileHandle.is_open(); }
const std::string &getFileName() const { return fileName; }
MOCKABLE_VIRTUAL void write(const char *data, size_t size);
MOCKABLE_VIRTUAL void flush();
MOCKABLE_VIRTUAL void expectMemory(uint64_t physAddress, const void *memory, size_t size);
MOCKABLE_VIRTUAL bool addComment(const char *message);
std::ofstream fileHandle;
std::string fileName;
};
template <int addressingBits>

View File

@@ -74,10 +74,12 @@ extern const size_t g_dwordCountMax;
void AubFileStream::open(const char *filePath) {
fileHandle.open(filePath, std::ofstream::binary);
fileName.assign(filePath);
}
void AubFileStream::close() {
fileHandle.close();
fileName.clear();
}
void AubFileStream::write(const char *data, size_t size) {

View File

@@ -45,7 +45,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
void processResidency(ResidencyContainer *allocationsForResidency) override;
bool writeMemory(GraphicsAllocation &gfxAllocation);
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
@@ -59,13 +59,19 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone);
AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, bool standalone);
AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone);
~AUBCommandStreamReceiverHw() override;
AUBCommandStreamReceiverHw(const AUBCommandStreamReceiverHw &) = delete;
AUBCommandStreamReceiverHw &operator=(const AUBCommandStreamReceiverHw &) = delete;
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);
MOCKABLE_VIRTUAL void closeFile();
MOCKABLE_VIRTUAL bool isFileOpen();
MOCKABLE_VIRTUAL const std::string &getFileName();
void initializeEngine(EngineType engineType);
void freeEngineInfoTable();
MemoryManager *createMemoryManager(bool enable64kbPages) override {
this->memoryManager = new OsAgnosticMemoryManager(enable64kbPages);
@@ -84,7 +90,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
uint32_t ggttRingBuffer;
size_t sizeRingBuffer;
uint32_t tailRingBuffer;
} engineInfoTable[EngineType::NUM_ENGINES];
} engineInfoTable[EngineType::NUM_ENGINES] = {};
std::unique_ptr<AUBCommandStreamReceiver::AubFileStream> stream;
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
@@ -105,5 +111,8 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
CommandStreamReceiverType getType() override {
return CommandStreamReceiverType::CSR_AUB;
}
protected:
bool dumpAubNonWritable = false;
};
} // namespace OCLRT

View File

@@ -35,10 +35,10 @@
namespace OCLRT {
template <typename GfxFamily>
AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, bool standalone)
AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone)
: BaseClass(hwInfoIn),
stream(std::unique_ptr<AUBCommandStreamReceiver::AubFileStream>(new AUBCommandStreamReceiver::AubFileStream())),
subCaptureManager(std::unique_ptr<AubSubCaptureManager>(new AubSubCaptureManager())),
subCaptureManager(std::unique_ptr<AubSubCaptureManager>(new AubSubCaptureManager(fileName))),
standalone(standalone) {
this->dispatchMode = DispatchMode::BatchedDispatch;
if (DebugManager.flags.CsrDispatchMode.get()) {
@@ -52,16 +52,6 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const Hardware
this->subCaptureManager->subCaptureFilter.dumpKernelName = DebugManager.flags.AUBDumpFilterKernelName.get();
}
}
for (auto &engineInfo : engineInfoTable) {
engineInfo.pLRCA = nullptr;
engineInfo.ggttLRCA = 0u;
engineInfo.pGlobalHWStatusPage = nullptr;
engineInfo.ggttHWSP = 0u;
engineInfo.pRingBuffer = nullptr;
engineInfo.ggttRingBuffer = 0u;
engineInfo.sizeRingBuffer = 0;
engineInfo.tailRingBuffer = 0;
}
auto debugDeviceId = DebugManager.flags.OverrideAubDeviceId.get();
this->aubDeviceId = debugDeviceId == -1
? hwInfoIn.capabilityTable.aubDeviceId
@@ -70,21 +60,8 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const Hardware
template <typename GfxFamily>
AUBCommandStreamReceiverHw<GfxFamily>::~AUBCommandStreamReceiverHw() {
stream->close();
for (auto &engineInfo : engineInfoTable) {
alignedFree(engineInfo.pLRCA);
gttRemap.unmap(engineInfo.pLRCA);
engineInfo.pLRCA = nullptr;
alignedFree(engineInfo.pGlobalHWStatusPage);
gttRemap.unmap(engineInfo.pGlobalHWStatusPage);
engineInfo.pGlobalHWStatusPage = nullptr;
alignedFree(engineInfo.pRingBuffer);
gttRemap.unmap(engineInfo.pRingBuffer);
engineInfo.pRingBuffer = nullptr;
}
closeFile();
freeEngineInfoTable();
}
template <typename GfxFamily>
@@ -109,6 +86,37 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initEngineMMIO(EngineType engineType
}
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::initFile(const std::string &fileName) {
stream.reset(new AUBCommandStreamReceiver::AubFileStream());
// Open our file
stream->open(fileName.c_str());
if (!stream->isOpen()) {
// This DEBUG_BREAK_IF most probably means you are not executing aub tests with correct current directory (containing aub_out folder)
// try adding <familycodename>_aub
DEBUG_BREAK_IF(true);
}
// Add the file header
stream->init(AubMemDump::SteppingValues::A, aubDeviceId);
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::closeFile() {
stream->close();
}
template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::isFileOpen() {
return stream->isOpen();
}
template <typename GfxFamily>
const std::string &AUBCommandStreamReceiverHw<GfxFamily>::getFileName() {
return stream->getFileName();
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineType) {
auto mmioBase = getCsTraits(engineType).mmioBase;
@@ -207,19 +215,29 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
}
template <typename GfxFamily>
CommandStreamReceiver *AUBCommandStreamReceiverHw<GfxFamily>::create(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone) {
auto csr = new AUBCommandStreamReceiverHw<GfxFamily>(hwInfoIn, standalone);
void AUBCommandStreamReceiverHw<GfxFamily>::freeEngineInfoTable() {
for (auto &engineInfo : engineInfoTable) {
alignedFree(engineInfo.pLRCA);
gttRemap.unmap(engineInfo.pLRCA);
engineInfo.pLRCA = nullptr;
// Open our file
csr->stream->open(fileName.c_str());
alignedFree(engineInfo.pGlobalHWStatusPage);
gttRemap.unmap(engineInfo.pGlobalHWStatusPage);
engineInfo.pGlobalHWStatusPage = nullptr;
if (!csr->stream->fileHandle.is_open()) {
// This DEBUG_BREAK_IF most probably means you are not executing aub tests with correct current directory (containing aub_out folder)
// try adding <familycodename>_aub
DEBUG_BREAK_IF(true);
alignedFree(engineInfo.pRingBuffer);
gttRemap.unmap(engineInfo.pRingBuffer);
engineInfo.pRingBuffer = nullptr;
}
}
template <typename GfxFamily>
CommandStreamReceiver *AUBCommandStreamReceiverHw<GfxFamily>::create(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone) {
auto csr = new AUBCommandStreamReceiverHw<GfxFamily>(hwInfoIn, fileName, standalone);
if (!csr->subCaptureManager->isSubCaptureMode()) {
csr->initFile(fileName);
}
// Add the file header.
csr->stream->init(AubMemDump::SteppingValues::A, csr->aubDeviceId);
return csr;
}
@@ -227,14 +245,6 @@ CommandStreamReceiver *AUBCommandStreamReceiverHw<GfxFamily>::create(const Hardw
template <typename GfxFamily>
FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer,
EngineType engineType, ResidencyContainer *allocationsForResidency) {
uint32_t mmioBase = getCsTraits(engineType).mmioBase;
auto &engineInfo = engineInfoTable[engineType];
if (!engineInfo.pLRCA) {
initializeEngine(engineType);
DEBUG_BREAK_IF(!engineInfo.pLRCA);
}
if (subCaptureManager->isSubCaptureMode()) {
if (!subCaptureManager->isSubCaptureEnabled()) {
if (this->standalone) {
@@ -244,6 +254,14 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
}
}
uint32_t mmioBase = getCsTraits(engineType).mmioBase;
auto &engineInfo = engineInfoTable[engineType];
if (!engineInfo.pLRCA) {
initializeEngine(engineType);
DEBUG_BREAK_IF(!engineInfo.pLRCA);
}
// Write our batch buffer
auto pBatchBuffer = ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset);
auto currentOffset = batchBuffer.usedSize;
@@ -417,7 +435,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
}
if (subCaptureManager->isSubCaptureMode()) {
subCaptureManager->deactivateSubCapture();
subCaptureManager->disableSubCapture();
}
stream->flush();
@@ -540,23 +558,25 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
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;
}
}
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations();
for (auto &gfxAllocation : residencyAllocations) {
if (dumpAubNonWritable) {
gfxAllocation->clearTypeAubNonWritable();
}
if (!writeMemory(*gfxAllocation)) {
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || gfxAllocation->isTypeAubNonWritable()));
}
gfxAllocation->residencyTaskCount = this->taskCount + 1;
}
dumpAubNonWritable = false;
}
template <typename GfxFamily>
@@ -569,7 +589,20 @@ void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
subCaptureManager->activateSubCapture(dispatchInfo);
bool active = subCaptureManager->activateSubCapture(dispatchInfo);
if (active) {
std::string subCaptureFile = subCaptureManager->getSubCaptureFileName(dispatchInfo);
if (isFileOpen()) {
if (subCaptureFile != getFileName()) {
closeFile();
freeEngineInfoTable();
}
}
if (!isFileOpen()) {
initFile(subCaptureFile);
dumpAubNonWritable = true;
}
}
if (this->standalone) {
if (DebugManager.flags.ForceCsrFlushing.get()) {
this->flushBatchedSubmissions();

View File

@@ -27,15 +27,16 @@
namespace OCLRT {
AubSubCaptureManager::AubSubCaptureManager() {
AubSubCaptureManager::AubSubCaptureManager(const std::string &fileName)
: initialFileName(fileName) {
settingsReader.reset(SettingsReader::createOsReader(true));
}
AubSubCaptureManager::~AubSubCaptureManager() = default;
void AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchInfo) {
bool AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchInfo) {
if (dispatchInfo.empty()) {
return;
return false;
}
subCaptureWasActive = subCaptureIsActive;
@@ -47,19 +48,41 @@ void AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchI
break;
case SubCaptureMode::Filter:
subCaptureIsActive = isSubCaptureFilterActive(dispatchInfo, kernelCurrentIdx);
kernelCurrentIdx++;
break;
default:
DEBUG_BREAK_IF(false);
break;
}
kernelCurrentIdx++;
setDebugManagerFlags();
return subCaptureIsActive;
}
void AubSubCaptureManager::deactivateSubCapture() {
subCaptureWasActive = false;
subCaptureIsActive = false;
const std::string &AubSubCaptureManager::getSubCaptureFileName(const MultiDispatchInfo &dispatchInfo) {
if (useExternalFileName) {
currentFileName = getExternalFileName();
}
switch (subCaptureMode) {
case SubCaptureMode::Filter:
if (currentFileName.empty()) {
currentFileName = generateFilterFileName();
useExternalFileName = false;
}
break;
case SubCaptureMode::Toggle:
if (currentFileName.empty()) {
currentFileName = generateToggleFileName(dispatchInfo);
useExternalFileName = false;
}
break;
default:
DEBUG_BREAK_IF(false);
break;
}
return currentFileName;
}
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const {
@@ -71,6 +94,33 @@ bool AubSubCaptureManager::isSubCaptureToggleActive() const {
return settingsReader->getSetting("AUBDumpToggleCaptureOnOff", false);
}
std::string AubSubCaptureManager::getExternalFileName() const {
return settingsReader->getSetting("AUBDumpToggleFileName", std::string(""));
}
std::string AubSubCaptureManager::generateFilterFileName() const {
std::string baseFileName = initialFileName.substr(0, initialFileName.length() - strlen(".aub"));
std::string filterFileName = baseFileName + "_filter";
filterFileName += "_from_" + std::to_string(subCaptureFilter.dumpKernelStartIdx);
filterFileName += "_to_" + std::to_string(subCaptureFilter.dumpKernelEndIdx);
if (!subCaptureFilter.dumpKernelName.empty()) {
filterFileName += "_" + subCaptureFilter.dumpKernelName;
}
filterFileName += ".aub";
return filterFileName;
}
std::string AubSubCaptureManager::generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const {
std::string baseFileName = initialFileName.substr(0, initialFileName.length() - strlen(".aub"));
std::string toggleFileName = baseFileName + "_toggle";
toggleFileName += "_from_" + std::to_string(kernelCurrentIdx - 1);
if (!dispatchInfo.empty()) {
toggleFileName += "_" + dispatchInfo.begin()->getKernel()->getKernelInfo().name;
}
toggleFileName += ".aub";
return toggleFileName;
}
bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const {
DEBUG_BREAK_IF(dispatchInfo.size() > 1);
auto kernelName = dispatchInfo.begin()->getKernel()->getKernelInfo().name;

View File

@@ -45,25 +45,36 @@ class AubSubCaptureManager {
inline bool isSubCaptureMode() const {
return subCaptureMode > SubCaptureMode::Off;
}
inline bool isSubCaptureEnabled() const {
return subCaptureIsActive || subCaptureWasActive;
}
inline void disableSubCapture() {
subCaptureIsActive = subCaptureWasActive = false;
};
void activateSubCapture(const MultiDispatchInfo &dispatchInfo);
void deactivateSubCapture();
bool activateSubCapture(const MultiDispatchInfo &dispatchInfo);
AubSubCaptureManager();
const std::string &getSubCaptureFileName(const MultiDispatchInfo &dispatchInfo);
AubSubCaptureManager(const std::string &fileName);
virtual ~AubSubCaptureManager();
protected:
MOCKABLE_VIRTUAL bool isSubCaptureToggleActive() const;
bool isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const;
MOCKABLE_VIRTUAL std::string getExternalFileName() const;
MOCKABLE_VIRTUAL std::string generateFilterFileName() const;
MOCKABLE_VIRTUAL std::string generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const;
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const;
void setDebugManagerFlags() const;
bool subCaptureIsActive = false;
bool subCaptureWasActive = false;
uint32_t kernelCurrentIdx = 0;
bool useExternalFileName = true;
std::string initialFileName;
std::string currentFileName;
std::unique_ptr<SettingsReader> settingsReader;
};
} // namespace OCLRT

View File

@@ -24,6 +24,7 @@ DECLARE_DEBUG_VARIABLE(std::string, TbxServer, std::string("127.0.0.1"), "TCP-IP
DECLARE_DEBUG_VARIABLE(std::string, ProductFamilyOverride, std::string("unk"), "Specify product for use in AUB/TBX")
DECLARE_DEBUG_VARIABLE(std::string, ForceCompilerUsePlatform, std::string("unk"), "Specify product for use in compiler interface")
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpFilterKernelName, std::string("unk"), "Name of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpToggleFileName, std::string("unk"), "Name of file to save AUB in toggle mode")
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")

View File

@@ -39,6 +39,16 @@ std::string getAubFileName(const OCLRT::Device *pDevice, const std::string baseN
typedef Test<DeviceFixture> AubMemDumpTests;
HWTEST_F(AubMemDumpTests, givenAubFileStreamWhenOpenAndCloseIsCalledThenFileNameIsReportedCorrectly) {
AUBCommandStreamReceiver::AubFileStream aubFile;
std::string fileName = "file_name.aub";
aubFile.open(fileName.c_str());
EXPECT_STREQ(fileName.c_str(), aubFile.getFileName().c_str());
aubFile.close();
EXPECT_STREQ("", aubFile.getFileName().c_str());
}
HWTEST_F(AubMemDumpTests, testHeader) {
typedef typename AUBFamilyMapper<FamilyType>::AUB AUB;
std::string filePath(folderAUB);

View File

@@ -33,6 +33,8 @@
#include "unit_tests/mocks/mock_aub_subcapture_manager.h"
#include "unit_tests/mocks/mock_gmm.h"
#include "unit_tests/mocks/mock_csr.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/mocks/mock_mdi.h"
#include <memory>
@@ -51,7 +53,8 @@ typedef Test<DeviceFixture> AubCommandStreamReceiverTests;
template <typename GfxFamily>
struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
MockAubCsr(const HardwareInfo &hwInfoIn, bool standalone) : AUBCommandStreamReceiverHw<GfxFamily>(hwInfoIn, standalone){};
MockAubCsr(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone)
: AUBCommandStreamReceiverHw<GfxFamily>(hwInfoIn, fileName, standalone){};
DispatchMode peekDispatchMode() const {
return this->dispatchMode;
@@ -68,17 +71,42 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
void flushBatchedSubmissions() override {
flushBatchedSubmissionsCalled = true;
}
void initProgrammingFlags() override {
initProgrammingFlagsCalled = true;
}
bool flushBatchedSubmissionsCalled = false;
bool initProgrammingFlagsCalled = false;
void initFile(const std::string &fileName) override {
fileIsOpen = true;
openFileName = fileName;
}
void closeFile() override {
fileIsOpen = false;
openFileName = "";
}
bool isFileOpen() override {
return fileIsOpen;
}
const std::string &getFileName() override {
return openFileName;
}
bool fileIsOpen = false;
std::string openFileName = "";
MOCK_METHOD0(addPatchInfoComments, bool(void));
};
template <typename GfxFamily>
struct MockAubCsrToTestDumpAubNonWritable : public AUBCommandStreamReceiverHw<GfxFamily> {
using AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw;
using AUBCommandStreamReceiverHw<GfxFamily>::dumpAubNonWritable;
bool writeMemory(GraphicsAllocation &gfxAllocation) override {
return true;
}
};
struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream {
void flush() override {
flushCalled = true;
@@ -133,28 +161,38 @@ TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenTypeIsChe
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenItIsCreatedWithDefaultSettingsThenItHasBatchedDispatchModeEnabled) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.CsrDispatchMode.set(0);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
EXPECT_EQ(DispatchMode::BatchedDispatch, aubCsr->peekDispatchMode());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenItIsCreatedWithDebugSettingsThenItHasProperDispatchModeEnabled) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
EXPECT_EQ(DispatchMode::ImmediateDispatch, aubCsr->peekDispatchMode());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreatedThenMemoryManagerIsNotNull) {
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
EXPECT_NE(nullptr, memoryManager.get());
aubCsr->setMemoryManager(nullptr);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenItIsCreatedThenFileIsNotCreated) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter));
HardwareInfo hwInfo = *platformDevices[0];
std::string fileName = "file_name.aub";
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(hwInfo, fileName, true)));
EXPECT_NE(nullptr, aubCsr);
EXPECT_FALSE(aubCsr->isFileOpen());
}
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));
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());
@@ -166,15 +204,36 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrInSubCaptureModeWhenItIsCreat
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));
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, givenAubCommandStreamReceiverWhenInitFileIsCalledWithInvalidFileNameThenFileIsNotOpened) {
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true));
std::string invalidFileName = "";
aubCsr->initFile(invalidFileName);
EXPECT_FALSE(aubCsr->isFileOpen());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenInitFileIsCalledThenFileIsOpenedAndFileNameIsStored) {
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true));
std::string fileName = "file_name.aub";
aubCsr->initFile(fileName);
EXPECT_TRUE(aubCsr->isFileOpen());
EXPECT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str());
aubCsr->closeFile();
EXPECT_FALSE(aubCsr->isFileOpen());
EXPECT_TRUE(aubCsr->getFileName().empty());
}
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentCalledMultipleTimesAffectsResidencyOnce) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -203,9 +262,63 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldInitializeEngineInfoTable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(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_NE(nullptr, aubCsr->engineInfoTable[engineType].pLRCA);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineType].pGlobalHWStatusPage);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineType].pRingBuffer);
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldntInitializeEngineInfoTable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("");
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManagerMock->disableSubCapture();
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(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_EQ(nullptr, aubCsr->engineInfoTable[engineType].pLRCA);
EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pGlobalHWStatusPage);
EXPECT_EQ(nullptr, aubCsr->engineInfoTable[engineType].pRingBuffer);
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldLeaveProperRingTailAlignment) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
@@ -235,7 +348,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneModeWhenFlushIsCalledThenItShouldNotUpdateHwTagWithLatestSentTaskCount) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -264,7 +377,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldUpdateHwTagWithLatestSentTaskCount) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -293,12 +406,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldUpdateHwTagWithLatestSentTaskCount) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("");
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManagerMock->deactivateSubCapture();
aubSubCaptureManagerMock->disableSubCapture();
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
@@ -328,12 +441,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneAndSubCaptureModeWhenFlushIsCalledButSubCaptureIsDisabledThenItShouldNotUpdateHwTagWithLatestSentTaskCount) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("");
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManagerMock->deactivateSubCapture();
aubSubCaptureManagerMock->disableSubCapture();
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
@@ -364,11 +477,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenFlushIsCalledAndSubCaptureIsEnabledThenItShouldDeactivateSubCapture) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
memoryManager.reset(aubCsr->createMemoryManager(false));
const DispatchInfo dispatchInfo;
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("");
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManagerMock->setSubCaptureToggleActive(true);
aubSubCaptureManagerMock->activateSubCapture(dispatchInfo);
@@ -392,7 +505,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnCommandBufferAllocation) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
@@ -422,7 +535,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", false));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -444,7 +557,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
@@ -484,7 +597,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnResidencyAllocations) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -511,11 +624,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenFlushIsCalledAndSubCaptureIsEnabledThenItShouldCallMakeResidentOnCommandBufferAndResidencyAllocations) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
const DispatchInfo dispatchInfo;
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("");
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManagerMock->setSubCaptureToggleActive(true);
aubSubCaptureManagerMock->activateSubCapture(dispatchInfo);
@@ -559,7 +672,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationIsCreatedThenItDoesntHaveTypeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -571,7 +684,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledOnDefaultAllocationThenAllocationTypeShouldNotBeMadeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxDefaultAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -586,7 +699,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledOnBufferAndImageAllocationsThenAllocationsTypesShouldBeMadeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
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);
@@ -605,40 +718,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
memoryManager->freeGraphicsMemory(gfxImageAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModWhenProcessResidencyIsCalledWhileSubcaptureIsEnabledThenAllocationsTypesShouldBeMadeNonAubWritable) {
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModWhenProcessResidencyIsCalledWithDumpAubNonWritableFlagThenAllocationsTypesShouldBeMadeAubWritable) {
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::AllocationType::BUFFER);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::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));
std::unique_ptr<MockAubCsrToTestDumpAubNonWritable<FamilyType>> aubCsr(new MockAubCsrToTestDumpAubNonWritable<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -647,11 +730,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock();
aubSubCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManagerMock->deactivateSubCapture();
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
aubCsr->dumpAubNonWritable = true;
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(&allocationsForResidency);
@@ -663,9 +742,33 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
memoryManager->freeGraphicsMemory(gfxImageAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledWithoutDumpAubWritableFlagThenAllocationsTypesShouldBeKeptNonAubWritable) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsrToTestDumpAubNonWritable<FamilyType>> aubCsr(new MockAubCsrToTestDumpAubNonWritable<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
auto gfxImageAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxImageAllocation->setAllocationType(GraphicsAllocation::AllocationType::IMAGE | GraphicsAllocation::AllocationType::NON_AUB_WRITABLE);
aubCsr->dumpAubNonWritable = false;
ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation};
aubCsr->processResidency(&allocationsForResidency);
EXPECT_TRUE(gfxBufferAllocation->isTypeAubNonWritable());
EXPECT_TRUE(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));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -677,7 +780,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationTypeIsNonAubWritableThenWriteMemoryIsNotAllowed) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
@@ -689,17 +792,159 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationSizeIsZeroThenWriteMemoryIsNotAllowed) {
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
GraphicsAllocation gfxAllocation((void *)0x1234, 0);
EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation));
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureIsActivatedThenFileIsOpened) {
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
ASSERT_FALSE(aubCsr->isFileOpen());
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_TRUE(aubCsr->isFileOpen());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureRemainsActivedThenTheSameFileShouldBeKeptOpened) {
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
std::string fileName = aubCsr->subCaptureManager->getSubCaptureFileName(multiDispatchInfo);
aubCsr->initFile(fileName);
ASSERT_TRUE(aubCsr->isFileOpen());
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_TRUE(aubCsr->isFileOpen());
EXPECT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureIsActivatedWithNewFileNameThenNewFileShouldBeReOpened) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
std::string newFileName = "new_file_name.aub";
auto subCaptureManagerMock = new AubSubCaptureManagerMock("");
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
subCaptureManagerMock->setSubCaptureIsActive(false);
subCaptureManagerMock->setSubCaptureToggleActive(true);
subCaptureManagerMock->setExternalFileName(newFileName);
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
std::string fileName = "file_name.aub";
aubCsr->initFile(fileName);
ASSERT_TRUE(aubCsr->isFileOpen());
ASSERT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str());
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_TRUE(aubCsr->isFileOpen());
EXPECT_STRNE(fileName.c_str(), aubCsr->getFileName().c_str());
EXPECT_STREQ(newFileName.c_str(), aubCsr->getFileName().c_str());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureIsActivatedForNewFileThenOldEngineInfoTableShouldBeFreed) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
std::string newFileName = "new_file_name.aub";
auto subCaptureManagerMock = new AubSubCaptureManagerMock("");
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
subCaptureManagerMock->setSubCaptureIsActive(false);
subCaptureManagerMock->setSubCaptureToggleActive(true);
subCaptureManagerMock->setExternalFileName(newFileName);
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
std::string fileName = "file_name.aub";
aubCsr->initFile(fileName);
ASSERT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str());
aubCsr->activateAubSubCapture(multiDispatchInfo);
ASSERT_STREQ(newFileName.c_str(), aubCsr->getFileName().c_str());
for (auto &engineInfo : aubCsr->engineInfoTable) {
EXPECT_EQ(nullptr, engineInfo.pLRCA);
EXPECT_EQ(nullptr, engineInfo.pGlobalHWStatusPage);
EXPECT_EQ(nullptr, engineInfo.pRingBuffer);
}
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureIsActivatedThenForceDumpingAllocationsAubNonWritable) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsrToTestDumpAubNonWritable<FamilyType>> aubCsr(new MockAubCsrToTestDumpAubNonWritable<FamilyType>(*platformDevices[0], "", false));
auto subCaptureManagerMock = new AubSubCaptureManagerMock("");
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
subCaptureManagerMock->setSubCaptureIsActive(false);
subCaptureManagerMock->setSubCaptureToggleActive(true);
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_TRUE(aubCsr->dumpAubNonWritable);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureRemainsActivatedThenDontForceDumpingAllocationsAubNonWritable) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsrToTestDumpAubNonWritable<FamilyType>> aubCsr(new MockAubCsrToTestDumpAubNonWritable<FamilyType>(*platformDevices[0], "", false));
auto subCaptureManagerMock = new AubSubCaptureManagerMock("");
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
subCaptureManagerMock->setSubCaptureIsActive(false);
subCaptureManagerMock->setSubCaptureToggleActive(true);
aubCsr->subCaptureManager.reset(subCaptureManagerMock);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->initFile(aubCsr->subCaptureManager->getSubCaptureFileName(multiDispatchInfo));
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_FALSE(aubCsr->dumpAubNonWritable);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenSubCaptureModeRemainsDeactivatedThenSubCaptureIsDisabled) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
auto subCaptureManagerMock = new AubSubCaptureManagerMock("");
subCaptureManagerMock->subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
subCaptureManagerMock->setSubCaptureIsActive(false);
subCaptureManagerMock->setSubCaptureToggleActive(false);
@@ -713,32 +958,36 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenSubCaptureIsToggledOnThenSubCaptureGetsEnabled) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false));
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureRemainsDeactivatedThenNeitherProgrammingFlagsAreInitializedNorCsrIsFlushed) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled);
@@ -746,16 +995,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureRemainsActivatedThenNeitherProgrammingFlagsAreInitializedNorCsrIsFlushed) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled);
@@ -763,16 +1014,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureGetsActivatedThenProgrammingFlagsAreInitialized) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
EXPECT_TRUE(aubCsr->initProgrammingFlagsCalled);
@@ -780,25 +1033,26 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneAndSubCaptureModeWhenSubCaptureGetsDeactivatedThenCsrIsFlushed) {
DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
auto subCaptureManagerMock = new AubSubCaptureManagerMock();
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);
MockKernelWithInternals kernelInternals(*pDevice);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
aubCsr->activateAubSubCapture(multiDispatchInfo);
EXPECT_TRUE(aubCsr->flushBatchedSubmissionsCalled);
EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferFlatteningInImmediateDispatchModeThenNewCombinedBatchBufferIsCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
@@ -826,7 +1080,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferInImmediateDispatchModeAndNoChainedBatchBufferThenCombinedBatchBufferIsNotCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
@@ -848,7 +1102,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferAndNotImmediateOrBatchedDispatchModeThenCombinedBatchBufferIsNotCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
@@ -878,7 +1132,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenRegiste
typedef typename FamilyType::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBufferAllocation = memoryManager->allocateGraphicsMemory(4096);
@@ -903,7 +1157,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenRegiste
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenRemovePatchInfoDataIsCalledThenElementIsRemovedFromPatchInfoList) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
PatchInfoData patchInfoData(0xA000, 0x0, PatchInfoAllocationType::KernelArg, 0xB000, 0x0, PatchInfoAllocationType::Default);
@@ -922,7 +1176,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddGucS
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
std::unique_ptr<char> batchBuffer(new char[1024]);
@@ -941,7 +1195,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::BatchedDispatch));
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
CommandChunk chunk1;
@@ -1011,7 +1265,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefaultDebugConfigThenExpectFlattenBatchBufferIsNotCalled) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
@@ -1039,7 +1293,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch));
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
@@ -1074,7 +1328,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::ImmediateDispatch));
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
@@ -1101,7 +1355,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::BatchedDispatch));
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
@@ -1128,7 +1382,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1148,7 +1402,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoCommentsIsNotCalled) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1168,7 +1422,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenNoPatchInfoDataObjectsThenCommentsAreEmpty) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1202,7 +1456,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenNoPat
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenFileStreamShouldBeFlushed) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", false));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1227,7 +1481,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenFirstAddCommentsFailsThenFunctionReturnsFalse) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1251,7 +1505,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenFirst
HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSecondAddCommentsFailsThenFunctionReturnsFalse) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1275,7 +1529,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSecon
HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenPatchInfoDataObjectsAddedThenCommentsAreNotEmpty) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1354,7 +1608,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenPatch
HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSourceAllocationIsNullThenDoNotAddToAllocationsList) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1415,7 +1669,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSourc
HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenTargetAllocationIsNullThenDoNotAddToAllocationsList) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
@@ -1476,7 +1730,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenTarge
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForEmptyPatchInfoListThenIndirectPatchCommandBufferIsNotCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
size_t indirectPatchCommandsSize = 0u;
@@ -1490,7 +1744,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndi
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForNonEmptyPatchInfoListThenIndirectPatchCommandBufferIsCreated) {
typedef typename FamilyType::MI_STORE_DATA_IMM MI_STORE_DATA_IMM;
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
PatchInfoData patchInfo1(0xA000, 0u, PatchInfoAllocationType::KernelArg, 0x6000, 0x100, PatchInfoAllocationType::IndirectObjectHeap);
@@ -1517,7 +1771,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddBatc
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(aubCsr->createMemoryManager(false));
MI_BATCH_BUFFER_START bbStart;
@@ -1534,7 +1788,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddBatc
HWTEST_F(AubCommandStreamReceiverTests, givenFlatBatchBufferHelperWhenSettingSroreQwordOnSDICommandThenAppropriateBitIsSet) {
typedef typename FamilyType::MI_STORE_DATA_IMM MI_STORE_DATA_IMM;
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
MI_STORE_DATA_IMM cmd;
cmd.init();
@@ -1583,7 +1837,7 @@ class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryMan
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnImageWithNoHostPtrThenResourceShouldBeLockedToGetCpuAddress) {
std::unique_ptr<OsAgnosticMemoryManagerForImagesWithNoHostPtr> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true));
memoryManager.reset(new OsAgnosticMemoryManagerForImagesWithNoHostPtr);
aubCsr->setMemoryManager(memoryManager.get());
@@ -1613,7 +1867,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
HWTEST_F(AubCommandStreamReceiverTests, givenNoDbgDeviceIdFlagWhenAubCsrIsCreatedThenUseDefaultDeviceId) {
const HardwareInfo &hwInfoIn = *platformDevices[0];
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, "", true));
EXPECT_EQ(hwInfoIn.capabilityTable.aubDeviceId, aubCsr->aubDeviceId);
}
@@ -1621,13 +1875,13 @@ HWTEST_F(AubCommandStreamReceiverTests, givenDbgDeviceIdFlagIsSetWhenAubCsrIsCre
DebugManagerStateRestore stateRestore;
DebugManager.flags.OverrideAubDeviceId.set(9); //this is Hsw, not used
const HardwareInfo &hwInfoIn = *platformDevices[0];
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, "", true));
EXPECT_EQ(9u, aubCsr->aubDeviceId);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetGTTDataIsCalledThenLocalMemoryShouldBeDisabled) {
const HardwareInfo &hwInfoIn = *platformDevices[0];
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, "", true));
AubGTTData data = {};
aubCsr->getGTTData(nullptr, data);
EXPECT_TRUE(data.present);

View File

@@ -49,16 +49,27 @@ struct AubSubCaptureTest : public DeviceFixture,
DebugManagerStateRestore *dbgRestore;
};
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureToggleRegKeyIsUnspecifiedThenSubCaptureIsToggledOffByDefault) {
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureToggleCaptureOnOffIsUnspecifiedThenSubCaptureIsToggledOffByDefault) {
struct AubSubCaptureManagerWithToggleActiveMock : public AubSubCaptureManager {
using AubSubCaptureManager::AubSubCaptureManager;
using AubSubCaptureManager::isSubCaptureToggleActive;
} aubSubCaptureManagerWithToggleActiveMock;
} aubSubCaptureManagerWithToggleActiveMock("");
EXPECT_FALSE(aubSubCaptureManagerWithToggleActiveMock.isSubCaptureToggleActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureToggleFileNameIsUnspecifiedThenEmptyExternalFileNameIsReturnedByDefault) {
struct AubSubCaptureManagerWithToggleActiveMock : public AubSubCaptureManager {
using AubSubCaptureManager::AubSubCaptureManager;
using AubSubCaptureManager::getExternalFileName;
} aubSubCaptureManagerWithToggleActiveMock("");
EXPECT_STREQ("", aubSubCaptureManagerWithToggleActiveMock.getExternalFileName().c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenItIsCreatedThenItIsInitializedWithDefaults) {
AubSubCaptureManagerMock aubSubCaptureManager;
std::string initialFileName = "initial_file_name.aub";
AubSubCaptureManagerMock aubSubCaptureManager(initialFileName);
EXPECT_EQ(AubSubCaptureManager::SubCaptureMode::Off, aubSubCaptureManager.subCaptureMode);
EXPECT_STREQ("", aubSubCaptureManager.subCaptureFilter.dumpKernelName.c_str());
@@ -68,54 +79,76 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenItIsCreatedThenItIsInitializ
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
EXPECT_FALSE(aubSubCaptureManager.wasSubCaptureActive());
EXPECT_EQ(0u, aubSubCaptureManager.getKernelCurrentIndex());
EXPECT_TRUE(aubSubCaptureManager.getUseExternalFileName());
EXPECT_STREQ(initialFileName.c_str(), aubSubCaptureManager.getInitialFileName().c_str());
EXPECT_STREQ("", aubSubCaptureManager.getCurrentFileName().c_str());
EXPECT_NE(nullptr, aubSubCaptureManager.getSettingsReader());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledWithEmptyDispatchInfoThenSubCaptureIsInactive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
MultiDispatchInfo dispatchInfo;
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledWithNonEmptyDispatchInfoThenKernelCurrentIndexIsIncremented) {
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
uint32_t kernelCurrentIndex = aubSubCaptureManager.getKernelCurrentIndex();
ASSERT_EQ(0u, kernelCurrentIndex);
aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_EQ(kernelCurrentIndex + 1, aubSubCaptureManager.getKernelCurrentIndex());
aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_EQ(kernelCurrentIndex + 2, aubSubCaptureManager.getKernelCurrentIndex());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenActivateSubCaptureIsCalledButSubCaptureModeIsOffThenSubCaptureIsInactive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Off;
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenActivateSubCaptureIsCalledAndSubCaptureIsToggledOnThenSubCaptureIsActive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManager.setSubCaptureToggleActive(true);
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_TRUE(active);
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenActivateSubCaptureIsCalledButSubCaptureIsToggledOffThenSubCaptureIsInactive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManager.setSubCaptureToggleActive(false);
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterIsDefaultThenSubCaptureIsActive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -123,12 +156,13 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptu
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_TRUE(active);
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithValidKernelStartIndexIsSpecifiedThenSubCaptureIsActive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -137,12 +171,13 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptu
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 0;
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_TRUE(active);
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelStartIndexIsSpecifiedThenSubCaptureIsInactive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -151,12 +186,13 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptu
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 1;
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelEndIndexIsSpecifiedThenSubCaptureIsInactive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -166,12 +202,13 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptu
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx = 0;
aubSubCaptureManager.setKernelCurrentIndex(1);
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithValidKernelNameIsSpecifiedThenSubCaptureIsActive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -180,12 +217,13 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptu
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelName = "kernel_name";
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_TRUE(active);
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptureIsCalledAndSubCaptureFilterWithInvalidKernelNameIsSpecifiedThenSubCaptureIsInactive) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -194,23 +232,24 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenActivateSubCaptu
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelName = "invalid_kernel_name";
aubSubCaptureManager.activateSubCapture(dispatchInfo);
bool active = aubSubCaptureManager.activateSubCapture(dispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenDeactivateSubCaptureIsCalledThenSubCaptureActiveStatesAreCleared) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
aubSubCaptureManager.setSubCaptureIsActive(true);
aubSubCaptureManager.setSubCaptureWasActive(true);
aubSubCaptureManager.deactivateSubCapture();
aubSubCaptureManager.disableSubCapture();
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
EXPECT_FALSE(aubSubCaptureManager.wasSubCaptureActive());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsInactiveThenMakeEachEnqueueBlocking) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -228,7 +267,7 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsInactiveThenM
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsActiveThenDontMakeEachEnqueueBlockingAndForceCsrReprogramming) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -246,7 +285,7 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsActiveThenDont
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsActiveThenDontMakeEachEnqueueBlocking) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -264,7 +303,7 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureKeepsActiveThenDon
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsInactiveThenMakeEachEnqueueBlockingAndForceCsrFlushing) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
@@ -282,7 +321,7 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureGetsInactiveThenMa
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureActiveStatesAreDeterminedThenIsSubCaptureFunctionReturnCorrectValues) {
AubSubCaptureManagerMock aubSubCaptureManager;
AubSubCaptureManagerMock aubSubCaptureManager("");
aubSubCaptureManager.setSubCaptureWasActive(false);
aubSubCaptureManager.setSubCaptureIsActive(false);
@@ -300,3 +339,113 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerWhenSubCaptureActiveStatesAreDet
aubSubCaptureManager.setSubCaptureWasActive(true);
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureEnabled());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInOffModeWhenGetSubCaptureFileNameIsCalledThenItReturnsEmptyFileName) {
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
EXPECT_STREQ("", aubSubCaptureManager.getSubCaptureFileName(dispatchInfo).c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsSpecifiedThenItReturnsItsName) {
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
std::string externalFileName = "external_file_name.aub";
aubSubCaptureManager.setExternalFileName(externalFileName);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
EXPECT_STREQ(externalFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(dispatchInfo).c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsSpecifiedThenItReturnsItsName) {
AubSubCaptureManagerMock aubSubCaptureManager("");
DispatchInfo dispatchInfo;
std::string externalFileName = "external_file_name.aub";
aubSubCaptureManager.setExternalFileName(externalFileName);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
EXPECT_STREQ(externalFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(dispatchInfo).c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsNotSpecifiedThenItGeneratesFilterFileName) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
DispatchInfo dispatchInfo;
std::string externalFileName = "";
aubSubCaptureManager.setExternalFileName(externalFileName);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
EXPECT_STREQ(filterFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(dispatchInfo).c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFileNameIsCalledAndExternalFileNameIsNotSpecifiedThenItGeneratesToggleFileName) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
DispatchInfo dispatchInfo;
MockKernel kernel(&program, kernelInfo, *pDevice);
dispatchInfo.setKernel(&kernel);
MultiDispatchInfo multiDispatchInfo(dispatchInfo);
std::string externalFileName = "";
aubSubCaptureManager.setExternalFileName(externalFileName);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
std::string toggleFileName = aubSubCaptureManager.generateToggleFileName(multiDispatchInfo);
EXPECT_STREQ(toggleFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGetSubCaptureFileNameIsCalledManyTimesAndExternalFileNameIsNotSpecifiedThenItGeneratesFilterFileNameOnceOnly) {
struct AubSubCaptureManagerMockWithFilterFileNameGenerationCount : AubSubCaptureManager {
using AubSubCaptureManager::AubSubCaptureManager;
std::string generateFilterFileName() const override {
generateFilterFileNameCount++;
return "aubfile_filter.aub";
}
mutable uint32_t generateFilterFileNameCount = 0;
} aubSubCaptureManager("");
DispatchInfo dispatchInfo;
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.getSubCaptureFileName(dispatchInfo);
aubSubCaptureManager.getSubCaptureFileName(dispatchInfo);
aubSubCaptureManager.getSubCaptureFileName(dispatchInfo);
EXPECT_EQ(1u, aubSubCaptureManager.generateFilterFileNameCount);
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFileNameIsCalledManyTimesAndExternalFileNameIsNotSpecifiedThenItGeneratesToggleFileNameOnceOnly) {
struct AubSubCaptureManagerMockWithToggleFileNameGenerationCount : AubSubCaptureManager {
using AubSubCaptureManager::AubSubCaptureManager;
std::string generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const override {
generateToggleFileNameCount++;
return "aubfile_toggle.aub";
}
mutable uint32_t generateToggleFileNameCount = 0;
} aubSubCaptureManager("");
DispatchInfo dispatchInfo;
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManager.getSubCaptureFileName(dispatchInfo);
aubSubCaptureManager.getSubCaptureFileName(dispatchInfo);
aubSubCaptureManager.getSubCaptureFileName(dispatchInfo);
EXPECT_EQ(1u, aubSubCaptureManager.generateToggleFileNameCount);
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledAndKernelNameIsSpecifiedInFilterThenItGeneratesFileNameWithNameOfKernel) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelName = "kernel_name";
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
EXPECT_NE(std::string::npos, filterFileName.find(kernelName));
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGenerateToggleFileNameIsCalledAndDispatchInfoIsEmptyThenItGeneratesFileNameWithoutNameOfKernel) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelName = "kernel_name";
MultiDispatchInfo dispatchInfo;
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
std::string toggleFileName = aubSubCaptureManager.generateToggleFileName(dispatchInfo);
EXPECT_EQ(std::string::npos, toggleFileName.find(kernelName));
}

View File

@@ -27,6 +27,8 @@ using namespace OCLRT;
class AubSubCaptureManagerMock : public AubSubCaptureManager {
public:
using AubSubCaptureManager::AubSubCaptureManager;
void setSubCaptureIsActive(bool on) {
subCaptureIsActive = on;
}
@@ -37,7 +39,7 @@ class AubSubCaptureManagerMock : public AubSubCaptureManager {
subCaptureWasActive = on;
}
bool wasSubCaptureActive() const {
return subCaptureIsActive;
return subCaptureWasActive;
}
void setKernelCurrentIndex(uint32_t index) {
kernelCurrentIdx = index;
@@ -45,6 +47,15 @@ class AubSubCaptureManagerMock : public AubSubCaptureManager {
uint32_t getKernelCurrentIndex() const {
return kernelCurrentIdx;
}
bool getUseExternalFileName() const {
return useExternalFileName;
}
const std::string &getInitialFileName() const {
return initialFileName;
}
const std::string &getCurrentFileName() const {
return currentFileName;
}
SettingsReader *getSettingsReader() const {
return settingsReader.get();
}
@@ -54,7 +65,17 @@ class AubSubCaptureManagerMock : public AubSubCaptureManager {
bool isSubCaptureToggleActive() const override {
return isToggledOn;
}
void setExternalFileName(const std::string &fileName) {
externalFileName = fileName;
}
std::string getExternalFileName() const override {
return externalFileName;
}
using AubSubCaptureManager::generateFilterFileName;
using AubSubCaptureManager::generateToggleFileName;
protected:
bool isToggledOn = false;
std::string externalFileName = "";
};

View File

@@ -71,6 +71,7 @@ ForceCompilerUsePlatform = unk
ForceCsrFlushing = false
ForceCsrReprogramming = false
AUBDumpSubCaptureMode = 0
AUBDumpToggleFileName = unk
AUBDumpToggleCaptureOnOff = 0
AUBDumpFilterKernelName = unk
AUBDumpFilterKernelStartIdx = 0