fix: Removing streamProvider and addressMapper

Related-To: NEO-14718
Signed-off-by: Aleksandra Nizio <aleksandra.nizio@intel.com>
This commit is contained in:
Aleksandra Nizio 2025-05-26 14:13:06 +00:00 committed by Compute-Runtime-Automation
parent 42a8b63725
commit 31fe1978d4
16 changed files with 20 additions and 1215 deletions

View File

@ -14,7 +14,6 @@ set(NEO_CORE_AUB
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_base.inl
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}aub_helper_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_mapper_base.h
${CMAKE_CURRENT_SOURCE_DIR}/aub_stream_provider.h
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_subcapture.h
)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -61,8 +61,6 @@ AubCenter::AubCenter(const RootDeviceEnvironment &rootDeviceEnvironment, bool lo
aubManager.reset(createAubManager(options));
}
addressMapper = std::make_unique<AddressMapper>();
streamProvider = std::make_unique<AubFileStreamProvider>();
subCaptureCommon = std::make_unique<AubSubCaptureCommon>();
if (debugManager.flags.AUBDumpSubCaptureMode.get()) {
this->subCaptureCommon->subCaptureMode = static_cast<AubSubCaptureCommon::SubCaptureMode>(debugManager.flags.AUBDumpSubCaptureMode.get());
@ -77,8 +75,6 @@ AubCenter::AubCenter(const RootDeviceEnvironment &rootDeviceEnvironment, bool lo
}
AubCenter::AubCenter() {
addressMapper = std::make_unique<AddressMapper>();
streamProvider = std::make_unique<AubFileStreamProvider>();
subCaptureCommon = std::make_unique<AubSubCaptureCommon>();
}

View File

@ -1,12 +1,11 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/aub/aub_stream_provider.h"
#include "shared/source/aub/aub_subcapture.h"
#include "shared/source/helpers/options.h"
#include "shared/source/memory_manager/address_mapper.h"
@ -32,14 +31,6 @@ class AubCenter {
return physicalAddressAllocator.get();
}
AddressMapper *getAddressMapper() const {
return addressMapper.get();
}
AubStreamProvider *getStreamProvider() const {
return streamProvider.get();
}
AubSubCaptureCommon *getSubCaptureCommon() const {
return subCaptureCommon.get();
}
@ -52,8 +43,6 @@ class AubCenter {
protected:
std::unique_ptr<PhysicalAddressAllocator> physicalAddressAllocator;
std::unique_ptr<AddressMapper> addressMapper;
std::unique_ptr<AubStreamProvider> streamProvider;
std::unique_ptr<AubSubCaptureCommon> subCaptureCommon;
std::unique_ptr<aub_stream::AubManager> aubManager;

View File

@ -1,29 +0,0 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
namespace NEO {
class AubStreamProvider {
public:
virtual ~AubStreamProvider() = default;
virtual AubMemDump::AubFileStream *getStream() = 0;
};
class AubFileStreamProvider : public AubStreamProvider {
public:
AubMemDump::AubFileStream *getStream() override {
return &stream;
};
protected:
AubMemDump::AubFileStream stream;
};
} // namespace NEO

View File

@ -29,7 +29,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
public:
using BaseClass::peekExecutionEnvironment;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::aubManager;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::hardwareContextController;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::engineInfo;
@ -43,10 +42,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void makeResidentExternal(AllocationView &allocationView);
void makeNonResidentExternal(uint64_t gpuAddress);
AubMemDump::AubFileStream *getAubStream() const {
return static_cast<AubMemDump::AubFileStream *>(this->stream);
}
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override;
bool writeMemory(GraphicsAllocation &gfxAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override;
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
@ -95,10 +90,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
std::unique_ptr<std::conditional<is64bit, PML4, PDPE>::type> ppgtt;
std::unique_ptr<PDPE> ggtt;
// remap CPU VA -> GGTT VA
AddressMapper *gttRemap;
MOCKABLE_VIRTUAL bool addPatchInfoComments();
void addGUCStartMessage(uint64_t batchBufferAddress);
uint32_t getGUCWorkQueueItemHeader();

View File

@ -7,7 +7,6 @@
#include "shared/source/aub/aub_center.h"
#include "shared/source/aub/aub_helper.h"
#include "shared/source/aub/aub_stream_provider.h"
#include "shared/source/aub/aub_subcapture.h"
#include "shared/source/aub_mem_dump/aub_alloc_dump.h"
#include "shared/source/aub_mem_dump/aub_alloc_dump.inl"
@ -70,19 +69,9 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const std::str
}
auto physicalAddressAllocator = aubCenter->getPhysicalAddressAllocator();
UNRECOVERABLE_IF(nullptr == physicalAddressAllocator);
ppgtt = std::make_unique<std::conditional<is64bit, PML4, PDPE>::type>(physicalAddressAllocator);
ggtt = std::make_unique<PDPE>(physicalAddressAllocator);
gttRemap = aubCenter->getAddressMapper();
UNRECOVERABLE_IF(nullptr == gttRemap);
auto streamProvider = aubCenter->getStreamProvider();
UNRECOVERABLE_IF(nullptr == streamProvider);
stream = streamProvider->getStream();
UNRECOVERABLE_IF(nullptr == stream);
if (debugManager.flags.CsrDispatchMode.get()) {
this->dispatchMode = (DispatchMode)debugManager.flags.CsrDispatchMode.get();
}
@ -99,7 +88,6 @@ AUBCommandStreamReceiverHw<GfxFamily>::~AUBCommandStreamReceiverHw() {
if (osContext) {
pollForCompletion();
}
this->freeEngineInfo(*gttRemap);
}
template <typename GfxFamily>
@ -115,7 +103,6 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::reopenFile(const std::string &fileNa
if (isFileOpen()) {
if (fileName != getFileName()) {
closeFile();
this->freeEngineInfo(*gttRemap);
}
}
if (!isFileOpen()) {
@ -148,36 +135,23 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initFile(const std::string &fileName
}
return;
}
if (!getAubStream()->isOpen()) {
// Open our file
stream->open(fileName.c_str());
if (!getAubStream()->isOpen()) {
// This UNRECOVERABLE_IF most probably means you are not executing aub tests with correct current directory (containing aub_out folder)
// try adding <familycodename>_aub
UNRECOVERABLE_IF(true);
}
// Add the file header
auto &hwInfo = this->peekHwInfo();
const auto &productHelper = this->getProductHelper();
stream->init(productHelper.getAubStreamSteppingFromHwRevId(hwInfo), aubDeviceId);
}
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::closeFile() {
aubManager ? aubManager->close() : stream->close();
if (aubManager && aubManager->isOpen()) {
aubManager->close();
}
}
template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::isFileOpen() const {
return aubManager ? aubManager->isOpen() : getAubStream()->isOpen();
return aubManager ? aubManager->isOpen() : false;
}
template <typename GfxFamily>
const std::string AUBCommandStreamReceiverHw<GfxFamily>::getFileName() {
return aubManager ? aubManager->getFileName() : getAubStream()->getFileName();
return aubManager ? aubManager->getFileName() : std::string{};
}
template <typename GfxFamily>
@ -187,115 +161,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine() {
if (hardwareContextController) {
hardwareContextController->initialize();
return;
}
auto csTraits = this->getCsTraits(osContext->getEngineType());
if (engineInfo.pLRCA) {
return;
}
this->initGlobalMMIO();
this->initEngineMMIO();
this->initAdditionalMMIO();
// Write driver version
{
std::ostringstream str;
str << "driver version: " << driverVersion;
getAubStream()->addComment(str.str().c_str());
}
// Global HW Status Page
{
const size_t sizeHWSP = 0x1000;
const size_t alignHWSP = 0x1000;
engineInfo.pGlobalHWStatusPage = alignedMalloc(sizeHWSP, alignHWSP);
engineInfo.ggttHWSP = gttRemap->map(engineInfo.pGlobalHWStatusPage, sizeHWSP);
auto physHWSP = ggtt->map(engineInfo.ggttHWSP, sizeHWSP, this->getGTTBits(), this->getMemoryBankForGtt());
// Write our GHWSP
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttHWSP;
getAubStream()->addComment(str.str().c_str());
}
AubGTTData data = {0};
this->getGTTData(reinterpret_cast<void *>(physHWSP), data);
AUB::reserveAddressGGTT(*stream, engineInfo.ggttHWSP, sizeHWSP, physHWSP, data);
stream->writeMMIO(AubMemDump::computeRegisterOffset(csTraits.mmioBase, 0x2080), engineInfo.ggttHWSP);
}
// Allocate the LRCA
const size_t sizeLRCA = csTraits.sizeLRCA;
const size_t alignLRCA = csTraits.alignLRCA;
auto pLRCABase = alignedMalloc(sizeLRCA, alignLRCA);
engineInfo.pLRCA = pLRCABase;
// Initialize the LRCA to a known state
csTraits.initialize(pLRCABase);
// Reserve the ring buffer
engineInfo.sizeRingBuffer = 0x4 * 0x1000;
{
const size_t alignRingBuffer = 0x1000;
engineInfo.pRingBuffer = alignedMalloc(engineInfo.sizeRingBuffer, alignRingBuffer);
engineInfo.ggttRingBuffer = gttRemap->map(engineInfo.pRingBuffer, engineInfo.sizeRingBuffer);
auto physRingBuffer = ggtt->map(engineInfo.ggttRingBuffer, engineInfo.sizeRingBuffer, this->getGTTBits(), this->getMemoryBankForGtt());
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttRingBuffer;
getAubStream()->addComment(str.str().c_str());
}
AubGTTData data = {0};
this->getGTTData(reinterpret_cast<void *>(physRingBuffer), data);
AUB::reserveAddressGGTT(*stream, engineInfo.ggttRingBuffer, engineInfo.sizeRingBuffer, physRingBuffer, data);
}
// Initialize the ring MMIO registers
{
uint32_t ringHead = 0x000;
uint32_t ringTail = 0x000;
auto ringBase = engineInfo.ggttRingBuffer;
auto ringCtrl = (uint32_t)((engineInfo.sizeRingBuffer - 0x1000) | 1);
csTraits.setRingHead(pLRCABase, ringHead);
csTraits.setRingTail(pLRCABase, ringTail);
csTraits.setRingBase(pLRCABase, ringBase);
csTraits.setRingCtrl(pLRCABase, ringCtrl);
}
// Write our LRCA
{
engineInfo.ggttLRCA = gttRemap->map(engineInfo.pLRCA, sizeLRCA);
auto lrcAddressPhys = ggtt->map(engineInfo.ggttLRCA, sizeLRCA, this->getGTTBits(), this->getMemoryBankForGtt());
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA;
getAubStream()->addComment(str.str().c_str());
}
AubGTTData data = {0};
this->getGTTData(reinterpret_cast<void *>(lrcAddressPhys), data);
AUB::reserveAddressGGTT(*stream, engineInfo.ggttLRCA, sizeLRCA, lrcAddressPhys, data);
AUB::addMemoryWrite(
*stream,
lrcAddressPhys,
pLRCABase,
sizeLRCA,
this->getAddressSpace(csTraits.aubHintLRCA),
csTraits.aubHintLRCA);
}
// Create a context to facilitate AUB dumping of memory using PPGTT
addContextToken(getDumpHandle());
DEBUG_BREAK_IF(!engineInfo.pLRCA);
}
template <typename GfxFamily>
@ -377,54 +243,11 @@ SubmissionStatus AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batch
batchBuffer.commandBufferAllocation = commandBufferAllocationBackup;
}
getAubStream()->flush();
return SubmissionStatus::success;
}
template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
std::map<uint64_t, uint64_t> allocationsMap;
std::ostringstream str;
str << "PatchInfoData" << std::endl;
for (auto &patchInfoData : this->flatBatchBufferHelper->getPatchInfoCollection()) {
str << std::hex << patchInfoData.sourceAllocation << ";";
str << std::hex << patchInfoData.sourceAllocationOffset << ";";
str << std::hex << patchInfoData.sourceType << ";";
str << std::hex << patchInfoData.targetAllocation << ";";
str << std::hex << patchInfoData.targetAllocationOffset << ";";
str << std::hex << patchInfoData.targetType << ";";
str << std::endl;
if (patchInfoData.sourceAllocation) {
allocationsMap.insert(std::pair<uint64_t, uint64_t>(patchInfoData.sourceAllocation,
ppgtt->map(static_cast<uintptr_t>(patchInfoData.sourceAllocation), 1, 0, MemoryBanks::mainBank)));
}
if (patchInfoData.targetAllocation) {
allocationsMap.insert(std::pair<uint64_t, uintptr_t>(patchInfoData.targetAllocation,
ppgtt->map(static_cast<uintptr_t>(patchInfoData.targetAllocation), 1, 0, MemoryBanks::mainBank)));
}
}
bool result = getAubStream()->addComment(str.str().c_str());
this->flatBatchBufferHelper->getPatchInfoCollection().clear();
if (!result) {
return false;
}
std::ostringstream allocationStr;
allocationStr << "AllocationsList" << std::endl;
for (auto &element : allocationsMap) {
allocationStr << std::hex << element.first << ";" << element.second << std::endl;
}
result = getAubStream()->addComment(allocationStr.str().c_str());
if (!result) {
return false;
}
return true;
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::submitBatchBufferAub(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits) {
auto streamLocked = lockStream();
@ -434,153 +257,6 @@ void AUBCommandStreamReceiverHw<GfxFamily>::submitBatchBufferAub(uint64_t batchB
}
return;
}
auto csTraits = this->getCsTraits(osContext->getEngineType());
{
{
std::ostringstream str;
str << "ppgtt: " << std::hex << std::showbase << batchBuffer;
getAubStream()->addComment(str.str().c_str());
}
auto physBatchBuffer = ppgtt->map(static_cast<uintptr_t>(batchBufferGpuAddress), batchBufferSize, entryBits, memoryBank);
AubHelperHw<GfxFamily> aubHelperHw(this->isLocalMemoryEnabled());
AUB::reserveAddressPPGTT(*stream, static_cast<uintptr_t>(batchBufferGpuAddress), batchBufferSize, physBatchBuffer,
entryBits, aubHelperHw);
AUB::addMemoryWrite(
*stream,
physBatchBuffer,
batchBuffer,
batchBufferSize,
this->getAddressSpace(AubMemDump::DataTypeHintValues::TraceBatchBufferPrimary),
AubMemDump::DataTypeHintValues::TraceBatchBufferPrimary);
}
if (debugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
addGUCStartMessage(static_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(batchBuffer)));
addPatchInfoComments();
}
// Add a batch buffer start to the ring buffer
auto previousTail = engineInfo.tailRingBuffer;
{
typedef typename GfxFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
typedef typename GfxFamily::MI_NOOP MI_NOOP;
auto pTail = ptrOffset(engineInfo.pRingBuffer, engineInfo.tailRingBuffer);
auto ggttTail = ptrOffset(engineInfo.ggttRingBuffer, engineInfo.tailRingBuffer);
auto sizeNeeded =
sizeof(MI_BATCH_BUFFER_START) +
sizeof(MI_LOAD_REGISTER_IMM);
auto tailAlignment = sizeof(uint64_t);
sizeNeeded = alignUp(sizeNeeded, tailAlignment);
if (engineInfo.tailRingBuffer + sizeNeeded >= engineInfo.sizeRingBuffer) {
// Pad the remaining ring with NOOPs
auto sizeToWrap = engineInfo.sizeRingBuffer - engineInfo.tailRingBuffer;
memset(pTail, 0, sizeToWrap);
// write remaining ring
auto physDumpStart = ggtt->map(ggttTail, sizeToWrap, this->getGTTBits(), this->getMemoryBankForGtt());
AUB::addMemoryWrite(
*stream,
physDumpStart,
pTail,
sizeToWrap,
this->getAddressSpace(AubMemDump::DataTypeHintValues::TraceCommandBuffer),
AubMemDump::DataTypeHintValues::TraceCommandBuffer);
previousTail = 0;
engineInfo.tailRingBuffer = 0;
pTail = engineInfo.pRingBuffer;
} else if (engineInfo.tailRingBuffer == 0) {
// Add a LRI if this is our first submission
auto lri = GfxFamily::cmdInitLoadRegisterImm;
lri.setRegisterOffset(AubMemDump::computeRegisterOffset(csTraits.mmioBase, 0x2244));
lri.setDataDword(0x00010000);
*(MI_LOAD_REGISTER_IMM *)pTail = lri;
pTail = ((MI_LOAD_REGISTER_IMM *)pTail) + 1;
}
// Add our BBS
auto bbs = GfxFamily::cmdInitBatchBufferStart;
bbs.setBatchBufferStartAddress(static_cast<uint64_t>(batchBufferGpuAddress));
bbs.setAddressSpaceIndicator(MI_BATCH_BUFFER_START::ADDRESS_SPACE_INDICATOR_PPGTT);
*(MI_BATCH_BUFFER_START *)pTail = bbs;
pTail = ((MI_BATCH_BUFFER_START *)pTail) + 1;
// Compute our new ring tail.
engineInfo.tailRingBuffer = (uint32_t)ptrDiff(pTail, engineInfo.pRingBuffer);
// Add NOOPs as needed as our tail needs to be aligned
while (engineInfo.tailRingBuffer % tailAlignment) {
*(MI_NOOP *)pTail = GfxFamily::cmdInitNoop;
pTail = ((MI_NOOP *)pTail) + 1;
engineInfo.tailRingBuffer = (uint32_t)ptrDiff(pTail, engineInfo.pRingBuffer);
}
UNRECOVERABLE_IF((engineInfo.tailRingBuffer % tailAlignment) != 0);
// Only dump the new commands
auto ggttDumpStart = ptrOffset(engineInfo.ggttRingBuffer, previousTail);
auto dumpStart = ptrOffset(engineInfo.pRingBuffer, previousTail);
auto dumpLength = engineInfo.tailRingBuffer - previousTail;
// write ring
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << ggttDumpStart;
getAubStream()->addComment(str.str().c_str());
}
auto physDumpStart = ggtt->map(ggttDumpStart, dumpLength, this->getGTTBits(), this->getMemoryBankForGtt());
AUB::addMemoryWrite(
*stream,
physDumpStart,
dumpStart,
dumpLength,
this->getAddressSpace(AubMemDump::DataTypeHintValues::TraceCommandBuffer),
AubMemDump::DataTypeHintValues::TraceCommandBuffer);
// update the ring mmio tail in the LRCA
{
std::ostringstream str;
str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA + 0x101c;
getAubStream()->addComment(str.str().c_str());
}
auto physLRCA = ggtt->map(engineInfo.ggttLRCA, sizeof(engineInfo.tailRingBuffer), this->getGTTBits(), this->getMemoryBankForGtt());
AUB::addMemoryWrite(
*stream,
physLRCA + 0x101c,
&engineInfo.tailRingBuffer,
sizeof(engineInfo.tailRingBuffer),
this->getAddressSpace(csTraits.aubHintLRCA));
DEBUG_BREAK_IF(engineInfo.tailRingBuffer >= engineInfo.sizeRingBuffer);
}
// Submit our execlist by submitting to the execlist submit ports
{
typename AUB::MiContextDescriptorReg contextDescriptor = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
contextDescriptor.sData.valid = true;
contextDescriptor.sData.forcePageDirRestore = false;
contextDescriptor.sData.forceRestore = false;
contextDescriptor.sData.legacy = true;
contextDescriptor.sData.faultSupport = 0;
contextDescriptor.sData.privilegeAccessOrPPGTT = true;
contextDescriptor.sData.aDor64bitSupport = AUB::Traits::addressingBits > 32;
auto ggttLRCA = engineInfo.ggttLRCA;
contextDescriptor.sData.logicalRingCtxAddress = ggttLRCA / 4096;
contextDescriptor.sData.contextID = 0;
this->submitLRCA(contextDescriptor);
}
}
template <typename GfxFamily>
@ -608,17 +284,6 @@ void AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletionImpl() {
hardwareContextController->pollForCompletion();
return;
}
const auto mmioBase = this->getCsTraits(osContext->getEngineType()).mmioBase;
const bool pollNotEqual = false;
const uint32_t mask = getMaskAndValueForPollForCompletion();
const uint32_t value = mask;
stream->registerPoll(
AubMemDump::computeRegisterOffset(mmioBase, 0x2234), // EXECLIST_STATUS
mask,
value,
pollNotEqual,
AubMemDump::CmdServicesMemTraceRegisterPoll::TimeoutActionValues::Abort);
}
template <typename GfxFamily>
@ -651,7 +316,6 @@ void AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(uint64_t gpuAddress, voi
{
std::ostringstream str;
str << "ppgtt: " << std::hex << std::showbase << gpuAddress << " end address: " << gpuAddress + size << " cpu address: " << cpuAddress << " size: " << std::dec << size;
getAubStream()->addComment(str.str().c_str());
}
AubHelperHw<GfxFamily> aubHelperHw(this->isLocalMemoryEnabled());
@ -688,7 +352,6 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
this->writeMemoryWithAubManager(gfxAllocation, isChunkCopy, gpuVaChunkOffset, chunkSize);
} else {
UNRECOVERABLE_IF(isChunkCopy);
writeMemory(gpuAddress, cpuAddress, size, this->getMemoryBank(&gfxAllocation), this->getPPGTTAdditionalBits(&gfxAllocation));
}
streamLocked.unlock();
@ -725,7 +388,6 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMMIO(uint32_t mmioRegister, ui
// Add support for expectMMIO to AubStream
return;
}
this->getAubStream()->expectMMIO(mmioRegister, expectedValue);
}
template <typename GfxFamily>
@ -739,19 +401,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(const void *gfxAddress,
hardwareContextController->expectMemory(reinterpret_cast<uint64_t>(gfxAddress), srcAddress, length, compareOperation);
return true;
}
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
UNRECOVERABLE_IF(offset > length);
this->getAubStream()->expectMemory(physAddress,
ptrOffset(srcAddress, offset),
size,
this->getAddressSpaceFromPTEBits(entryBits),
compareOperation);
};
this->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::bankNotSpecified);
return true;
return false;
}
template <typename GfxFamily>
@ -816,8 +466,6 @@ void AUBCommandStreamReceiverHw<GfxFamily>::dumpAllocation(GraphicsAllocation &g
}
return;
}
AubAllocDump::dumpAllocation<GfxFamily>(dumpFormat, gfxAllocation, getAubStream(), getDumpHandle());
}
template <typename GfxFamily>
@ -843,8 +491,6 @@ void AUBCommandStreamReceiverHw<GfxFamily>::addAubComment(const char *message) {
aubManager->addComment(message);
return;
}
getAubStream()->addComment(message);
}
template <typename GfxFamily>

