mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
Refactor graphics memory allocation scheme
- replace createGraphicsAllocationWithRequiredBitness with more general methodallocateGraphicsMemoryInPreferredPool based on passed AllocationData - proper flags for allocation selected based on AllocationType - remove allocateGraphicsMemory(size_t size, size_t alignment) and use allocateGraphicsMemory(size_t size) instead where default alignment is sufficient, otherwise use full options version: allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) Change-Id: I2da891f372ee181253cb840568a61b33c0d71fc9
This commit is contained in:
committed by
sys_ocldev
parent
4993a94b5b
commit
55a045ebe1
@@ -231,7 +231,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
|
||||
GraphicsAllocation *allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release();
|
||||
|
||||
if (!allocation) {
|
||||
allocation = memoryManager->allocateGraphicsMemory(requiredSize, MemoryConstants::pageSize);
|
||||
allocation = memoryManager->allocateGraphicsMemory(requiredSize);
|
||||
}
|
||||
|
||||
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
||||
|
||||
@@ -46,7 +46,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
|
||||
auto memoryManager = getDevice().getMemoryManager();
|
||||
DEBUG_BREAK_IF(nullptr == memoryManager);
|
||||
|
||||
auto patternAllocation = memoryManager->allocateGraphicsMemory(alignUp(patternSize, MemoryConstants::cacheLineSize), MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = memoryManager->allocateGraphicsMemory(alignUp(patternSize, MemoryConstants::cacheLineSize));
|
||||
patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
|
||||
|
||||
if (patternSize == 1) {
|
||||
|
||||
@@ -244,7 +244,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
|
||||
deviceOwnership.unlock();
|
||||
|
||||
if (!patternAllocation) {
|
||||
patternAllocation = memoryManager->allocateGraphicsMemory(patternSize, MemoryConstants::preferredAlignment);
|
||||
patternAllocation = memoryManager->allocateGraphicsMemory(patternSize);
|
||||
}
|
||||
|
||||
patternAllocation->setAllocationType(GraphicsAllocation::AllocationType::FILL_PATTERN);
|
||||
|
||||
@@ -163,7 +163,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
|
||||
auto allocation = memoryManager->obtainReusableAllocation(requiredSize, false).release();
|
||||
if (!allocation) {
|
||||
allocation = memoryManager->allocateGraphicsMemory(requiredSize, MemoryConstants::pageSize);
|
||||
allocation = memoryManager->allocateGraphicsMemory(requiredSize);
|
||||
}
|
||||
|
||||
allocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM);
|
||||
@@ -303,7 +303,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
|
||||
if (requireInternalHeap) {
|
||||
heapMemory = memoryManager->allocate32BitGraphicsMemory(finalHeapSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION);
|
||||
} else {
|
||||
heapMemory = memoryManager->allocateGraphicsMemory(finalHeapSize, MemoryConstants::pageSize);
|
||||
heapMemory = memoryManager->allocateGraphicsMemory(finalHeapSize);
|
||||
}
|
||||
} else {
|
||||
finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize);
|
||||
|
||||
@@ -239,7 +239,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
|
||||
scratchAllocation->taskCount = this->taskCount;
|
||||
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(scratchAllocation), TEMPORARY_ALLOCATION);
|
||||
}
|
||||
scratchAllocation = getMemoryManager()->createGraphicsAllocationWithRequiredBitness(requiredScratchSizeInBytes, nullptr);
|
||||
scratchAllocation = getMemoryManager()->allocateGraphicsMemoryInPreferredPool(false, true, false, false, nullptr, requiredScratchSizeInBytes, GraphicsAllocation::AllocationType::SCRATCH_SURFACE);
|
||||
overrideMediaVFEStateDirty(true);
|
||||
if (is64bit && !force32BitAllocations) {
|
||||
stateBaseAddressDirty = true;
|
||||
|
||||
@@ -151,8 +151,7 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
|
||||
|
||||
outDevice.memoryManager->csr = commandStreamReceiver;
|
||||
|
||||
auto pTagAllocation = outDevice.memoryManager->allocateGraphicsMemory(
|
||||
sizeof(uint32_t), sizeof(uint32_t));
|
||||
auto pTagAllocation = outDevice.memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
if (!pTagAllocation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -265,8 +265,7 @@ cl_int Kernel::initialize() {
|
||||
retVal = CL_OUT_OF_RESOURCES;
|
||||
break;
|
||||
}
|
||||
|
||||
privateSurface = device.getMemoryManager()->createGraphicsAllocationWithRequiredBitness(static_cast<size_t>(privateSurfaceSize), nullptr);
|
||||
privateSurface = device.getMemoryManager()->allocateGraphicsMemoryInPreferredPool(false, true, false, false, nullptr, static_cast<size_t>(privateSurfaceSize), GraphicsAllocation::AllocationType::PRIVATE_SURFACE);
|
||||
if (privateSurface == nullptr) {
|
||||
retVal = CL_OUT_OF_RESOURCES;
|
||||
break;
|
||||
|
||||
@@ -123,8 +123,12 @@ Buffer *Buffer::create(Context *context,
|
||||
allocateMemory = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!memory) {
|
||||
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(zeroCopy, allocateMemory, true, false, hostPtr, static_cast<size_t>(size), GraphicsAllocation::AllocationType::BUFFER);
|
||||
}
|
||||
|
||||
if (allocateMemory) {
|
||||
memory = memoryManager->createGraphicsAllocationWithRequiredBitness(size, nullptr, true);
|
||||
if (memory) {
|
||||
memoryManager->addAllocationToHostPtrManager(memory);
|
||||
}
|
||||
@@ -132,15 +136,11 @@ Buffer *Buffer::create(Context *context,
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_BUFFER_NEEDS_ALLOCATE_MEMORY);
|
||||
}
|
||||
} else {
|
||||
if (!memory) {
|
||||
//Host ptr was not created with clSVMAlloc - create graphic allocation
|
||||
memory = memoryManager->createGraphicsAllocationWithRequiredBitness(size, hostPtr, true);
|
||||
}
|
||||
if (!memory && Buffer::isReadOnlyMemoryPermittedByFlags(flags)) {
|
||||
memory = memoryManager->createGraphicsAllocationWithRequiredBitness(size, nullptr, true);
|
||||
zeroCopy = false;
|
||||
copyMemoryFromHostPtr = true;
|
||||
allocateMemory = true;
|
||||
memory = memoryManager->allocateGraphicsMemoryInPreferredPool(zeroCopy, allocateMemory, true, false, nullptr, static_cast<size_t>(size), GraphicsAllocation::AllocationType::BUFFER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -62,7 +62,8 @@ Pipe *Pipe::create(Context *context,
|
||||
DEBUG_BREAK_IF(!memoryManager);
|
||||
|
||||
while (true) {
|
||||
GraphicsAllocation *memory = memoryManager->createGraphicsAllocationWithRequiredBitness(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace, nullptr);
|
||||
auto size = static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace);
|
||||
GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, size, GraphicsAllocation::AllocationType::PIPE);
|
||||
if (!memory) {
|
||||
errcodeRet = CL_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
|
||||
@@ -61,6 +61,20 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
TAG_BUFFER,
|
||||
LINEAR_STREAM,
|
||||
FILL_PATTERN,
|
||||
PIPE,
|
||||
EVENT_TAG_BUFFER,
|
||||
COMMAND_BUFFER,
|
||||
PRINTF_SURFACE,
|
||||
GLOBAL_SURFACE,
|
||||
PRIVATE_SURFACE,
|
||||
CONSTANT_SURFACE,
|
||||
SCRATCH_SURFACE,
|
||||
CSR_SURFACE,
|
||||
INSTRUCTION_HEAP,
|
||||
INDIRECT_OBJECT_HEAP,
|
||||
SURFACE_STATE_HEAP,
|
||||
DYNAMIC_STATE_HEAP,
|
||||
SHARED_RESOURCE,
|
||||
NON_AUB_WRITABLE = 0x40000000,
|
||||
WRITABLE = 0x80000000
|
||||
};
|
||||
|
||||
@@ -116,7 +116,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForSVM(size_t size, boo
|
||||
if (enable64kbpages) {
|
||||
graphicsAllocation = allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, false);
|
||||
} else {
|
||||
graphicsAllocation = allocateGraphicsMemory(size, MemoryConstants::pageSize);
|
||||
graphicsAllocation = allocateGraphicsMemory(size);
|
||||
}
|
||||
if (graphicsAllocation) {
|
||||
graphicsAllocation->setCoherent(coherent);
|
||||
@@ -165,7 +165,7 @@ void MemoryManager::cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *gr
|
||||
|
||||
GraphicsAllocation *MemoryManager::createGraphicsAllocationWithPadding(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) {
|
||||
if (!paddingAllocation) {
|
||||
paddingAllocation = allocateGraphicsMemory(paddingBufferSize, MemoryConstants::pageSize);
|
||||
paddingAllocation = allocateGraphicsMemory(paddingBufferSize);
|
||||
}
|
||||
return createPaddedAllocation(inputGraphicsAllocation, sizeWithPadding);
|
||||
}
|
||||
@@ -367,4 +367,67 @@ RequirementsStatus MemoryManager::checkAllocationsForOverlapping(AllocationRequi
|
||||
return status;
|
||||
}
|
||||
|
||||
bool MemoryManager::getAllocationData(AllocationData &allocationData, bool mustBeZeroCopy, bool allocateMemory, bool forcePin, bool uncacheable, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) {
|
||||
UNRECOVERABLE_IF(hostPtr == nullptr && !allocateMemory);
|
||||
|
||||
bool allow64KbPages = false;
|
||||
bool allow32Bit = false;
|
||||
|
||||
switch (type) {
|
||||
case GraphicsAllocation::AllocationType::BUFFER:
|
||||
case GraphicsAllocation::AllocationType::PIPE:
|
||||
case GraphicsAllocation::AllocationType::SCRATCH_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::PRIVATE_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::PRINTF_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::CONSTANT_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::GLOBAL_SURFACE:
|
||||
allow64KbPages = true;
|
||||
allow32Bit = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
allocationData.flags.mustBeZeroCopy = mustBeZeroCopy;
|
||||
allocationData.flags.allocateMemory = allocateMemory;
|
||||
allocationData.flags.allow32Bit = allow32Bit;
|
||||
allocationData.flags.allow64kbPages = allow64KbPages;
|
||||
allocationData.flags.forcePin = forcePin;
|
||||
allocationData.flags.uncacheable = uncacheable;
|
||||
|
||||
if (allocationData.flags.mustBeZeroCopy) {
|
||||
allocationData.flags.useSystemMemory = true;
|
||||
}
|
||||
|
||||
allocationData.hostPtr = hostPtr;
|
||||
allocationData.size = size;
|
||||
allocationData.type = type;
|
||||
|
||||
if (allocationData.flags.allocateMemory) {
|
||||
allocationData.hostPtr = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(bool mustBeZeroCopy, bool allocateMemory, bool forcePin, bool uncacheable, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) {
|
||||
AllocationData allocationData;
|
||||
getAllocationData(allocationData, mustBeZeroCopy, allocateMemory, forcePin, uncacheable, hostPtr, size, type);
|
||||
UNRECOVERABLE_IF(allocationData.type == GraphicsAllocation::AllocationType::IMAGE || allocationData.type == GraphicsAllocation::AllocationType::SHARED_RESOURCE);
|
||||
|
||||
return allocateGraphicsMemory(allocationData);
|
||||
}
|
||||
|
||||
GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &allocationData) {
|
||||
if (force32bitAllocations && allocationData.flags.allow32Bit && is64bit) {
|
||||
return allocate32BitGraphicsMemory(allocationData.size, allocationData.hostPtr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
}
|
||||
if (allocationData.hostPtr) {
|
||||
return allocateGraphicsMemory(allocationData.size, allocationData.hostPtr, allocationData.flags.forcePin);
|
||||
}
|
||||
if (enable64kbpages && allocationData.flags.allow64kbPages) {
|
||||
return allocateGraphicsMemory64kb(allocationData.size, MemoryConstants::pageSize64k, allocationData.flags.forcePin);
|
||||
}
|
||||
return allocateGraphicsMemory(allocationData.size, MemoryConstants::pageSize, allocationData.flags.forcePin, allocationData.flags.uncacheable);
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -60,6 +60,27 @@ enum AllocationOrigin {
|
||||
INTERNAL_ALLOCATION
|
||||
};
|
||||
|
||||
struct AllocationData {
|
||||
union {
|
||||
struct {
|
||||
uint32_t mustBeZeroCopy : 1;
|
||||
uint32_t allocateMemory : 1;
|
||||
uint32_t allow64kbPages : 1;
|
||||
uint32_t allow32Bit : 1;
|
||||
uint32_t useSystemMemory : 1;
|
||||
uint32_t forcePin : 1;
|
||||
uint32_t uncacheable : 1;
|
||||
uint32_t reserved : 25;
|
||||
} flags;
|
||||
uint32_t allFlags = 0;
|
||||
};
|
||||
static_assert(sizeof(AllocationData::flags) == sizeof(AllocationData::allFlags), "");
|
||||
|
||||
GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::UNKNOWN;
|
||||
const void *hostPtr = nullptr;
|
||||
size_t size = 0;
|
||||
};
|
||||
|
||||
struct AlignedMallocRestrictions {
|
||||
uintptr_t minAddress;
|
||||
};
|
||||
@@ -93,12 +114,8 @@ class MemoryManager {
|
||||
virtual void addAllocationToHostPtrManager(GraphicsAllocation *memory) = 0;
|
||||
virtual void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) = 0;
|
||||
|
||||
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size) {
|
||||
return allocateGraphicsMemory(size, static_cast<size_t>(0u));
|
||||
}
|
||||
|
||||
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment) {
|
||||
return allocateGraphicsMemory(size, alignment, false, false);
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size) {
|
||||
return allocateGraphicsMemory(size, MemoryConstants::preferredAlignment, false, false);
|
||||
}
|
||||
|
||||
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) = 0;
|
||||
@@ -110,10 +127,12 @@ class MemoryManager {
|
||||
}
|
||||
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr, bool forcePin);
|
||||
|
||||
virtual GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) = 0;
|
||||
virtual GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) = 0;
|
||||
|
||||
virtual GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) = 0;
|
||||
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(bool mustBeZeroCopy, bool allocateMemory, bool forcePin, bool uncacheable, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type);
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryForSVM(size_t size, bool coherent);
|
||||
|
||||
virtual GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) = 0;
|
||||
@@ -177,25 +196,6 @@ class MemoryManager {
|
||||
bool peekForce32BitAllocations() { return force32bitAllocations; }
|
||||
void setForce32BitAllocations(bool newValue);
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocationWithRequiredBitness(size_t size, void *ptr) {
|
||||
return createGraphicsAllocationWithRequiredBitness(size, ptr, false);
|
||||
}
|
||||
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *createGraphicsAllocationWithRequiredBitness(size_t size, void *ptr, bool forcePin) {
|
||||
if (force32bitAllocations && is64bit) {
|
||||
return allocate32BitGraphicsMemory(size, ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
} else {
|
||||
if (ptr) {
|
||||
return allocateGraphicsMemory(size, ptr, forcePin);
|
||||
}
|
||||
if (enable64kbpages) {
|
||||
return allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, forcePin);
|
||||
} else {
|
||||
return allocateGraphicsMemory(size, MemoryConstants::pageSize, forcePin, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Allocator32bit> allocator32Bit;
|
||||
|
||||
bool peekVirtualPaddingSupport() { return virtualPaddingAvailable; }
|
||||
@@ -235,6 +235,9 @@ class MemoryManager {
|
||||
}
|
||||
|
||||
protected:
|
||||
static bool getAllocationData(AllocationData &allocationData, bool mustBeZeroCopy, bool allocateMemory, bool forcePin, bool uncacheable, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type);
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemory(const AllocationData &allocationData);
|
||||
std::recursive_mutex mtx;
|
||||
std::unique_ptr<TagAllocator<HwTimeStamps>> profilingTimeStampAllocator;
|
||||
std::unique_ptr<TagAllocator<HwPerfCounter>> perfCounterAllocator;
|
||||
|
||||
@@ -67,15 +67,15 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size_t s
|
||||
return allocateGraphicsMemory(alignUp(size, MemoryConstants::pageSize64k), MemoryConstants::pageSize64k, forcePin, false);
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) {
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) {
|
||||
if (ptr) {
|
||||
auto allocationSize = alignSizeWholePage(reinterpret_cast<void *>(ptr), size);
|
||||
auto allocationSize = alignSizeWholePage(ptr, size);
|
||||
auto gpuVirtualAddress = allocator32Bit->allocate(allocationSize);
|
||||
if (!gpuVirtualAddress) {
|
||||
return nullptr;
|
||||
}
|
||||
uint64_t offset = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(ptr) & MemoryConstants::pageMask);
|
||||
MemoryAllocation *memAlloc = new MemoryAllocation(false, reinterpret_cast<void *>(ptr), GmmHelper::canonize(gpuVirtualAddress + offset), size, counter);
|
||||
MemoryAllocation *memAlloc = new MemoryAllocation(false, const_cast<void *>(ptr), GmmHelper::canonize(gpuVirtualAddress + offset), size, counter);
|
||||
memAlloc->is32BitAllocation = true;
|
||||
memAlloc->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase());
|
||||
memAlloc->sizeToFree = allocationSize;
|
||||
@@ -205,7 +205,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage) {
|
||||
}
|
||||
}
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) {
|
||||
auto alloc = allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment);
|
||||
auto alloc = allocateGraphicsMemory(imgInfo.size);
|
||||
if (alloc) {
|
||||
alloc->gmm = gmm;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
~OsAgnosticMemoryManager() override;
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override { return nullptr; }
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override;
|
||||
|
||||
@@ -211,7 +211,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) {
|
||||
if (!GmmHelper::allowTiling(*imgInfo.imgDesc)) {
|
||||
auto alloc = allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment);
|
||||
auto alloc = MemoryManager::allocateGraphicsMemory(imgInfo.size);
|
||||
if (alloc) {
|
||||
alloc->gmm = gmm;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &
|
||||
return allocation;
|
||||
}
|
||||
|
||||
DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) {
|
||||
DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) {
|
||||
auto allocatorToUse = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit.get() : internal32bitAllocator.get();
|
||||
auto allocatorType = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? BIT32_ALLOCATOR_EXTERNAL : BIT32_ALLOCATOR_INTERNAL;
|
||||
|
||||
@@ -289,7 +289,7 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemory(size_t size, void *
|
||||
if (allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION && device && device->getProgramCount() == 0) {
|
||||
this->force32bitAllocations = false;
|
||||
device->setForce32BitAddressing(false);
|
||||
return (DrmAllocation *)createGraphicsAllocationWithRequiredBitness(size, ptr);
|
||||
return (DrmAllocation *)allocateGraphicsMemoryInPreferredPool(false, ptr == nullptr, false, false, ptr, static_cast<size_t>(size), GraphicsAllocation::AllocationType::BUFFER);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -34,6 +34,7 @@ class Drm;
|
||||
|
||||
class DrmMemoryManager : public MemoryManager {
|
||||
public:
|
||||
using MemoryManager::allocateGraphicsMemory;
|
||||
using MemoryManager::createGraphicsAllocationFromSharedHandle;
|
||||
|
||||
DrmMemoryManager(Drm *drm, gemCloseWorkerMode mode, bool forcePinAllowed, bool validateHostPtrMemory);
|
||||
@@ -43,9 +44,6 @@ class DrmMemoryManager : public MemoryManager {
|
||||
void addAllocationToHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
void removeAllocationFromHostPtrManager(GraphicsAllocation *gfxAllocation) override;
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
|
||||
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment) override {
|
||||
return allocateGraphicsMemory(size, alignment, false, false);
|
||||
}
|
||||
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
|
||||
DrmAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
|
||||
DrmAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override {
|
||||
@@ -53,7 +51,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
}
|
||||
DrmAllocation *allocateGraphicsMemory(size_t size, const void *ptr, bool forcePin) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override;
|
||||
DrmAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) override;
|
||||
DrmAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;
|
||||
GraphicsAllocation *createPaddedAllocation(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override { return nullptr; }
|
||||
|
||||
@@ -63,7 +63,7 @@ void APIENTRY WddmMemoryManager::trimCallback(_Inout_ D3DKMT_TRIMNOTIFICATION *t
|
||||
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) {
|
||||
if (!GmmHelper::allowTiling(*imgInfo.imgDesc) && imgInfo.mipCount == 0) {
|
||||
delete gmm;
|
||||
return allocateGraphicsMemory(imgInfo.size, MemoryConstants::preferredAlignment);
|
||||
return allocateGraphicsMemory(imgInfo.size);
|
||||
}
|
||||
auto allocation = new WddmAllocation(nullptr, imgInfo.size, nullptr);
|
||||
allocation->gmm = gmm;
|
||||
@@ -162,7 +162,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, const
|
||||
return MemoryManager::allocateGraphicsMemory(size, ptr);
|
||||
}
|
||||
|
||||
GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) {
|
||||
GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) {
|
||||
Gmm *gmm = nullptr;
|
||||
const void *ptrAligned = nullptr;
|
||||
size_t sizeAligned = size;
|
||||
|
||||
@@ -49,7 +49,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) override;
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override;
|
||||
|
||||
@@ -52,8 +52,7 @@ void PrintfHandler::prepareDispatch(const MultiDispatchInfo &multiDispatchInfo)
|
||||
return;
|
||||
}
|
||||
kernel = multiDispatchInfo.begin()->getKernel();
|
||||
|
||||
printfSurface = device.getMemoryManager()->createGraphicsAllocationWithRequiredBitness(printfSurfaceSize, nullptr);
|
||||
printfSurface = device.getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, printfSurfaceSize, GraphicsAllocation::AllocationType::PRINTF_SURFACE);
|
||||
|
||||
*reinterpret_cast<uint32_t *>(printfSurface->getUnderlyingBuffer()) = printfSurfaceInitialDataSize;
|
||||
|
||||
|
||||
@@ -844,8 +844,7 @@ cl_int Program::parseProgramScopePatchList() {
|
||||
|
||||
surfaceSize = patch.InlineDataSize;
|
||||
headerSize = sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo);
|
||||
|
||||
constantSurface = pDevice->getMemoryManager()->createGraphicsAllocationWithRequiredBitness(surfaceSize, nullptr);
|
||||
constantSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, surfaceSize, GraphicsAllocation::AllocationType::CONSTANT_SURFACE);
|
||||
|
||||
memcpy_s(constantSurface->getUnderlyingBuffer(), surfaceSize, (cl_char *)pPatch + headerSize, surfaceSize);
|
||||
pCurPatchListPtr = ptrOffset(pCurPatchListPtr, surfaceSize);
|
||||
@@ -867,7 +866,8 @@ cl_int Program::parseProgramScopePatchList() {
|
||||
surfaceSize = patch.InlineDataSize;
|
||||
globalVarTotalSize += (size_t)surfaceSize;
|
||||
headerSize = sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo);
|
||||
globalSurface = pDevice->getMemoryManager()->createGraphicsAllocationWithRequiredBitness(surfaceSize, nullptr);
|
||||
globalSurface = pDevice->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, surfaceSize, GraphicsAllocation::AllocationType::GLOBAL_SURFACE);
|
||||
|
||||
memcpy_s(globalSurface->getUnderlyingBuffer(), surfaceSize, (cl_char *)pPatch + headerSize, surfaceSize);
|
||||
pCurPatchListPtr = ptrOffset(pCurPatchListPtr, surfaceSize);
|
||||
DBG_LOG(LogPatchTokens,
|
||||
|
||||
@@ -392,8 +392,7 @@ void Program::allocateBlockPrivateSurfaces() {
|
||||
|
||||
if (privateSize > 0 && blockKernelManager->getPrivateSurface(i) == nullptr) {
|
||||
privateSize *= getDevice(0).getDeviceInfo().computeUnitsUsedForScratch * info->getMaxSimdSize();
|
||||
|
||||
auto *privateSurface = getDevice(0).getMemoryManager()->createGraphicsAllocationWithRequiredBitness(privateSize, nullptr);
|
||||
auto *privateSurface = getDevice(0).getMemoryManager()->allocateGraphicsMemoryInPreferredPool(false, true, false, false, nullptr, static_cast<size_t>(privateSize), GraphicsAllocation::AllocationType::PRIVATE_SURFACE);
|
||||
blockKernelManager->pushPrivateSurface(privateSurface, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ TEST_F(CommandQueueCommandStreamTest, MemoryManagerWithReusableAllocationsWhenAs
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
size_t requiredSize = alignUp(100, MemoryConstants::pageSize) + CSRequirements::csOverfetchSize;
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(requiredSize, 4096);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(requiredSize);
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
|
||||
EXPECT_FALSE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
@@ -105,7 +105,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, GPGPUWalker) {
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueFillBufferCmdTests, addsIndirectData) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
auto dshBefore = pDSH->getUsed();
|
||||
auto iohBefore = pIOH->getUsed();
|
||||
@@ -140,7 +140,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, addsIndirectData) {
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueFillBufferCmdTests, FillBufferRightLeftover) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
EnqueueFillBufferHelper<>::enqueueFillBuffer(pCmdQ, buffer);
|
||||
|
||||
@@ -166,7 +166,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferRightLeftover) {
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueFillBufferCmdTests, FillBufferMiddle) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
EnqueueFillBufferHelper<>::enqueueFillBuffer(pCmdQ, buffer);
|
||||
|
||||
@@ -192,7 +192,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferMiddle) {
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueFillBufferCmdTests, FillBufferLeftLeftover) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
EnqueueFillBufferHelper<>::enqueueFillBuffer(pCmdQ, buffer);
|
||||
|
||||
@@ -295,7 +295,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, MediaVFEState) {
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, argumentZeroShouldMatchDestAddress) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
enqueueFillBuffer<FamilyType>();
|
||||
|
||||
@@ -330,7 +330,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, argumentZeroShouldMatchDe
|
||||
// This could happen if KernelInfo.kernelArgInfo was accessible given a Kernel. Just need an offset
|
||||
// into CrossThreadData.
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, DISABLED_argumentOneShouldMatchOffset) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
enqueueFillBuffer<FamilyType>();
|
||||
|
||||
@@ -362,7 +362,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, DISABLED_argumentOneShoul
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, argumentTwoShouldMatchPatternPtr) {
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
auto patternAllocation = context.getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
|
||||
enqueueFillBuffer<FamilyType>();
|
||||
|
||||
|
||||
@@ -936,7 +936,7 @@ TEST_F(EnqueueMapImageTest, givenImage1DArrayWhenEnqueueMapImageIsCalledThenRetu
|
||||
imageFormat.image_channel_data_type = CL_UNSIGNED_INT16;
|
||||
|
||||
const SurfaceFormatInfo *surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat);
|
||||
auto allocation = context->getMemoryManager()->allocateGraphicsMemory(imgSize, MemoryConstants::preferredAlignment);
|
||||
auto allocation = context->getMemoryManager()->allocateGraphicsMemory(imgSize);
|
||||
ASSERT_NE(allocation, nullptr);
|
||||
|
||||
MockImage image(context, flags, allocation, *surfaceFormat, imageFormat, imageDesc);
|
||||
|
||||
@@ -496,7 +496,7 @@ HWTEST_F(EnqueueThreading, flushWaitList_ReleaseOwnershipWhenQueueIsBlocked) {
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
pMyDevice->setMemoryManager(memoryManager);
|
||||
|
||||
auto pTagAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t));
|
||||
auto pTagAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
*(uint32_t *)(pTagAllocation->getUnderlyingBuffer()) = initialHardwareTag;
|
||||
ASSERT_NE(nullptr, pTagAllocation);
|
||||
pMyDevice->setTagAllocation(pTagAllocation);
|
||||
|
||||
@@ -57,7 +57,7 @@ struct GetSizeRequiredBufferTest : public CommandEnqueueFixture,
|
||||
BufferDefaults::context = new MockContext;
|
||||
srcBuffer = BufferHelper<>::create();
|
||||
dstBuffer = BufferHelper<>::create();
|
||||
patternAllocation = context->getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize, MemoryConstants::preferredAlignment);
|
||||
patternAllocation = context->getMemoryManager()->allocateGraphicsMemory(EnqueueFillBufferTraits::patternSize);
|
||||
pDevice->setPreemptionMode(PreemptionMode::Disabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -238,7 +238,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], false));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -267,7 +267,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -302,7 +302,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -337,7 +337,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStanda
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_FALSE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -375,7 +375,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
|
||||
aubCsr->subCaptureManager.reset(aubSubCaptureManagerMock);
|
||||
ASSERT_TRUE(aubCsr->subCaptureManager->isSubCaptureEnabled());
|
||||
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -398,7 +398,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -425,7 +425,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -453,7 +453,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, gfxAllocation);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -488,7 +488,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -528,7 +528,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, gfxAllocation);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -807,7 +807,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
|
||||
ASSERT_NE(nullptr, chainedBatchBuffer);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -831,7 +831,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
auto flatBatchBufferHelper = new FlatBatchBufferHelperHw<FamilyType>(memoryManager.get());
|
||||
aubCsr->overwriteFlatBatchBufferHelper(flatBatchBufferHelper);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -857,7 +857,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
|
||||
ASSERT_NE(nullptr, chainedBatchBuffer);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -881,7 +881,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenRegiste
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBufferAllocation = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBufferAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBufferAllocation);
|
||||
LinearStream cs(commandBufferAllocation);
|
||||
|
||||
@@ -984,7 +984,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
|
||||
ASSERT_EQ(3u, aubCsr->getFlatBatchBufferHelper().getPatchInfoCollection().size());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1019,7 +1019,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefault
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1047,7 +1047,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1082,7 +1082,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1109,7 +1109,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
aubCsr->setTagAllocation(pDevice->getTagAllocation());
|
||||
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
ResidencyContainer allocationsForResidency;
|
||||
@@ -1131,7 +1131,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1151,7 +1151,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatc
|
||||
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1171,7 +1171,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenNoPat
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1205,7 +1205,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1230,7 +1230,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenFirst
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1254,7 +1254,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSecon
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1278,7 +1278,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenPatch
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1357,7 +1357,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSourc
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1418,7 +1418,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenTarge
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
|
||||
memoryManager.reset(aubCsr->createMemoryManager(false));
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenCheckedForInit
|
||||
TEST_F(CommandStreamReceiverTest, makeResidentPushesAllocationToMemoryManagerResidencyList) {
|
||||
auto *memoryManager = commandStreamReceiver->getMemoryManager();
|
||||
|
||||
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(0x1000, 0x34000);
|
||||
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(0x1000);
|
||||
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
|
||||
}
|
||||
|
||||
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenBaseCsrFlushStampIsReturned) {
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC
|
||||
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(0u, memoryManager->getResidencyAllocations().size());
|
||||
@@ -201,7 +201,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHas
|
||||
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(0u, memoryManager->getResidencyAllocations().size());
|
||||
@@ -222,7 +222,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa
|
||||
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_TRUE(tbxCsr->writeMemory(*graphicsAllocation));
|
||||
@@ -242,7 +242,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
|
||||
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount);
|
||||
@@ -261,7 +261,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenProcessResidenc
|
||||
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(ObjectNotResident, graphicsAllocation->residencyTaskCount);
|
||||
@@ -283,7 +283,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, MemoryConstants::pageSize);
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -1599,7 +1599,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenKernelIsaIs
|
||||
commandStreamReceiver.storeMakeResidentAllocations = true;
|
||||
|
||||
auto memoryManager = commandStreamReceiver.getMemoryManager();
|
||||
pKernelInfo->kernelAllocation = memoryManager->allocateGraphicsMemory(MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
pKernelInfo->kernelAllocation = memoryManager->allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
|
||||
// setup kernel arg offsets
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
@@ -108,9 +108,9 @@ INSTANTIATE_TEST_CASE_P(
|
||||
|
||||
class GMockMemoryManagerFailFirstAllocation : public MockMemoryManager {
|
||||
public:
|
||||
MOCK_METHOD3(createGraphicsAllocationWithRequiredBitness, GraphicsAllocation *(size_t size, void *ptr, bool forcePin));
|
||||
GraphicsAllocation *baseCreateGraphicsAllocationWithRequiredBitness(size_t size, void *ptr, bool forcePin) {
|
||||
return MockMemoryManager::createGraphicsAllocationWithRequiredBitness(size, ptr, forcePin);
|
||||
MOCK_METHOD7(allocateGraphicsMemoryInPreferredPool, GraphicsAllocation *(bool mustBeZeroCopy, bool allocateMemory, bool forcePin, bool uncacheable, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type));
|
||||
GraphicsAllocation *baseallocateGraphicsMemoryInPreferredPool(bool mustBeZeroCopy, bool allocateMemory, bool forcePin, bool uncacheable, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) {
|
||||
return MockMemoryManager::allocateGraphicsMemoryInPreferredPool(mustBeZeroCopy, allocateMemory, forcePin, uncacheable, hostPtr, size, type);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,12 +126,10 @@ TEST(Buffer, givenReadOnlyHostPtrMemoryWhenBufferIsCreatedWithReadOnlyFlagsThenB
|
||||
device->injectMemoryManager(memoryManager);
|
||||
MockContext ctx(device.get());
|
||||
|
||||
// First fail in createGraphicsAllocation simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, createGraphicsAllocationWithRequiredBitness(MemoryConstants::pageSize, (void *)memory, true))
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
|
||||
EXPECT_CALL(*memoryManager, createGraphicsAllocationWithRequiredBitness(::testing::_, nullptr, ::testing::_))
|
||||
.WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseCreateGraphicsAllocationWithRequiredBitness));
|
||||
// First fail simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
||||
.WillOnce(::testing::Return(nullptr))
|
||||
.WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseallocateGraphicsMemoryInPreferredPool));
|
||||
|
||||
cl_int retVal;
|
||||
cl_mem_flags flags = CL_MEM_HOST_READ_ONLY | CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR;
|
||||
@@ -158,12 +156,10 @@ TEST(Buffer, givenReadOnlyHostPtrMemoryWhenBufferIsCreatedWithReadOnlyFlagsAndSe
|
||||
device->injectMemoryManager(memoryManager);
|
||||
MockContext ctx(device.get());
|
||||
|
||||
// First fail in createGraphicsAllocation simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, createGraphicsAllocationWithRequiredBitness(MemoryConstants::pageSize, (void *)memory, true))
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
|
||||
EXPECT_CALL(*memoryManager, createGraphicsAllocationWithRequiredBitness(::testing::_, nullptr, ::testing::_))
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
// First fail simulates error for read only memory allocation
|
||||
// Second fail returns nullptr
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
||||
.WillRepeatedly(::testing::Return(nullptr));
|
||||
|
||||
cl_int retVal;
|
||||
cl_mem_flags flags = CL_MEM_HOST_READ_ONLY | CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR;
|
||||
@@ -186,8 +182,8 @@ TEST(Buffer, givenReadOnlyHostPtrMemoryWhenBufferIsCreatedWithKernelWriteFlagThe
|
||||
device->injectMemoryManager(memoryManager);
|
||||
MockContext ctx(device.get());
|
||||
|
||||
// First fail in createGraphicsAllocation simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, createGraphicsAllocationWithRequiredBitness(MemoryConstants::pageSize, (void *)memory, true))
|
||||
// First fail simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
|
||||
cl_int retVal;
|
||||
@@ -206,8 +202,8 @@ TEST(Buffer, givenNullPtrWhenBufferIsCreatedWithKernelReadOnlyFlagsThenBufferAll
|
||||
device->injectMemoryManager(memoryManager);
|
||||
MockContext ctx(device.get());
|
||||
|
||||
// First fail in createGraphicsAllocation simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, createGraphicsAllocationWithRequiredBitness(::testing::_, nullptr, ::testing::_))
|
||||
// First fail simulates error for read only memory allocation
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInPreferredPool(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
|
||||
.WillOnce(::testing::Return(nullptr));
|
||||
|
||||
cl_int retVal;
|
||||
|
||||
@@ -48,7 +48,7 @@ class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
|
||||
device = static_cast<MockDevice *>(context->getDevice(0));
|
||||
device->injectMemoryManager(memoryManager);
|
||||
context->setMemoryManager(memoryManager);
|
||||
allocation = memoryManager->allocateGraphicsMemory(size, MemoryConstants::pageSize);
|
||||
allocation = memoryManager->allocateGraphicsMemory(size);
|
||||
memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER,
|
||||
CL_MEM_READ_WRITE,
|
||||
size,
|
||||
@@ -195,7 +195,7 @@ HWTEST_P(MemObjAsyncDestructionTest, givenUsedMemObjWithAsyncDestructionsEnabled
|
||||
|
||||
if (!hasAllocatedMappedPtr) {
|
||||
delete memObj;
|
||||
allocation = memoryManager->allocateGraphicsMemory(size, MemoryConstants::pageSize);
|
||||
allocation = memoryManager->allocateGraphicsMemory(size);
|
||||
MemObjOffsetArray origin = {{0, 0, 0}};
|
||||
MemObjSizeArray region = {{1, 1, 1}};
|
||||
cl_map_flags mapFlags = CL_MAP_READ;
|
||||
|
||||
@@ -175,7 +175,7 @@ TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThe
|
||||
context.setMemoryManager(&memoryManager);
|
||||
memoryManager.setDevice(context.getDevice(0));
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
allocation->taskCount = 2;
|
||||
*memoryManager.device->getTagAddress() = 1;
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
@@ -194,7 +194,7 @@ TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAl
|
||||
context.setMemoryManager(&memoryManager);
|
||||
memoryManager.setDevice(context.getDevice(0));
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
allocation->taskCount = 1;
|
||||
*memoryManager.device->getTagAddress() = 1;
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
@@ -213,7 +213,7 @@ TEST(MemObj, givenNotUsedGraphicsAllocationWhenMemObjDestroysAllocationAsyncThen
|
||||
context.setMemoryManager(&memoryManager);
|
||||
memoryManager.setDevice(context.getDevice(0));
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
allocation->taskCount = ObjectNotUsed;
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
||||
@@ -230,7 +230,7 @@ TEST(MemObj, givenMemoryManagerWithoutDeviceWhenMemObjDestroysAllocationAsyncThe
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize);
|
||||
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
|
||||
@@ -336,7 +336,7 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) {
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(1, 1);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(1);
|
||||
allocation->gmm = new Gmm(nullptr, 1, false);
|
||||
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE,
|
||||
@@ -354,7 +354,7 @@ TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
|
||||
|
||||
context.setMemoryManager(&memoryManager);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(64, 1);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(64);
|
||||
|
||||
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
|
||||
64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false);
|
||||
|
||||
@@ -24,7 +24,7 @@ set(IGDRCL_SRCS_tests_memory_manager
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter_mt_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_allocate_with_ptr_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_allocate_in_preferred_pool_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/surface_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/svm_memory_manager.cpp
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
class MemoryManagerGetAlloctionDataTest : public testing::TestWithParam<GraphicsAllocation::AllocationType> {
|
||||
public:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
class MockOsAgnosticMemoryManager : public OsAgnosticMemoryManager {
|
||||
public:
|
||||
using MemoryManager::allocateGraphicsMemory;
|
||||
using MemoryManager::getAllocationData;
|
||||
MockOsAgnosticMemoryManager(bool enable64kbPages) : OsAgnosticMemoryManager(enable64kbPages) {
|
||||
}
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override {
|
||||
allocationCreated = true;
|
||||
return OsAgnosticMemoryManager::allocateGraphicsMemory(size, alignment, forcePin, uncacheable);
|
||||
}
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override {
|
||||
allocation64kbPageCreated = true;
|
||||
return OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size, alignment, forcePin);
|
||||
}
|
||||
bool allocationCreated = false;
|
||||
bool allocation64kbPageCreated = false;
|
||||
};
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenMustBeZeroCopyAndAllocateMemoryFlagsAndNullptrWhenAllocationDataIsQueriedThenCorrectFlagsAndSizeAreSet) {
|
||||
AllocationData allocData;
|
||||
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, true, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_TRUE(allocData.flags.mustBeZeroCopy);
|
||||
EXPECT_TRUE(allocData.flags.useSystemMemory);
|
||||
EXPECT_EQ(10u, allocData.size);
|
||||
EXPECT_EQ(nullptr, allocData.hostPtr);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenMustBeZeroCopyFlagFalseWhenAllocationDataIsQueriedThenMustBeZeroCopyAndUseSystemMemoryFlagsAreNotSet) {
|
||||
AllocationData allocData;
|
||||
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_FALSE(allocData.flags.mustBeZeroCopy);
|
||||
EXPECT_FALSE(allocData.flags.useSystemMemory);
|
||||
EXPECT_EQ(10u, allocData.size);
|
||||
EXPECT_EQ(nullptr, allocData.hostPtr);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenAllocateMemoryFlagTrueWhenHostPtrIsNotNullThenAllocationDataHasHostPtrNulled) {
|
||||
AllocationData allocData;
|
||||
char memory = 0;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, &memory, sizeof(memory), GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_EQ(sizeof(memory), allocData.size);
|
||||
EXPECT_EQ(nullptr, allocData.hostPtr);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenForcePinFlagTrueWhenAllocationDataIsQueriedThenCorrectFlagIsSet) {
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, true, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_TRUE(allocData.flags.forcePin);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenUncacheableFlagTrueWhenAllocationDataIsQueriedThenCorrectFlagIsSet) {
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, true, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_TRUE(allocData.flags.uncacheable);
|
||||
}
|
||||
|
||||
typedef MemoryManagerGetAlloctionDataTest MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest;
|
||||
|
||||
TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest, givenAllocationTypesWith32BitAnd64kbPagesAllowedWhenAllocationDataIsQueriedThenProperFlagsAreSet) {
|
||||
AllocationData allocData;
|
||||
|
||||
auto allocType = GetParam();
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, allocType);
|
||||
|
||||
EXPECT_TRUE(allocData.flags.allow32Bit);
|
||||
EXPECT_TRUE(allocData.flags.allow64kbPages);
|
||||
EXPECT_EQ(allocType, allocData.type);
|
||||
}
|
||||
|
||||
typedef MemoryManagerGetAlloctionDataTest MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest;
|
||||
|
||||
TEST_P(MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest, givenAllocationTypesWith32BitAnd64kbPagesDisallowedWhenAllocationDataIsQueriedThenFlagsAreNotSet) {
|
||||
AllocationData allocData;
|
||||
|
||||
auto allocType = GetParam();
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, allocType);
|
||||
|
||||
EXPECT_FALSE(allocData.flags.allow32Bit);
|
||||
EXPECT_FALSE(allocData.flags.allow64kbPages);
|
||||
EXPECT_EQ(allocType, allocData.type);
|
||||
}
|
||||
|
||||
static const GraphicsAllocation::AllocationType allocationTypesWith32BitAnd64KbPagesAllowed[] = {GraphicsAllocation::AllocationType::BUFFER,
|
||||
GraphicsAllocation::AllocationType::PIPE,
|
||||
GraphicsAllocation::AllocationType::SCRATCH_SURFACE,
|
||||
GraphicsAllocation::AllocationType::PRIVATE_SURFACE,
|
||||
GraphicsAllocation::AllocationType::PRINTF_SURFACE,
|
||||
GraphicsAllocation::AllocationType::CONSTANT_SURFACE,
|
||||
GraphicsAllocation::AllocationType::GLOBAL_SURFACE};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Allow32BitAnd64kbPagesTypes,
|
||||
MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest,
|
||||
::testing::ValuesIn(allocationTypesWith32BitAnd64KbPagesAllowed));
|
||||
|
||||
static const GraphicsAllocation::AllocationType allocationTypesWith32BitAnd64KbPagesNotAllowed[] = {GraphicsAllocation::AllocationType::COMMAND_BUFFER,
|
||||
GraphicsAllocation::AllocationType::CSR_SURFACE,
|
||||
GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP,
|
||||
GraphicsAllocation::AllocationType::EVENT_TAG_BUFFER,
|
||||
GraphicsAllocation::AllocationType::IMAGE,
|
||||
GraphicsAllocation::AllocationType::INSTRUCTION_HEAP,
|
||||
GraphicsAllocation::AllocationType::SHARED_RESOURCE};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Disallow32BitAnd64kbPagesTypes,
|
||||
MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest,
|
||||
::testing::ValuesIn(allocationTypesWith32BitAnd64KbPagesNotAllowed));
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedTypeIsAllocatedThen32BitAllocationIsReturned) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
if (is64bit) {
|
||||
EXPECT_TRUE(allocation->is32BitAllocation);
|
||||
} else {
|
||||
EXPECT_FALSE(allocation->is32BitAllocation);
|
||||
}
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitEnabledWhenGraphicsMemorywihtoutAllow32BitFlagIsAllocatedThenNon32BitAllocationIsReturned) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
allocData.flags.allow32Bit = false;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_FALSE(allocation->is32BitAllocation);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitDisabledWhenGraphicsMemoryWith32BitFlagFor32BitAllowedTypeIsAllocatedThenNon32BitAllocationIsReturned) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
memoryManager.setForce32BitAllocations(false);
|
||||
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_FALSE(allocation->is32BitAllocation);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryMustBeZeroCopyAndIsAllocatedWithNullptrForBufferThen64kbAllocationIsReturned) {
|
||||
OsAgnosticMemoryManager memoryManager(true);
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, true, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(allocation->getUnderlyingBuffer()) & MemoryConstants::page64kMask);
|
||||
EXPECT_EQ(0u, allocation->getGpuAddress() & MemoryConstants::page64kMask);
|
||||
EXPECT_EQ(0u, allocation->getUnderlyingBufferSize() & MemoryConstants::page64kMask);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryWithoutAllow64kbPagesFlagsIsAllocatedThenNon64kbAllocationIsReturned) {
|
||||
MockOsAgnosticMemoryManager memoryManager(true);
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, false, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
allocData.flags.allow64kbPages = false;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_FALSE(memoryManager.allocation64kbPageCreated);
|
||||
EXPECT_TRUE(memoryManager.allocationCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenDisabled64kbPagesWhenGraphicsMemoryMustBeZeroCopyAndIsAllocatedWithNullptrForBufferThenNon64kbAllocationIsReturned) {
|
||||
MockOsAgnosticMemoryManager memoryManager(false);
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, true, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_FALSE(memoryManager.allocation64kbPageCreated);
|
||||
EXPECT_TRUE(memoryManager.allocationCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenForced32BitAndEnabled64kbPagesWhenGraphicsMemoryMustBeZeroCopyAndIsAllocatedWithNullptrForBufferThen32BitAllocationOver64kbIsChosen) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
AllocationData allocData;
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, true, true, false, false, nullptr, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
if (is64bit) {
|
||||
EXPECT_TRUE(allocation->is32BitAllocation);
|
||||
} else {
|
||||
EXPECT_FALSE(allocation->is32BitAllocation);
|
||||
}
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryIsAllocatedWithHostPtrForBufferThenExistingMemoryIsUsedForAllocation) {
|
||||
OsAgnosticMemoryManager memoryManager(true);
|
||||
AllocationData allocData;
|
||||
char memory[10];
|
||||
MockOsAgnosticMemoryManager::getAllocationData(allocData, true, false, false, false, &memory, 10, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(1u, allocation->fragmentsStorage.fragmentCount);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ TEST_F(MemoryAllocatorTest, allocateGraphics) {
|
||||
TEST_F(MemoryAllocatorTest, allocateGraphicsPageAligned) {
|
||||
unsigned int alignment = 4096;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char), alignment);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char));
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(allocation->getUnderlyingBuffer()) & (alignment - 1));
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
@@ -222,7 +222,7 @@ TEST_F(MemoryAllocatorTest, allocateGraphicsPageAligned) {
|
||||
TEST_F(MemoryAllocatorTest, allocateGraphicsMoreThanPageAligned) {
|
||||
unsigned int alignment = 6144;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char), 6144);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(char), 6144, false, false);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(allocation->getUnderlyingBuffer()) & (alignment - 1));
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
@@ -239,25 +239,24 @@ TEST_F(MemoryAllocatorTest, storeTemporaryAllocation) {
|
||||
TEST_F(MemoryAllocatorTest, DISABLED_allocateGraphicsPageDebugInitialized) {
|
||||
// Test the memory initialization control when debugging
|
||||
if (OCLRT::DebugManager.disabled() == false) {
|
||||
unsigned int alignment = 4096;
|
||||
auto f = DebugManager.flags.InitializeMemoryInDebug.get();
|
||||
|
||||
DebugManager.flags.InitializeMemoryInDebug.set(0x10);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), alignment);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
uint32_t *a = reinterpret_cast<uint32_t *>(allocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(0xFEFEFEFE, *a);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
|
||||
DebugManager.flags.InitializeMemoryInDebug.set(0x20);
|
||||
allocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), alignment);
|
||||
allocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
a = reinterpret_cast<uint32_t *>(allocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(0u, *a);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
|
||||
DebugManager.flags.InitializeMemoryInDebug.set(0x00);
|
||||
allocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), alignment);
|
||||
allocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t));
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
|
||||
@@ -391,9 +390,9 @@ TEST_F(MemoryAllocatorTest, obtainAllocationFromReusableList) {
|
||||
TEST_F(MemoryAllocatorTest, obtainAllocationFromMidlleOfReusableList) {
|
||||
EXPECT_TRUE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1, 4096);
|
||||
auto allocation2 = memoryManager->allocateGraphicsMemory(10000, 4096);
|
||||
auto allocation3 = memoryManager->allocateGraphicsMemory(1, 4096);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1);
|
||||
auto allocation2 = memoryManager->allocateGraphicsMemory(10000);
|
||||
auto allocation3 = memoryManager->allocateGraphicsMemory(1);
|
||||
|
||||
EXPECT_TRUE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
@@ -431,7 +430,7 @@ TEST_F(MemoryAllocatorTest, obtainAllocationFromMidlleOfReusableList) {
|
||||
TEST_F(MemoryAllocatorTest, givenNonInternalAllocationWhenItIsPutOnReusableListWhenInternalAllocationIsRequestedThenNullIsReturned) {
|
||||
EXPECT_TRUE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
|
||||
EXPECT_FALSE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
@@ -443,7 +442,7 @@ TEST_F(MemoryAllocatorTest, givenNonInternalAllocationWhenItIsPutOnReusableListW
|
||||
TEST_F(MemoryAllocatorTest, givenInternalAllocationWhenItIsPutOnReusableListWhenNonInternalAllocationIsRequestedThenNullIsReturned) {
|
||||
EXPECT_TRUE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
allocation->is32BitAllocation = true;
|
||||
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
@@ -457,7 +456,7 @@ TEST_F(MemoryAllocatorTest, givenInternalAllocationWhenItIsPutOnReusableListWhen
|
||||
TEST_F(MemoryAllocatorTest, givenInternalAllocationWhenItIsPutOnReusableListWhenInternalAllocationIsRequestedThenItIsReturned) {
|
||||
EXPECT_TRUE(memoryManager->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(4096, 4096);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(4096);
|
||||
allocation->is32BitAllocation = true;
|
||||
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
@@ -901,7 +900,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandle
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenLockUnlockCalledThenDoNothing) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(1, 1);
|
||||
auto allocation = memoryManager.allocateGraphicsMemory(1);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ptr = memoryManager.lockResource(allocation);
|
||||
@@ -914,7 +913,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenLockUnlockCalledThenDoNothin
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationContainsOffsetWhenAddressIsObtainedThenOffsetIsAdded) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
auto graphicsAddress = graphicsAllocation->getGpuAddress();
|
||||
auto graphicsAddressToPatch = graphicsAllocation->getGpuAddressToPatch();
|
||||
@@ -932,7 +931,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationCon
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationIsPaddedThenNewGraphicsAllocationIsCreated) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
auto sizeWithPadding = 8192;
|
||||
auto paddedGraphicsAllocation = memoryManager.createGraphicsAllocationWithPadding(graphicsAllocation, sizeWithPadding);
|
||||
@@ -950,7 +949,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationIsP
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenTwoGraphicsAllocationArePaddedThenOnlyOnePaddingBufferIsUsed) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
auto sizeWithPadding = 8192;
|
||||
auto paddedGraphicsAllocation = memoryManager.createGraphicsAllocationWithPadding(graphicsAllocation, sizeWithPadding);
|
||||
@@ -973,7 +972,7 @@ TEST(OsAgnosticMemoryManager, pleaseDetectLeak) {
|
||||
|
||||
TEST(OsAgnosticMemoryManager, pushAllocationForResidency) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
EXPECT_EQ(0u, memoryManager.getResidencyAllocations().size());
|
||||
|
||||
@@ -985,7 +984,7 @@ TEST(OsAgnosticMemoryManager, pushAllocationForResidency) {
|
||||
|
||||
TEST(OsAgnosticMemoryManager, clearResidencyAllocations) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
memoryManager.pushAllocationForResidency(graphicsAllocation);
|
||||
|
||||
@@ -998,7 +997,7 @@ TEST(OsAgnosticMemoryManager, clearResidencyAllocations) {
|
||||
|
||||
TEST(OsAgnosticMemoryManager, pushAllocationForEviction) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
EXPECT_EQ(0u, memoryManager.getEvictionAllocations().size());
|
||||
|
||||
@@ -1010,7 +1009,7 @@ TEST(OsAgnosticMemoryManager, pushAllocationForEviction) {
|
||||
|
||||
TEST(OsAgnosticMemoryManager, clearEvictionAllocations) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u, MemoryConstants::pageSize);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory(4096u);
|
||||
|
||||
memoryManager.pushAllocationForEviction(graphicsAllocation);
|
||||
|
||||
@@ -1024,7 +1023,7 @@ TEST(OsAgnosticMemoryManager, clearEvictionAllocations) {
|
||||
TEST(OsAgnosticMemoryManager, alignmentIsCorrect) {
|
||||
OsAgnosticMemoryManager memoryManager;
|
||||
const size_t alignment = 0;
|
||||
auto ga = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize >> 1, alignment);
|
||||
auto ga = memoryManager.allocateGraphicsMemory(MemoryConstants::pageSize >> 1, alignment, false, false);
|
||||
uintptr_t ptr = reinterpret_cast<uintptr_t>(ga->getUnderlyingBuffer());
|
||||
ptr &= (MemoryConstants::allocationAlignment - 1);
|
||||
EXPECT_EQ(ptr, 0u);
|
||||
@@ -1124,27 +1123,18 @@ TEST(OsAgnosticMemoryManager, GivenEnabled64kbPagesWhenAllocationIsCreatedThenAl
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.Enable64kbpages.set(true);
|
||||
OsAgnosticMemoryManager memoryManager(true);
|
||||
GraphicsAllocation *galloc = memoryManager.createGraphicsAllocationWithRequiredBitness(64 * 1024, nullptr);
|
||||
|
||||
GraphicsAllocation *galloc = memoryManager.allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, 64 * 1024, GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_NE(nullptr, galloc);
|
||||
memoryManager.freeGraphicsMemory(galloc);
|
||||
|
||||
galloc = memoryManager.createGraphicsAllocationWithRequiredBitness(64 * 1024, nullptr, false);
|
||||
galloc = memoryManager.allocateGraphicsMemoryInPreferredPool(true, true, true, false, nullptr, 64 * 1024, GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_NE(nullptr, galloc);
|
||||
memoryManager.freeGraphicsMemory(galloc);
|
||||
|
||||
galloc = memoryManager.createGraphicsAllocationWithRequiredBitness(64 * 1024, nullptr, true);
|
||||
EXPECT_NE(nullptr, galloc);
|
||||
galloc->getUnderlyingBuffer();
|
||||
EXPECT_NE(nullptr, galloc->getUnderlyingBuffer());
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getUnderlyingBuffer() % 65536U);
|
||||
galloc->getGpuAddress();
|
||||
EXPECT_NE(0u, galloc->getGpuAddress());
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getGpuAddress() % 65536U);
|
||||
memoryManager.freeGraphicsMemory(galloc);
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getUnderlyingBuffer() % MemoryConstants::pageSize64k);
|
||||
|
||||
char ptr[1];
|
||||
galloc = memoryManager.createGraphicsAllocationWithRequiredBitness(64 * 1024, ptr, true);
|
||||
EXPECT_NE(nullptr, galloc);
|
||||
EXPECT_NE(0u, galloc->getGpuAddress());
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getGpuAddress() % MemoryConstants::pageSize64k);
|
||||
memoryManager.freeGraphicsMemory(galloc);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -120,7 +120,7 @@ TEST_F(SVMMemoryAllocatorTest, WhenCouldNotAllocateInMemoryManagerThenReturnsNul
|
||||
using OsAgnosticMemoryManager::allocateGraphicsMemory;
|
||||
|
||||
public:
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment) override {
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -164,7 +164,7 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) override {
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override {
|
||||
|
||||
@@ -536,7 +536,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DrmCsrVfeTests, givenNonDirtyVfeForDefaultContextWhe
|
||||
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024, 1024);
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024);
|
||||
IndirectHeap stream(graphicAlloc);
|
||||
|
||||
EXPECT_TRUE(mockCsr->peekDefaultMediaVfeStateDirty());
|
||||
@@ -564,7 +564,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DrmCsrVfeTests, givenNonDirtyVfeForLowPriorityContex
|
||||
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024, 1024);
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024);
|
||||
IndirectHeap stream(graphicAlloc);
|
||||
|
||||
EXPECT_TRUE(mockCsr->peekDefaultMediaVfeStateDirty());
|
||||
@@ -592,7 +592,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DrmCsrVfeTests, givenNonDirtyVfeForLowPriorityContex
|
||||
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024, 1024);
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024);
|
||||
IndirectHeap stream(graphicAlloc);
|
||||
|
||||
EXPECT_TRUE(mockCsr->peekDefaultMediaVfeStateDirty());
|
||||
@@ -620,7 +620,7 @@ HWTEST_F(DrmCsrVfeTests, givenNonDirtyVfeForBothPriorityContextWhenFlushedLowWit
|
||||
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024, 1024);
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024);
|
||||
IndirectHeap stream(graphicAlloc);
|
||||
|
||||
mockCsr->overrideMediaVFEStateDirty(false);
|
||||
@@ -641,7 +641,7 @@ HWTEST_F(DrmCsrVfeTests, givenNonDirtyVfeForBothPriorityContextWhenFlushedDefaul
|
||||
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024, 1024);
|
||||
auto graphicAlloc = mockCsr->getMemoryManager()->allocateGraphicsMemory(1024);
|
||||
IndirectHeap stream(graphicAlloc);
|
||||
|
||||
mockCsr->overrideMediaVFEStateDirty(false);
|
||||
@@ -790,7 +790,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenDefaultDrmCSRWhenItIsCreatedThenGemC
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamGemWorkerTests, givenCommandStreamWhenItIsFlushedWithGemCloseWorkerInDefaultModeThenWorkerDecreasesTheRefCount) {
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(static_cast<size_t>(1024));
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -823,11 +823,11 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenTaskThatRequiresLargeResourceCountWh
|
||||
execStorage.resize(0);
|
||||
|
||||
for (auto id = 0; id < 10; id++) {
|
||||
auto graphicsAllocation = mm->allocateGraphicsMemory(1, 4096);
|
||||
auto graphicsAllocation = mm->allocateGraphicsMemory(1);
|
||||
csr->makeResident(*graphicsAllocation);
|
||||
graphicsAllocations.push_back(graphicsAllocation);
|
||||
}
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024);
|
||||
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -847,7 +847,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenTaskThatRequiresLargeResourceCountWh
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamGemWorkerTests, givenGemCloseWorkerInactiveModeWhenMakeResidentIsCalledThenRefCountsAreNotUpdated) {
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto dummyAllocation = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
|
||||
auto bo = dummyAllocation->getBO();
|
||||
EXPECT_EQ(1u, bo->getRefCount());
|
||||
@@ -864,8 +864,8 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenGemCloseWorkerInactiveModeWhenMakeRe
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamGemWorkerTests, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) {
|
||||
auto allocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation2 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
auto allocation2 = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
|
||||
auto bo1 = allocation->getBO();
|
||||
auto bo2 = allocation2->getBO();
|
||||
@@ -892,8 +892,8 @@ TEST_F(DrmCommandStreamGemWorkerTests, GivenTwoAllocationsWhenBackingStorageIsDi
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamGemWorkerTests, givenCommandStreamWithDuplicatesWhenItIsFlushedWithGemCloseWorkerInactiveModeThenCsIsNotNulled) {
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
auto dummyAllocation = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
ASSERT_EQ(0u, reinterpret_cast<uintptr_t>(commandBuffer->getUnderlyingBuffer()) & 0xFFF);
|
||||
LinearStream cs(commandBuffer);
|
||||
@@ -934,7 +934,7 @@ class DrmCommandStreamBatchingTests : public Test<DrmCommandStreamEnhancedFixtur
|
||||
DrmCommandStreamEnhancedFixture::SetUp();
|
||||
if (PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]) == PreemptionMode::MidThread) {
|
||||
tmpAllocation = GlobalMockSipProgram::sipProgram->getAllocation();
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(device->getMemoryManager()->allocateGraphicsMemory(1024, 4096));
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(device->getMemoryManager()->allocateGraphicsMemory(1024));
|
||||
}
|
||||
tagAllocation = static_cast<DrmAllocation *>(device->getTagAllocation());
|
||||
preemptionAllocation = static_cast<DrmAllocation *>(device->getPreemptionAllocation());
|
||||
@@ -949,8 +949,8 @@ class DrmCommandStreamBatchingTests : public Test<DrmCommandStreamEnhancedFixtur
|
||||
};
|
||||
|
||||
TEST_F(DrmCommandStreamBatchingTests, givenCSRWhenFlushIsCalledThenProperFlagsArePassed) {
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
ASSERT_EQ(0u, reinterpret_cast<uintptr_t>(commandBuffer->getUnderlyingBuffer()) & 0xFFF);
|
||||
LinearStream cs(commandBuffer);
|
||||
@@ -979,8 +979,8 @@ TEST_F(DrmCommandStreamBatchingTests, givenCsrWhenDispatchPolicyIsSetToBatchingT
|
||||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
tCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
ASSERT_EQ(0u, reinterpret_cast<uintptr_t>(commandBuffer->getUnderlyingBuffer()) & 0xFFF);
|
||||
IndirectHeap cs(commandBuffer);
|
||||
@@ -1039,8 +1039,8 @@ TEST_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhenItIsSubmitte
|
||||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
tCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = mm->allocateGraphicsMemory(1024);
|
||||
auto dummyAllocation = mm->allocateGraphicsMemory(1024);
|
||||
IndirectHeap cs(commandBuffer);
|
||||
std::unique_ptr<Device> device(DeviceHelper<>::create(nullptr));
|
||||
|
||||
@@ -1468,8 +1468,8 @@ TEST_F(DrmCommandStreamLeaksTest, Flush) {
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamLeaksTest, ClearResidencyWhenFlushNotCalled) {
|
||||
auto allocation1 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation2 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation1 = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
auto allocation2 = reinterpret_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
ASSERT_NE(nullptr, allocation1);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
@@ -1515,9 +1515,9 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
|
||||
BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
csr->flush(batchBuffer2, EngineType::ENGINE_RCS, nullptr);
|
||||
|
||||
auto allocation = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation = mm->allocateGraphicsMemory(1024);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
auto allocation2 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation2 = mm->allocateGraphicsMemory(1024);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
csr->makeResident(*allocation);
|
||||
@@ -1525,10 +1525,10 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
|
||||
|
||||
mm->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandBuffer), REUSABLE_ALLOCATION);
|
||||
|
||||
commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
cs.replaceBuffer(commandBuffer->getUnderlyingBuffer(), commandBuffer->getUnderlyingBufferSize());
|
||||
cs.replaceGraphicsAllocation(commandBuffer);
|
||||
auto commandBuffer2 = mm->allocateGraphicsMemory(1024);
|
||||
ASSERT_NE(nullptr, commandBuffer2);
|
||||
cs.replaceBuffer(commandBuffer2->getUnderlyingBuffer(), commandBuffer2->getUnderlyingBufferSize());
|
||||
cs.replaceGraphicsAllocation(commandBuffer2);
|
||||
csr->addBatchBufferEnd(cs, nullptr);
|
||||
csr->alignToCacheLine(cs);
|
||||
BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -1537,11 +1537,11 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
|
||||
mm->freeGraphicsMemory(allocation);
|
||||
mm->freeGraphicsMemory(allocation2);
|
||||
|
||||
mm->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandBuffer), REUSABLE_ALLOCATION);
|
||||
commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
cs.replaceBuffer(commandBuffer->getUnderlyingBuffer(), commandBuffer->getUnderlyingBufferSize());
|
||||
cs.replaceGraphicsAllocation(commandBuffer);
|
||||
mm->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandBuffer2), REUSABLE_ALLOCATION);
|
||||
commandBuffer2 = mm->allocateGraphicsMemory(1024);
|
||||
ASSERT_NE(nullptr, commandBuffer2);
|
||||
cs.replaceBuffer(commandBuffer2->getUnderlyingBuffer(), commandBuffer2->getUnderlyingBufferSize());
|
||||
cs.replaceGraphicsAllocation(commandBuffer2);
|
||||
csr->addBatchBufferEnd(cs, nullptr);
|
||||
csr->alignToCacheLine(cs);
|
||||
BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -1596,7 +1596,7 @@ TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) {
|
||||
ASSERT_NE(0u, (reinterpret_cast<uintptr_t>(commandBuffer->getUnderlyingBuffer()) + 4) & 0xFFF);
|
||||
ASSERT_EQ(4u, (reinterpret_cast<uintptr_t>(commandBuffer->getUnderlyingBuffer()) + 4) & 0x7F);
|
||||
|
||||
auto allocation = mm->allocateGraphicsMemory(1024, 128);
|
||||
auto allocation = mm->allocateGraphicsMemory(1024);
|
||||
|
||||
csr->makeResident(*allocation);
|
||||
csr->addBatchBufferEnd(cs, nullptr);
|
||||
@@ -1608,8 +1608,8 @@ TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) {
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInMemoryManager) {
|
||||
auto allocation1 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation2 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation1 = mm->allocateGraphicsMemory(1024);
|
||||
auto allocation2 = mm->allocateGraphicsMemory(1024);
|
||||
|
||||
ASSERT_NE(nullptr, allocation1);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
@@ -1627,7 +1627,7 @@ TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInMemoryM
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamLeaksTest, givenMultipleMakeResidentWhenMakeNonResidentIsCalledOnlyOnceThenSurfaceIsMadeNonResident) {
|
||||
auto allocation1 = mm->allocateGraphicsMemory(1024, 4096);
|
||||
auto allocation1 = mm->allocateGraphicsMemory(1024);
|
||||
|
||||
ASSERT_NE(nullptr, allocation1);
|
||||
|
||||
@@ -1646,7 +1646,7 @@ TEST_F(DrmCommandStreamLeaksTest, givenMultipleMakeResidentWhenMakeNonResidentIs
|
||||
}
|
||||
|
||||
TEST_F(DrmCommandStreamLeaksTest, makeNonResidentOnMemObjectCallsDrmCSMakeNonResidentWithGraphicsAllocation) {
|
||||
auto allocation1 = mm->allocateGraphicsMemory(0x1000, 0x1000);
|
||||
auto allocation1 = mm->allocateGraphicsMemory(0x1000);
|
||||
ASSERT_NE(nullptr, allocation1);
|
||||
|
||||
tCsr->makeResident(*allocation1);
|
||||
|
||||
@@ -426,7 +426,7 @@ TEST_F(DrmMemoryManagerTest, AllocateThenFree) {
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto alloc = memoryManager->allocateGraphicsMemory(1024, 1024);
|
||||
auto alloc = reinterpret_cast<DrmAllocation *>(memoryManager->allocateGraphicsMemory(1024));
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
EXPECT_NE(nullptr, alloc->getBO());
|
||||
|
||||
@@ -438,7 +438,7 @@ TEST_F(DrmMemoryManagerTest, AllocateNewFail) {
|
||||
mock->ioctl_expected.total = -1; //don't care
|
||||
|
||||
InjectedFunction method = [this](size_t failureIndex) {
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(1024, 1024);
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(1024);
|
||||
|
||||
if (nonfailingAllocation != failureIndex) {
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
@@ -455,7 +455,7 @@ TEST_F(DrmMemoryManagerTest, Allocate0Bytes) {
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(static_cast<size_t>(0), static_cast<size_t>(0));
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(static_cast<size_t>(0));
|
||||
ASSERT_NE(nullptr, ptr);
|
||||
EXPECT_NE(nullptr, ptr->getUnderlyingBuffer());
|
||||
|
||||
@@ -467,7 +467,7 @@ TEST_F(DrmMemoryManagerTest, Allocate3Bytes) {
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(3, 3);
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(3);
|
||||
ASSERT_NE(nullptr, ptr);
|
||||
EXPECT_NE(nullptr, ptr->getUnderlyingBuffer());
|
||||
|
||||
@@ -478,7 +478,7 @@ TEST_F(DrmMemoryManagerTest, AllocateUserptrFail) {
|
||||
mock->ioctl_expected.gemUserptr = 1;
|
||||
mock->ioctl_res = -1;
|
||||
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(3, 3);
|
||||
auto ptr = memoryManager->allocateGraphicsMemory(3);
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
}
|
||||
|
||||
@@ -1138,7 +1138,10 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExh
|
||||
|
||||
//ask for 4GB
|
||||
auto allocationSize = 4096u;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationWithRequiredBitness(allocationSize, nullptr);
|
||||
bool force32Bit = memoryManager->peekForce32BitAllocations();
|
||||
EXPECT_TRUE(force32Bit);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, static_cast<size_t>(allocationSize), GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_NE(nullptr, graphicsAllocation);
|
||||
EXPECT_FALSE(pDevice->getDeviceInfo().force32BitAddressess);
|
||||
|
||||
@@ -1157,7 +1160,8 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExh
|
||||
|
||||
//ask for 4GB - 1
|
||||
size_t allocationSize = (4 * 1023 * 1024 * (size_t)1024u - 1) + 4 * 1024 * (size_t)1024u;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationWithRequiredBitness(allocationSize, nullptr);
|
||||
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, static_cast<size_t>(allocationSize), GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
EXPECT_TRUE(pDevice->getDeviceInfo().force32BitAddressess);
|
||||
}
|
||||
@@ -1690,7 +1694,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledThenRetu
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1, 1);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ptr = memoryManager->lockResource(allocation);
|
||||
@@ -1706,7 +1710,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAlloca
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1, 1);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(1);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
|
||||
|
||||
@@ -1863,7 +1867,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndUnifiedAuxCapableAllocation
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto gmm = new Gmm(nullptr, 123, false);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(123, 123);
|
||||
auto allocation = memoryManager->allocateGraphicsMemory(123);
|
||||
allocation->gmm = gmm;
|
||||
|
||||
auto mockGmmRes = reinterpret_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
|
||||
@@ -1936,7 +1940,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenItIsR
|
||||
mock->ioctl_expected.gemClose = 3;
|
||||
//first let's create normal buffer
|
||||
auto bufferSize = MemoryConstants::pageSize;
|
||||
auto buffer = memoryManager->allocateGraphicsMemory(bufferSize, MemoryConstants::pageSize);
|
||||
auto buffer = memoryManager->allocateGraphicsMemory(bufferSize);
|
||||
|
||||
//buffer should have size 16
|
||||
EXPECT_EQ(bufferSize, buffer->getUnderlyingBufferSize());
|
||||
@@ -2051,7 +2055,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenAlloc
|
||||
|
||||
//first let's create normal buffer
|
||||
auto bufferSize = MemoryConstants::pageSize;
|
||||
auto buffer = memoryManager->allocateGraphicsMemory(bufferSize, MemoryConstants::pageSize);
|
||||
auto buffer = memoryManager->allocateGraphicsMemory(bufferSize);
|
||||
|
||||
//buffer should have size 16
|
||||
EXPECT_EQ(bufferSize, buffer->getUnderlyingBufferSize());
|
||||
|
||||
@@ -118,9 +118,9 @@ class WddmCommandStreamWithMockGdiFixture {
|
||||
device = MockDevice::createWithMemoryManager<MockDevice>(platformDevices[0], memManager);
|
||||
ASSERT_NE(nullptr, device);
|
||||
memManager->device = device;
|
||||
tagAllocation = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
tagAllocation = memManager->allocateGraphicsMemory(1024);
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
preemptionAllocation = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
preemptionAllocation = memManager->allocateGraphicsMemory(1024);
|
||||
}
|
||||
auto tagBuffer = (uint32_t *)tagAllocation->getUnderlyingBuffer();
|
||||
tagBuffer[0] = initialHardwareTag;
|
||||
@@ -167,7 +167,7 @@ TEST_F(WddmCommandStreamTest, givenFlushStampWhenWaitCalledThenWaitForSpecifiedM
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, Flush) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -181,7 +181,7 @@ TEST_F(WddmCommandStreamTest, Flush) {
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThenCpuAddressWhenSubmitIsCalledThenGpuAddressIsUsed) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
|
||||
auto cpuAddress = commandBuffer->getUnderlyingBuffer();
|
||||
uint64_t mockGpuAddres = 1337;
|
||||
@@ -195,7 +195,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen
|
||||
}
|
||||
TEST_F(WddmCommandStreamTest, FlushWithOffset) {
|
||||
auto offset = 128u;
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -209,7 +209,7 @@ TEST_F(WddmCommandStreamTest, FlushWithOffset) {
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFlagIsSetToFalse) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -227,7 +227,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
|
||||
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndPreemptionIsDisabledThenSetHeaderFieldToFalse) {
|
||||
device->setPreemptionMode(PreemptionMode::Disabled);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -245,7 +245,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndPreemptionIsDisabled
|
||||
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndPreemptionIsEnabledThenSetHeaderFieldToTrue) {
|
||||
device->setPreemptionMode(PreemptionMode::ThreadGroup);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -261,7 +261,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndPreemptionIsEnabledT
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenSetHeaderFieldsProperly) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -279,7 +279,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenS
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumThenSetHeaderFieldsProperly) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -297,7 +297,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumTh
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThenSetHeaderFieldsProperly) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -315,7 +315,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThen
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAllocationsForResidencyThenNoneAllocationShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -336,7 +336,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAll
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutAllocationsForResidencyThenNoneAllocationShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -351,7 +351,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutA
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResidencyAllocationsInMemoryManagerThenLinearStreamAllocationsShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -376,7 +376,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenLinearStreamAllocationsShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -398,7 +398,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenFillPatternAllocationsShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -420,7 +420,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenNonLinearStreamAllocationShouldNotBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -442,7 +442,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
TEST_F(WddmCommandStreamTest, makeResident) {
|
||||
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memManager);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -458,7 +458,7 @@ TEST_F(WddmCommandStreamTest, makeResident) {
|
||||
TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations) {
|
||||
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memManager);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -474,8 +474,8 @@ TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations
|
||||
TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidateList) {
|
||||
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memManager);
|
||||
|
||||
GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *allocation2 = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096);
|
||||
GraphicsAllocation *allocation2 = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
@@ -495,7 +495,7 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate
|
||||
TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
|
||||
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memManager);
|
||||
|
||||
GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *allocation = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
memManager->pushAllocationForEviction(allocation);
|
||||
@@ -601,7 +601,7 @@ TEST_F(WddmCommandStreamTest, killCompletedAllocations) {
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAllocations) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -620,7 +620,7 @@ TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAlloc
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
|
||||
@@ -674,7 +674,7 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
csrSurfaceCount = 2;
|
||||
tmpAllocation = GlobalMockSipProgram::sipProgram->getAllocation();
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(memManager->allocateGraphicsMemory(1024, 4096));
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(memManager->allocateGraphicsMemory(1024));
|
||||
}
|
||||
std::unique_ptr<MockWddmCsr<FamilyType>> mockCsr(new MockWddmCsr<FamilyType>(*platformDevices[0], this->wddm));
|
||||
mockCsr->setMemoryManager(memManager);
|
||||
@@ -683,10 +683,10 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
||||
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
|
||||
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
|
||||
|
||||
auto commandBuffer = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
auto dshAlloc = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
auto iohAlloc = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
auto sshAlloc = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
auto commandBuffer = memManager->allocateGraphicsMemory(1024);
|
||||
auto dshAlloc = memManager->allocateGraphicsMemory(1024);
|
||||
auto iohAlloc = memManager->allocateGraphicsMemory(1024);
|
||||
auto sshAlloc = memManager->allocateGraphicsMemory(1024);
|
||||
|
||||
mockCsr->setTagAllocation(tagAllocation);
|
||||
mockCsr->setPreemptionCsrAllocation(preemptionAllocation);
|
||||
@@ -864,7 +864,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra
|
||||
mockWddmCsr.setPreemptionCsrAllocation(preemptionAllocation);
|
||||
auto &csrCS = mockWddmCsr.getCS();
|
||||
|
||||
auto graphicsAllocation = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
auto graphicsAllocation = memManager->allocateGraphicsMemory(1024);
|
||||
IndirectHeap cs(graphicsAllocation);
|
||||
|
||||
EXPECT_FALSE(mockWddmCsr.pageTableManagerInitialized);
|
||||
@@ -899,7 +899,7 @@ HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenFlushingThenDontIn
|
||||
mockWddmCsr.setTagAllocation(tagAllocation);
|
||||
mockWddmCsr.setPreemptionCsrAllocation(preemptionAllocation);
|
||||
|
||||
auto graphicsAllocation = memManager->allocateGraphicsMemory(1024, 4096);
|
||||
auto graphicsAllocation = memManager->allocateGraphicsMemory(1024);
|
||||
IndirectHeap cs(graphicsAllocation);
|
||||
|
||||
EXPECT_FALSE(mockWddmCsr.pageTableManagerInitialized);
|
||||
|
||||
@@ -137,7 +137,7 @@ HWTEST_F(WddmMemoryManagerTest, AllocateGpuMemHostPtr) {
|
||||
|
||||
HWTEST_F(WddmMemoryManagerTest, givenDefaultMemoryManagerWhenAllocateWithSizeIsCalledThenResourceHandleIsZero) {
|
||||
SetUpMm<FamilyType>();
|
||||
auto *gpuAllocation = memoryManager->allocateGraphicsMemory(0x1000, MemoryConstants::pageSize);
|
||||
auto *gpuAllocation = memoryManager->allocateGraphicsMemory(0x1000);
|
||||
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(gpuAllocation);
|
||||
|
||||
@@ -1898,46 +1898,34 @@ HWTEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalle
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
}
|
||||
|
||||
HWTEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhencreateGraphicsAllocationWithRequiredBitnessThenAllocated64kbAdress) {
|
||||
HWTEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemoryForBufferWithoutHostPtrThen64kbAdressIsAllocated) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
WddmMock *wddm = new WddmMock;
|
||||
EXPECT_TRUE(wddm->init<FamilyType>());
|
||||
DebugManager.flags.Enable64kbpages.set(true);
|
||||
WddmMemoryManager memoryManager64k(true, wddm);
|
||||
EXPECT_EQ(0, wddm->createAllocationResult.called);
|
||||
GraphicsAllocation *galloc = memoryManager64k.createGraphicsAllocationWithRequiredBitness(64 * 1024, nullptr, false);
|
||||
|
||||
GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemoryInPreferredPool(true, true, false, false, nullptr, static_cast<size_t>(MemoryConstants::pageSize64k), GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_EQ(1, wddm->createAllocationResult.called);
|
||||
EXPECT_NE(nullptr, galloc);
|
||||
EXPECT_EQ(true, galloc->isLocked());
|
||||
EXPECT_NE(nullptr, galloc->getUnderlyingBuffer());
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getUnderlyingBuffer() % 65536U);
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getUnderlyingBuffer() % MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(0u, (uintptr_t)galloc->getGpuAddress() % MemoryConstants::pageSize64k);
|
||||
memoryManager64k.freeGraphicsMemory(galloc);
|
||||
}
|
||||
|
||||
HWTEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenSetLockThenLockIsSet) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
WddmMock *wddm = new WddmMock;
|
||||
EXPECT_TRUE(wddm->init<FamilyType>());
|
||||
DebugManager.flags.Enable64kbpages.set(true);
|
||||
WddmMemoryManager memoryManager64k(true, wddm);
|
||||
EXPECT_EQ(0, wddm->createAllocationResult.called);
|
||||
GraphicsAllocation *galloc = memoryManager64k.createGraphicsAllocationWithRequiredBitness(64 * 1024, nullptr, false);
|
||||
galloc->setLocked(false);
|
||||
EXPECT_FALSE(galloc->isLocked());
|
||||
galloc->setLocked(true);
|
||||
EXPECT_TRUE(galloc->isLocked());
|
||||
memoryManager64k.freeGraphicsMemory(galloc);
|
||||
}
|
||||
|
||||
HWTEST_F(OsAgnosticMemoryManagerUsingWddmTest, GivenEnabled64kbPagesWhenAllocationIsCreatedWithSizeSmallerThen64KBThenGraphicsAllocationsHas64KBAlignedUnderlyingsize) {
|
||||
HWTEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocationIsCreatedWithSizeSmallerThan64kbThenGraphicsAllocationsHas64kbAlignedUnderlyingSize) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
WddmMock *wddm = new WddmMock;
|
||||
EXPECT_TRUE(wddm->init<FamilyType>());
|
||||
DebugManager.flags.Enable64kbpages.set(true);
|
||||
WddmMemoryManager memoryManager(true, wddm);
|
||||
auto graphicsAllocation = memoryManager.createGraphicsAllocationWithRequiredBitness(1, nullptr);
|
||||
auto graphicsAllocation = memoryManager.allocateGraphicsMemory64kb(1, MemoryConstants::pageSize64k, false);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation);
|
||||
EXPECT_EQ(64 * MemoryConstants::kiloByte, graphicsAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE(0llu, graphicsAllocation->getGpuAddress());
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2055,7 +2043,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleasein
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
wddm->resetPageTableManager(mockMngr);
|
||||
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemory(4096u, 4096u));
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemory(4096u));
|
||||
wddmAlloc->gpuPtr = gpuVa;
|
||||
wddmAlloc->gmm->isRenderCompressed = true;
|
||||
|
||||
@@ -2080,7 +2068,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleas
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
wddm->resetPageTableManager(mockMngr);
|
||||
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemory(4096u, 4096u));
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemory(4096u));
|
||||
wddmAlloc->gmm->isRenderCompressed = false;
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
@@ -2128,7 +2116,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUn
|
||||
myGmm->isRenderCompressed = false;
|
||||
myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1;
|
||||
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemory(4096u, 4096u));
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemory(4096u));
|
||||
delete wddmAlloc->gmm;
|
||||
wddmAlloc->gmm = myGmm;
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationThenCopyWholeKerne
|
||||
|
||||
class MyMemoryManager : public OsAgnosticMemoryManager {
|
||||
public:
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr, AllocationOrigin allocationOrigin) override { return nullptr; }
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override { return nullptr; }
|
||||
};
|
||||
|
||||
TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationAndCannotAllocateMemoryThenReturnsFalse) {
|
||||
|
||||
Reference in New Issue
Block a user