mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:11:16 +08:00
GraphicsAllocation constructor accepts allocationType and memoryPool.
Change-Id: I5044ed26ba0cb0fc9ca7077595f5ab56353ab58c
This commit is contained in:
@@ -657,7 +657,7 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(AllocationView &allocationView) {
|
||||
GraphicsAllocation gfxAllocation(reinterpret_cast<void *>(allocationView.first), allocationView.first, 0llu, allocationView.second, false);
|
||||
GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast<void *>(allocationView.first), allocationView.first, 0llu, allocationView.second, MemoryPool::MemoryNull, false);
|
||||
return writeMemory(gfxAllocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -350,8 +350,7 @@ AllocationsList &CommandStreamReceiver::getAllocationsForReuse() { return intern
|
||||
|
||||
bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surface, Device &device, bool requiresL3Flush) {
|
||||
auto memoryManager = getMemoryManager();
|
||||
GraphicsAllocation *allocation = nullptr;
|
||||
allocation = memoryManager->allocateGraphicsMemoryForHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), device.isFullRangeSvm(), requiresL3Flush);
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryForHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), device.isFullRangeSvm(), requiresL3Flush);
|
||||
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
|
||||
// Try with no host pointer allocation and copy
|
||||
AllocationProperties properties(true, surface.getSurfaceSize(), GraphicsAllocation::AllocationType::UNDECIDED);
|
||||
|
||||
@@ -23,19 +23,24 @@ bool GraphicsAllocation::isL3Capable() {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress,
|
||||
size_t sizeIn, bool multiOsContextCapable)
|
||||
GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress,
|
||||
size_t sizeIn, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: gpuBaseAddress(baseAddress),
|
||||
size(sizeIn),
|
||||
cpuPtr(cpuPtrIn),
|
||||
gpuAddress(gpuAddress),
|
||||
memoryPool(pool),
|
||||
allocationType(allocationType),
|
||||
multiOsContextCapable(multiOsContextCapable) {}
|
||||
|
||||
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, bool multiOsContextCapable)
|
||||
GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn,
|
||||
MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: size(sizeIn),
|
||||
cpuPtr(cpuPtrIn),
|
||||
gpuAddress(castToUint64(cpuPtrIn)),
|
||||
sharedHandle(sharedHandleIn),
|
||||
memoryPool(pool),
|
||||
allocationType(allocationType),
|
||||
multiOsContextCapable(multiOsContextCapable) {}
|
||||
|
||||
GraphicsAllocation::~GraphicsAllocation() = default;
|
||||
|
||||
@@ -90,9 +90,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
GraphicsAllocation &operator=(const GraphicsAllocation &) = delete;
|
||||
GraphicsAllocation(const GraphicsAllocation &) = delete;
|
||||
|
||||
GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, bool multiOsContextCapable);
|
||||
GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, bool multiOsContextCapable);
|
||||
|
||||
GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, bool multiOsContextCapable);
|
||||
GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, bool multiOsContextCapable);
|
||||
|
||||
void *getUnderlyingBuffer() const { return cpuPtr; }
|
||||
void setCpuPtrAndGpuAddress(void *cpuPtr, uint64_t gpuAddress) {
|
||||
@@ -137,15 +137,13 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
void incReuseCount() { reuseCount++; }
|
||||
void decReuseCount() { reuseCount--; }
|
||||
uint32_t peekReuseCount() const { return reuseCount; }
|
||||
MemoryPool::Type getMemoryPool() const {
|
||||
return memoryPool;
|
||||
}
|
||||
MemoryPool::Type getMemoryPool() const { return memoryPool; }
|
||||
bool isUsed() const { return registeredContextsNum > 0; }
|
||||
bool isUsedByOsContext(uint32_t contextId) const { return objectNotUsed != getTaskCount(contextId); }
|
||||
void updateTaskCount(uint32_t newTaskCount, uint32_t contextId);
|
||||
uint32_t getTaskCount(uint32_t contextId) const { return usageInfos[contextId].taskCount; }
|
||||
void releaseUsageInOsContext(uint32_t contextId) { updateTaskCount(objectNotUsed, contextId); }
|
||||
uint32_t getInspectionId(uint32_t contextId) { return usageInfos[contextId].inspectionId; }
|
||||
uint32_t getInspectionId(uint32_t contextId) const { return usageInfos[contextId].inspectionId; }
|
||||
void setInspectionId(uint32_t newInspectionId, uint32_t contextId) { usageInfos[contextId].inspectionId = newInspectionId; }
|
||||
|
||||
bool isResident(uint32_t contextId) const { return GraphicsAllocation::objectNotResident != getResidencyTaskCount(contextId); }
|
||||
|
||||
@@ -73,7 +73,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(Allocati
|
||||
allocationData.alignment = MemoryConstants::pageSize64k;
|
||||
auto memoryAllocation = allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
if (memoryAllocation) {
|
||||
reinterpret_cast<MemoryAllocation *>(memoryAllocation)->overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
static_cast<MemoryAllocation *>(memoryAllocation)->overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
}
|
||||
return memoryAllocation;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ class MemoryAllocation : public GraphicsAllocation {
|
||||
void setSharedHandle(osHandle handle) { this->sharedHandle = handle; }
|
||||
|
||||
MemoryAllocation(void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(pMem, gpuAddress, 0u, memSize, multiOsContextCapable), id(count) {
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, pMem, gpuAddress, 0u, memSize, pool, multiOsContextCapable),
|
||||
id(count) {
|
||||
|
||||
this->driverAllocatedCpuPointer = driverAllocatedCpuPointer;
|
||||
overrideMemoryPool(pool);
|
||||
|
||||
@@ -17,11 +17,14 @@ struct OsHandle {
|
||||
|
||||
class DrmAllocation : public GraphicsAllocation {
|
||||
public:
|
||||
DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, bool multiOsContextCapable) : GraphicsAllocation(ptrIn, sizeIn, sharedHandle, multiOsContextCapable), bo(bo) {
|
||||
this->memoryPool = pool;
|
||||
DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, ptrIn, sizeIn, sharedHandle, pool, multiOsContextCapable),
|
||||
bo(bo) {
|
||||
}
|
||||
DrmAllocation(BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool, bool multiOsContextCapable) : GraphicsAllocation(ptrIn, gpuAddress, 0, sizeIn, multiOsContextCapable), bo(bo) {
|
||||
this->memoryPool = pool;
|
||||
|
||||
DrmAllocation(BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, ptrIn, gpuAddress, 0, sizeIn, pool, multiOsContextCapable),
|
||||
bo(bo) {
|
||||
}
|
||||
|
||||
std::string getAllocationInfoString() const override;
|
||||
|
||||
@@ -31,22 +31,21 @@ class WddmAllocation : public GraphicsAllocation {
|
||||
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
|
||||
|
||||
D3DGPU_VIRTUAL_ADDRESS gpuPtr; // set by mapGpuVA
|
||||
|
||||
WddmAllocation(void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, multiOsContextCapable),
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool, multiOsContextCapable),
|
||||
handle(0),
|
||||
gpuPtr(0),
|
||||
trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) {
|
||||
reservedAddressSpace = reservedAddr;
|
||||
this->memoryPool = pool;
|
||||
}
|
||||
|
||||
WddmAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, bool multiOsContextCapable)
|
||||
: GraphicsAllocation(cpuPtrIn, sizeIn, sharedHandle, multiOsContextCapable),
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, cpuPtrIn, sizeIn, sharedHandle, pool, multiOsContextCapable),
|
||||
handle(0),
|
||||
gpuPtr(0),
|
||||
trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) {
|
||||
reservedAddressSpace = nullptr;
|
||||
this->memoryPool = pool;
|
||||
}
|
||||
|
||||
void *getAlignedCpuPtr() const {
|
||||
|
||||
@@ -114,7 +114,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(srcMemory, 0xFFFF800400001000, 0xFFFF800400001000, sizeof(srcMemory), false);
|
||||
GraphicsAllocation *srcAlocation = new GraphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN,
|
||||
srcMemory,
|
||||
0xFFFF800400001000,
|
||||
0xFFFF800400001000,
|
||||
sizeof(srcMemory),
|
||||
MemoryPool::MemoryNull,
|
||||
false);
|
||||
|
||||
std::unique_ptr<Buffer> srcBuffer(Buffer::createBufferHw(&context,
|
||||
CL_MEM_USE_HOST_PTR,
|
||||
|
||||
@@ -336,7 +336,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye
|
||||
|
||||
bool destructorCalled = false;
|
||||
|
||||
auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(nullptr, 0llu, 0llu, 1u, false);
|
||||
auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0llu, 0llu, 1u, MemoryPool::MemoryNull, false);
|
||||
mockGraphicsAllocation->destructorCalled = &destructorCalled;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.commandStreamReceivers.resize(1);
|
||||
|
||||
@@ -347,7 +347,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU
|
||||
uint64_t gpuAddr = 0x4000u;
|
||||
size_t allocSize = size;
|
||||
length.Length = static_cast<uint32_t>(allocSize - 1);
|
||||
GraphicsAllocation allocation(cpuAddr, gpuAddr, 0u, allocSize, false);
|
||||
GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false);
|
||||
allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false);
|
||||
ASSERT_NE(nullptr, allocation.gmm);
|
||||
SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER;
|
||||
@@ -385,7 +385,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres
|
||||
void *cpuAddr = reinterpret_cast<void *>(0x4000);
|
||||
uint64_t gpuAddr = 0x4000u;
|
||||
size_t allocSize = size;
|
||||
GraphicsAllocation allocation(cpuAddr, gpuAddr, 0u, allocSize, false);
|
||||
GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false);
|
||||
allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false);
|
||||
ASSERT_NE(nullptr, allocation.gmm);
|
||||
allocation.gmm->isRenderCompressed = true;
|
||||
@@ -419,7 +419,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionEnabledAn
|
||||
void *cpuAddr = reinterpret_cast<void *>(0x4000);
|
||||
uint64_t gpuAddr = 0x4000u;
|
||||
size_t allocSize = size;
|
||||
GraphicsAllocation allocation(cpuAddr, gpuAddr, 0u, allocSize, false);
|
||||
GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false);
|
||||
allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false);
|
||||
ASSERT_NE(nullptr, allocation.gmm);
|
||||
allocation.gmm->isRenderCompressed = true;
|
||||
@@ -452,7 +452,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA
|
||||
void *cpuAddr = reinterpret_cast<void *>(0x4000);
|
||||
uint64_t gpuAddr = 0x4000u;
|
||||
size_t allocSize = size;
|
||||
GraphicsAllocation allocation(cpuAddr, gpuAddr, 0u, allocSize, false);
|
||||
GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false);
|
||||
allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false);
|
||||
ASSERT_NE(nullptr, allocation.gmm);
|
||||
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
@@ -485,7 +485,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres
|
||||
void *cpuAddr = reinterpret_cast<void *>(0x4000);
|
||||
uint64_t gpuAddr = 0x4000u;
|
||||
size_t allocSize = size;
|
||||
GraphicsAllocation allocation(cpuAddr, gpuAddr, 0u, allocSize, false);
|
||||
GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, false);
|
||||
allocation.gmm = new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false);
|
||||
ASSERT_NE(nullptr, allocation.gmm);
|
||||
allocation.gmm->isRenderCompressed = true;
|
||||
|
||||
@@ -676,12 +676,12 @@ HWCMDTEST_F(IGFX_GEN8_CORE, KernelCommandsTest, usedBindingTableStatePointersFor
|
||||
|
||||
// setup global memory
|
||||
char globalBuffer[16];
|
||||
GraphicsAllocation gfxGlobalAlloc(globalBuffer, castToUint64(globalBuffer), 0llu, sizeof(globalBuffer), false);
|
||||
GraphicsAllocation gfxGlobalAlloc(GraphicsAllocation::AllocationType::UNKNOWN, globalBuffer, castToUint64(globalBuffer), 0llu, sizeof(globalBuffer), MemoryPool::MemoryNull, false);
|
||||
program.setGlobalSurface(&gfxGlobalAlloc);
|
||||
|
||||
// setup constant memory
|
||||
char constBuffer[16];
|
||||
GraphicsAllocation gfxConstAlloc(constBuffer, castToUint64(constBuffer), 0llu, sizeof(constBuffer), false);
|
||||
GraphicsAllocation gfxConstAlloc(GraphicsAllocation::AllocationType::UNKNOWN, constBuffer, castToUint64(constBuffer), 0llu, sizeof(constBuffer), MemoryPool::MemoryNull, false);
|
||||
program.setConstantSurface(&gfxConstAlloc);
|
||||
|
||||
// create kernel
|
||||
|
||||
@@ -902,7 +902,7 @@ TEST_F(KernelGlobalSurfaceTest, givenBuiltInKernelWhenKernelIsCreatedThenGlobalS
|
||||
|
||||
char buffer[16];
|
||||
|
||||
GraphicsAllocation gfxAlloc((void *)buffer, (uint64_t)buffer - 8u, 8, 1u, false);
|
||||
GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, 1u, MemoryPool::MemoryNull, false);
|
||||
uint64_t bufferAddress = (uint64_t)gfxAlloc.getUnderlyingBuffer();
|
||||
|
||||
// create kernel
|
||||
@@ -945,7 +945,7 @@ TEST_F(KernelGlobalSurfaceTest, givenNDRangeKernelWhenKernelIsCreatedThenGlobalS
|
||||
|
||||
char buffer[16];
|
||||
|
||||
GraphicsAllocation gfxAlloc((void *)buffer, (uint64_t)buffer - 8u, 8, false);
|
||||
GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, false);
|
||||
uint64_t bufferAddress = gfxAlloc.getGpuAddress();
|
||||
|
||||
// create kernel
|
||||
@@ -1077,7 +1077,7 @@ TEST_F(KernelConstantSurfaceTest, givenBuiltInKernelWhenKernelIsCreatedThenConst
|
||||
|
||||
char buffer[16];
|
||||
|
||||
GraphicsAllocation gfxAlloc((void *)buffer, (uint64_t)buffer - 8u, 8, 1u, false);
|
||||
GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, 1u, MemoryPool::MemoryNull, false);
|
||||
uint64_t bufferAddress = (uint64_t)gfxAlloc.getUnderlyingBuffer();
|
||||
|
||||
// create kernel
|
||||
@@ -1119,7 +1119,7 @@ TEST_F(KernelConstantSurfaceTest, givenNDRangeKernelWhenKernelIsCreatedThenConst
|
||||
|
||||
char buffer[16];
|
||||
|
||||
GraphicsAllocation gfxAlloc((void *)buffer, (uint64_t)buffer - 8u, 8, false);
|
||||
GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, false);
|
||||
uint64_t bufferAddress = gfxAlloc.getGpuAddress();
|
||||
|
||||
// create kernel
|
||||
|
||||
@@ -70,7 +70,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
|
||||
UltCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) : BaseClass(hwInfoIn, executionEnvironment), recursiveLockCounter(0) {
|
||||
if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
|
||||
tempPreemptionLocation = std::make_unique<GraphicsAllocation>(nullptr, 0, 0, 0, false);
|
||||
tempPreemptionLocation = std::make_unique<GraphicsAllocation>(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false);
|
||||
this->preemptionCsrAllocation = tempPreemptionLocation.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
using namespace OCLRT;
|
||||
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenAllInspectionIdsAreSetToZero) {
|
||||
MockGraphicsAllocation graphicsAllocation(nullptr, 0u, 0u, maxOsContextCount, true);
|
||||
MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, maxOsContextCount, MemoryPool::MemoryNull, true);
|
||||
for (auto i = 0u; i < maxOsContextCount; i++) {
|
||||
EXPECT_EQ(0u, graphicsAllocation.getInspectionId(i));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenTaskCountsAreInitializedProperly) {
|
||||
GraphicsAllocation graphicsAllocation1(nullptr, 0u, 0u, 0u, true);
|
||||
GraphicsAllocation graphicsAllocation2(nullptr, 0u, 0u, true);
|
||||
GraphicsAllocation graphicsAllocation1(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0u, MemoryPool::MemoryNull, true);
|
||||
GraphicsAllocation graphicsAllocation2(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, MemoryPool::MemoryNull, true);
|
||||
for (auto i = 0u; i < maxOsContextCount; i++) {
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation1.getTaskCount(i));
|
||||
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation2.getTaskCount(i));
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST(GraphicsAllocationTest, Ctor2) {
|
||||
void *cpuPtr = (void *)0x30000;
|
||||
size_t size = 0x1000;
|
||||
osHandle sharedHandle = Sharing::nonSharedResource;
|
||||
GraphicsAllocation gfxAllocation(cpuPtr, size, sharedHandle, false);
|
||||
GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, size, sharedHandle, MemoryPool::MemoryNull, false);
|
||||
uint64_t expectedGpuAddr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(gfxAllocation.getUnderlyingBuffer()));
|
||||
|
||||
EXPECT_EQ(expectedGpuAddr, gfxAllocation.getGpuAddress());
|
||||
@@ -87,7 +87,7 @@ TEST(GraphicsAllocationTest, getGpuAddress) {
|
||||
uint64_t gpuBaseAddr = 0x10000;
|
||||
size_t size = 0x1000;
|
||||
|
||||
GraphicsAllocation gfxAllocation(cpuPtr, gpuAddr, gpuBaseAddr, size, false);
|
||||
GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull, false);
|
||||
|
||||
EXPECT_EQ(gpuAddr, gfxAllocation.getGpuAddress());
|
||||
|
||||
@@ -104,7 +104,7 @@ TEST(GraphicsAllocationTest, getGpuAddressToPatch) {
|
||||
uint64_t gpuBaseAddr = 0x10000;
|
||||
size_t size = 0x1000;
|
||||
|
||||
GraphicsAllocation gfxAllocation(cpuPtr, gpuAddr, gpuBaseAddr, size, false);
|
||||
GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull, false);
|
||||
|
||||
EXPECT_EQ(gpuAddr - gpuBaseAddr, gfxAllocation.getGpuAddressToPatch());
|
||||
}
|
||||
@@ -115,7 +115,7 @@ TEST(GraphicsAllocationTest, setSize) {
|
||||
uint64_t gpuBaseAddr = 0x10000;
|
||||
size_t size = 0x2000;
|
||||
|
||||
GraphicsAllocation gfxAllocation(cpuPtr, gpuAddr, gpuBaseAddr, size, false);
|
||||
GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull, false);
|
||||
EXPECT_EQ(size, gfxAllocation.getUnderlyingBufferSize());
|
||||
|
||||
size = 0x3000;
|
||||
@@ -1516,7 +1516,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation
|
||||
void *addressWithTrailingBitSet = reinterpret_cast<void *>(address);
|
||||
uint64_t expectedGpuAddress = 0xf0000000;
|
||||
osHandle sharedHandle{};
|
||||
GraphicsAllocation graphicsAllocation(addressWithTrailingBitSet, 1u, sharedHandle, false);
|
||||
GraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, addressWithTrailingBitSet, 1u, sharedHandle, MemoryPool::MemoryNull, false);
|
||||
EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress());
|
||||
}
|
||||
|
||||
@@ -1620,27 +1620,27 @@ TEST(OsContextTest, givenOsContextWithNumberOfSupportedDevicesWhenConstructingTh
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
allocation.is32BitAllocation = true;
|
||||
allocation.setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA);
|
||||
EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0]));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
allocation.is32BitAllocation = false;
|
||||
allocation.setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA);
|
||||
EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0]));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
allocation.is32BitAllocation = true;
|
||||
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0]));
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenLimitedHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
if (platformDevices[0]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
|
||||
return;
|
||||
}
|
||||
@@ -1648,7 +1648,7 @@ TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAlloc
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
if (platformDevices[0]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
|
||||
return;
|
||||
}
|
||||
@@ -1656,7 +1656,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
auto gmm = std::make_unique<Gmm>(nullptr, 0, false);
|
||||
auto resourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
|
||||
resourceInfo->is64KBPageSuitableValue = true;
|
||||
@@ -1668,7 +1668,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati
|
||||
}
|
||||
|
||||
TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) {
|
||||
GraphicsAllocation allocation{nullptr, 0, 0, 0, false};
|
||||
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
|
||||
auto gmm = std::make_unique<Gmm>(nullptr, 0, false);
|
||||
auto resourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
|
||||
resourceInfo->is64KBPageSuitableValue = false;
|
||||
|
||||
@@ -16,10 +16,17 @@ class MockGraphicsAllocation : public GraphicsAllocation {
|
||||
using GraphicsAllocation::objectNotUsed;
|
||||
using GraphicsAllocation::usageInfos;
|
||||
|
||||
MockGraphicsAllocation() : MockGraphicsAllocation(true) {}
|
||||
MockGraphicsAllocation(bool multiOsContextCapable) : GraphicsAllocation(nullptr, 0u, 0, multiOsContextCapable) {}
|
||||
MockGraphicsAllocation(void *buffer, size_t sizeIn) : GraphicsAllocation(buffer, castToUint64(buffer), 0llu, sizeIn, false) {}
|
||||
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn) : GraphicsAllocation(buffer, gpuAddr, 0llu, sizeIn, false) {}
|
||||
MockGraphicsAllocation()
|
||||
: MockGraphicsAllocation(true) {}
|
||||
|
||||
MockGraphicsAllocation(bool multiOsContextCapable)
|
||||
: GraphicsAllocation(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) {}
|
||||
|
||||
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn)
|
||||
: GraphicsAllocation(AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, false) {}
|
||||
|
||||
void resetInspectionIds() {
|
||||
for (auto &usageInfo : usageInfos) {
|
||||
|
||||
@@ -865,35 +865,35 @@ TEST(DebugSettingsManager, givenReaderImplInDebugManagerWhenSettingDifferentRead
|
||||
}
|
||||
|
||||
struct AllocationTypeTestCase {
|
||||
OCLRT::GraphicsAllocation::AllocationType type;
|
||||
GraphicsAllocation::AllocationType type;
|
||||
const char *str;
|
||||
};
|
||||
|
||||
AllocationTypeTestCase allocationTypeValues[] = {
|
||||
{OCLRT::GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, "BUFFER_COMPRESSED"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, "BUFFER_HOST_MEMORY"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::BUFFER, "BUFFER"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::IMAGE, "IMAGE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::TAG_BUFFER, "TAG_BUFFER"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::LINEAR_STREAM, "LINEAR_STREAM"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::FILL_PATTERN, "FILL_PATTERN"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::PIPE, "PIPE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER, "TIMESTAMP_PACKET_TAG_BUFFER"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER, "PROFILING_TAG_BUFFER"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::COMMAND_BUFFER, "COMMAND_BUFFER"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::PRINTF_SURFACE, "PRINTF_SURFACE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::GLOBAL_SURFACE, "GLOBAL_SURFACE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::PRIVATE_SURFACE, "PRIVATE_SURFACE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::CONSTANT_SURFACE, "CONSTANT_SURFACE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::SCRATCH_SURFACE, "SCRATCH_SURFACE"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::INSTRUCTION_HEAP, "INSTRUCTION_HEAP"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::INDIRECT_OBJECT_HEAP, "INDIRECT_OBJECT_HEAP"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP, "SURFACE_STATE_HEAP"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP, "DYNAMIC_STATE_HEAP"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY, "SHARED_RESOURCE_COPY"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::SVM, "SVM"},
|
||||
{OCLRT::GraphicsAllocation::AllocationType::UNDECIDED, "UNDECIDED"}};
|
||||
{GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"},
|
||||
{GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, "BUFFER_COMPRESSED"},
|
||||
{GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, "BUFFER_HOST_MEMORY"},
|
||||
{GraphicsAllocation::AllocationType::BUFFER, "BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::IMAGE, "IMAGE"},
|
||||
{GraphicsAllocation::AllocationType::TAG_BUFFER, "TAG_BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::LINEAR_STREAM, "LINEAR_STREAM"},
|
||||
{GraphicsAllocation::AllocationType::FILL_PATTERN, "FILL_PATTERN"},
|
||||
{GraphicsAllocation::AllocationType::PIPE, "PIPE"},
|
||||
{GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER, "TIMESTAMP_PACKET_TAG_BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER, "PROFILING_TAG_BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::COMMAND_BUFFER, "COMMAND_BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::PRINTF_SURFACE, "PRINTF_SURFACE"},
|
||||
{GraphicsAllocation::AllocationType::GLOBAL_SURFACE, "GLOBAL_SURFACE"},
|
||||
{GraphicsAllocation::AllocationType::PRIVATE_SURFACE, "PRIVATE_SURFACE"},
|
||||
{GraphicsAllocation::AllocationType::CONSTANT_SURFACE, "CONSTANT_SURFACE"},
|
||||
{GraphicsAllocation::AllocationType::SCRATCH_SURFACE, "SCRATCH_SURFACE"},
|
||||
{GraphicsAllocation::AllocationType::INSTRUCTION_HEAP, "INSTRUCTION_HEAP"},
|
||||
{GraphicsAllocation::AllocationType::INDIRECT_OBJECT_HEAP, "INDIRECT_OBJECT_HEAP"},
|
||||
{GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP, "SURFACE_STATE_HEAP"},
|
||||
{GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP, "DYNAMIC_STATE_HEAP"},
|
||||
{GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY, "SHARED_RESOURCE_COPY"},
|
||||
{GraphicsAllocation::AllocationType::SVM, "SVM"},
|
||||
{GraphicsAllocation::AllocationType::UNDECIDED, "UNDECIDED"}};
|
||||
|
||||
class AllocationTypeLogging : public ::testing::TestWithParam<AllocationTypeTestCase> {};
|
||||
|
||||
@@ -901,8 +901,7 @@ TEST_P(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringT
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
auto input = GetParam();
|
||||
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0, true);
|
||||
graphicsAllocation.setAllocationType(input.type);
|
||||
GraphicsAllocation graphicsAllocation(input.type, nullptr, 0u, 0, MemoryPool::MemoryNull, true);
|
||||
|
||||
auto result = debugManager.getAllocationTypeString(&graphicsAllocation);
|
||||
|
||||
@@ -916,8 +915,7 @@ INSTANTIATE_TEST_CASE_P(AllAllocationTypes,
|
||||
TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStringIllegalValueThenILLEGAL_VALUEIsReturned) {
|
||||
FullyEnabledTestDebugManager debugManager;
|
||||
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0, true);
|
||||
graphicsAllocation.setAllocationType(static_cast<OCLRT::GraphicsAllocation::AllocationType>(999));
|
||||
GraphicsAllocation graphicsAllocation(static_cast<GraphicsAllocation::AllocationType>(999), nullptr, 0u, 0, MemoryPool::MemoryNull, true);
|
||||
|
||||
auto result = debugManager.getAllocationTypeString(&graphicsAllocation);
|
||||
|
||||
@@ -927,8 +925,7 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStr
|
||||
TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenDebugManagerDisabledThennullptrReturned) {
|
||||
FullyDisabledTestDebugManager debugManager;
|
||||
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0, true);
|
||||
graphicsAllocation.setAllocationType(OCLRT::GraphicsAllocation::AllocationType::BUFFER);
|
||||
GraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::BUFFER, nullptr, 0u, 0, MemoryPool::MemoryNull, true);
|
||||
|
||||
auto result = debugManager.getAllocationTypeString(&graphicsAllocation);
|
||||
|
||||
@@ -936,6 +933,6 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenDebugManagerDis
|
||||
}
|
||||
|
||||
TEST(AllocationInfoLogging, givenBaseGraphicsAllocationWhenGettingImplementationSpecificAllocationInfoThenReturnEmptyInfoString) {
|
||||
GraphicsAllocation graphicsAllocation(nullptr, 0u, 0, true);
|
||||
GraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, true);
|
||||
EXPECT_STREQ(graphicsAllocation.getAllocationInfoString().c_str(), "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user