View File

@ -29,7 +29,6 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
using MiContextDescriptorReg = typename AUB::MiContextDescriptorReg;
bool getParametersForMemory(GraphicsAllocation &graphicsAllocation, uint64_t &gpuAddress, void *&cpuAddress, size_t &size) const;
void freeEngineInfo(AddressMapper &gttRemap);
MOCKABLE_VIRTUAL uint32_t getDeviceIndex() const;
public:
@ -45,7 +44,6 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
return 0u;
}
void initGlobalMMIO();
void initAdditionalMMIO();
uint64_t getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation);
void getGTTData(void *memory, AubGTTData &data);
uint32_t getMemoryBankForGtt() const;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2024 Intel Corporation
* Copyright (C) 2019-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -26,16 +26,6 @@
namespace NEO {
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO() {
if (debugManager.flags.AubDumpAddMmioRegistersList.get() != "unk") {
auto mmioList = AubHelper::getAdditionalMmioList();
for (auto &mmioPair : mmioList) {
stream->writeMMIO(mmioPair.first, mmioPair.second);
}
}
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::setupContext(OsContext &osContext) {
CommandStreamReceiverHw<GfxFamily>::setupContext(osContext);
@ -99,21 +89,6 @@ bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::expectMemoryCompressed(v
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual);
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::freeEngineInfo(AddressMapper &gttRemap) {
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;
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.isResident(osContext->getContextId())) {

View File

@ -45,7 +45,6 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void protectCPUMemoryFromWritesIfTbxFaultable(GraphicsAllocation *gfxAllocation, void *cpuAddress, size_t size);
public:
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::aubManager;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::hardwareContextController;
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::engineInfo;

View File

@ -78,8 +78,6 @@ TbxCommandStreamReceiverHw<GfxFamily>::~TbxCommandStreamReceiverHw() {
if (streamInitialized) {
tbxStream.close();
}
this->freeEngineInfo(gttRemap);
}
template <typename GfxFamily>
@ -154,10 +152,6 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine() {
return;
}
this->initGlobalMMIO();
this->initEngineMMIO();
this->initAdditionalMMIO();
// Global HW Status Page
{
const size_t sizeHWSP = 0x1000;

View File

@ -8,7 +8,7 @@
#pragma once
#include "shared/source/aub/aub_center.h"
#include "shared/source/aub/aub_stream_provider.h"
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
#include "shared/test/common/mocks/mock_aub_file_stream.h"
namespace NEO {

View File

@ -42,16 +42,6 @@ struct MockAubFileStreamMockMmioWrite : public AubMemDump::AubFileStream {
std::vector<std::pair<uint32_t, uint32_t>> mmioList;
};
template <typename GfxFamily>
struct MockAubCsrToTestDumpContext : public AUBCommandStreamReceiverHw<GfxFamily> {
using AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw;
void addContextToken(uint32_t dumpHandle) override {
handle = dumpHandle;
}
uint32_t handle = 0;
};
template <typename GfxFamily>
struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
using CommandStreamReceiverHw<GfxFamily>::defaultSshSize;
@ -200,8 +190,6 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
bool fileIsOpen = false;
std::string openFileName = "";
ADDMETHOD_NOBASE(addPatchInfoComments, bool, true, ());
using CommandStreamReceiverHw<GfxFamily>::localMemoryEnabled;
};

View File

@ -32,6 +32,7 @@ using namespace NEO;
using AubCommandStreamReceiverTests = Test<AubCommandStreamReceiverFixture>;
using AubCommandStreamReceiverWithoutAubStreamTests = Test<AubCommandStreamReceiverWithoutAubStreamFixture>;
using AubCsrTests = Test<AubCommandStreamReceiverFixture>;
template <typename GfxFamily>
struct MockAubCsrToTestDumpAubNonWritable : public AUBCommandStreamReceiverHw<GfxFamily> {
@ -130,42 +131,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
EXPECT_NE(nullptr, memoryManager.get());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyOperateOnSingleFileStream) {
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_EQ(aubCsr1->stream, aubCsr2->stream);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameFileStream) {
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto streamProvider1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getStreamProvider();
EXPECT_NE(nullptr, streamProvider1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto streamProvider2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getStreamProvider();
EXPECT_NE(nullptr, streamProvider2);
EXPECT_EQ(streamProvider1, streamProvider2);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSamePhysicalAddressAllocator) {
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto physicalAddressAllocator1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getPhysicalAddressAllocator();
EXPECT_NE(nullptr, physicalAddressAllocator1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto physicalAddressAllocator2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getPhysicalAddressAllocator();
EXPECT_NE(nullptr, physicalAddressAllocator2);
EXPECT_EQ(physicalAddressAllocator1, physicalAddressAllocator2);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameAddressMapper) {
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto addressMapper1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getAddressMapper();
EXPECT_NE(nullptr, addressMapper1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto addressMapper2 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getAddressMapper();
EXPECT_NE(nullptr, addressMapper2);
EXPECT_EQ(addressMapper1, addressMapper2);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameSubCaptureCommon) {
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto subCaptureCommon1 = pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter->getSubCaptureCommon();
@ -287,43 +252,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
memoryManager->freeGraphicsMemory(gfxAllocation);
}
HWTEST_F(AubCommandStreamReceiverWithoutAubStreamTests, givenAubCommandStreamReceiverWhenMultipleInstancesInitializeTheirEnginesThenUniqueGlobalGttAddressesAreGenerated) {
pDevice->executionEnvironment->rootDeviceEnvironments[0]->aubCenter.reset(new AubCenter);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto engineInstance = gfxCoreHelper.getGpgpuEngineInstances(pDevice->getRootDeviceEnvironment())[0];
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor(engineInstance));
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
aubCsr1->setupContext(osContext);
aubCsr1->initializeEngine();
EXPECT_NE(0u, aubCsr1->engineInfo.ggttLRCA);
EXPECT_NE(0u, aubCsr1->engineInfo.ggttHWSP);
EXPECT_NE(0u, aubCsr1->engineInfo.ggttRingBuffer);
aubCsr2->setupContext(osContext);
aubCsr2->initializeEngine();
EXPECT_NE(aubCsr1->engineInfo.ggttLRCA, aubCsr2->engineInfo.ggttLRCA);
EXPECT_NE(aubCsr1->engineInfo.ggttHWSP, aubCsr2->engineInfo.ggttHWSP);
EXPECT_NE(aubCsr1->engineInfo.ggttRingBuffer, aubCsr2->engineInfo.ggttRingBuffer);
}
HWTEST_F(AubCommandStreamReceiverWithoutAubStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldInitializeEngineInfo) {
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->hardwareContextController.reset(nullptr);
LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_NE(nullptr, aubCsr->engineInfo.pLRCA);
EXPECT_NE(nullptr, aubCsr->engineInfo.pGlobalHWStatusPage);
EXPECT_NE(nullptr, aubCsr->engineInfo.pRingBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenProcessResidencyIsCalledButSubCaptureIsDisabledThenItShouldntWriteMemory) {
AubSubCaptureCommon aubSubCaptureCommon;
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("", aubSubCaptureCommon);

View File

@ -168,22 +168,6 @@ HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenRemoveP
EXPECT_EQ(0u, aubCsr->getFlatBatchBufferHelper().getPatchInfoCollection().size());
}
HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenAddGucStartMessageIsCalledThenBatchBufferAddressIsStoredInPatchInfoCollection) {
debugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, false, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
LinearStream cs(aubExecutionEnvironment->commandBuffer);
std::unique_ptr<char[]> batchBuffer(new char[1024]);
aubCsr->addGUCStartMessage(static_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(batchBuffer.get())));
auto &patchInfoCollection = aubCsr->getFlatBatchBufferHelper().getPatchInfoCollection();
ASSERT_EQ(1u, patchInfoCollection.size());
EXPECT_EQ(patchInfoCollection[0].sourceAllocation, reinterpret_cast<uint64_t>(batchBuffer.get()));
EXPECT_EQ(patchInfoCollection[0].targetType, PatchInfoAllocationType::gucStartMessage);
}
HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenForcedBatchBufferFlatteningInBatchedDispatchModeThenNewCombinedBatchBufferIsCreated) {
debugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
debugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::batchedDispatch));
@ -431,38 +415,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
EXPECT_EQ(aubCsr->getOsContext().getDeviceBitfield().to_ulong(), mockHelper->flattenBatchBufferParamsPassed[0].deviceBitfield.to_ulong());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoCommentsIsCalled) {
DebugManagerStateRestore stateRestore;
debugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->hardwareContextController.reset(nullptr);
LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
ResidencyContainer allocationsForResidency;
aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(1u, aubCsr->addPatchInfoCommentsCalled);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoCommentsIsNotCalled) {
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
ResidencyContainer allocationsForResidency;
aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_EQ(0u, aubCsr->addPatchInfoCommentsCalled);
}
HWTEST_F(FlatBatchBufferHelperAubTests, givenAubCommandStreamReceiverWhenGetIndirectPatchCommandsIsCalledForEmptyPatchInfoListThenIndirectPatchCommandBufferIsNotCreated) {
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, false, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
@ -812,158 +764,6 @@ HWTEST_F(AubCommandStreamReceiverTests, whenAubCommandStreamReceiverIsCreatedThe
EXPECT_NE(0u, physicalAddress);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenEngineIsInitializedThenDumpHandleIsGenerated) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
auto &gfxCoreHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();
auto engineInstance = gfxCoreHelper.getGpgpuEngineInstances(*executionEnvironment.rootDeviceEnvironments[0])[0];
DeviceBitfield deviceBitfield(1);
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor(engineInstance, deviceBitfield));
executionEnvironment.initializeMemoryManager();
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, executionEnvironment, 0, deviceBitfield);
EXPECT_NE(nullptr, aubCsr);
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
aubCsr->aubManager = nullptr;
aubCsr->setupContext(osContext);
aubCsr->initializeEngine();
EXPECT_NE(0u, aubCsr->handle);
}
using InjectMmmioTest = Test<DeviceFixture>;
HWTEST_F(InjectMmmioTest, givenAddMmioKeySetToZeroWhenInitAdditionalMmioCalledThenDoNotWriteMmio) {
DebugManagerStateRestore stateRestore;
debugManager.flags.AubDumpAddMmioRegistersList.set("");
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(0u, stream->mmioList.size());
}
HWTEST_F(InjectMmmioTest, givenAddMmioRegistersListSetWhenInitAdditionalMmioCalledThenWriteGivenMmio) {
std::string registers("0xdead;0xbeef;and another very long string");
MMIOPair mmioPair(0xdead, 0xbeef);
DebugManagerStateRestore stateRestore;
debugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(1u, stream->mmioList.size());
EXPECT_TRUE(stream->isOnMmioList(mmioPair));
};
HWTEST_F(InjectMmmioTest, givenLongSequenceOfAddMmioRegistersListSetWhenInitAdditionalMmioCalledThenWriteGivenMmio) {
std::string registers("1;1;2;2;3;3");
DebugManagerStateRestore stateRestore;
debugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(3u, stream->mmioList.size());
}
HWTEST_F(InjectMmmioTest, givenSequenceWithIncompletePairOfAddMmioRegistersListSetWhenInitAdditionalMmioCalledThenWriteGivenMmio) {
std::string registers("0x1;0x1;0x2");
MMIOPair mmioPair0(0x1, 0x1);
MMIOPair mmioPair1(0x2, 0x2);
DebugManagerStateRestore stateRestore;
debugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(1u, stream->mmioList.size());
EXPECT_TRUE(stream->isOnMmioList(mmioPair0));
EXPECT_FALSE(stream->isOnMmioList(mmioPair1));
}
HWTEST_F(InjectMmmioTest, givenAddMmioRegistersListSetWithSemicolonAtTheEndWhenInitAdditionalMmioCalledThenWriteGivenMmio) {
std::string registers("0xdead;0xbeef;");
MMIOPair mmioPair(0xdead, 0xbeef);
DebugManagerStateRestore stateRestore;
debugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(1u, stream->mmioList.size());
EXPECT_TRUE(stream->isOnMmioList(mmioPair));
}
HWTEST_F(InjectMmmioTest, givenAddMmioRegistersListSetWithInvalidValueWhenInitAdditionalMmioCalledThenMmioIsNotWritten) {
std::string registers("0xdead;invalid");
DebugManagerStateRestore stateRestore;
debugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
aubCsr->stream = stream.get();
EXPECT_EQ(0u, stream->mmioList.size());
aubCsr->initAdditionalMMIO();
EXPECT_EQ(0u, stream->mmioList.size());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenAskedForMemoryExpectationThenPassValidCompareOperationType) {
class MyMockAubCsr : public AUBCommandStreamReceiverHw<FamilyType> {
public:
using AUBCommandStreamReceiverHw<FamilyType>::AUBCommandStreamReceiverHw;
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override {
inputCompareOperation = compareOperation;
return this->AUBCommandStreamReceiverHw<FamilyType>::expectMemory(gfxAddress, srcAddress, length, compareOperation);
}
uint32_t inputCompareOperation = 0;
};
void *mockAddress = reinterpret_cast<void *>(1);
uint32_t compareNotEqual = AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual;
uint32_t compareEqual = AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual;
auto mockStream = std::make_unique<MockAubFileStream>();
MyMockAubCsr myMockCsr(std::string(), true, *pDevice->getExecutionEnvironment(), pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
myMockCsr.setupContext(pDevice->commandStreamReceivers[0]->getOsContext());
myMockCsr.stream = mockStream.get();
myMockCsr.hardwareContextController.reset(nullptr);
myMockCsr.expectMemoryNotEqual(mockAddress, mockAddress, 1);
EXPECT_EQ(compareNotEqual, myMockCsr.inputCompareOperation);
EXPECT_EQ(compareNotEqual, mockStream->compareOperationFromExpectMemory);
myMockCsr.expectMemoryEqual(mockAddress, mockAddress, 1);
EXPECT_EQ(compareEqual, myMockCsr.inputCompareOperation);
EXPECT_EQ(compareEqual, mockStream->compareOperationFromExpectMemory);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenObtainingPreferredTagPoolSizeThenReturnOne) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
EXPECT_EQ(1u, aubCsr->getPreferredTagPoolSize());

View File

@ -38,15 +38,7 @@ using namespace NEO;
using AubFileStreamTests = Test<AubCommandStreamReceiverFixture>;
using AubFileStreamWithoutAubStreamTests = Test<AubCommandStreamReceiverWithoutAubStreamFixture>;
struct AddPatchInfoCommentsAubTests : AubFileStreamWithoutAubStreamTests {
void SetUp() override {
debugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
AubFileStreamWithoutAubStreamTests::SetUp();
}
DebugManagerStateRestore restore;
};
using AubCsrTests = Test<AubCommandStreamReceiverFixture>;
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitFileIsCalledWithInvalidFileNameThenFileIsNotOpened) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
@ -55,18 +47,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitFileIsCalledWi
EXPECT_THROW(aubCsr->initFile(invalidFileName), std::exception);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithoutAubManagerWhenInitFileIsCalledWithInvalidFileNameThenFileIsNotOpened) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(1);
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, executionEnvironment, 0, deviceBitfield);
std::string invalidFileName = "";
aubCsr->aubManager = nullptr;
EXPECT_THROW(aubCsr->initFile(invalidFileName), std::exception);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitFileIsCalledThenFileIsOpenedAndFileNameIsStored) {
HWTEST_F(AubCsrTests, givenAubCommandStreamReceiverWhenInitFileIsCalledThenFileIsOpenedAndFileNameIsStored) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
std::string fileName = "file_name.aub";
@ -79,7 +60,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitFileIsCalledTh
EXPECT_TRUE(aubCsr->getFileName().empty());
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenReopenFileIsCalledThenFileWithSpecifiedNameIsReopened) {
HWTEST_F(AubCsrTests, givenAubCommandStreamReceiverWhenReopenFileIsCalledThenFileWithSpecifiedNameIsReopened) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
std::string fileName = "file_name.aub";
std::string newFileName = "new_file_name.aub";
@ -93,20 +74,6 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenReopenFileIsCalled
EXPECT_STREQ(newFileName.c_str(), aubCsr->getFileName().c_str());
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithoutAubManagerWhenInitFileIsCalledThenFileShouldBeInitializedWithHeaderOnce) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
std::string fileName = "file_name.aub";
aubCsr->aubManager = nullptr;
aubCsr->stream = mockAubFileStream.get();
aubCsr->initFile(fileName);
aubCsr->initFile(fileName);
EXPECT_EQ(1u, mockAubFileStream->openCalledCnt);
EXPECT_EQ(1u, mockAubFileStream->initCalledCnt);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInitFileIsCalledThenFileShouldBeInitializedOnce) {
auto mockAubManager = std::make_unique<MockAubManager>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
@ -119,29 +86,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInit
EXPECT_EQ(1u, mockAubManager->openCalledCnt);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithoutAubManagerWhenFileFunctionsAreCalledThenTheyShouldCallTheExpectedAubManagerFunctions) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
std::string fileName = "file_name.aub";
aubCsr->aubManager = nullptr;
aubCsr->stream = mockAubFileStream.get();
aubCsr->initFile(fileName);
EXPECT_EQ(1u, mockAubFileStream->initCalledCnt);
EXPECT_TRUE(aubCsr->isFileOpen());
EXPECT_TRUE(mockAubFileStream->isOpenCalled);
EXPECT_STREQ(fileName.c_str(), aubCsr->getFileName().c_str());
EXPECT_TRUE(mockAubFileStream->getFileNameCalled);
aubCsr->closeFile();
EXPECT_FALSE(aubCsr->isFileOpen());
EXPECT_TRUE(aubCsr->getFileName().empty());
EXPECT_TRUE(mockAubFileStream->closeCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenFileFunctionsAreCalledThenTheyShouldCallTheExpectedAubManagerFunctions) {
HWTEST_F(AubCsrTests, givenAubCommandStreamReceiverWithAubManagerWhenFileFunctionsAreCalledThenTheyShouldCallTheExpectedAubManagerFunctions) {
auto mockAubManager = std::make_unique<MockAubManager>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
std::string fileName = "file_name.aub";
@ -253,42 +198,8 @@ HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverWhenDu
aubCsr->dumpAllocation(allocation);
EXPECT_TRUE(aubCsr->lockStreamCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedFunctions) {
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->aubManager = nullptr;
LinearStream cs(aubExecutionEnvironment->commandBuffer);
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(aubCsr->initializeEngineCalled);
EXPECT_TRUE(aubCsr->writeMemoryCalled);
EXPECT_TRUE(aubCsr->submitBatchBufferCalled);
EXPECT_FALSE(aubCsr->pollForCompletionCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCallingAddAubCommentThenCallAddCommentOnAubFileStream) {
DebugManagerStateRestore stateRestore;
auto aubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->stream = aubFileStream.get();
aubCsr->aubManager = nullptr;
const char *comment = "message";
aubCsr->addAubComment(comment);
EXPECT_TRUE(aubCsr->addAubCommentCalled);
EXPECT_LT(0u, aubFileStream->addCommentCalled);
EXPECT_STREQ(comment, aubFileStream->comments[0].c_str());
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenCallingAddAubCommentThenCallAddCommentOnAubManager) {
using AubCsrTests = Test<AubCommandStreamReceiverFixture>;
HWTEST_F(AubCsrTests, givenAubCommandStreamReceiverWithAubManagerWhenCallingAddAubCommentThenCallAddCommentOnAubManager) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor());
aubCsr.setupContext(osContext);
@ -311,22 +222,6 @@ HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverWhenCa
EXPECT_TRUE(aubCsr->pollForCompletionCalled);
}
HWTEST_F(AubFileStreamTests, givenNewTaskSinceLastPollWhenCallingPollForCompletionThenCallRegisterPoll) {
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->hardwareContextController.reset(nullptr);
aubCsr->stream = aubStream.get();
aubCsr->latestSentTaskCount = 50;
aubCsr->pollForCompletionTaskCount = 49;
ASSERT_FALSE(aubStream->registerPollCalled);
aubCsr->pollForCompletion();
EXPECT_TRUE(aubStream->registerPollCalled);
EXPECT_EQ(50u, aubCsr->pollForCompletionTaskCount);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenNoNewTasksSinceLastPollWhenCallingPollForCompletionThenDontCallRegisterPoll) {
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
@ -342,21 +237,6 @@ HWTEST_F(AubFileStreamWithoutAubStreamTests, givenNoNewTasksSinceLastPollWhenCal
EXPECT_EQ(50u, aubCsr->pollForCompletionTaskCount);
}
HWTEST_F(AubFileStreamTests, givenNewTaskSinceLastPollWhenDeletingAubCsrThenCallRegisterPoll) {
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->hardwareContextController.reset(nullptr);
aubCsr->stream = aubStream.get();
aubCsr->latestSentTaskCount = 50;
aubCsr->pollForCompletionTaskCount = 49;
ASSERT_FALSE(aubStream->registerPollCalled);
aubExecutionEnvironment->commandStreamReceiver.reset();
EXPECT_TRUE(aubStream->registerPollCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenNoNewTaskSinceLastPollWhenDeletingAubCsrThenDontCallRegisterPoll) {
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
@ -371,7 +251,7 @@ HWTEST_F(AubFileStreamWithoutAubStreamTests, givenNoNewTaskSinceLastPollWhenDele
EXPECT_FALSE(aubStream->registerPollCalled);
}
HWTEST_F(AubFileStreamTests, givenNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenCallPollForCompletion) {
HWTEST_F(AubCsrTests, givenNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenCallPollForCompletion) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor());
aubCsr.setupContext(osContext);
@ -385,7 +265,7 @@ HWTEST_F(AubFileStreamTests, givenNewTasksAndHardwareContextPresentWhenCallingPo
EXPECT_TRUE(hardwareContext->pollForCompletionCalled);
}
HWTEST_F(AubFileStreamTests, givenNoNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenDontCallPollForCompletion) {
HWTEST_F(AubCsrTests, givenNoNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenDontCallPollForCompletion) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor());
aubCsr.setupContext(osContext);
@ -399,64 +279,6 @@ HWTEST_F(AubFileStreamTests, givenNoNewTasksAndHardwareContextPresentWhenCalling
EXPECT_FALSE(hardwareContext->pollForCompletionCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenNoNewTasksSinceLastPollWhenCallingExpectMemoryThenDontCallRegisterPoll) {
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->stream = aubStream.get();
aubCsr->latestSentTaskCount = 50;
aubCsr->pollForCompletionTaskCount = 50;
ASSERT_FALSE(aubStream->registerPollCalled);
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
aubCsr->expectMemoryNotEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
EXPECT_FALSE(aubStream->registerPollCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenNewTasksSinceLastPollWhenCallingExpectMemoryThenCallRegisterPoll) {
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->hardwareContextController.reset(nullptr);
aubCsr->stream = aubStream.get();
aubCsr->latestSentTaskCount = 50;
aubCsr->pollForCompletionTaskCount = 49;
ASSERT_FALSE(aubStream->registerPollCalled);
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
aubCsr->expectMemoryNotEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
EXPECT_TRUE(aubStream->registerPollCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverInSubCaptureModeWhenPollForCompletionIsCalledAndSubCaptureIsEnabledThenItShouldCallRegisterPoll) {
DebugManagerStateRestore stateRestore;
AubSubCaptureCommon aubSubCaptureCommon;
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("", aubSubCaptureCommon);
auto aubStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->hardwareContextController.reset(nullptr);
aubCsr->stream = aubStream.get();
aubSubCaptureCommon.subCaptureMode = AubSubCaptureManager::SubCaptureMode::toggle;
aubSubCaptureManagerMock->setSubCaptureToggleActive(true);
aubSubCaptureManagerMock->checkAndActivateSubCapture("kernelName");
aubCsr->subCaptureManager = std::unique_ptr<AubSubCaptureManagerMock>(aubSubCaptureManagerMock);
ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
aubCsr->latestSentTaskCount = 50;
aubCsr->pollForCompletionTaskCount = 49;
ASSERT_FALSE(aubStream->registerPollCalled);
aubCsr->pollForCompletion();
EXPECT_TRUE(aubStream->registerPollCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverInSubCaptureModeWhenPollForCompletionIsCalledButSubCaptureIsDisabledThenItShouldntCallRegisterPoll) {
DebugManagerStateRestore stateRestore;
AubSubCaptureCommon aubSubCaptureCommon;
@ -480,7 +302,7 @@ HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverInSubC
EXPECT_FALSE(aubStream->registerPollCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithHardwareContextInSubCaptureModeWhenPollForCompletionIsCalledAndSubCaptureIsEnabledThenItShouldCallPollForCompletionOnHwContext) {
HWTEST_F(AubCsrTests, givenAubCommandStreamReceiverWithHardwareContextInSubCaptureModeWhenPollForCompletionIsCalledAndSubCaptureIsEnabledThenItShouldCallPollForCompletionOnHwContext) {
DebugManagerStateRestore stateRestore;
AubSubCaptureCommon aubSubCaptureCommon;
auto aubSubCaptureManagerMock = new AubSubCaptureManagerMock("", aubSubCaptureCommon);
@ -527,19 +349,6 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithHardwareContextInS
EXPECT_FALSE(hardwareContext->pollForCompletionCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCalledThenItShouldCallTheExpectedFunctions) {
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->initializeEngine();
aubCsr->aubManager = nullptr;
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
ResidencyContainer allocationsForResidency = {&allocation};
aubCsr->processResidency(allocationsForResidency, 0u);
EXPECT_TRUE(aubCsr->writeMemoryCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryEqualIsCalledThenItShouldCallTheExpectedFunctions) {
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
@ -654,85 +463,6 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqu
EXPECT_TRUE(mockHardwareContext->expectMemoryCalled);
}
HWTEST_F(AubFileStreamWithoutAubStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenFileStreamShouldBeFlushed) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
LinearStream cs(aubExecutionEnvironment->commandBuffer);
aubCsr->stream = mockAubFileStream.get();
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
ResidencyContainer allocationsForResidency = {};
aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_TRUE(mockAubFileStream->flushCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryIsCalledThenPageWalkIsCallingStreamsExpectMemory) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
aubCsr->setupContext(pDevice->commandStreamReceivers[0]->getOsContext());
aubCsr->hardwareContextController.reset(nullptr);
aubCsr->stream = mockAubFileStream.get();
uintptr_t gpuAddress = 0x30000;
void *sourceAddress = reinterpret_cast<void *>(0x50000);
auto physicalAddress = aubCsr->ppgtt->map(gpuAddress, MemoryConstants::pageSize, PageTableEntry::presentBit, MemoryBanks::mainBank);
aubCsr->expectMemoryEqual(reinterpret_cast<void *>(gpuAddress), sourceAddress, MemoryConstants::pageSize);
EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceNonlocal, mockAubFileStream->addressSpaceCapturedFromExpectMemory);
EXPECT_EQ(reinterpret_cast<uintptr_t>(sourceAddress), mockAubFileStream->memoryCapturedFromExpectMemory);
EXPECT_EQ(physicalAddress, mockAubFileStream->physAddressCapturedFromExpectMemory);
EXPECT_EQ(MemoryConstants::pageSize, mockAubFileStream->sizeCapturedFromExpectMemory);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithoutAubManagerWhenExpectMMIOIsCalledThenTheCorrectFunctionIsCalledFromAubFileStream) {
std::string fileName = "file_name.aub";
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(fileName.c_str(), true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
aubCsr->aubManager = nullptr;
aubCsr->stream = mockAubFileStream.get();
aubCsr->setupContext(pDevice->commandStreamReceivers[0]->getOsContext());
aubCsr->initFile(fileName);
aubCsr->expectMMIO(5, 10);
EXPECT_EQ(5u, mockAubFileStream->mmioRegisterFromExpectMMIO);
EXPECT_EQ(10u, mockAubFileStream->expectedValueFromExpectMMIO);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenExpectMMIOIsCalledThenNoFunctionIsCalledFromAubFileStream) {
std::string fileName = "file_name.aub";
auto mockAubManager = std::make_unique<MockAubManager>();
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(fileName.c_str(), true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
aubCsr->stream = mockAubFileStream.get();
aubCsr->setupContext(pDevice->commandStreamReceivers[0]->getOsContext());
aubCsr->initFile(fileName);
aubCsr->expectMMIO(5, 10);
EXPECT_NE(5u, mockAubFileStream->mmioRegisterFromExpectMMIO);
EXPECT_NE(10u, mockAubFileStream->expectedValueFromExpectMMIO);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenInitializeEngineIsCalledThenMemTraceCommentWithDriverVersionIsPutIntoAubStream) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
aubCsr->hardwareContextController.reset(nullptr);
aubCsr->initializeEngine();
std::string commentWithDriverVersion = "driver version: " + std::string(driverVersion);
EXPECT_EQ(commentWithDriverVersion, mockAubFileStream->comments[0]);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInitFileIsCalledThenMemTraceCommentWithDriverVersionIsPutIntoAubStream) {
auto mockAubManager = std::make_unique<MockAubManager>();
@ -754,197 +484,6 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWithAubManagerWhenInit
aubCsr->aubManager = nullptr;
}
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenNoPatchInfoDataObjectsThenCommentsAreEmpty) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
bool result = aubCsr->addPatchInfoComments();
EXPECT_TRUE(result);
ASSERT_EQ(2u, mockAubFileStream->comments.size());
EXPECT_EQ("PatchInfoData\n", mockAubFileStream->comments[0]);
EXPECT_EQ("AllocationsList\n", mockAubFileStream->comments[1]);
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
}
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenFirstAddCommentsFailsThenFunctionReturnsFalse) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
mockAubFileStream->addCommentResult = false;
bool result = aubCsr->addPatchInfoComments();
EXPECT_FALSE(result);
EXPECT_EQ(1u, mockAubFileStream->addCommentCalled);
}
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSecondAddCommentsFailsThenFunctionReturnsFalse) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
mockAubFileStream->addCommentResults = {true, false};
bool result = aubCsr->addPatchInfoComments();
EXPECT_FALSE(result);
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
}
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenPatchInfoDataObjectsAddedThenCommentsAreNotEmpty) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
PatchInfoData patchInfoData[2] = {{0xAAAAAAAA, 128u, PatchInfoAllocationType::defaultType, 0xBBBBBBBB, 256u, PatchInfoAllocationType::defaultType},
{0xBBBBBBBB, 128u, PatchInfoAllocationType::defaultType, 0xDDDDDDDD, 256u, PatchInfoAllocationType::defaultType}};
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData[0]));
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData[1]));
bool result = aubCsr->addPatchInfoComments();
EXPECT_TRUE(result);
ASSERT_EQ(2u, mockAubFileStream->comments.size());
EXPECT_EQ("PatchInfoData", mockAubFileStream->comments[0].substr(0, 13));
EXPECT_EQ("AllocationsList", mockAubFileStream->comments[1].substr(0, 15));
std::string line;
std::istringstream input1;
input1.str(mockAubFileStream->comments[0]);
uint32_t lineNo = 0;
while (std::getline(input1, line)) {
if (line.substr(0, 13) == "PatchInfoData") {
continue;
}
std::ostringstream ss;
ss << std::hex << patchInfoData[lineNo].sourceAllocation << ";" << patchInfoData[lineNo].sourceAllocationOffset << ";" << patchInfoData[lineNo].sourceType << ";";
ss << patchInfoData[lineNo].targetAllocation << ";" << patchInfoData[lineNo].targetAllocationOffset << ";" << patchInfoData[lineNo].targetType << ";";
EXPECT_EQ(ss.str(), line);
lineNo++;
}
std::vector<std::string> expectedAddresses = {"aaaaaaaa", "bbbbbbbb", "cccccccc", "dddddddd"};
lineNo = 0;
std::istringstream input2;
input2.str(mockAubFileStream->comments[1]);
while (std::getline(input2, line)) {
if (line.substr(0, 15) == "AllocationsList") {
continue;
}
bool foundAddr = false;
for (auto &addr : expectedAddresses) {
if (line.substr(0, 8) == addr) {
foundAddr = true;
break;
}
}
EXPECT_TRUE(foundAddr);
EXPECT_TRUE(line.size() > 9);
lineNo++;
}
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
}
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenSourceAllocationIsNullThenDoNotAddToAllocationsList) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
PatchInfoData patchInfoData = {0x0, 0u, PatchInfoAllocationType::defaultType, 0xBBBBBBBB, 0u, PatchInfoAllocationType::defaultType};
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData));
bool result = aubCsr->addPatchInfoComments();
EXPECT_TRUE(result);
ASSERT_EQ(2u, mockAubFileStream->comments.size());
ASSERT_EQ("PatchInfoData", mockAubFileStream->comments[0].substr(0, 13));
ASSERT_EQ("AllocationsList", mockAubFileStream->comments[1].substr(0, 15));
std::string line;
std::istringstream input;
input.str(mockAubFileStream->comments[1]);
std::vector<std::string> expectedAddresses = {"bbbbbbbb"};
while (std::getline(input, line)) {
if (line.substr(0, 15) == "AllocationsList") {
continue;
}
bool foundAddr = false;
for (auto &addr : expectedAddresses) {
if (line.substr(0, 8) == addr) {
foundAddr = true;
break;
}
}
EXPECT_TRUE(foundAddr);
EXPECT_TRUE(line.size() > 9);
}
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
}
HWTEST_F(AddPatchInfoCommentsAubTests, givenAddPatchInfoCommentsCalledWhenTargetAllocationIsNullThenDoNotAddToAllocationsList) {
auto mockAubFileStream = std::make_unique<MockAubFileStream>();
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(false, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
aubCsr->stream = mockAubFileStream.get();
PatchInfoData patchInfoData = {0xAAAAAAAA, 0u, PatchInfoAllocationType::defaultType, 0x0, 0u, PatchInfoAllocationType::defaultType};
EXPECT_TRUE(aubCsr->getFlatBatchBufferHelper().setPatchInfoData(patchInfoData));
bool result = aubCsr->addPatchInfoComments();
EXPECT_TRUE(result);
ASSERT_EQ(2u, mockAubFileStream->comments.size());
ASSERT_EQ("PatchInfoData", mockAubFileStream->comments[0].substr(0, 13));
ASSERT_EQ("AllocationsList", mockAubFileStream->comments[1].substr(0, 15));
std::string line;
std::istringstream input;
input.str(mockAubFileStream->comments[1]);
std::vector<std::string> expectedAddresses = {"aaaaaaaa"};
while (std::getline(input, line)) {
if (line.substr(0, 15) == "AllocationsList") {
continue;
}
bool foundAddr = false;
for (auto &addr : expectedAddresses) {
if (line.substr(0, 8) == addr) {
foundAddr = true;
break;
}
}
EXPECT_TRUE(foundAddr);
EXPECT_TRUE(line.size() > 9);
}
EXPECT_EQ(2u, mockAubFileStream->addCommentCalled);
}
HWTEST2_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenCreateFullFilePathIsCalledForMultipleDevicesThenFileNameIsExtendedWithSuffixToIndicateMultipleDevices, IsAtMostXeHpcCore) {
DebugManagerStateRestore stateRestore;

View File

@ -204,23 +204,15 @@ TEST(RootDeviceEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenR
auto aubManager = rootDeviceEnvironment->aubCenter->getAubManager();
EXPECT_EQ(nullptr, aubManager);
}
TEST(RootDeviceEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) {
MockExecutionEnvironment executionEnvironment{defaultHwInfo.get(), false, 1u};
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::aub);
auto currentAubCenter = rootDeviceEnvironment->aubCenter.get();
EXPECT_NE(nullptr, currentAubCenter);
auto currentAubStreamProvider = currentAubCenter->getStreamProvider();
EXPECT_NE(nullptr, currentAubStreamProvider);
auto currentAubFileStream = currentAubStreamProvider->getStream();
EXPECT_NE(nullptr, currentAubFileStream);
rootDeviceEnvironment->initAubCenter(false, "", CommandStreamReceiverType::aub);
EXPECT_EQ(currentAubCenter, rootDeviceEnvironment->aubCenter.get());
EXPECT_EQ(currentAubStreamProvider, rootDeviceEnvironment->aubCenter->getStreamProvider());
EXPECT_EQ(currentAubFileStream, rootDeviceEnvironment->aubCenter->getStreamProvider()->getStream());
}
TEST(RootDeviceEnvironment, givenRootExecutionEnvironmentWhenGetAssertHandlerIsCalledThenItIsInitalizedOnce) {
const HardwareInfo *hwInfo = defaultHwInfo.get();
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo));