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