mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Use GfxPartition for GPU address range allocations
[2/n] - OsAgnosticMemoryManager Related-To: NEO-2877 Change-Id: I887126362381ac960608a2150fae211631d3cd5b Signed-off-by: Venevtsev, Igor <igor.venevtsev@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
bb6dfd4fe6
commit
165d1e4e55
@ -115,7 +115,7 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; }
|
||||
uint32_t getDeviceIndex() const { return deviceIndex; }
|
||||
bool isFullRangeSvm() const {
|
||||
return getHardwareInfo().capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress;
|
||||
return executionEnvironment->isFullRangeSvm();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -11,7 +11,13 @@
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
size_t getSizeToMap() {
|
||||
return static_cast<size_t>(alignUp(4 * GB - 8096, 4096));
|
||||
}
|
||||
|
||||
size_t getSizeToReserve() {
|
||||
return maxNBitValue<47> / 4;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -54,7 +54,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
|
||||
const HardwareInfo *getHardwareInfo() const { return hwInfo.get(); }
|
||||
HardwareInfo *getMutableHardwareInfo() const { return hwInfo.get(); }
|
||||
bool isFullRangeSvm() const {
|
||||
return hwInfo->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress;
|
||||
return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue<47>;
|
||||
}
|
||||
|
||||
GmmHelper *getGmmHelper() const;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "runtime/memory_manager/gfx_partition.h"
|
||||
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/os_interface/os_memory.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@ -16,33 +17,115 @@ const std::array<HeapIndex, 4> GfxPartition::heap32Names{{HeapIndex::HEAP_INTERN
|
||||
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
|
||||
HeapIndex::HEAP_EXTERNAL}};
|
||||
|
||||
void GfxPartition::init(uint64_t gpuAddressSpace) {
|
||||
const std::array<HeapIndex, 6> GfxPartition::heapNonSvmNames{{HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY,
|
||||
HeapIndex::HEAP_INTERNAL,
|
||||
HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY,
|
||||
HeapIndex::HEAP_EXTERNAL,
|
||||
HeapIndex::HEAP_STANDARD,
|
||||
HeapIndex::HEAP_STANDARD64KB}};
|
||||
GfxPartition::~GfxPartition() {
|
||||
if (reservedCpuAddressRange) {
|
||||
OSMemory::releaseCpuAddressRange(reservedCpuAddressRange, reservedCpuAddressRangeSize);
|
||||
}
|
||||
}
|
||||
|
||||
// 1) Full Range SVM gfx layout:
|
||||
//
|
||||
// SVM H0 H1 H2 H3 STANDARD STANDARD64K
|
||||
// |__________________________________|____|____|____|____|________________|______________|
|
||||
// | | | | | | | |
|
||||
// | gfxBase gfxTop
|
||||
// 0x0 0x0000800000000000/0x10000000 for 32 bit 0x0000FFFFFFFFFFFFFFFF
|
||||
//
|
||||
// 2) Limited Range gfx layout (no SVM):
|
||||
//
|
||||
// H0 H1 H2 H3 STANDARD STANDARD64K
|
||||
// |____|____|____|____|____________________|__________________|
|
||||
// | | | | | | |
|
||||
// gfxBase gfxTop
|
||||
// 0x0 0xFFF...FFF < 48 bit
|
||||
void GfxPartition::Heap::init(uint64_t base, uint64_t size) {
|
||||
this->base = base;
|
||||
this->size = size;
|
||||
|
||||
uint64_t gfxTop = gpuAddressSpace + 1;
|
||||
uint64_t gfxBase = is64bit ? MemoryConstants::max64BitAppAddress + 1 : MemoryConstants::max32BitAddress + 1;
|
||||
const uint64_t gfxHeap32Size = 4 * MemoryConstants::gigaByte;
|
||||
|
||||
if (gpuAddressSpace < MemoryConstants::max48BitAddress) {
|
||||
gfxBase = 0ull;
|
||||
// Exclude very first and very last 64K from GPU address range allocation
|
||||
if (size > 2 * GfxPartition::heapGranularity) {
|
||||
size -= 2 * GfxPartition::heapGranularity;
|
||||
}
|
||||
|
||||
heapInit(HeapIndex::HEAP_SVM, 0ull, gfxBase);
|
||||
alloc = std::make_unique<HeapAllocator>(base + GfxPartition::heapGranularity, size);
|
||||
}
|
||||
|
||||
void GfxPartition::freeGpuAddressRange(uint64_t ptr, size_t size) {
|
||||
for (auto heapName : GfxPartition::heapNonSvmNames) {
|
||||
auto &heap = getHeap(heapName);
|
||||
if ((ptr > heap.getBase()) && ((ptr + size) < heap.getLimit())) {
|
||||
heap.free(ptr, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve) {
|
||||
|
||||
/*
|
||||
* I. 64-bit builds:
|
||||
*
|
||||
* 1) 48-bit Full Range SVM gfx layout:
|
||||
*
|
||||
* SVM H0 H1 H2 H3 STANDARD STANDARD64K
|
||||
* |__________________________________|____|____|____|____|________________|______________|
|
||||
* | | | | | | | |
|
||||
* | gfxBase gfxTop
|
||||
* 0x0 0x0000800000000000 0x0000FFFFFFFFFFFF
|
||||
*
|
||||
*
|
||||
* 2) 47-bit Full Range SVM gfx layout:
|
||||
*
|
||||
* gfxSize = 2^47 / 4 = 0x200000000000
|
||||
* ________________________________________________
|
||||
* / \
|
||||
* SVM / H0 H1 H2 H3 STANDARD STANDARD64K \ SVM
|
||||
* |________________|____|____|____|____|________________|______________|_______________|
|
||||
* | | | | | | | | |
|
||||
* | gfxBase gfxTop |
|
||||
* 0x0 reserveCpuAddressRange(gfxSize) 0x00007FFFFFFFFFFF
|
||||
* \_____________________________________ SVM _________________________________________/
|
||||
*
|
||||
*
|
||||
*
|
||||
* 3) Limited Range gfx layout (no SVM):
|
||||
*
|
||||
* H0 H1 H2 H3 STANDARD STANDARD64K
|
||||
* |____|____|____|____|____________________|__________________|
|
||||
* | | | | | | |
|
||||
* gfxBase gfxTop
|
||||
* 0x0 0xFFF...FFF < 47 bit
|
||||
*
|
||||
*
|
||||
* II. 32-bit builds:
|
||||
*
|
||||
* 1) 32-bit Full Range SVM gfx layout:
|
||||
*
|
||||
* SVM H0 H1 H2 H3 STANDARD STANDARD64K
|
||||
* |_______|____|____|____|____|________________|______________|
|
||||
* | | | | | | | |
|
||||
* | gfxBase gfxTop
|
||||
* 0x0 0x100000000 gpuAddressSpace
|
||||
*/
|
||||
|
||||
uint64_t gfxTop = gpuAddressSpace + 1;
|
||||
uint64_t gfxBase = 0x0ull;
|
||||
const uint64_t gfxHeap32Size = 4 * MemoryConstants::gigaByte;
|
||||
|
||||
if (is32bit) {
|
||||
gfxBase = maxNBitValue<32> + 1;
|
||||
heapInit(HeapIndex::HEAP_SVM, 0ull, gfxBase);
|
||||
} else {
|
||||
if (gpuAddressSpace == maxNBitValue<48>) {
|
||||
gfxBase = maxNBitValue<48 - 1> + 1;
|
||||
heapInit(HeapIndex::HEAP_SVM, 0ull, gfxBase);
|
||||
} else if (gpuAddressSpace == maxNBitValue<47>) {
|
||||
reservedCpuAddressRangeSize = cpuAddressRangeSizeToReserve;
|
||||
UNRECOVERABLE_IF(reservedCpuAddressRangeSize == 0);
|
||||
reservedCpuAddressRange = OSMemory::reserveCpuAddressRange(reservedCpuAddressRangeSize);
|
||||
UNRECOVERABLE_IF(reservedCpuAddressRange == nullptr);
|
||||
UNRECOVERABLE_IF(!isAligned<GfxPartition::heapGranularity>(reservedCpuAddressRange));
|
||||
gfxBase = reinterpret_cast<uint64_t>(reservedCpuAddressRange);
|
||||
gfxTop = gfxBase + reservedCpuAddressRangeSize;
|
||||
heapInit(HeapIndex::HEAP_SVM, 0ull, gpuAddressSpace + 1);
|
||||
} else if (gpuAddressSpace < maxNBitValue<47>) {
|
||||
gfxBase = 0ull;
|
||||
heapInit(HeapIndex::HEAP_SVM, 0ull, 0ull);
|
||||
} else {
|
||||
UNRECOVERABLE_IF("Invalid GPU Address Range!");
|
||||
}
|
||||
}
|
||||
|
||||
for (auto heap : GfxPartition::heap32Names) {
|
||||
heapInit(heap, gfxBase, gfxHeap32Size);
|
||||
|
@ -31,8 +31,9 @@ constexpr auto internalHeapIndex = is32bit ? HeapIndex::HEAP_INTERNAL : HeapInde
|
||||
class GfxPartition {
|
||||
public:
|
||||
GfxPartition() {}
|
||||
~GfxPartition();
|
||||
|
||||
void init(uint64_t gpuAddressSpace);
|
||||
void init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToReserve);
|
||||
|
||||
void heapInit(HeapIndex heapIndex, uint64_t base, uint64_t size) {
|
||||
getHeap(heapIndex).init(base, size);
|
||||
@ -46,33 +47,35 @@ class GfxPartition {
|
||||
getHeap(heapIndex).free(ptr, size);
|
||||
}
|
||||
|
||||
void freeGpuAddressRange(uint64_t ptr, size_t size);
|
||||
|
||||
uint64_t getHeapBase(HeapIndex heapIndex) {
|
||||
return getHeap(heapIndex).getBase();
|
||||
}
|
||||
|
||||
uint64_t getHeapLimit(HeapIndex heapIndex) {
|
||||
return getHeap(heapIndex).getBase() + getHeap(heapIndex).getSize() - 1;
|
||||
return getHeap(heapIndex).getLimit();
|
||||
}
|
||||
|
||||
uint64_t getHeapMinimalAddress(HeapIndex heapIndex) {
|
||||
return getHeapBase(heapIndex) + heapGranularity;
|
||||
}
|
||||
|
||||
bool isLimitedRange() { return getHeap(HeapIndex::HEAP_SVM).getSize() == 0ull; }
|
||||
|
||||
static const uint64_t heapGranularity = MemoryConstants::pageSize64k;
|
||||
|
||||
static const std::array<HeapIndex, 4> heap32Names;
|
||||
static const std::array<HeapIndex, 6> heapNonSvmNames;
|
||||
|
||||
protected:
|
||||
class Heap {
|
||||
public:
|
||||
Heap() = default;
|
||||
void init(uint64_t base, uint64_t size);
|
||||
uint64_t getBase() const { return base; }
|
||||
uint64_t getSize() const { return size; }
|
||||
void init(uint64_t base, uint64_t size) {
|
||||
this->base = base;
|
||||
this->size = size;
|
||||
alloc = std::make_unique<HeapAllocator>(base + heapGranularity, size ? size - heapGranularity : 0ull);
|
||||
}
|
||||
uint64_t getLimit() const { return base + size - 1; }
|
||||
uint64_t allocate(size_t &size) { return alloc->allocate(size); }
|
||||
void free(uint64_t ptr, size_t size) { alloc->free(ptr, size); }
|
||||
|
||||
@ -82,10 +85,13 @@ class GfxPartition {
|
||||
};
|
||||
|
||||
Heap &getHeap(HeapIndex heapIndex) {
|
||||
return heap[static_cast<uint32_t>(heapIndex)];
|
||||
return heaps[static_cast<uint32_t>(heapIndex)];
|
||||
}
|
||||
|
||||
std::array<Heap, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)> heap;
|
||||
std::array<Heap, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)> heaps;
|
||||
|
||||
void *reservedCpuAddressRange = nullptr;
|
||||
size_t reservedCpuAddressRangeSize = 0;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -111,6 +111,8 @@ class MemoryManager {
|
||||
|
||||
virtual uint64_t getExternalHeapBaseAddress() = 0;
|
||||
|
||||
bool isLimitedRange() { return gfxPartition.isLimitedRange(); }
|
||||
|
||||
bool peek64kbPagesEnabled() const { return enable64kbpages; }
|
||||
bool peekForce32BitAllocations() const { return force32bitAllocations; }
|
||||
virtual void setForce32BitAllocations(bool newValue);
|
||||
|
@ -18,11 +18,20 @@
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
#include "runtime/memory_manager/host_ptr_manager.h"
|
||||
#include "runtime/os_interface/os_memory.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
OsAgnosticMemoryManager::OsAgnosticMemoryManager(bool aubUsage, ExecutionEnvironment &executionEnvironment) : MemoryManager(executionEnvironment) {
|
||||
auto gpuAddressSpace = executionEnvironment.getHardwareInfo()->capabilityTable.gpuAddressSpace;
|
||||
|
||||
// 4 x sizeof(Heap32) + 2 x sizeof(Standard/Standard64k)
|
||||
size_t reservedCpuAddressRangeSize = is64bit ? (4 * 4 + 2 * (aubUsage ? 32 : 4)) * GB : 0;
|
||||
gfxPartition.init(gpuAddressSpace, reservedCpuAddressRangeSize);
|
||||
}
|
||||
|
||||
OsAgnosticMemoryManager::~OsAgnosticMemoryManager() {
|
||||
applyCommonCleanup();
|
||||
}
|
||||
@ -35,22 +44,19 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment
|
||||
MemoryAllocation *memoryAllocation = nullptr;
|
||||
|
||||
if (fakeBigAllocations && allocationData.size > bigAllocation) {
|
||||
memoryAllocation = new MemoryAllocation(
|
||||
memoryAllocation = createMemoryAllocation(
|
||||
allocationData.type, nullptr, (void *)dummyAddress, static_cast<uint64_t>(dummyAddress), allocationData.size, counter,
|
||||
MemoryPool::System4KBPages, allocationData.flags.multiOsContextCapable, allocationData.flags.uncacheable,
|
||||
allocationData.flags.flushL3);
|
||||
allocationData.flags.flushL3, false);
|
||||
counter++;
|
||||
return memoryAllocation;
|
||||
}
|
||||
auto ptr = allocateSystemMemory(sizeAligned, allocationData.alignment ? alignUp(allocationData.alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
|
||||
if (ptr != nullptr) {
|
||||
memoryAllocation = new MemoryAllocation(allocationData.type, ptr, ptr, reinterpret_cast<uint64_t>(ptr), allocationData.size,
|
||||
counter, MemoryPool::System4KBPages, allocationData.flags.multiOsContextCapable,
|
||||
allocationData.flags.uncacheable, allocationData.flags.flushL3);
|
||||
if (!memoryAllocation) {
|
||||
alignedFreeWrapper(ptr);
|
||||
return nullptr;
|
||||
}
|
||||
memoryAllocation = createMemoryAllocation(allocationData.type, ptr, ptr, reinterpret_cast<uint64_t>(ptr), allocationData.size,
|
||||
counter, MemoryPool::System4KBPages, allocationData.flags.multiOsContextCapable,
|
||||
allocationData.flags.uncacheable, allocationData.flags.flushL3, false);
|
||||
|
||||
if (allocationData.type == GraphicsAllocation::AllocationType::SVM_CPU) {
|
||||
//add 2MB padding in case mapPtr is not 2MB aligned
|
||||
size_t reserveSize = sizeAligned + allocationData.alignment;
|
||||
@ -73,11 +79,12 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForNonSvmHost
|
||||
auto alignedPtr = alignDown(allocationData.hostPtr, MemoryConstants::pageSize);
|
||||
auto offsetInPage = ptrDiff(allocationData.hostPtr, alignedPtr);
|
||||
|
||||
auto memoryAllocation = new MemoryAllocation(allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr),
|
||||
reinterpret_cast<uint64_t>(alignedPtr), allocationData.size, counter,
|
||||
MemoryPool::System4KBPages, false, false, allocationData.flags.flushL3);
|
||||
auto memoryAllocation = createMemoryAllocation(allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr),
|
||||
reinterpret_cast<uint64_t>(alignedPtr), allocationData.size, counter,
|
||||
MemoryPool::System4KBPages, false, false, allocationData.flags.flushL3, false);
|
||||
|
||||
memoryAllocation->setAllocationOffset(offsetInPage);
|
||||
|
||||
counter++;
|
||||
return memoryAllocation;
|
||||
}
|
||||
@ -94,9 +101,10 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) {
|
||||
auto heap = useInternal32BitAllocator(allocationData.type) ? internalHeapIndex : HeapIndex::HEAP_EXTERNAL;
|
||||
if (allocationData.hostPtr) {
|
||||
auto allocationSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size);
|
||||
auto gpuVirtualAddress = allocator32Bit->allocate(allocationSize);
|
||||
auto gpuVirtualAddress = gfxPartition.heapAllocate(heap, allocationSize);
|
||||
if (!gpuVirtualAddress) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -104,8 +112,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
|
||||
MemoryAllocation *memAlloc = new MemoryAllocation(
|
||||
allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr), GmmHelper::canonize(gpuVirtualAddress + offset),
|
||||
allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, false, false, false);
|
||||
|
||||
memAlloc->set32BitAllocation(true);
|
||||
memAlloc->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress()));
|
||||
memAlloc->setGpuBaseAddress(GmmHelper::canonize(gfxPartition.getHeapBase(heap)));
|
||||
memAlloc->sizeToFree = allocationSize;
|
||||
|
||||
counter++;
|
||||
@ -114,7 +123,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
|
||||
|
||||
auto allocationSize = alignUp(allocationData.size, MemoryConstants::pageSize);
|
||||
void *ptrAlloc = nullptr;
|
||||
auto gpuAddress = allocator32Bit->allocate(allocationSize);
|
||||
auto gpuAddress = gfxPartition.heapAllocate(heap, allocationSize);
|
||||
|
||||
if (allocationData.size < 0xfffff000) {
|
||||
if (fakeBigAllocations) {
|
||||
@ -129,8 +138,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
|
||||
memoryAllocation = new MemoryAllocation(allocationData.type, ptrAlloc, ptrAlloc, GmmHelper::canonize(gpuAddress),
|
||||
allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, false,
|
||||
false, false);
|
||||
|
||||
memoryAllocation->set32BitAllocation(true);
|
||||
memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress()));
|
||||
memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition.getHeapBase(heap)));
|
||||
memoryAllocation->sizeToFree = allocationSize;
|
||||
}
|
||||
counter++;
|
||||
@ -138,9 +148,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) {
|
||||
auto graphicsAllocation = new MemoryAllocation(properties.allocationType, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
4096u, static_cast<uint64_t>(handle), MemoryPool::SystemCpuInaccessible, false,
|
||||
false, false);
|
||||
auto graphicsAllocation = createMemoryAllocation(properties.allocationType, nullptr, reinterpret_cast<void *>(1), 1,
|
||||
4096u, static_cast<uint64_t>(handle), MemoryPool::SystemCpuInaccessible, false,
|
||||
false, false, requireSpecificBitness);
|
||||
graphicsAllocation->setSharedHandle(handle);
|
||||
graphicsAllocation->set32BitAllocation(requireSpecificBitness);
|
||||
|
||||
@ -191,9 +201,12 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo
|
||||
return;
|
||||
}
|
||||
|
||||
if (gfxAllocation->is32BitAllocation()) {
|
||||
auto gpuAddressToFree = gfxAllocation->getGpuAddress() & ~MemoryConstants::pageMask;
|
||||
allocator32Bit->free(gpuAddressToFree, static_cast<MemoryAllocation *>(gfxAllocation)->sizeToFree);
|
||||
auto memoryAllocation = static_cast<MemoryAllocation *>(gfxAllocation);
|
||||
auto sizeToFree = memoryAllocation->sizeToFree;
|
||||
|
||||
if (sizeToFree) {
|
||||
auto gpuAddressToFree = GmmHelper::decanonize(memoryAllocation->getGpuAddress()) & ~MemoryConstants::pageMask;
|
||||
gfxPartition.freeGpuAddressRange(gpuAddressToFree, sizeToFree);
|
||||
}
|
||||
|
||||
alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr());
|
||||
@ -218,17 +231,22 @@ uint64_t OsAgnosticMemoryManager::getMaxApplicationAddress() {
|
||||
}
|
||||
|
||||
uint64_t OsAgnosticMemoryManager::getInternalHeapBaseAddress() {
|
||||
return this->allocator32Bit->getBase();
|
||||
return gfxPartition.getHeapBase(internalHeapIndex);
|
||||
}
|
||||
|
||||
uint64_t OsAgnosticMemoryManager::getExternalHeapBaseAddress() {
|
||||
return this->allocator32Bit->getBase();
|
||||
return gfxPartition.getHeapBase(HeapIndex::HEAP_EXTERNAL);
|
||||
}
|
||||
|
||||
void OsAgnosticMemoryManager::setForce32BitAllocations(bool newValue) {
|
||||
force32bitAllocations = newValue;
|
||||
}
|
||||
|
||||
GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) {
|
||||
auto allocation = new MemoryAllocation(allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr),
|
||||
reinterpret_cast<uint64_t>(allocationData.hostPtr), allocationData.size, counter++,
|
||||
MemoryPool::System4KBPages, false, false, false);
|
||||
auto allocation = createMemoryAllocation(allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr),
|
||||
reinterpret_cast<uint64_t>(allocationData.hostPtr), allocationData.size, counter++,
|
||||
MemoryPool::System4KBPages, false, false, false, false);
|
||||
|
||||
allocation->fragmentsStorage = handleStorage;
|
||||
return allocation;
|
||||
}
|
||||
@ -276,8 +294,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImageImpl(
|
||||
|
||||
auto ptr = allocateSystemMemory(alignUp(allocationData.imgInfo->size, MemoryConstants::pageSize), MemoryConstants::pageSize);
|
||||
if (ptr != nullptr) {
|
||||
alloc = new MemoryAllocation(allocationData.type, ptr, ptr, reinterpret_cast<uint64_t>(ptr), allocationData.imgInfo->size,
|
||||
counter, MemoryPool::SystemCpuInaccessible, false, allocationData.flags.uncacheable, allocationData.flags.flushL3);
|
||||
alloc = createMemoryAllocation(allocationData.type, ptr, ptr, reinterpret_cast<uint64_t>(ptr), allocationData.imgInfo->size,
|
||||
counter, MemoryPool::SystemCpuInaccessible, false, allocationData.flags.uncacheable, allocationData.flags.flushL3, false);
|
||||
counter++;
|
||||
}
|
||||
|
||||
@ -288,21 +306,6 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImageImpl(
|
||||
return alloc;
|
||||
}
|
||||
|
||||
Allocator32bit *OsAgnosticMemoryManager::create32BitAllocator(bool aubUsage) {
|
||||
uint64_t allocatorSize = MemoryConstants::gigaByte - 2 * 4096;
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
if (is64bit && this->localMemorySupported && aubUsage) {
|
||||
heap32Base = 0x40000000000ul;
|
||||
}
|
||||
|
||||
if (is32bit) {
|
||||
heap32Base = 0x0;
|
||||
}
|
||||
|
||||
return new Allocator32bit(heap32Base, allocatorSize);
|
||||
}
|
||||
|
||||
void *OsAgnosticMemoryManager::reserveCpuAddressRange(size_t size) {
|
||||
void *reservePtr = allocateSystemMemory(size, MemoryConstants::preferredAlignment);
|
||||
return reservePtr;
|
||||
@ -311,4 +314,28 @@ void *OsAgnosticMemoryManager::reserveCpuAddressRange(size_t size) {
|
||||
void OsAgnosticMemoryManager::releaseReservedCpuAddressRange(void *reserved, size_t size) {
|
||||
alignedFreeWrapper(reserved);
|
||||
}
|
||||
|
||||
MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(GraphicsAllocation::AllocationType allocationType, void *driverAllocatedCpuPointer,
|
||||
void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count,
|
||||
MemoryPool::Type pool, bool multiOsContextCapable, bool uncacheable,
|
||||
bool flushL3Required, bool requireSpecificBitness) {
|
||||
if (!isLimitedRange()) {
|
||||
return new MemoryAllocation(allocationType, driverAllocatedCpuPointer, pMem, gpuAddress, memSize,
|
||||
count, pool, multiOsContextCapable, uncacheable, flushL3Required);
|
||||
}
|
||||
|
||||
size_t alignedSize = alignSizeWholePage(pMem, memSize);
|
||||
|
||||
auto heap = (force32bitAllocations || requireSpecificBitness) ? HeapIndex::HEAP_EXTERNAL : HeapIndex::HEAP_STANDARD;
|
||||
|
||||
uint64_t limitedGpuAddress = gfxPartition.heapAllocate(heap, alignedSize);
|
||||
|
||||
auto memoryAllocation = new MemoryAllocation(allocationType, driverAllocatedCpuPointer, pMem, limitedGpuAddress, memSize,
|
||||
count, pool, multiOsContextCapable, uncacheable, flushL3Required);
|
||||
|
||||
memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition.getHeapBase(heap)));
|
||||
memoryAllocation->sizeToFree = alignedSize;
|
||||
|
||||
return memoryAllocation;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
#include "core/helpers/basic_math.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
@ -22,6 +20,15 @@ class MemoryAllocation : public GraphicsAllocation {
|
||||
|
||||
void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; }
|
||||
|
||||
MemoryAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn,
|
||||
MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool, multiOsContextCapable),
|
||||
id(0), uncacheable(false) {}
|
||||
|
||||
MemoryAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, multiOsContextCapable),
|
||||
id(0), uncacheable(false) {}
|
||||
|
||||
MemoryAllocation(AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize,
|
||||
uint64_t count, MemoryPool::Type pool, bool multiOsContextCapable, bool uncacheable, bool flushL3Required)
|
||||
: GraphicsAllocation(allocationType, pMem, gpuAddress, 0u, memSize, pool, multiOsContextCapable),
|
||||
@ -40,12 +47,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
using MemoryManager::allocateGraphicsMemory;
|
||||
|
||||
OsAgnosticMemoryManager(ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(false, executionEnvironment) {}
|
||||
|
||||
OsAgnosticMemoryManager(bool aubUsage, ExecutionEnvironment &executionEnvironment) : MemoryManager(executionEnvironment) {
|
||||
allocator32Bit.reset(create32BitAllocator(aubUsage));
|
||||
gfxPartition.init(platformDevices[0]->capabilityTable.gpuAddressSpace);
|
||||
}
|
||||
|
||||
OsAgnosticMemoryManager(bool aubUsage, ExecutionEnvironment &executionEnvironment);
|
||||
~OsAgnosticMemoryManager() override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) override;
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override { return nullptr; }
|
||||
@ -61,11 +63,10 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
uint64_t getMaxApplicationAddress() override;
|
||||
uint64_t getInternalHeapBaseAddress() override;
|
||||
uint64_t getExternalHeapBaseAddress() override;
|
||||
void setForce32BitAllocations(bool newValue) override;
|
||||
|
||||
void turnOnFakingBigAllocations();
|
||||
|
||||
Allocator32bit *create32BitAllocator(bool enableLocalMemory);
|
||||
|
||||
void *reserveCpuAddressRange(size_t size) override;
|
||||
void releaseReservedCpuAddressRange(void *reserved, size_t size) override;
|
||||
|
||||
@ -80,6 +81,8 @@ class OsAgnosticMemoryManager : public MemoryManager {
|
||||
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override {}
|
||||
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
MemoryAllocation *createMemoryAllocation(GraphicsAllocation::AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize,
|
||||
uint64_t count, MemoryPool::Type pool, bool multiOsContextCapable, bool uncacheable, bool flushL3Required, bool requireSpecificBitness);
|
||||
|
||||
private:
|
||||
unsigned long long counter = 0;
|
||||
|
@ -18,6 +18,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_BASE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_inc_base.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time.h
|
||||
|
@ -45,6 +45,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_time_linux.cpp
|
||||
|
@ -10,4 +10,5 @@
|
||||
|
||||
namespace NEO {
|
||||
size_t getSizeToMap();
|
||||
} // namespace NEO
|
||||
size_t getSizeToReserve();
|
||||
} // namespace NEO
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "runtime/helpers/surface_formats.h"
|
||||
#include "runtime/memory_manager/host_ptr_manager.h"
|
||||
#include "runtime/os_interface/32bit_memory.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
#include "runtime/os_interface/linux/os_context_linux.h"
|
||||
#include "runtime/os_interface/linux/os_interface.h"
|
||||
#include "runtime/os_interface/linux/tiling_mode_helper.h"
|
||||
@ -39,7 +40,7 @@ DrmMemoryManager::DrmMemoryManager(gemCloseWorkerMode mode,
|
||||
forcePinEnabled(forcePinAllowed),
|
||||
validateHostPtrMemory(validateHostPtrMemory) {
|
||||
supportsMultiStorageResources = false;
|
||||
gfxPartition.init(platformDevices[0]->capabilityTable.gpuAddressSpace);
|
||||
gfxPartition.init(platformDevices[0]->capabilityTable.gpuAddressSpace, getSizeToReserve());
|
||||
MemoryManager::virtualPaddingAvailable = true;
|
||||
if (mode != gemCloseWorkerMode::gemCloseWorkerInactive) {
|
||||
gemCloseWorker.reset(new DrmGemCloseWorker(*this));
|
||||
|
23
runtime/os_interface/linux/os_memory_linux.cpp
Normal file
23
runtime/os_interface/linux/os_memory_linux.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/os_memory.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void *OSMemory::reserveCpuAddressRange(size_t sizeToReserve) {
|
||||
return mmap(0, sizeToReserve, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_HUGETLB, open("/dev/null", O_RDONLY), 0);
|
||||
}
|
||||
|
||||
void OSMemory::releaseCpuAddressRange(void *reservedCpuAddressRange, size_t reservedSize) {
|
||||
munmap(reservedCpuAddressRange, reservedSize);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
19
runtime/os_interface/os_memory.h
Normal file
19
runtime/os_interface/os_memory.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct OSMemory {
|
||||
public:
|
||||
static void *reserveCpuAddressRange(size_t sizeToReserve);
|
||||
static void releaseCpuAddressRange(void *reservedCpuAddressRange, size_t reservedSize);
|
||||
};
|
||||
|
||||
} // namespace NEO
|
@ -35,6 +35,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.h
|
||||
|
22
runtime/os_interface/windows/os_memory_win.cpp
Normal file
22
runtime/os_interface/windows/os_memory_win.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/os_memory.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void *OSMemory::reserveCpuAddressRange(size_t sizeToReserve) {
|
||||
return VirtualAlloc(0, sizeToReserve, MEM_RESERVE, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void OSMemory::releaseCpuAddressRange(void *reservedCpuAddressRange, size_t /* reservedSize */) {
|
||||
VirtualFree(reservedCpuAddressRange, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
@ -13,6 +13,7 @@
|
||||
#include "unit_tests/aub_tests/aub_tests_configuration.h"
|
||||
#include "unit_tests/aub_tests/command_queue/command_enqueue_fixture.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -115,13 +116,13 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) {
|
||||
|
||||
cl_float srcMemory[] = {1.0f, 2.0f, 3.0f, 4.0f};
|
||||
cl_float dstMemory[] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
GraphicsAllocation *srcAlocation = new GraphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN,
|
||||
srcMemory,
|
||||
0xFFFF800400001000,
|
||||
0xFFFF800400001000,
|
||||
sizeof(srcMemory),
|
||||
MemoryPool::MemoryNull,
|
||||
false);
|
||||
GraphicsAllocation *srcAlocation = new MockGraphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN,
|
||||
srcMemory,
|
||||
0xFFFF800400001000,
|
||||
0xFFFF800400001000,
|
||||
sizeof(srcMemory),
|
||||
MemoryPool::MemoryNull,
|
||||
false);
|
||||
|
||||
std::unique_ptr<Buffer> srcBuffer(Buffer::createBufferHw(&context,
|
||||
CL_MEM_USE_HOST_PTR,
|
||||
|
@ -370,7 +370,7 @@ HWTEST_F(EnqueueKernelTest, givenReducedAddressSpaceGraphicsAllocationForHostPtr
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<CommandQueue> cmdQ;
|
||||
auto hwInfoToModify = *platformDevices[0];
|
||||
hwInfoToModify.capabilityTable.gpuAddressSpace = MemoryConstants::max32BitAddress;
|
||||
hwInfoToModify.capabilityTable.gpuAddressSpace = MemoryConstants::max36BitAddress;
|
||||
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfoToModify));
|
||||
auto mockCsr = new MockCsrHw2<FamilyType>(*device->executionEnvironment);
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
@ -394,7 +394,7 @@ HWTEST_F(EnqueueKernelTest, givenReducedAddressSpaceGraphicsAllocationForHostPtr
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<CommandQueue> cmdQ;
|
||||
auto hwInfoToModify = *platformDevices[0];
|
||||
hwInfoToModify.capabilityTable.gpuAddressSpace = MemoryConstants::max32BitAddress;
|
||||
hwInfoToModify.capabilityTable.gpuAddressSpace = MemoryConstants::max36BitAddress;
|
||||
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfoToModify));
|
||||
auto mockCsr = new MockCsrHw2<FamilyType>(*device->executionEnvironment);
|
||||
device->resetCommandStreamReceiver(mockCsr);
|
||||
|
@ -324,13 +324,13 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
|
||||
EXPECT_EQ(bitValue, cmd->getPerThreadScratchSpace());
|
||||
EXPECT_EQ(bitValue, cmd->getStackSize());
|
||||
auto graphicsAllocation = csr.getScratchAllocation();
|
||||
auto GSHaddress = (uintptr_t)sba->getGeneralStateBaseAddress();
|
||||
auto GSHaddress = sba->getGeneralStateBaseAddress();
|
||||
if (is32bit) {
|
||||
EXPECT_NE(0u, cmd->getScratchSpaceBasePointer());
|
||||
EXPECT_EQ(0u, GSHaddress);
|
||||
} else {
|
||||
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), cmd->getScratchSpaceBasePointer());
|
||||
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), (uintptr_t)graphicsAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), graphicsAllocation->getGpuAddress());
|
||||
}
|
||||
|
||||
auto allocationSize = scratchSize * pDevice->getDeviceInfo().computeUnitsUsedForScratch;
|
||||
@ -374,9 +374,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
|
||||
auto graphicsAllocation2 = csr.getScratchAllocation();
|
||||
|
||||
if (is32bit) {
|
||||
auto scratchBase = (uintptr_t)cmd2->getScratchSpaceBasePointer();
|
||||
auto scratchBase = cmd2->getScratchSpaceBasePointer();
|
||||
EXPECT_NE(0u, scratchBase);
|
||||
auto graphicsAddress = (uintptr_t)graphicsAllocation2->getUnderlyingBuffer();
|
||||
auto graphicsAddress = graphicsAllocation2->getGpuAddress();
|
||||
EXPECT_EQ(graphicsAddress, scratchBase);
|
||||
} else {
|
||||
auto *sba2 = (STATE_BASE_ADDRESS *)*itorCmdForStateBase;
|
||||
@ -403,7 +403,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueScratchSpaceTests, GivenKernelRequiringScratc
|
||||
if (is32bit) {
|
||||
EXPECT_EQ(0u, GSBaddress);
|
||||
} else if (is64bit) {
|
||||
EXPECT_EQ((uintptr_t)graphicsAllocation2->getUnderlyingBuffer(), GSBaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit());
|
||||
EXPECT_EQ(graphicsAllocation2->getGpuAddress(), GSBaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(csr.getAllocationsForReuse().peekIsEmpty());
|
||||
@ -489,7 +489,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueKernelWithScratch, givenDeviceForcing32bitAll
|
||||
ASSERT_NE(itorCmdForStateBase, itorWalker);
|
||||
auto *sba = (STATE_BASE_ADDRESS *)*itorCmdForStateBase;
|
||||
|
||||
auto GSHaddress = (uintptr_t)sba->getGeneralStateBaseAddress();
|
||||
auto GSHaddress = sba->getGeneralStateBaseAddress();
|
||||
|
||||
EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(), GSHaddress);
|
||||
|
||||
@ -595,7 +595,8 @@ HWTEST_P(EnqueueKernelPrintfTest, GivenKernelWithPrintfBlockedByEventWhenEventUn
|
||||
|
||||
// In scenarios with 32bit allocator and 64 bit tests this code won't work
|
||||
// due to inability to retrieve original buffer pointer as it is done in this test.
|
||||
if (!pDevice->getMemoryManager()->peekForce32BitAllocations()) {
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
if (!memoryManager->peekForce32BitAllocations() && !memoryManager->isLimitedRange()) {
|
||||
testing::internal::CaptureStdout();
|
||||
|
||||
auto userEvent = make_releaseable<UserEvent>(context);
|
||||
|
@ -61,6 +61,6 @@ HWTEST_F(IOQWithTwoWalkers, shouldHaveAPipecontrolBetweenWalkers2) {
|
||||
uint64_t addressPC = ((uint64_t)pipeControl->getAddressHigh() << 32) | pipeControl->getAddress();
|
||||
|
||||
// The PC address should match the CS tag address
|
||||
EXPECT_EQ((uint64_t)commandStreamReceiver.getTagAddress(), addressPC);
|
||||
EXPECT_EQ(commandStreamReceiver.getTagAllocation()->getGpuAddress(), addressPC);
|
||||
EXPECT_EQ(1u, pipeControl->getImmediateData());
|
||||
}
|
||||
|
@ -24,6 +24,11 @@ struct EnqueueSvmMemCopyTest : public DeviceFixture,
|
||||
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
|
||||
if (!pDevice->isFullRangeSvm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommandQueueFixture::SetUp(pDevice, 0);
|
||||
srcSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
ASSERT_NE(nullptr, srcSvmPtr);
|
||||
@ -40,9 +45,11 @@ struct EnqueueSvmMemCopyTest : public DeviceFixture,
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(srcSvmPtr);
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(dstSvmPtr);
|
||||
CommandQueueFixture::TearDown();
|
||||
if (pDevice->isFullRangeSvm()) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(srcSvmPtr);
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(dstSvmPtr);
|
||||
CommandQueueFixture::TearDown();
|
||||
}
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
@ -53,6 +60,10 @@ struct EnqueueSvmMemCopyTest : public DeviceFixture,
|
||||
};
|
||||
|
||||
HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBufferBuilderThenItConfiguredWithBuiltinOpsAndProducesDispatchInfo) {
|
||||
if (!pDevice->isFullRangeSvm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto &builtIns = *pCmdQ->getDevice().getExecutionEnvironment()->getBuiltIns();
|
||||
|
||||
// retrieve original builder
|
||||
@ -125,6 +136,10 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBufferBuilderAndSrcHostPtrThenItConfiguredWithBuiltinOpsAndProducesDispatchInfo) {
|
||||
if (!pDevice->isFullRangeSvm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto &builtIns = *pCmdQ->getDevice().getExecutionEnvironment()->getBuiltIns();
|
||||
void *srcHostPtr = alignedMalloc(256, 64);
|
||||
|
||||
@ -199,6 +214,10 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBufferBuilderAndDstHostPtrThenItConfiguredWithBuiltinOpsAndProducesDispatchInfo) {
|
||||
if (!pDevice->isFullRangeSvm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto &builtIns = *pCmdQ->getDevice().getExecutionEnvironment()->getBuiltIns();
|
||||
auto dstHostPtr = alignedMalloc(256, 64);
|
||||
|
||||
@ -270,4 +289,4 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
|
||||
auto kernel = mdi->begin()->getKernel();
|
||||
EXPECT_EQ("CopyBufferToBufferMiddle", kernel->getKernelInfo().name);
|
||||
alignedFree(dstHostPtr);
|
||||
}
|
||||
}
|
||||
|
@ -732,6 +732,10 @@ TEST_F(EnqueueSvmTest, enqueueSVMMigrateMem_Success) {
|
||||
}
|
||||
|
||||
TEST(CreateSvmAllocTests, givenVariousSvmAllocationPropertiesWhenAllocatingSvmThenSvmIsCorrectlyAllocated) {
|
||||
if (!platformDevices[0]->capabilityTable.ftrSvm) {
|
||||
return;
|
||||
}
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
SVMAllocsManager::SvmAllocationProperties svmAllocationProperties;
|
||||
|
||||
|
@ -44,7 +44,10 @@ TEST_F(EnqueueKernelTest, givenKernelWithSharedObjArgsWhenEnqueueIsCalledThenRes
|
||||
(uint32_t *)(pKernel->getCrossThreadData() + kernelInfo.kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
auto address1 = static_cast<uint64_t>(*pKernelArg);
|
||||
EXPECT_EQ(sharedBuffer->getGraphicsAllocation()->getGpuAddress(), address1);
|
||||
auto sharedBufferGpuAddress =
|
||||
pKernel->isBuiltIn ? sharedBuffer->getGraphicsAllocation()->getGpuAddress()
|
||||
: sharedBuffer->getGraphicsAllocation()->getGpuAddressToPatch();
|
||||
EXPECT_EQ(sharedBufferGpuAddress, address1);
|
||||
|
||||
// update address
|
||||
glSharing.uploadDataToBufferInfo(1, 1);
|
||||
@ -54,7 +57,10 @@ TEST_F(EnqueueKernelTest, givenKernelWithSharedObjArgsWhenEnqueueIsCalledThenRes
|
||||
|
||||
auto address2 = static_cast<uint64_t>(*pKernelArg);
|
||||
EXPECT_NE(address1, address2);
|
||||
EXPECT_EQ(sharedBuffer->getGraphicsAllocation()->getGpuAddress(), address2);
|
||||
sharedBufferGpuAddress =
|
||||
pKernel->isBuiltIn ? sharedBuffer->getGraphicsAllocation()->getGpuAddress()
|
||||
: sharedBuffer->getGraphicsAllocation()->getGpuAddressToPatch();
|
||||
EXPECT_EQ(sharedBufferGpuAddress, address2);
|
||||
|
||||
delete sharedBuffer;
|
||||
delete nonSharedBuffer;
|
||||
|
@ -462,13 +462,14 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
|
||||
|
||||
EXPECT_EQ(false, kernel.mockKernel->isBuiltIn);
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
auto deviceInfo = pDevice->getDeviceInfo();
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_FALSE(commandStreamReceiver->getGSBAFor32BitProgrammed());
|
||||
}
|
||||
|
||||
commandQueue.enqueueKernel(kernel, 1, nullptr, &GWS, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_TRUE(commandStreamReceiver->getGSBAFor32BitProgrammed());
|
||||
}
|
||||
|
||||
@ -490,9 +491,12 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
|
||||
// Get address ( offset in 32 bit addressing ) of sratch
|
||||
graphicsAddress = (uint64_t)graphicsAllocationScratch->getGpuAddressToPatch();
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true && is64bit) {
|
||||
if (deviceInfo.force32BitAddressess && is64bit) {
|
||||
EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation());
|
||||
EXPECT_EQ((uint64_t)graphicsAllocationScratch->getGpuAddress() - GSHaddress, graphicsAddress);
|
||||
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress);
|
||||
} else if (!deviceInfo.svmCapabilities && is64bit) {
|
||||
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), mediaVfeState->getScratchSpaceBasePointer());
|
||||
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), graphicsAllocationScratch->getGpuAddressToPatch());
|
||||
} else {
|
||||
EXPECT_EQ((uint64_t)graphicsAllocationScratch->getUnderlyingBuffer(), graphicsAddress);
|
||||
}
|
||||
@ -503,7 +507,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
|
||||
uint64_t scratchBaseLowPart = (uint64_t)mediaVfeState->getScratchSpaceBasePointer();
|
||||
uint64_t scratchBaseHighPart = (uint64_t)mediaVfeState->getScratchSpaceBasePointerHigh();
|
||||
|
||||
if (is64bit && !pDevice->getDeviceInfo().force32BitAddressess) {
|
||||
if (is64bit && !deviceInfo.force32BitAddressess) {
|
||||
uint64_t expectedAddress = HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit();
|
||||
EXPECT_EQ(expectedAddress, scratchBaseLowPart);
|
||||
EXPECT_EQ(0u, scratchBaseHighPart);
|
||||
@ -512,7 +516,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu
|
||||
EXPECT_EQ(highPartGraphicsAddress, scratchBaseHighPart);
|
||||
}
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(), GSHaddress);
|
||||
} else {
|
||||
if (is64bit) {
|
||||
@ -572,13 +576,14 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
|
||||
EXPECT_EQ(false, kernel.mockKernel->isBuiltIn);
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
auto deviceInfo = pDevice->getDeviceInfo();
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_FALSE(commandStreamReceiver->getGSBAFor32BitProgrammed());
|
||||
}
|
||||
|
||||
commandQueue.enqueueKernel(kernel, 1, nullptr, &GWS, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_TRUE(commandStreamReceiver->getGSBAFor32BitProgrammed());
|
||||
}
|
||||
|
||||
@ -600,9 +605,12 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
// Get address ( offset in 32 bit addressing ) of sratch
|
||||
graphicsAddress = (uint64_t)graphicsAllocationScratch->getGpuAddressToPatch();
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true && is64bit) {
|
||||
if (deviceInfo.force32BitAddressess && is64bit) {
|
||||
EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation());
|
||||
EXPECT_EQ((uint64_t)graphicsAllocationScratch->getGpuAddress() - GSHaddress, graphicsAddress);
|
||||
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress);
|
||||
} else if (!deviceInfo.svmCapabilities && is64bit) {
|
||||
EXPECT_EQ(HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), mediaVfeState->getScratchSpaceBasePointer());
|
||||
EXPECT_EQ(GSHaddress + HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit(), graphicsAllocationScratch->getGpuAddressToPatch());
|
||||
} else {
|
||||
EXPECT_EQ((uint64_t)graphicsAllocationScratch->getUnderlyingBuffer(), graphicsAddress);
|
||||
}
|
||||
@ -613,7 +621,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
uint64_t scratchBaseLowPart = (uint64_t)mediaVfeState->getScratchSpaceBasePointer();
|
||||
uint64_t scratchBaseHighPart = (uint64_t)mediaVfeState->getScratchSpaceBasePointerHigh();
|
||||
|
||||
if (is64bit && !pDevice->getDeviceInfo().force32BitAddressess) {
|
||||
if (is64bit && !deviceInfo.force32BitAddressess) {
|
||||
lowPartGraphicsAddress = HwHelperHw<FamilyType>::get().getScratchSpaceOffsetFor64bit();
|
||||
highPartGraphicsAddress = 0u;
|
||||
}
|
||||
@ -621,7 +629,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
EXPECT_EQ(lowPartGraphicsAddress, scratchBaseLowPart);
|
||||
EXPECT_EQ(highPartGraphicsAddress, scratchBaseHighPart);
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(), GSHaddress);
|
||||
} else {
|
||||
if (is64bit) {
|
||||
@ -644,7 +652,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
|
||||
itorCmdForStateBase = find<STATE_BASE_ADDRESS *>(itorWalker, cmdList.end());
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_NE(itorWalker, itorCmdForStateBase);
|
||||
|
||||
if (itorCmdForStateBase != cmdList.end()) {
|
||||
@ -655,14 +663,14 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer
|
||||
EXPECT_NE(sba, sba2);
|
||||
EXPECT_EQ(0u, GSHaddress2);
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
EXPECT_FALSE(commandStreamReceiver->getGSBAFor32BitProgrammed());
|
||||
}
|
||||
}
|
||||
}
|
||||
delete buffer;
|
||||
|
||||
if (pDevice->getDeviceInfo().force32BitAddressess == true) {
|
||||
if (deviceInfo.force32BitAddressess) {
|
||||
// Asserts placed after restoring old CSR to avoid heap corruption
|
||||
ASSERT_NE(itorCmdForStateBase, cmdList.end());
|
||||
}
|
||||
|
@ -252,8 +252,9 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddre
|
||||
scratchController->setRequiredScratchSpace(surfaceHeap.get(), 0x1000u, 0u, 0u, stateBaseAddressDirty, cfeStateDirty);
|
||||
|
||||
uint64_t expectedScratchAddress = 0xAAABBBCCCDDD000ull;
|
||||
scratchController->getScratchSpaceAllocation()->setCpuPtrAndGpuAddress(scratchController->getScratchSpaceAllocation()->getUnderlyingBuffer(), expectedScratchAddress);
|
||||
EXPECT_TRUE(UnitTestHelper<FamilyType>::evaluateGshAddressForScratchSpace((expectedScratchAddress - MemoryConstants::pageSize), scratchController->calculateNewGSH()));
|
||||
auto scratchAllocation = scratchController->getScratchSpaceAllocation();
|
||||
scratchAllocation->setCpuPtrAndGpuAddress(scratchAllocation->getUnderlyingBuffer(), expectedScratchAddress);
|
||||
EXPECT_TRUE(UnitTestHelper<FamilyType>::evaluateGshAddressForScratchSpace((scratchAllocation->getGpuAddress() - MemoryConstants::pageSize), scratchController->calculateNewGSH()));
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsNotRequiredThenGshAddressZeroIsReturned) {
|
||||
@ -591,7 +592,9 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
|
||||
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
|
||||
EXPECT_NE(nullptr, bltCmd);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getSourceBaseAddress());
|
||||
if (pDevice->isFullRangeSvm()) {
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getSourceBaseAddress());
|
||||
}
|
||||
EXPECT_EQ(buffer1->getGraphicsAllocation()->getGpuAddress(), bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
{
|
||||
@ -605,7 +608,9 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
|
||||
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
|
||||
EXPECT_NE(nullptr, bltCmd);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getDestinationBaseAddress());
|
||||
if (pDevice->isFullRangeSvm()) {
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
EXPECT_EQ(buffer1->getGraphicsAllocation()->getGpuAddress(), bltCmd->getSourceBaseAddress());
|
||||
}
|
||||
{
|
||||
@ -645,7 +650,9 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
|
||||
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
|
||||
EXPECT_NE(nullptr, bltCmd);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getSourceBaseAddress());
|
||||
if (pDevice->isFullRangeSvm()) {
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getSourceBaseAddress());
|
||||
}
|
||||
EXPECT_EQ(ptrOffset(buffer1->getGraphicsAllocation()->getGpuAddress(), buffer1Offset), bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
{
|
||||
@ -659,7 +666,9 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
|
||||
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*hwParser.cmdList.begin());
|
||||
EXPECT_NE(nullptr, bltCmd);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getDestinationBaseAddress());
|
||||
if (pDevice->isFullRangeSvm()) {
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(hostPtr), bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
EXPECT_EQ(ptrOffset(buffer1->getGraphicsAllocation()->getGpuAddress(), buffer1Offset), bltCmd->getSourceBaseAddress());
|
||||
}
|
||||
|
||||
|
@ -340,8 +340,8 @@ TEST(CommandStreamReceiverSimpleTest, givenCSRWithTagAllocationSetWhenGetTagAllo
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroyedThenItDestroysTagAllocation) {
|
||||
struct MockGraphicsAllocationWithDestructorTracing : public GraphicsAllocation {
|
||||
using GraphicsAllocation::GraphicsAllocation;
|
||||
struct MockGraphicsAllocationWithDestructorTracing : public MockGraphicsAllocation {
|
||||
using MockGraphicsAllocation::MockGraphicsAllocation;
|
||||
~MockGraphicsAllocationWithDestructorTracing() override { *destructorCalled = true; }
|
||||
bool *destructorCalled = nullptr;
|
||||
};
|
||||
|
@ -322,7 +322,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueSlb, cleanupSection) {
|
||||
hwParser.parseCommands<FamilyType>(*slbCS, cleanupSectionOffsetToParse);
|
||||
hwParser.findHardwareCommands<FamilyType>();
|
||||
|
||||
uint64_t cleanUpSectionAddress = (uint64_t)slbCS->getCpuBase() + cleanupSectionOffset;
|
||||
uint64_t cleanUpSectionAddress = mockDeviceQueueHw->getSlbBuffer()->getGpuAddress() + cleanupSectionOffset;
|
||||
EXPECT_EQ(cleanUpSectionAddress, igilCmdQueue->m_controls.m_CleanupSectionAddress);
|
||||
EXPECT_EQ(slbCS->getUsed() - cleanupSectionOffset, igilCmdQueue->m_controls.m_CleanupSectionSize);
|
||||
|
||||
@ -334,7 +334,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueSlb, cleanupSection) {
|
||||
MI_BATCH_BUFFER_END *bbEnd = (MI_BATCH_BUFFER_END *)*bbEndItor;
|
||||
uint64_t bbEndAddres = (uint64_t)bbEnd;
|
||||
|
||||
EXPECT_LE(mockDeviceQueueHw->getSlbBuffer()->getGpuAddress() + cleanupSectionOffset, bbEndAddres);
|
||||
EXPECT_LE((uint64_t)mockDeviceQueueHw->getSlbBuffer()->getUnderlyingBuffer() + cleanupSectionOffset, bbEndAddres);
|
||||
|
||||
delete mockParentKernel;
|
||||
delete mockDeviceQueueHw;
|
||||
@ -369,7 +369,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueSlb, AddEMCleanupSectionWithProfiling) {
|
||||
hwParser.parseCommands<FamilyType>(*slbCS, cleanupSectionOffsetToParse);
|
||||
hwParser.findHardwareCommands<FamilyType>();
|
||||
|
||||
uint64_t cleanUpSectionAddress = (uint64_t)slbCS->getCpuBase() + cleanupSectionOffset;
|
||||
uint64_t cleanUpSectionAddress = mockDeviceQueueHw->getSlbBuffer()->getGpuAddress() + cleanupSectionOffset;
|
||||
EXPECT_EQ(cleanUpSectionAddress, igilCmdQueue->m_controls.m_CleanupSectionAddress);
|
||||
EXPECT_EQ(slbCS->getUsed() - cleanupSectionOffset, igilCmdQueue->m_controls.m_CleanupSectionSize);
|
||||
|
||||
@ -405,7 +405,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueSlb, AddEMCleanupSectionWithProfiling) {
|
||||
MI_BATCH_BUFFER_END *bbEnd = (MI_BATCH_BUFFER_END *)*bbEndItor;
|
||||
uint64_t bbEndAddres = (uint64_t)bbEnd;
|
||||
|
||||
EXPECT_LE(mockDeviceQueueHw->getSlbBuffer()->getGpuAddress() + cleanupSectionOffset, bbEndAddres);
|
||||
EXPECT_LE((uint64_t)mockDeviceQueueHw->getSlbBuffer()->getUnderlyingBuffer() + cleanupSectionOffset, bbEndAddres);
|
||||
|
||||
delete mockParentKernel;
|
||||
delete mockDeviceQueueHw;
|
||||
|
@ -425,14 +425,14 @@ TEST_F(ParentKernelEnqueueFixture, GivenParentKernelWhenEnqueuedTheDefaultDevice
|
||||
auto patchLocation = ptrOffset(reinterpret_cast<uint64_t *>(parentKernel->getCrossThreadData()),
|
||||
patchInfo.pAllocateStatelessDefaultDeviceQueueSurface->DataParamOffset);
|
||||
|
||||
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddress(), *patchLocation);
|
||||
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddressToPatch(), *patchLocation);
|
||||
}
|
||||
|
||||
if (patchInfo.pAllocateStatelessEventPoolSurface) {
|
||||
auto patchLocation = ptrOffset(reinterpret_cast<uint64_t *>(parentKernel->getCrossThreadData()),
|
||||
patchInfo.pAllocateStatelessEventPoolSurface->DataParamOffset);
|
||||
|
||||
EXPECT_EQ(pDevQueue->getEventPoolBuffer()->getGpuAddress(), *patchLocation);
|
||||
EXPECT_EQ(pDevQueue->getEventPoolBuffer()->getGpuAddressToPatch(), *patchLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -463,15 +463,15 @@ HWTEST_F(ParentKernelEnqueueFixture, GivenParentKernelWhenEnqueuedThenBlocksDSHO
|
||||
uint32_t offset = MockKernel::ReflectionSurfaceHelperPublic::getConstantBufferOffset(reflectionSurface, i);
|
||||
|
||||
if (defaultQueueSize == sizeof(uint64_t)) {
|
||||
EXPECT_EQ_VAL(pDevQueueHw->getQueueBuffer()->getGpuAddressToPatch(), *(uint64_t *)ptrOffset(reflectionSurface, offset + defaultQueueOffset));
|
||||
EXPECT_EQ_VAL(pDevQueueHw->getQueueBuffer()->getGpuAddress(), *(uint64_t *)ptrOffset(reflectionSurface, offset + defaultQueueOffset));
|
||||
} else {
|
||||
EXPECT_EQ((uint32_t)pDevQueueHw->getQueueBuffer()->getGpuAddressToPatch(), *(uint32_t *)ptrOffset(reflectionSurface, offset + defaultQueueOffset));
|
||||
EXPECT_EQ((uint32_t)pDevQueueHw->getQueueBuffer()->getGpuAddress(), *(uint32_t *)ptrOffset(reflectionSurface, offset + defaultQueueOffset));
|
||||
}
|
||||
|
||||
if (eventPoolSize == sizeof(uint64_t)) {
|
||||
EXPECT_EQ_VAL(pDevQueueHw->getEventPoolBuffer()->getGpuAddressToPatch(), *(uint64_t *)ptrOffset(reflectionSurface, offset + eventPoolOffset));
|
||||
EXPECT_EQ_VAL(pDevQueueHw->getEventPoolBuffer()->getGpuAddress(), *(uint64_t *)ptrOffset(reflectionSurface, offset + eventPoolOffset));
|
||||
} else {
|
||||
EXPECT_EQ((uint32_t)pDevQueueHw->getEventPoolBuffer()->getGpuAddressToPatch(), *(uint32_t *)ptrOffset(reflectionSurface, offset + eventPoolOffset));
|
||||
EXPECT_EQ((uint32_t)pDevQueueHw->getEventPoolBuffer()->getGpuAddress(), *(uint32_t *)ptrOffset(reflectionSurface, offset + eventPoolOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ void validateStateBaseAddress(uint64_t internalHeapBase, IndirectHeap *pDSH,
|
||||
EXPECT_TRUE(cmd->getIndirectObjectBaseAddressModifyEnable());
|
||||
EXPECT_TRUE(cmd->getInstructionBaseAddressModifyEnable());
|
||||
|
||||
EXPECT_EQ(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(pDSH->getCpuBase())), cmd->getDynamicStateBaseAddress());
|
||||
EXPECT_EQ(pDSH->getGraphicsAllocation()->getGpuAddress(), cmd->getDynamicStateBaseAddress());
|
||||
// Stateless accesses require GSH.base to be 0.
|
||||
EXPECT_EQ(expectedGeneralStateHeapBaseAddress, cmd->getGeneralStateBaseAddress());
|
||||
EXPECT_EQ(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(pSSH->getCpuBase())), cmd->getSurfaceStateBaseAddress());
|
||||
EXPECT_EQ(pSSH->getGraphicsAllocation()->getGpuAddress(), cmd->getSurfaceStateBaseAddress());
|
||||
EXPECT_EQ(pIOH->getGraphicsAllocation()->getGpuBaseAddress(), cmd->getIndirectObjectBaseAddress());
|
||||
EXPECT_EQ(internalHeapBase, cmd->getInstructionBaseAddress());
|
||||
|
||||
|
@ -1362,7 +1362,7 @@ TEST_F(KernelEventPoolSurfaceTest, givenStatelessKernelWhenEventPoolIsPatchedThe
|
||||
|
||||
pKernel->patchEventPool(pDevQueue);
|
||||
|
||||
EXPECT_EQ(pDevQueue->getEventPoolBuffer()->getGpuAddress(), *(uint64_t *)pKernel->getCrossThreadData());
|
||||
EXPECT_EQ(pDevQueue->getEventPoolBuffer()->getGpuAddressToPatch(), *(uint64_t *)pKernel->getCrossThreadData());
|
||||
|
||||
delete pKernel;
|
||||
}
|
||||
@ -1572,7 +1572,7 @@ TEST_F(KernelDefaultDeviceQueueSurfaceTest, givenStatelessKernelWhenDefaultDevic
|
||||
|
||||
pKernel->patchDefaultDeviceQueue(pDevQueue);
|
||||
|
||||
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddress(), *(uint64_t *)pKernel->getCrossThreadData());
|
||||
EXPECT_EQ(pDevQueue->getQueueBuffer()->getGpuAddressToPatch(), *(uint64_t *)pKernel->getCrossThreadData());
|
||||
|
||||
delete pKernel;
|
||||
}
|
||||
|
@ -361,6 +361,10 @@ TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedVa
|
||||
EXPECT_EQ((alignUp(4 * GB - 8096, 4096)), NEO::getSizeToMap());
|
||||
}
|
||||
|
||||
TEST(AllocatorHelper, givenExpectedSizeToReserveWhenGetSizeToReserveCalledThenExpectedValueReturned) {
|
||||
EXPECT_EQ(maxNBitValue<47> / 4, NEO::getSizeToReserve());
|
||||
}
|
||||
|
||||
TEST(DrmMemoryManagerCreate, whenCallCreateMemoryManagerThenDrmMemoryManagerIsCreated) {
|
||||
DrmMockSuccess mock;
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
|
@ -1101,7 +1101,7 @@ HWTEST_F(ImageSetArgTest, givenImageWithOffsetGreaterThan4GBWhenSurfaceStateIsPr
|
||||
srcImage->setSurfaceOffsets(surfaceOffset, 0, 0, 0);
|
||||
srcImage->setImageArg(&surfaceState, false, 0);
|
||||
|
||||
auto expectedAddress = srcImage->getGraphicsAllocation()->getGpuAddressToPatch() + surfaceOffset;
|
||||
auto expectedAddress = srcImage->getGraphicsAllocation()->getGpuAddress() + surfaceOffset;
|
||||
auto surfaceAddress = surfaceState.getSurfaceBaseAddress();
|
||||
|
||||
EXPECT_EQ(expectedAddress, surfaceAddress);
|
||||
|
@ -5,8 +5,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/helpers/basic_math.h"
|
||||
#include "core/helpers/ptr_math.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/os_interface/os_memory.h"
|
||||
#include "unit_tests/mocks/mock_gfx_partition.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@ -15,18 +17,27 @@ using namespace NEO;
|
||||
|
||||
void testGfxPartition(uint64_t gpuAddressSpace) {
|
||||
MockGfxPartition gfxPartition;
|
||||
gfxPartition.init(gpuAddressSpace);
|
||||
size_t reservedCpuAddressRangeSize = is64bit ? (6 * 4 * GB) : 0;
|
||||
gfxPartition.init(gpuAddressSpace, reservedCpuAddressRangeSize);
|
||||
|
||||
uint64_t gfxTop = gpuAddressSpace + 1;
|
||||
uint64_t gfxBase = MemoryConstants::maxSvmAddress + 1;
|
||||
const uint64_t sizeHeap32 = 4 * MemoryConstants::gigaByte;
|
||||
|
||||
if (MemoryConstants::max48BitAddress == gpuAddressSpace) {
|
||||
// Full range SVM
|
||||
if (is32bit || maxNBitValue<48> == gpuAddressSpace) {
|
||||
// Full range SVM 48/32-bit
|
||||
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::HEAP_SVM));
|
||||
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_SVM), 0ull);
|
||||
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_SVM), gfxBase);
|
||||
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_SVM), MemoryConstants::maxSvmAddress);
|
||||
} else if (maxNBitValue<47> == gpuAddressSpace) {
|
||||
// Full range SVM 47-bit
|
||||
gfxBase = (uint64_t)gfxPartition.getReservedCpuAddressRange();
|
||||
gfxTop = gfxBase + gfxPartition.getReservedCpuAddressRangeSize();
|
||||
EXPECT_TRUE(gfxPartition.heapInitialized(HeapIndex::HEAP_SVM));
|
||||
EXPECT_EQ(gfxPartition.getHeapBase(HeapIndex::HEAP_SVM), 0ull);
|
||||
EXPECT_EQ(gfxPartition.getHeapSize(HeapIndex::HEAP_SVM), is64bit ? gpuAddressSpace + 1 : gfxBase);
|
||||
EXPECT_EQ(gfxPartition.getHeapLimit(HeapIndex::HEAP_SVM), MemoryConstants::maxSvmAddress);
|
||||
} else {
|
||||
// Limited range
|
||||
EXPECT_FALSE(gfxPartition.heapInitialized(HeapIndex::HEAP_SVM));
|
||||
@ -81,15 +92,20 @@ void testGfxPartition(uint64_t gpuAddressSpace) {
|
||||
auto ptrSmall = gfxPartition.heapAllocate(heap, sizeSmall);
|
||||
EXPECT_NE(ptrSmall, 0ull);
|
||||
EXPECT_LT(gfxPartition.getHeapBase(heap), ptrSmall);
|
||||
EXPECT_EQ(ptrSmall, gfxPartition.getHeapBase(heap) + gfxPartition.getHeapSize(heap) - sizeSmall);
|
||||
EXPECT_GT(gfxPartition.getHeapLimit(heap), ptrSmall);
|
||||
EXPECT_EQ(ptrSmall, gfxPartition.getHeapBase(heap) + gfxPartition.getHeapSize(heap) - GfxPartition::heapGranularity - sizeSmall);
|
||||
gfxPartition.heapFree(heap, ptrSmall, sizeSmall);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GfxPartitionTest, testGfxPartitionFullRangeSVM) {
|
||||
testGfxPartition(MemoryConstants::max48BitAddress);
|
||||
TEST(GfxPartitionTest, testGfxPartitionFullRange48BitSVM) {
|
||||
testGfxPartition(maxNBitValue<48>);
|
||||
}
|
||||
|
||||
TEST(GfxPartitionTest, testGfxPartitionFullRange47BitSVM) {
|
||||
testGfxPartition(maxNBitValue<47>);
|
||||
}
|
||||
|
||||
TEST(GfxPartitionTest, testGfxPartitionLimitedRange) {
|
||||
testGfxPartition(maxNBitValue<48 - 1>);
|
||||
testGfxPartition(maxNBitValue<47 - 1>);
|
||||
}
|
||||
|
@ -63,6 +63,10 @@ TEST(MemoryManagerTest, givenSvmGpuAllocationTypeWhenAllocationSystemMemoryFails
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenSvmGpuAllocationTypeWhenAllocationSucceedThenReturnGpuAddressAsHostPtr) {
|
||||
if (platformDevices[0]->capabilityTable.gpuAddressSpace != maxNBitValue<48> && platformDevices[0]->capabilityTable.gpuAddressSpace != maxNBitValue<47>) {
|
||||
return;
|
||||
}
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
|
||||
@ -79,4 +83,4 @@ TEST(MemoryManagerTest, givenSvmGpuAllocationTypeWhenAllocationSucceedThenReturn
|
||||
EXPECT_NE(reinterpret_cast<uint64_t>(allocation->getUnderlyingBuffer()), allocation->getGpuAddress());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,9 @@ TEST_F(MemoryAllocatorTest, allocateGraphics) {
|
||||
EXPECT_EQ(Sharing::nonSharedResource, allocation->peekSharedHandle());
|
||||
|
||||
// Gpu address equal to cpu address
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(allocation->getUnderlyingBuffer()), allocation->getGpuAddress());
|
||||
if (platformDevices[0]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(allocation->getUnderlyingBuffer()), allocation->getGpuAddress());
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
@ -374,21 +376,6 @@ TEST_F(MemoryAllocatorTest, GivenPointerAndSizeWhenAskedToCreateGrahicsAllocatio
|
||||
EXPECT_NE(&allocation->fragmentsStorage, &handleStorage);
|
||||
}
|
||||
|
||||
TEST_F(MemoryAllocatorTest, givenMemoryManagerWhensetForce32BitAllocationsIsCalledWithTrueMultipleTimesThenAllocatorIsReused) {
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
EXPECT_NE(nullptr, memoryManager->allocator32Bit.get());
|
||||
auto currentAllocator = memoryManager->allocator32Bit.get();
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
EXPECT_EQ(memoryManager->allocator32Bit.get(), currentAllocator);
|
||||
}
|
||||
|
||||
TEST_F(MemoryAllocatorTest, givenMemoryManagerWhensetForce32BitAllocationsIsCalledWithFalseThenAllocatorIsNotDeleted) {
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
EXPECT_NE(nullptr, memoryManager->allocator32Bit.get());
|
||||
memoryManager->setForce32BitAllocations(false);
|
||||
EXPECT_NE(nullptr, memoryManager->allocator32Bit.get());
|
||||
}
|
||||
|
||||
TEST_F(MemoryAllocatorTest, givenMemoryManagerWhenAskedFor32bitAllocationThen32bitGraphicsAllocationIsReturned) {
|
||||
size_t size = 10;
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
@ -834,6 +821,23 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocat
|
||||
memoryManager.freeGraphicsMemory(sharedAllocation);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocationFromSharedObjectIsCalledWithSpecificBitnessThen32BitGraphicsAllocationIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
osHandle handle = 1;
|
||||
auto size = 4096u;
|
||||
AllocationProperties properties(false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto sharedAllocation = memoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, true);
|
||||
EXPECT_NE(nullptr, sharedAllocation);
|
||||
EXPECT_TRUE(sharedAllocation->is32BitAllocation());
|
||||
EXPECT_FALSE(sharedAllocation->isCoherent());
|
||||
EXPECT_NE(nullptr, sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(size, sharedAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, sharedAllocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(sharedAllocation);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
@ -1069,12 +1073,7 @@ TEST(OsAgnosticMemoryManager, givenPointerAndSizeWhenCreateInternalAllocationIsC
|
||||
EXPECT_EQ(allocationSize, graphicsAllocation->getUnderlyingBufferSize());
|
||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultOsAgnosticMemoryManagerWhenItIsQueriedForInternalHeapBaseThen32BitAllocatorBaseIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
auto heapBase = memoryManager.getExternalHeapBaseAddress();
|
||||
EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledThenAllocationIsCreated) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(executionEnvironment);
|
||||
@ -1156,54 +1155,6 @@ INSTANTIATE_TEST_CASE_P(OsAgnosticMemoryManagerWithParams,
|
||||
OsAgnosticMemoryManagerWithParams,
|
||||
::testing::Values(false, true));
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemoryNotSupportedWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, false, executionEnvironment);
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
if (is32bit) {
|
||||
heap32Base = 0;
|
||||
}
|
||||
EXPECT_EQ(heap32Base, memoryManager.getExternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndNotAubUsageWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, false, executionEnvironment);
|
||||
memoryManager.allocator32Bit.reset(memoryManager.create32BitAllocator(false));
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
if (is32bit) {
|
||||
heap32Base = 0;
|
||||
}
|
||||
EXPECT_EQ(heap32Base, memoryManager.getExternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemoryNotSupportedAndAubUsageWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, false, true, executionEnvironment);
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
if (is32bit) {
|
||||
heap32Base = 0;
|
||||
}
|
||||
EXPECT_EQ(heap32Base, memoryManager.getExternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndAubUsageWhenMemoryManagerIsCreatedThenAllocator32BitHasCorrectBaseAddress) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
MockMemoryManager memoryManager(false, true, true, executionEnvironment);
|
||||
memoryManager.allocator32Bit.reset(memoryManager.create32BitAllocator(true));
|
||||
uint64_t heap32Base = 0x80000000000ul;
|
||||
|
||||
if (is32bit) {
|
||||
heap32Base = 0;
|
||||
} else {
|
||||
heap32Base = 0x40000000000ul;
|
||||
}
|
||||
EXPECT_EQ(heap32Base, memoryManager.getExternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGraphicsAllocationIsDestroyedThenFreeMemoryOnAubManagerShouldBeCalled) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
|
@ -19,5 +19,13 @@ class MockGfxPartition : public GfxPartition {
|
||||
return getHeapSize(heapIndex) > 0;
|
||||
}
|
||||
|
||||
void *getReservedCpuAddressRange() {
|
||||
return reservedCpuAddressRange;
|
||||
}
|
||||
|
||||
size_t getReservedCpuAddressRangeSize() {
|
||||
return reservedCpuAddressRangeSize;
|
||||
}
|
||||
|
||||
static std::array<HeapIndex, static_cast<uint32_t>(HeapIndex::TOTAL_HEAPS)> allHeapNames;
|
||||
};
|
||||
|
@ -7,26 +7,27 @@
|
||||
|
||||
#pragma once
|
||||
#include "runtime/memory_manager/graphics_allocation.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
class MockGraphicsAllocation : public GraphicsAllocation {
|
||||
class MockGraphicsAllocation : public MemoryAllocation {
|
||||
public:
|
||||
using GraphicsAllocation::GraphicsAllocation;
|
||||
using GraphicsAllocation::objectNotResident;
|
||||
using GraphicsAllocation::objectNotUsed;
|
||||
using GraphicsAllocation::usageInfos;
|
||||
using MemoryAllocation::MemoryAllocation;
|
||||
using MemoryAllocation::objectNotResident;
|
||||
using MemoryAllocation::objectNotUsed;
|
||||
using MemoryAllocation::usageInfos;
|
||||
|
||||
MockGraphicsAllocation()
|
||||
: MockGraphicsAllocation(true) {}
|
||||
|
||||
MockGraphicsAllocation(bool multiOsContextCapable)
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, multiOsContextCapable) {}
|
||||
: MemoryAllocation(AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, multiOsContextCapable) {}
|
||||
|
||||
MockGraphicsAllocation(void *buffer, size_t sizeIn)
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, false) {}
|
||||
: MemoryAllocation(AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, false) {}
|
||||
|
||||
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn)
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, false) {}
|
||||
: MemoryAllocation(AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, false) {}
|
||||
|
||||
void resetInspectionIds() {
|
||||
for (auto &usageInfo : usageInfos) {
|
||||
|
@ -16,6 +16,7 @@ set(IGDRCL_SRCS_tests_os_interface_base
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_performance_counters.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_gen_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_tests.cpp
|
||||
)
|
||||
|
@ -7,8 +7,17 @@
|
||||
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
|
||||
#include "core/helpers/basic_math.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
size_t getSizeToMap() {
|
||||
return static_cast<size_t>(1 * 1024 * 1024u);
|
||||
}
|
||||
|
||||
size_t getSizeToReserve() {
|
||||
// 4 x sizeof(Heap32) + 2 x sizeof(Standard/Standard64k)
|
||||
return (4 * 4 + 2 * 4) * GB;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/helpers/basic_math.h"
|
||||
#include "runtime/os_interface/linux/allocator_helper.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@ -12,3 +13,7 @@
|
||||
TEST(AllocatorHelper, givenExpectedSizeToMapWhenGetSizetoMapCalledThenExpectedValueReturned) {
|
||||
EXPECT_EQ(1 * 1024 * 1024u, NEO::getSizeToMap());
|
||||
}
|
||||
|
||||
TEST(AllocatorHelper, givenExpectedSizeToReserveWhenGetSizeToReserveCalledThenExpectedValueReturned) {
|
||||
EXPECT_EQ((4 * 4 + 2 * 4) * GB, NEO::getSizeToReserve());
|
||||
}
|
||||
|
19
unit_tests/os_interface/os_memory_tests.cpp
Normal file
19
unit_tests/os_interface/os_memory_tests.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/os_memory.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(OSMemory, reserveCpuAddressRange) {
|
||||
size_t reservedCpuAddressRangeSize = 1024;
|
||||
auto reservedCpuAddressRange = OSMemory::reserveCpuAddressRange(reservedCpuAddressRangeSize);
|
||||
EXPECT_NE(reservedCpuAddressRange, nullptr);
|
||||
OSMemory::releaseCpuAddressRange(reservedCpuAddressRange, reservedCpuAddressRangeSize);
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
#include "elf/reader.h"
|
||||
#include "runtime/command_stream/command_stream_receiver_hw.h"
|
||||
#include "runtime/compiler_interface/compiler_options.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/hardware_commands_helper.h"
|
||||
#include "runtime/helpers/hash.h"
|
||||
@ -645,11 +646,7 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi
|
||||
auto kernelIsa = graphicsAllocation->getUnderlyingBuffer();
|
||||
EXPECT_NE(kernelInfo->heapInfo.pKernelHeap, kernelIsa);
|
||||
EXPECT_EQ(0, memcmp(kernelIsa, kernelInfo->heapInfo.pKernelHeap, kernelInfo->heapInfo.pKernelHeader->KernelHeapSize));
|
||||
if (sizeof(void *) == sizeof(uint32_t)) {
|
||||
EXPECT_EQ(0u, graphicsAllocation->getGpuBaseAddress());
|
||||
} else {
|
||||
EXPECT_NE(0u, graphicsAllocation->getGpuBaseAddress());
|
||||
}
|
||||
EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pProgram->getDevice(0).getMemoryManager()->getInternalHeapBaseAddress());
|
||||
}
|
||||
|
||||
TEST_P(ProgramFromBinaryTest, givenProgramWhenCleanKernelInfoIsCalledThenKernelAllocationIsFreed) {
|
||||
|
Reference in New Issue
Block a user