mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Command stream receiver: use memory manager from execution environment
Change-Id: I236218a73bd7dac6e5744e3596f146b77b5ca1c8 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
97c56b9de0
commit
4f028d13a1
@@ -80,9 +80,12 @@ class BuiltinDispatchInfoBuilder {
|
||||
protected:
|
||||
template <typename KernelNameT, typename... KernelsDescArgsT>
|
||||
void grabKernels(KernelNameT &&kernelName, Kernel *&kernelDst, KernelsDescArgsT &&... kernelsDesc) {
|
||||
const KernelInfo *ki = prog->getKernelInfo(kernelName);
|
||||
const KernelInfo *kernelInfo = prog->getKernelInfo(kernelName);
|
||||
if (!kernelInfo) {
|
||||
return;
|
||||
}
|
||||
cl_int err = 0;
|
||||
kernelDst = Kernel::create(prog.get(), *ki, &err);
|
||||
kernelDst = Kernel::create(prog.get(), *kernelInfo, &err);
|
||||
kernelDst->isBuiltIn = true;
|
||||
usedKernels.push_back(std::unique_ptr<Kernel>(kernelDst));
|
||||
grabKernels(std::forward<KernelsDescArgsT>(kernelsDesc)...);
|
||||
|
||||
@@ -69,9 +69,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
||||
void freeEngineInfoTable();
|
||||
|
||||
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
||||
this->memoryManager = new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, true, this->executionEnvironment);
|
||||
this->flatBatchBufferHelper->setMemoryManager(this->memoryManager);
|
||||
return this->memoryManager;
|
||||
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, true, this->executionEnvironment);
|
||||
}
|
||||
|
||||
static const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType);
|
||||
|
||||
@@ -43,7 +43,7 @@ CommandStreamReceiver::~CommandStreamReceiver() {
|
||||
if (indirectHeap[i] != nullptr) {
|
||||
auto allocation = indirectHeap[i]->getGraphicsAllocation();
|
||||
if (allocation != nullptr) {
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
}
|
||||
delete indirectHeap[i];
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf
|
||||
|
||||
void CommandStreamReceiver::waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType) {
|
||||
auto address = getTagAddress();
|
||||
if (address && requiredTaskCount != (unsigned int)-1) {
|
||||
if (address && requiredTaskCount != ObjectNotUsed) {
|
||||
while (*address < requiredTaskCount)
|
||||
;
|
||||
}
|
||||
@@ -131,21 +131,12 @@ void CommandStreamReceiver::waitForTaskCountAndCleanAllocationList(uint32_t requ
|
||||
getMemoryManager()->freeAllocationsList(requiredTaskCount, allocationList);
|
||||
}
|
||||
|
||||
MemoryManager *CommandStreamReceiver::getMemoryManager() {
|
||||
return memoryManager;
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::setMemoryManager(MemoryManager *mm) {
|
||||
memoryManager = mm;
|
||||
if (flatBatchBufferHelper) {
|
||||
flatBatchBufferHelper->setMemoryManager(mm);
|
||||
}
|
||||
MemoryManager *CommandStreamReceiver::getMemoryManager() const {
|
||||
DEBUG_BREAK_IF(!executionEnvironment.memoryManager);
|
||||
return executionEnvironment.memoryManager.get();
|
||||
}
|
||||
|
||||
LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
auto memoryManager = this->getMemoryManager();
|
||||
DEBUG_BREAK_IF(nullptr == memoryManager);
|
||||
|
||||
if (commandStream.getAvailableSpace() < minRequiredSize) {
|
||||
// Make sure we have enough room for a MI_BATCH_BUFFER_END and any padding.
|
||||
// Currently reserving 64bytes (cacheline) which should be more than enough.
|
||||
@@ -156,16 +147,16 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
|
||||
auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize;
|
||||
|
||||
auto allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release();
|
||||
auto allocation = getMemoryManager()->obtainReusableAllocation(requiredSize, false).release();
|
||||
if (!allocation) {
|
||||
allocation = memoryManager->allocateGraphicsMemory(requiredSize);
|
||||
allocation = getMemoryManager()->allocateGraphicsMemory(requiredSize);
|
||||
}
|
||||
|
||||
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
||||
|
||||
//pass current allocation to reusable list
|
||||
if (commandStream.getCpuBase()) {
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
||||
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
||||
}
|
||||
|
||||
commandStream.replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - sizeForSubmission);
|
||||
@@ -176,30 +167,30 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::cleanupResources() {
|
||||
if (!memoryManager)
|
||||
if (!getMemoryManager())
|
||||
return;
|
||||
|
||||
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, TEMPORARY_ALLOCATION);
|
||||
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, REUSABLE_ALLOCATION);
|
||||
|
||||
if (scratchAllocation) {
|
||||
memoryManager->freeGraphicsMemory(scratchAllocation);
|
||||
getMemoryManager()->freeGraphicsMemory(scratchAllocation);
|
||||
scratchAllocation = nullptr;
|
||||
}
|
||||
|
||||
if (debugSurface) {
|
||||
memoryManager->freeGraphicsMemory(debugSurface);
|
||||
getMemoryManager()->freeGraphicsMemory(debugSurface);
|
||||
debugSurface = nullptr;
|
||||
}
|
||||
|
||||
if (commandStream.getCpuBase()) {
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
getMemoryManager()->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
commandStream.replaceGraphicsAllocation(nullptr);
|
||||
commandStream.replaceBuffer(nullptr, 0);
|
||||
}
|
||||
|
||||
if (tagAllocation) {
|
||||
memoryManager->freeGraphicsMemory(tagAllocation);
|
||||
getMemoryManager()->freeGraphicsMemory(tagAllocation);
|
||||
tagAllocation = nullptr;
|
||||
tagAddress = nullptr;
|
||||
}
|
||||
@@ -267,7 +258,7 @@ void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispa
|
||||
|
||||
GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {
|
||||
UNRECOVERABLE_IF(debugSurface != nullptr);
|
||||
debugSurface = memoryManager->allocateGraphicsMemory(size);
|
||||
debugSurface = getMemoryManager()->allocateGraphicsMemory(size);
|
||||
return debugSurface;
|
||||
}
|
||||
|
||||
@@ -281,7 +272,7 @@ IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType
|
||||
heapMemory = heap->getGraphicsAllocation();
|
||||
|
||||
if (heap && heap->getAvailableSpace() < minRequiredSize && heapMemory) {
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
|
||||
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
|
||||
heapMemory = nullptr;
|
||||
}
|
||||
|
||||
@@ -309,13 +300,13 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
|
||||
|
||||
finalHeapSize = alignUp(std::max(finalHeapSize, minRequiredSize), MemoryConstants::pageSize);
|
||||
|
||||
auto heapMemory = memoryManager->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release();
|
||||
auto heapMemory = getMemoryManager()->obtainReusableAllocation(finalHeapSize, requireInternalHeap).release();
|
||||
|
||||
if (!heapMemory) {
|
||||
if (requireInternalHeap) {
|
||||
heapMemory = memoryManager->allocate32BitGraphicsMemory(finalHeapSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION);
|
||||
heapMemory = getMemoryManager()->allocate32BitGraphicsMemory(finalHeapSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION);
|
||||
} else {
|
||||
heapMemory = memoryManager->allocateGraphicsMemory(finalHeapSize);
|
||||
heapMemory = getMemoryManager()->allocateGraphicsMemory(finalHeapSize);
|
||||
}
|
||||
} else {
|
||||
finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize);
|
||||
@@ -344,7 +335,7 @@ void CommandStreamReceiver::releaseIndirectHeap(IndirectHeap::Type heapType) {
|
||||
if (heap) {
|
||||
auto heapMemory = heap->getGraphicsAllocation();
|
||||
if (heapMemory != nullptr)
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
|
||||
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
|
||||
heap->replaceBuffer(nullptr, 0);
|
||||
heap->replaceGraphicsAllocation(nullptr);
|
||||
}
|
||||
@@ -355,7 +346,7 @@ void CommandStreamReceiver::setExperimentalCmdBuffer(std::unique_ptr<Experimenta
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::initializeTagAllocation() {
|
||||
auto tagAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
auto tagAllocation = getMemoryManager()->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
if (!tagAllocation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,8 @@ class CommandStreamReceiver {
|
||||
|
||||
virtual void addPipeControl(LinearStream &commandStream, bool dcFlush) = 0;
|
||||
|
||||
MemoryManager *getMemoryManager();
|
||||
MemoryManager *getMemoryManager() const;
|
||||
virtual MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) { return nullptr; }
|
||||
void setMemoryManager(MemoryManager *mm);
|
||||
|
||||
ResidencyContainer &getResidencyAllocations();
|
||||
ResidencyContainer &getEvictionAllocations();
|
||||
@@ -193,8 +192,6 @@ class CommandStreamReceiver {
|
||||
GraphicsAllocation *scratchAllocation = nullptr;
|
||||
GraphicsAllocation *preemptionCsrAllocation = nullptr;
|
||||
GraphicsAllocation *debugSurface = nullptr;
|
||||
|
||||
MemoryManager *memoryManager = nullptr;
|
||||
OSInterface *osInterface = nullptr;
|
||||
std::unique_ptr<SubmissionAggregator> submissionAggregator;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(const HardwareInfo &
|
||||
localMemoryEnabled(HwHelper::get(hwInfo.pPlatform->eRenderCoreFamily).isLocalMemoryEnabled(hwInfo)) {
|
||||
requiredThreadArbitrationPolicy = PreambleHelper<GfxFamily>::getDefaultThreadArbitrationPolicy();
|
||||
resetKmdNotifyHelper(new KmdNotifyHelper(&(hwInfoIn.capabilityTable.kmdNotifyProperties)));
|
||||
flatBatchBufferHelper.reset(new FlatBatchBufferHelperHw<GfxFamily>(this->memoryManager));
|
||||
flatBatchBufferHelper.reset(new FlatBatchBufferHelperHw<GfxFamily>(executionEnvironment));
|
||||
defaultSshSize = getSshHeapSize();
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
|
||||
if (is64bit && scratchAllocation && !force32BitAllocations) {
|
||||
newGSHbase = (uint64_t)scratchAllocation->getUnderlyingBuffer() - PreambleHelper<GfxFamily>::getScratchSpaceOffsetFor64bit();
|
||||
} else if (is64bit && force32BitAllocations && dispatchFlags.GSBA32BitRequired) {
|
||||
newGSHbase = memoryManager->allocator32Bit->getBase();
|
||||
newGSHbase = getMemoryManager()->allocator32Bit->getBase();
|
||||
GSBAFor32BitProgrammed = true;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
|
||||
ssh,
|
||||
newGSHbase,
|
||||
requiredL3Index,
|
||||
memoryManager->getInternalHeapBaseAddress(),
|
||||
getMemoryManager()->getInternalHeapBaseAddress(),
|
||||
device.getGmmHelper());
|
||||
|
||||
if (sshDirty) {
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace OCLRT {
|
||||
template <typename BaseCSR>
|
||||
class CommandStreamReceiverWithAUBDump : public BaseCSR {
|
||||
public:
|
||||
using BaseCSR::createMemoryManager;
|
||||
CommandStreamReceiverWithAUBDump(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
|
||||
~CommandStreamReceiverWithAUBDump() override;
|
||||
|
||||
@@ -24,8 +25,6 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR {
|
||||
|
||||
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
||||
|
||||
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override;
|
||||
|
||||
CommandStreamReceiver *aubCSR = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -50,13 +50,4 @@ void CommandStreamReceiverWithAUBDump<BaseCSR>::activateAubSubCapture(const Mult
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BaseCSR>
|
||||
MemoryManager *CommandStreamReceiverWithAUBDump<BaseCSR>::createMemoryManager(bool enable64kbPages, bool enableLocalMemory) {
|
||||
auto memoryManager = BaseCSR::createMemoryManager(enable64kbPages, enableLocalMemory);
|
||||
if (aubCSR) {
|
||||
aubCSR->setMemoryManager(memoryManager);
|
||||
}
|
||||
return memoryManager;
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -37,7 +37,6 @@ ExperimentalCommandBuffer::~ExperimentalCommandBuffer() {
|
||||
timestamp += 2;
|
||||
}
|
||||
MemoryManager *memoryManager = commandStreamReceiver->getMemoryManager();
|
||||
if (memoryManager) {
|
||||
memoryManager->freeGraphicsMemory(timestamps);
|
||||
memoryManager->freeGraphicsMemory(experimentalAllocation);
|
||||
|
||||
@@ -46,7 +45,6 @@ ExperimentalCommandBuffer::~ExperimentalCommandBuffer() {
|
||||
currentStream->replaceGraphicsAllocation(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) {
|
||||
if (!currentStream) {
|
||||
|
||||
@@ -28,7 +28,6 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
||||
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
|
||||
typedef typename OCLRT::AUBFamilyMapper<GfxFamily>::AUB AUB;
|
||||
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
|
||||
using CommandStreamReceiverHw<GfxFamily>::memoryManager;
|
||||
|
||||
public:
|
||||
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
|
||||
@@ -65,8 +64,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
||||
} engineInfoTable[EngineType::NUM_ENGINES];
|
||||
|
||||
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
||||
memoryManager = new TbxMemoryManager(enable64kbPages, enableLocalMemory, this->executionEnvironment);
|
||||
return memoryManager;
|
||||
return new TbxMemoryManager(enable64kbPages, enableLocalMemory, this->executionEnvironment);
|
||||
}
|
||||
TbxMemoryManager *getMemoryManager() {
|
||||
return (TbxMemoryManager *)CommandStreamReceiver::getMemoryManager();
|
||||
|
||||
@@ -54,12 +54,10 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p
|
||||
}
|
||||
void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex) {
|
||||
if (this->memoryManager) {
|
||||
commandStreamReceivers[deviceIndex]->setMemoryManager(this->memoryManager.get());
|
||||
return;
|
||||
}
|
||||
|
||||
memoryManager.reset(commandStreamReceivers[deviceIndex]->createMemoryManager(enable64KBpages, enableLocalMemory));
|
||||
commandStreamReceivers[deviceIndex]->setMemoryManager(memoryManager.get());
|
||||
DEBUG_BREAK_IF(!this->memoryManager);
|
||||
}
|
||||
void ExecutionEnvironment::initSourceLevelDebugger(const HardwareInfo &hwInfo) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/flat_batch_buffer_helper.h"
|
||||
#include "runtime/memory_manager/graphics_allocation.h"
|
||||
|
||||
@@ -61,4 +62,8 @@ void FlatBatchBufferHelper::fixCrossThreadDataInfo(std::vector<PatchInfoData> &d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MemoryManager *FlatBatchBufferHelper::getMemoryManager() const {
|
||||
return executionEnvironemnt.memoryManager.get();
|
||||
}
|
||||
}; // namespace OCLRT
|
||||
@@ -16,10 +16,11 @@ namespace OCLRT {
|
||||
|
||||
enum class DispatchMode;
|
||||
class MemoryManager;
|
||||
class ExecutionEnvironment;
|
||||
|
||||
class FlatBatchBufferHelper {
|
||||
public:
|
||||
FlatBatchBufferHelper(MemoryManager *memoryManager) : memoryManager(memoryManager) {}
|
||||
FlatBatchBufferHelper(ExecutionEnvironment &executionEnvironemnt) : executionEnvironemnt(executionEnvironemnt) {}
|
||||
virtual ~FlatBatchBufferHelper(){};
|
||||
MOCKABLE_VIRTUAL bool setPatchInfoData(const PatchInfoData &data);
|
||||
MOCKABLE_VIRTUAL bool removePatchInfoData(uint64_t targetLocation);
|
||||
@@ -30,7 +31,6 @@ class FlatBatchBufferHelper {
|
||||
virtual GraphicsAllocation *flattenBatchBuffer(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer, DispatchMode dispatchMode) = 0;
|
||||
virtual char *getIndirectPatchCommands(size_t &indirectPatchCommandsSize, std::vector<PatchInfoData> &indirectPatchInfo) = 0;
|
||||
virtual void removePipeControlData(size_t pipeControlLocationSize, void *pipeControlForNooping) = 0;
|
||||
void setMemoryManager(MemoryManager *memoryManager) { this->memoryManager = memoryManager; }
|
||||
static void fixCrossThreadDataInfo(std::vector<PatchInfoData> &data, size_t offsetCrossThreadData, uint64_t gpuAddress);
|
||||
|
||||
std::vector<CommandChunk> &getCommandChunkList() { return commandChunkList; }
|
||||
@@ -38,7 +38,8 @@ class FlatBatchBufferHelper {
|
||||
std::map<uint64_t, uint64_t> &getBatchBufferStartAddressSequence() { return batchBufferStartAddressSequence; }
|
||||
|
||||
protected:
|
||||
MemoryManager *memoryManager = nullptr;
|
||||
MemoryManager *getMemoryManager() const;
|
||||
ExecutionEnvironment &executionEnvironemnt;
|
||||
|
||||
std::vector<PatchInfoData> patchInfoCollection;
|
||||
std::vector<CommandChunk> commandChunkList;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OCLRT {
|
||||
template <typename GfxFamily>
|
||||
class FlatBatchBufferHelperHw : public FlatBatchBufferHelper {
|
||||
public:
|
||||
FlatBatchBufferHelperHw(MemoryManager *memoryManager) : FlatBatchBufferHelper(memoryManager) {}
|
||||
using FlatBatchBufferHelper::FlatBatchBufferHelper;
|
||||
GraphicsAllocation *flattenBatchBuffer(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer, DispatchMode dispatchMode) override;
|
||||
char *getIndirectPatchCommands(size_t &indirectPatchCommandsSize, std::vector<PatchInfoData> &indirectPatchInfo) override;
|
||||
void removePipeControlData(size_t pipeControlLocationSize, void *pipeControlForNooping) override;
|
||||
|
||||
@@ -33,7 +33,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(Batch
|
||||
|
||||
auto flatBatchBufferSize = alignUp(sizeMainBatchBuffer + indirectPatchCommandsSize + batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), MemoryConstants::pageSize);
|
||||
flatBatchBuffer =
|
||||
this->memoryManager->allocateGraphicsMemory(flatBatchBufferSize, MemoryConstants::pageSize, false, false);
|
||||
getMemoryManager()->allocateGraphicsMemory(flatBatchBufferSize, MemoryConstants::pageSize, false, false);
|
||||
UNRECOVERABLE_IF(flatBatchBuffer == nullptr);
|
||||
// Copy main batchbuffer
|
||||
memcpy_s(flatBatchBuffer->getUnderlyingBuffer(), sizeMainBatchBuffer,
|
||||
@@ -108,7 +108,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw<GfxFamily>::flattenBatchBuffer(Batch
|
||||
|
||||
flatBatchBufferSize = alignUp(flatBatchBufferSize, MemoryConstants::pageSize);
|
||||
flatBatchBufferSize += CSRequirements::csOverfetchSize;
|
||||
flatBatchBuffer = this->memoryManager->allocateGraphicsMemory(static_cast<size_t>(flatBatchBufferSize),
|
||||
flatBatchBuffer = getMemoryManager()->allocateGraphicsMemory(static_cast<size_t>(flatBatchBufferSize),
|
||||
MemoryConstants::pageSize, false, false);
|
||||
UNRECOVERABLE_IF(flatBatchBuffer == nullptr);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
|
||||
protected:
|
||||
typedef DeviceCommandStreamReceiver<GfxFamily> BaseClass;
|
||||
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::getTagAddress;
|
||||
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::memoryManager;
|
||||
using BaseClass::getScratchPatchAddress;
|
||||
using BaseClass::hwInfo;
|
||||
using BaseClass::makeNonResident;
|
||||
|
||||
@@ -152,8 +152,7 @@ DrmMemoryManager *DrmCommandStreamReceiver<GfxFamily>::getMemoryManager() {
|
||||
|
||||
template <typename GfxFamily>
|
||||
MemoryManager *DrmCommandStreamReceiver<GfxFamily>::createMemoryManager(bool enable64kbPages, bool enableLocalMemory) {
|
||||
memoryManager = new DrmMemoryManager(this->drm, this->gemCloseWorkerOperationMode, DebugManager.flags.EnableForcePin.get(), true, this->executionEnvironment);
|
||||
return memoryManager;
|
||||
return new DrmMemoryManager(this->drm, this->gemCloseWorkerOperationMode, DebugManager.flags.EnableForcePin.get(), true, this->executionEnvironment);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -19,7 +19,6 @@ class Wddm;
|
||||
template <typename GfxFamily>
|
||||
class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
|
||||
typedef DeviceCommandStreamReceiver<GfxFamily> BaseClass;
|
||||
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::memoryManager;
|
||||
|
||||
public:
|
||||
WddmCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
@@ -150,12 +150,12 @@ void WddmCommandStreamReceiver<GfxFamily>::processEviction(OsContext &osContext)
|
||||
|
||||
template <typename GfxFamily>
|
||||
WddmMemoryManager *WddmCommandStreamReceiver<GfxFamily>::getMemoryManager() {
|
||||
return (WddmMemoryManager *)CommandStreamReceiver::getMemoryManager();
|
||||
return static_cast<WddmMemoryManager *>(CommandStreamReceiver::getMemoryManager());
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
MemoryManager *WddmCommandStreamReceiver<GfxFamily>::createMemoryManager(bool enable64kbPages, bool enableLocalMemory) {
|
||||
return memoryManager = new WddmMemoryManager(enable64kbPages, enableLocalMemory, this->wddm, executionEnvironment);
|
||||
return new WddmMemoryManager(enable64kbPages, enableLocalMemory, this->wddm, executionEnvironment);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -63,19 +63,19 @@ struct CommandEnqueueFixture : public CommandEnqueueBaseFixture,
|
||||
struct NegativeFailAllocationCommandEnqueueBaseFixture : public CommandEnqueueBaseFixture {
|
||||
void SetUp() override {
|
||||
CommandEnqueueBaseFixture::SetUp();
|
||||
failMemManager.reset(new FailMemoryManager());
|
||||
failMemManager.reset(new FailMemoryManager(*pDevice->getExecutionEnvironment()));
|
||||
|
||||
BufferDefaults::context = context;
|
||||
Image2dDefaults::context = context;
|
||||
buffer.reset(BufferHelper<>::create());
|
||||
image.reset(ImageHelper<Image2dDefaults>::create());
|
||||
ptr = static_cast<void *>(array);
|
||||
oldMemManager = pDevice->getMemoryManager();
|
||||
pDevice->getCommandStreamReceiver().setMemoryManager(failMemManager.get());
|
||||
oldMemManager = pDevice->getExecutionEnvironment()->memoryManager.release();
|
||||
pDevice->injectMemoryManager(failMemManager.release());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
pDevice->getCommandStreamReceiver().setMemoryManager(oldMemManager);
|
||||
pDevice->injectMemoryManager(oldMemManager);
|
||||
buffer.reset(nullptr);
|
||||
image.reset(nullptr);
|
||||
BufferDefaults::context = nullptr;
|
||||
|
||||
@@ -132,7 +132,6 @@ HWTEST_F(DrmRequirementsTests, enqueueKernelFinish) {
|
||||
HWTEST_F(DrmRequirementsTests, csrNewCS) {
|
||||
CommandStreamReceiver *pCSR = new UltCommandStreamReceiver<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
ASSERT_NE(nullptr, pCSR);
|
||||
pCSR->setMemoryManager(pDevice->getMemoryManager());
|
||||
auto memoryManager = pCSR->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
{
|
||||
@@ -158,7 +157,6 @@ HWTEST_F(DrmRequirementsTests, csrNewCS) {
|
||||
HWTEST_F(DrmRequirementsTests, csrNewCSSized) {
|
||||
CommandStreamReceiver *pCSR = new UltCommandStreamReceiver<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
ASSERT_NE(nullptr, pCSR);
|
||||
pCSR->setMemoryManager(pDevice->getMemoryManager());
|
||||
auto memoryManager = pCSR->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ HWTEST_F(EnqueueHandlerTest, enqueueWithOutputEventRegistersEvent) {
|
||||
|
||||
HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenPatchInfoDataIsNotTransferredToCSR) {
|
||||
auto csr = new MockCsrHw2<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(csr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment);
|
||||
csr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
pDevice->resetCommandStreamReceiver(csr);
|
||||
|
||||
@@ -241,7 +241,7 @@ HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenAddPatchInfoCommentsForAUBDu
|
||||
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
|
||||
|
||||
auto csr = new MockCsrHw2<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(csr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment);
|
||||
csr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
pDevice->resetCommandStreamReceiver(csr);
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(**platformDevices, "", true, *pDevice->executionEnvironment));
|
||||
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false, false));
|
||||
EXPECT_NE(nullptr, memoryManager.get());
|
||||
aubCsr->setMemoryManager(nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyOperateOnSingleFileStream) {
|
||||
@@ -987,7 +986,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false, false));
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
|
||||
|
||||
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
|
||||
@@ -1017,7 +1016,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false, false));
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
@@ -1041,7 +1040,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
std::unique_ptr<MemoryManager> memoryManager(nullptr);
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false, false));
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(*pDevice->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
|
||||
|
||||
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
|
||||
@@ -1197,7 +1196,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefault
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*aubExecutionEnvironment->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -1218,7 +1217,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
auto allocationsForResidency = aubCsr->getResidencyAllocations();
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*aubExecutionEnvironment->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
|
||||
auto chainedBatchBuffer = aubExecutionEnvironment->executionEnvironment->memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
|
||||
@@ -1252,7 +1251,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
auto allocationsForResidency = aubCsr->getResidencyAllocations();
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*aubExecutionEnvironment->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -1271,7 +1270,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(aubCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*aubExecutionEnvironment->executionEnvironment);
|
||||
aubCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
@@ -1411,9 +1410,11 @@ class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryMan
|
||||
};
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnImageWithNoHostPtrThenResourceShouldBeLockedToGetCpuAddress) {
|
||||
auto memoryManager = std::make_unique<OsAgnosticMemoryManagerForImagesWithNoHostPtr>(*pDevice->executionEnvironment);
|
||||
auto memoryManager = new OsAgnosticMemoryManagerForImagesWithNoHostPtr(*pDevice->executionEnvironment);
|
||||
std::unique_ptr<MemoryManager> oldMemoryManager(pDevice->executionEnvironment->memoryManager.release());
|
||||
pDevice->executionEnvironment->memoryManager.reset(memoryManager);
|
||||
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
|
||||
aubCsr->setMemoryManager(memoryManager.get());
|
||||
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 512;
|
||||
@@ -1437,6 +1438,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
|
||||
|
||||
queryGmm.release();
|
||||
memoryManager->freeGraphicsMemory(imageAllocation);
|
||||
pDevice->executionEnvironment->memoryManager.reset(oldMemoryManager.release());
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenNoDbgDeviceIdFlagWhenAubCsrIsCreatedThenUseDefaultDeviceId) {
|
||||
|
||||
@@ -60,7 +60,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskGmockTests, givenCsrInBatchingModeThreeRe
|
||||
auto &commandStream = commandQueue.getCS(4096u);
|
||||
|
||||
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(mockCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment);
|
||||
mockCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
pDevice->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
@@ -126,7 +126,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskGmockTests, givenMockCommandStreamerWhenA
|
||||
auto &commandStream = commandQueue.getCS(4096u);
|
||||
|
||||
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(mockCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment);
|
||||
mockCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
pDevice->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
@@ -153,7 +153,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskGmockTests, givenMockCommandStreamerWhenA
|
||||
auto &commandStream = commandQueue.getCS(4096u);
|
||||
|
||||
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(mockCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment);
|
||||
mockCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
|
||||
pDevice->resetCommandStreamReceiver(mockCsr);
|
||||
@@ -205,7 +205,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskGmockTests, givenMockCsrWhenCollectStateB
|
||||
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
|
||||
|
||||
std::unique_ptr<MockCsrHw2<FamilyType>> mockCsr(new MockCsrHw2<FamilyType>(*platformDevices[0], *pDevice->executionEnvironment));
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(mockCsr->getMemoryManager());
|
||||
auto mockHelper = new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment);
|
||||
mockCsr->overwriteFlatBatchBufferHelper(mockHelper);
|
||||
|
||||
std::vector<PatchInfoData> patchInfoDataVector;
|
||||
|
||||
@@ -768,7 +768,6 @@ struct CommandStreamReceiverHwLog : public UltCommandStreamReceiver<FamilyType>
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithBothCSCallsFlushOnce) {
|
||||
CommandStreamReceiverHwLog<FamilyType> commandStreamReceiver(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
commandStreamReceiver.setMemoryManager(pDevice->getMemoryManager());
|
||||
commandStreamReceiver.initializeTagAllocation();
|
||||
commandStream.getSpace(sizeof(typename FamilyType::MI_NOOP));
|
||||
|
||||
@@ -2595,7 +2594,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes
|
||||
executionEnvironment.memoryManager.reset(mockedMemoryManager);
|
||||
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0], executionEnvironment);
|
||||
executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(mockCsr));
|
||||
mockCsr->setMemoryManager(mockedMemoryManager);
|
||||
mockCsr->initializeTagAllocation();
|
||||
mockCsr->setPreemptionCsrAllocation(pDevice->getPreemptionAllocation());
|
||||
mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
|
||||
|
||||
@@ -283,7 +283,8 @@ HWTEST_F(CommandStreamReceiverTest, givenCsrWhenAllocateHeapMemoryIsCalledThenHe
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCSRWithoutTagAllocationWhenGetTagAllocationIsCalledThenNullptrIsReturned) {
|
||||
MockCommandStreamReceiver csr;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockCommandStreamReceiver csr(executionEnvironment);
|
||||
EXPECT_EQ(nullptr, csr.getTagAllocation());
|
||||
}
|
||||
|
||||
@@ -291,16 +292,18 @@ TEST(CommandStreamReceiverSimpleTest, givenDebugVariableEnabledWhenCreatingCsrTh
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
DebugManager.flags.EnableTimestampPacket.set(true);
|
||||
MockCommandStreamReceiver csr1;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockCommandStreamReceiver csr1(executionEnvironment);
|
||||
EXPECT_TRUE(csr1.peekTimestampPacketWriteEnabled());
|
||||
|
||||
DebugManager.flags.EnableTimestampPacket.set(false);
|
||||
MockCommandStreamReceiver csr2;
|
||||
MockCommandStreamReceiver csr2(executionEnvironment);
|
||||
EXPECT_FALSE(csr2.peekTimestampPacketWriteEnabled());
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCSRWithTagAllocationSetWhenGetTagAllocationIsCalledThenCorrectAllocationIsReturned) {
|
||||
MockCommandStreamReceiver csr;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockCommandStreamReceiver csr(executionEnvironment);
|
||||
GraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
csr.setTagAllocation(&allocation);
|
||||
EXPECT_EQ(&allocation, csr.getTagAllocation());
|
||||
@@ -318,10 +321,9 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye
|
||||
auto mockGraphicsAllocation = new MockGraphicsAllocation(nullptr, 1u);
|
||||
mockGraphicsAllocation->destructorCalled = &destructorCalled;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.commandStreamReceivers.push_back(std::make_unique<MockCommandStreamReceiver>());
|
||||
executionEnvironment.commandStreamReceivers.push_back(std::make_unique<MockCommandStreamReceiver>(executionEnvironment));
|
||||
auto csr = executionEnvironment.commandStreamReceivers[0].get();
|
||||
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, executionEnvironment));
|
||||
csr->setMemoryManager(memoryManager.get());
|
||||
executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(false, false, executionEnvironment));
|
||||
csr->setTagAllocation(mockGraphicsAllocation);
|
||||
EXPECT_FALSE(destructorCalled);
|
||||
executionEnvironment.commandStreamReceivers[0].reset(nullptr);
|
||||
@@ -329,39 +331,36 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocated) {
|
||||
auto csr = new MockCommandStreamReceiver;
|
||||
auto executionEnvironment = csr->mockExecutionEnvironment.get();
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
executionEnvironment->memoryManager.reset(new OsAgnosticMemoryManager(false, false, *executionEnvironment));
|
||||
csr->setMemoryManager(executionEnvironment->memoryManager.get());
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
auto csr = new MockCommandStreamReceiver(executionEnvironment);
|
||||
executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(false, false, executionEnvironment));
|
||||
EXPECT_EQ(nullptr, csr->getTagAllocation());
|
||||
EXPECT_TRUE(csr->getTagAddress() == nullptr);
|
||||
csr->initializeTagAllocation();
|
||||
EXPECT_NE(nullptr, csr->getTagAllocation());
|
||||
EXPECT_TRUE(csr->getTagAddress() != nullptr);
|
||||
EXPECT_EQ(*csr->getTagAddress(), initialHardwareTag);
|
||||
csr->mockExecutionEnvironment.reset();
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenNullHardwareDebugModeWhenInitializeTagAllocationIsCalledThenTagAllocationIsBeingAllocatedAndinitialValueIsMinusOne) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableNullHardware.set(true);
|
||||
auto csr = new MockCommandStreamReceiver;
|
||||
auto executionEnvironment = csr->mockExecutionEnvironment.get();
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *executionEnvironment));
|
||||
csr->setMemoryManager(memoryManager.get());
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
auto csr = new MockCommandStreamReceiver(executionEnvironment);
|
||||
executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
executionEnvironment.memoryManager.reset(new OsAgnosticMemoryManager(false, false, executionEnvironment));
|
||||
EXPECT_EQ(nullptr, csr->getTagAllocation());
|
||||
EXPECT_TRUE(csr->getTagAddress() == nullptr);
|
||||
csr->initializeTagAllocation();
|
||||
EXPECT_NE(nullptr, csr->getTagAllocation());
|
||||
EXPECT_TRUE(csr->getTagAddress() != nullptr);
|
||||
EXPECT_EQ(*csr->getTagAddress(), static_cast<uint32_t>(-1));
|
||||
csr->mockExecutionEnvironment.reset();
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCSRWhenWaitBeforeMakingNonResidentWhenRequiredIsCalledWithBlockingFlagSetThenItReturnsImmediately) {
|
||||
MockCommandStreamReceiver csr;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockCommandStreamReceiver csr(executionEnvironment);
|
||||
uint32_t tag = 0;
|
||||
GraphicsAllocation allocation(&tag, sizeof(tag));
|
||||
csr.latestFlushedTaskCount = 3;
|
||||
|
||||
@@ -106,14 +106,13 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bo
|
||||
createAubCSR = GetParam();
|
||||
csrWithAubDump = new MyMockCsrWithAubDump<MyMockCsr>(DEFAULT_TEST_PLATFORM::hwInfo, createAubCSR, executionEnvironment);
|
||||
ASSERT_NE(nullptr, csrWithAubDump);
|
||||
|
||||
memoryManager = csrWithAubDump->createMemoryManager(false, false);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete csrWithAubDump;
|
||||
delete memoryManager;
|
||||
}
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MyMockCsrWithAubDump<MyMockCsr> *csrWithAubDump;
|
||||
|
||||
@@ -160,26 +160,6 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
|
||||
EXPECT_EQ(expectedExOffset, mockExCmdBuffer->experimentalAllocationOffset);
|
||||
}
|
||||
|
||||
HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhenMemoryManagerIsNotAvailableThenExperimentalBufferAllocationsRemainAllocated) {
|
||||
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
MockExperimentalCommandBuffer *mockExCmdBuffer = static_cast<MockExperimentalCommandBuffer *>(commandStreamReceiver.experimentalCmdBuffer.get());
|
||||
|
||||
EXPECT_NE(nullptr, mockExCmdBuffer->experimentalAllocation);
|
||||
EXPECT_NE(nullptr, mockExCmdBuffer->timestamps);
|
||||
|
||||
auto experimentalAllocation = mockExCmdBuffer->experimentalAllocation;
|
||||
auto timestamps = mockExCmdBuffer->timestamps;
|
||||
auto memoryManager = commandStreamReceiver.getMemoryManager();
|
||||
|
||||
//null memManager
|
||||
commandStreamReceiver.setMemoryManager(nullptr);
|
||||
//delete experimental cmd buffer and verify its allocations remain intact
|
||||
commandStreamReceiver.setExperimentalCmdBuffer(std::move(std::unique_ptr<ExperimentalCommandBuffer>(nullptr)));
|
||||
memoryManager->freeGraphicsMemory(experimentalAllocation);
|
||||
memoryManager->freeGraphicsMemory(timestamps);
|
||||
commandStreamReceiver.setMemoryManager(memoryManager);
|
||||
}
|
||||
|
||||
HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhenCsrIsFlushedTwiceThenExpectProperlyFilledExperimentalCmdBufferAndTimestampOffset) {
|
||||
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END;
|
||||
|
||||
@@ -307,8 +307,8 @@ HWTEST_F(TbxCommandStreamTests, givenDbgDeviceIdFlagIsSetWhenTbxCsrIsCreatedThen
|
||||
HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenWaitBeforeMakeNonResidentWhenRequiredIsCalledWithBlockingFlagTrueThenFunctionStallsUntilMakeCoherentUpdatesTagAddress) {
|
||||
uint32_t tag = 0;
|
||||
MockTbxCsr<FamilyType> tbxCsr(*platformDevices[0], *pDevice->executionEnvironment);
|
||||
GraphicsAllocation graphicsAllocation(&tag, sizeof(tag));
|
||||
tbxCsr.setTagAllocation(&graphicsAllocation);
|
||||
|
||||
tbxCsr.setTagAllocation(pDevice->getMemoryManager()->allocateGraphicsMemory(sizeof(tag), &tag));
|
||||
|
||||
EXPECT_FALSE(tbxCsr.makeCoherentCalled);
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ class ContextWithAsyncDeleterTest : public ::testing::WithParamInterface<bool>,
|
||||
memoryManager = new MockMemoryManager();
|
||||
device = new MockDevice(*platformDevices[0]);
|
||||
deleter = new MockDeferredDeleter();
|
||||
device->setMemoryManager(memoryManager);
|
||||
device->injectMemoryManager(memoryManager);
|
||||
memoryManager->setDeferredDeleter(deleter);
|
||||
}
|
||||
void TearDown() override {
|
||||
|
||||
@@ -105,7 +105,7 @@ TEST_F(DeviceTest, givenDebugVariableOverrideEngineTypeWhenDeviceIsCreatedThenUs
|
||||
|
||||
TEST(DeviceCleanup, givenDeviceWhenItIsDestroyedThenFlushBatchedSubmissionsIsCalled) {
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver;
|
||||
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver(*mockDevice->getExecutionEnvironment());
|
||||
mockDevice->resetCommandStreamReceiver(csr);
|
||||
int flushedBatchedSubmissionsCalledCount = 0;
|
||||
csr->flushBatchedSubmissionsCallCounter = &flushedBatchedSubmissionsCalledCount;
|
||||
|
||||
@@ -880,7 +880,6 @@ HWTEST_F(InternalsEventTest, GivenBufferWithoutZeroCopyOnCommandMapOrUnmapFlushe
|
||||
CommandQueue *pCmdQ = new CommandQueue(mockContext, pDevice, props);
|
||||
MockNonZeroCopyBuff buffer(executionStamp);
|
||||
MockCsr<FamilyType> csr(executionStamp, *pDevice->executionEnvironment);
|
||||
csr.setMemoryManager(pDevice->getMemoryManager());
|
||||
csr.setTagAllocation(pDevice->getTagAllocation());
|
||||
|
||||
MemObjSizeArray size = {{4, 1, 1}};
|
||||
|
||||
@@ -164,7 +164,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
||||
};
|
||||
struct CommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 3> {
|
||||
CommandStreamReceiverMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
||||
CommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
|
||||
};
|
||||
struct BuiltinsMock : public DestructorCounted<BuiltIns, 2> {
|
||||
BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
|
||||
@@ -181,7 +181,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
|
||||
executionEnvironment->osInterface = std::make_unique<OsInterfaceMock>(destructorId);
|
||||
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId);
|
||||
executionEnvironment->aubCenter = std::make_unique<AubCenterMock>(destructorId);
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::make_unique<CommandStreamReceiverMock>(destructorId));
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::make_unique<CommandStreamReceiverMock>(destructorId, *executionEnvironment));
|
||||
executionEnvironment->builtins = std::make_unique<BuiltinsMock>(destructorId);
|
||||
executionEnvironment->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
|
||||
executionEnvironment->sourceLevelDebugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
|
||||
|
||||
@@ -23,7 +23,6 @@ class MemoryAllocatorFixture : public MemoryManagementFixture {
|
||||
memoryManager = new OsAgnosticMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
csr = memoryManager->getCommandStreamReceiver(0);
|
||||
csr->setMemoryManager(memoryManager);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
||||
@@ -16,7 +16,6 @@ void MemoryManagerWithCsrFixture::SetUp() {
|
||||
csr = new MockCommandStreamReceiver(this->executionEnvironment);
|
||||
gmockMemoryManager = new NiceMock<GMockMemoryManager>(executionEnvironment);
|
||||
memoryManager = gmockMemoryManager;
|
||||
csr->setMemoryManager(memoryManager);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
|
||||
ON_CALL(*gmockMemoryManager, cleanAllocationList(::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(gmockMemoryManager, &GMockMemoryManager::MemoryManagerCleanAllocationList));
|
||||
|
||||
@@ -20,8 +20,7 @@ using namespace OCLRT;
|
||||
TEST(CommandTest, mapUnmapSubmitWithoutTerminateFlagFlushesCsr) {
|
||||
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
std::unique_ptr<MockCommandQueue> cmdQ(new MockCommandQueue(nullptr, device.get(), nullptr));
|
||||
MockCommandStreamReceiver csr;
|
||||
csr.setMemoryManager(device->getMemoryManager());
|
||||
MockCommandStreamReceiver csr(*device->getExecutionEnvironment());
|
||||
MockBuffer buffer;
|
||||
|
||||
auto initialTaskCount = csr.peekTaskCount();
|
||||
@@ -38,8 +37,7 @@ TEST(CommandTest, mapUnmapSubmitWithoutTerminateFlagFlushesCsr) {
|
||||
TEST(CommandTest, mapUnmapSubmitWithTerminateFlagAbortsFlush) {
|
||||
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
std::unique_ptr<MockCommandQueue> cmdQ(new MockCommandQueue(nullptr, device.get(), nullptr));
|
||||
MockCommandStreamReceiver csr;
|
||||
csr.setMemoryManager(device->getMemoryManager());
|
||||
MockCommandStreamReceiver csr(*device->getExecutionEnvironment());
|
||||
MockBuffer buffer;
|
||||
|
||||
auto initialTaskCount = csr.peekTaskCount();
|
||||
@@ -59,8 +57,7 @@ TEST(CommandTest, mapUnmapSubmitWithTerminateFlagAbortsFlush) {
|
||||
TEST(CommandTest, markerSubmitWithoutTerminateFlagFlushesCsr) {
|
||||
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
std::unique_ptr<MockCommandQueue> cmdQ(new MockCommandQueue(nullptr, device.get(), nullptr));
|
||||
MockCommandStreamReceiver csr;
|
||||
csr.setMemoryManager(device->getMemoryManager());
|
||||
MockCommandStreamReceiver csr(*device->getExecutionEnvironment());
|
||||
MockBuffer buffer;
|
||||
|
||||
auto initialTaskCount = csr.peekTaskCount();
|
||||
@@ -74,7 +71,7 @@ TEST(CommandTest, markerSubmitWithoutTerminateFlagFlushesCsr) {
|
||||
TEST(CommandTest, markerSubmitWithTerminateFlagAbortsFlush) {
|
||||
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
std::unique_ptr<MockCommandQueue> cmdQ(new MockCommandQueue(nullptr, device.get(), nullptr));
|
||||
MockCommandStreamReceiver csr;
|
||||
MockCommandStreamReceiver csr(*device->getExecutionEnvironment());
|
||||
MockBuffer buffer;
|
||||
|
||||
auto initialTaskCount = csr.peekTaskCount();
|
||||
|
||||
@@ -190,9 +190,7 @@ HWTEST_F(KernelImageArgTest, givenImgWithMcsAllocWhenMakeResidentThenMakeMcsAllo
|
||||
cl_mem memObj = img;
|
||||
pKernel->setArg(0, sizeof(memObj), &memObj);
|
||||
|
||||
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *pDevice->executionEnvironment));
|
||||
std::unique_ptr<MockCsr<FamilyType>> csr(new MockCsr<FamilyType>(execStamp, *pDevice->executionEnvironment));
|
||||
csr->setMemoryManager(memoryManager.get());
|
||||
|
||||
pKernel->makeResident(*csr.get());
|
||||
EXPECT_TRUE(csr->isMadeResident(mcsAlloc));
|
||||
|
||||
@@ -407,6 +407,7 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
|
||||
typedef CommandStreamReceiver BaseClass;
|
||||
|
||||
public:
|
||||
using BaseClass::CommandStreamReceiver;
|
||||
CommandStreamReceiverMock() : BaseClass(*(new ExecutionEnvironment)) {
|
||||
this->mockExecutionEnvironment.reset(&this->executionEnvironment);
|
||||
}
|
||||
@@ -485,9 +486,9 @@ TEST_F(KernelPrivateSurfaceTest, testPrivateSurface) {
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
|
||||
// Test it
|
||||
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager(false, false, *context.getDevice(0)->getExecutionEnvironment()));
|
||||
std::unique_ptr<CommandStreamReceiverMock> csr(new CommandStreamReceiverMock());
|
||||
csr->setMemoryManager(memoryManager.get());
|
||||
auto executionEnvironment = pDevice->getExecutionEnvironment();
|
||||
executionEnvironment->memoryManager = std::make_unique<OsAgnosticMemoryManager>(false, false, *executionEnvironment);
|
||||
std::unique_ptr<CommandStreamReceiverMock> csr(new CommandStreamReceiverMock(*executionEnvironment));
|
||||
csr->residency.clear();
|
||||
EXPECT_EQ(0u, csr->residency.size());
|
||||
|
||||
|
||||
@@ -69,8 +69,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
||||
}
|
||||
|
||||
virtual MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
||||
memoryManager = new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment);
|
||||
return memoryManager;
|
||||
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment);
|
||||
}
|
||||
|
||||
virtual GmmPageTableMngr *createPageTableManager() override {
|
||||
@@ -137,7 +136,6 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
||||
bool initProgrammingFlagsCalled = false;
|
||||
|
||||
protected:
|
||||
using BaseClass::CommandStreamReceiver::memoryManager;
|
||||
using BaseClass::CommandStreamReceiver::tagAddress;
|
||||
using BaseClass::CommandStreamReceiver::tagAllocation;
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ std::unique_ptr<AubExecutionEnvironment> getEnvironment(bool createTagAllocation
|
||||
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::make_unique<CsrType>(*platformDevices[0], "", standalone, *executionEnvironment));
|
||||
executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0u]->createMemoryManager(false, false));
|
||||
executionEnvironment->commandStreamReceivers[0u]->setMemoryManager(executionEnvironment->memoryManager.get());
|
||||
if (createTagAllocation) {
|
||||
executionEnvironment->commandStreamReceivers[0u]->initializeTagAllocation();
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
|
||||
template <typename GfxFamily>
|
||||
class MockFlatBatchBufferHelper : public FlatBatchBufferHelperHw<GfxFamily> {
|
||||
public:
|
||||
MockFlatBatchBufferHelper(MemoryManager *memoryManager) : FlatBatchBufferHelperHw<GfxFamily>(memoryManager) {}
|
||||
using FlatBatchBufferHelperHw<GfxFamily>::FlatBatchBufferHelperHw;
|
||||
MOCK_METHOD1(setPatchInfoData, bool(const PatchInfoData &));
|
||||
MOCK_METHOD1(removePatchInfoData, bool(uint64_t));
|
||||
MOCK_METHOD1(registerCommandChunk, bool(CommandChunk &));
|
||||
@@ -215,12 +215,6 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
|
||||
std::vector<char> instructionHeapReserveredData;
|
||||
int *flushBatchedSubmissionsCallCounter = nullptr;
|
||||
|
||||
std::unique_ptr<ExecutionEnvironment> mockExecutionEnvironment;
|
||||
|
||||
MockCommandStreamReceiver() : CommandStreamReceiver(*(new ExecutionEnvironment)) {
|
||||
mockExecutionEnvironment.reset(&this->executionEnvironment);
|
||||
}
|
||||
|
||||
~MockCommandStreamReceiver() {
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo)
|
||||
CommandStreamReceiver *commandStreamReceiver = createCommandStream(&hwInfo, *this->executionEnvironment);
|
||||
executionEnvironment->commandStreamReceivers.resize(getDeviceIndex() + 1);
|
||||
executionEnvironment->commandStreamReceivers[getDeviceIndex()].reset(commandStreamReceiver);
|
||||
commandStreamReceiver->setMemoryManager(this->mockMemoryManager.get());
|
||||
this->executionEnvironment->memoryManager = std::move(this->mockMemoryManager);
|
||||
this->commandStreamReceiver = commandStreamReceiver;
|
||||
}
|
||||
@@ -33,15 +32,6 @@ OCLRT::MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *
|
||||
mockWaTable = *hwInfo.pWaTable;
|
||||
}
|
||||
|
||||
void MockDevice::setMemoryManager(MemoryManager *memoryManager) {
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
for (auto &commandStreamReceiver : executionEnvironment->commandStreamReceivers) {
|
||||
if (commandStreamReceiver) {
|
||||
commandStreamReceiver->setMemoryManager(memoryManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MockDevice::setOSTime(OSTime *osTime) {
|
||||
this->osTime.reset(osTime);
|
||||
};
|
||||
@@ -55,13 +45,11 @@ bool MockDevice::hasDriverInfo() {
|
||||
};
|
||||
|
||||
void MockDevice::injectMemoryManager(MemoryManager *memoryManager) {
|
||||
executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setMemoryManager(memoryManager);
|
||||
setMemoryManager(memoryManager);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
}
|
||||
|
||||
void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) {
|
||||
executionEnvironment->commandStreamReceivers[getDeviceIndex()].reset(newCsr);
|
||||
executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setMemoryManager(executionEnvironment->memoryManager.get());
|
||||
executionEnvironment->commandStreamReceivers[getDeviceIndex()]->initializeTagAllocation();
|
||||
executionEnvironment->commandStreamReceivers[getDeviceIndex()]->setPreemptionCsrAllocation(preemptionAllocation);
|
||||
this->commandStreamReceiver = newCsr;
|
||||
@@ -69,11 +57,6 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) {
|
||||
this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()]->getTagAddress();
|
||||
}
|
||||
|
||||
OCLRT::FailMemoryManager::FailMemoryManager() {
|
||||
agnostic = nullptr;
|
||||
fail = 0;
|
||||
}
|
||||
|
||||
OCLRT::FailMemoryManager::FailMemoryManager(int32_t fail) {
|
||||
allocations.reserve(fail);
|
||||
agnostic = new OsAgnosticMemoryManager(false, false, executionEnvironment);
|
||||
|
||||
@@ -70,7 +70,6 @@ class MockDevice : public Device {
|
||||
void setPerfCounters(PerformanceCounters *perfCounters) {
|
||||
performanceCounters = std::unique_ptr<PerformanceCounters>(perfCounters);
|
||||
}
|
||||
void setMemoryManager(MemoryManager *memoryManager);
|
||||
|
||||
template <typename T>
|
||||
UltCommandStreamReceiver<T> &getUltCommandStreamReceiver() {
|
||||
@@ -124,7 +123,7 @@ inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const Hardw
|
||||
|
||||
class FailMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
FailMemoryManager();
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
FailMemoryManager(int32_t fail);
|
||||
virtual ~FailMemoryManager() override {
|
||||
if (agnostic) {
|
||||
@@ -182,8 +181,8 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override {
|
||||
return nullptr;
|
||||
}
|
||||
int32_t fail;
|
||||
OsAgnosticMemoryManager *agnostic;
|
||||
int32_t fail = 0;
|
||||
OsAgnosticMemoryManager *agnostic = nullptr;
|
||||
std::vector<GraphicsAllocation *> allocations;
|
||||
};
|
||||
|
||||
@@ -191,7 +190,7 @@ class FailDevice : public MockDevice {
|
||||
public:
|
||||
FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new FailMemoryManager);
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(*executionEnvironment));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,49 +20,38 @@ class DrmCommandStreamMMTest : public ::testing::Test {
|
||||
|
||||
HWTEST_F(DrmCommandStreamMMTest, MMwithPinBB) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
{
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
DebugManager.flags.EnableForcePin.set(true);
|
||||
|
||||
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom());
|
||||
ASSERT_NE(nullptr, mock);
|
||||
DrmMockCustom mock;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(mock.get());
|
||||
executionEnvironment.osInterface->get()->setDrm(&mock);
|
||||
|
||||
DrmCommandStreamReceiver<FamilyType> csr(*platformDevices[0], executionEnvironment,
|
||||
gemCloseWorkerMode::gemCloseWorkerInactive);
|
||||
|
||||
auto mm = (DrmMemoryManager *)csr.createMemoryManager(false, false);
|
||||
ASSERT_NE(nullptr, mm);
|
||||
EXPECT_NE(nullptr, mm->getPinBB());
|
||||
csr.setMemoryManager(nullptr);
|
||||
|
||||
delete mm;
|
||||
}
|
||||
auto memoryManager = static_cast<DrmMemoryManager *>(csr.createMemoryManager(false, false));
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
EXPECT_NE(nullptr, memoryManager->getPinBB());
|
||||
}
|
||||
|
||||
HWTEST_F(DrmCommandStreamMMTest, givenForcePinDisabledWhenMemoryManagerIsCreatedThenPinBBIsCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
{
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
DebugManager.flags.EnableForcePin.set(false);
|
||||
|
||||
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom());
|
||||
ASSERT_NE(nullptr, mock);
|
||||
DrmMockCustom mock;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(mock.get());
|
||||
executionEnvironment.osInterface->get()->setDrm(&mock);
|
||||
|
||||
DrmCommandStreamReceiver<FamilyType> csr(*platformDevices[0], executionEnvironment,
|
||||
gemCloseWorkerMode::gemCloseWorkerInactive);
|
||||
|
||||
auto mm = (DrmMemoryManager *)csr.createMemoryManager(false, false);
|
||||
csr.setMemoryManager(nullptr);
|
||||
|
||||
ASSERT_NE(nullptr, mm);
|
||||
EXPECT_NE(nullptr, mm->getPinBB());
|
||||
|
||||
delete mm;
|
||||
}
|
||||
auto memoryManager = static_cast<DrmMemoryManager *>(csr.createMemoryManager(false, false));
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
EXPECT_NE(nullptr, memoryManager->getPinBB());
|
||||
}
|
||||
|
||||
@@ -36,53 +36,48 @@ using namespace OCLRT;
|
||||
|
||||
class DrmCommandStreamFixture {
|
||||
public:
|
||||
DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr = nullptr;
|
||||
DrmMemoryManager *mm = nullptr;
|
||||
DrmMockImpl *mock;
|
||||
const int mockFd = 33;
|
||||
|
||||
void SetUp() {
|
||||
osContext = std::make_unique<OsContext>(nullptr, 0u);
|
||||
this->dbgState = new DebugManagerStateRestore();
|
||||
//make sure this is disabled, we don't want test this now
|
||||
DebugManager.flags.EnableForcePin.set(false);
|
||||
|
||||
this->mock = new DrmMockImpl(mockFd);
|
||||
mock = std::make_unique<DrmMockImpl>(mockFd);
|
||||
|
||||
executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.osInterface->get()->setDrm(mock);
|
||||
executionEnvironment.osInterface->get()->setDrm(mock.get());
|
||||
|
||||
csr = new DrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*platformDevices[0], executionEnvironment,
|
||||
gemCloseWorkerMode::gemCloseWorkerActive);
|
||||
ASSERT_NE(nullptr, csr);
|
||||
executionEnvironment.commandStreamReceivers.resize(1);
|
||||
executionEnvironment.commandStreamReceivers[0].reset(csr);
|
||||
executionEnvironment.commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(csr));
|
||||
|
||||
// Memory manager creates pinBB with ioctl, expect one call
|
||||
EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_))
|
||||
.Times(1);
|
||||
mm = static_cast<DrmMemoryManager *>(csr->createMemoryManager(false, false));
|
||||
::testing::Mock::VerifyAndClearExpectations(mock);
|
||||
memoryManager = static_cast<DrmMemoryManager *>(csr->createMemoryManager(false, false));
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
::testing::Mock::VerifyAndClearExpectations(mock.get());
|
||||
|
||||
//assert we have memory manager
|
||||
ASSERT_NE(nullptr, mm);
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
mm->waitForDeletions();
|
||||
mm->peekGemCloseWorker()->close(true);
|
||||
memoryManager->waitForDeletions();
|
||||
memoryManager->peekGemCloseWorker()->close(true);
|
||||
executionEnvironment.commandStreamReceivers.clear();
|
||||
::testing::Mock::VerifyAndClearExpectations(mock);
|
||||
::testing::Mock::VerifyAndClearExpectations(mock.get());
|
||||
// Memory manager closes pinBB with ioctl, expect one call
|
||||
EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_))
|
||||
.Times(::testing::AtLeast(1));
|
||||
delete mm;
|
||||
delete this->mock;
|
||||
this->mock = 0;
|
||||
delete dbgState;
|
||||
}
|
||||
|
||||
DeviceCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *csr = nullptr;
|
||||
DrmMemoryManager *memoryManager = nullptr;
|
||||
std::unique_ptr<DrmMockImpl> mock;
|
||||
const int mockFd = 33;
|
||||
static const uint64_t alignment = MemoryConstants::allocationAlignment;
|
||||
DebugManagerStateRestore *dbgState;
|
||||
DebugManagerStateRestore dbgState;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<OsContext> osContext;
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ class DriverInfoDeviceTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
CommandStreamReceiver *createMockCommandStreamReceiver(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
|
||||
auto csr = new MockCommandStreamReceiver();
|
||||
auto csr = new MockCommandStreamReceiver(executionEnvironment);
|
||||
OSInterface *osInterface = new OSInterface();
|
||||
executionEnvironment.osInterface.reset(osInterface);
|
||||
auto wddm = new WddmMock();
|
||||
|
||||
@@ -64,7 +64,7 @@ struct GlArbSyncEventTest : public ::testing::Test {
|
||||
|
||||
void SetUp() override {
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
auto mockCsr = new MockCommandStreamReceiver();
|
||||
auto mockCsr = new MockCommandStreamReceiver(*executionEnvironment);
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr<MockCommandStreamReceiver>(mockCsr));
|
||||
executionEnvironment->memoryManager = std::make_unique<OsAgnosticMemoryManager>(false, false, *executionEnvironment);
|
||||
device.reset(MockDevice::create<MockDevice>(nullptr, executionEnvironment, 0u));
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace OCLRT {
|
||||
template <typename BaseType, uint32_t ordinal>
|
||||
struct DestructorCounted : public BaseType {
|
||||
template <typename... Args>
|
||||
DestructorCounted(uint32_t &destructorId, Args... args) : BaseType(args...),
|
||||
DestructorCounted(uint32_t &destructorId, Args &&... args) : BaseType(std::forward<Args>(args)...),
|
||||
destructorId(destructorId) {}
|
||||
|
||||
~DestructorCounted() override {
|
||||
|
||||
Reference in New Issue
Block a user