diff --git a/runtime/command_queue/enqueue_common.h b/runtime/command_queue/enqueue_common.h index 4d02b9f1f4..9ae8e1149e 100644 --- a/runtime/command_queue/enqueue_common.h +++ b/runtime/command_queue/enqueue_common.h @@ -604,7 +604,7 @@ CompletionStamp CommandQueueHw::enqueueNonBlocked( auto allocNeedsFlushDC = false; if (!device->isFullRangeSvm()) { - if (std::any_of(getCommandStreamReceiver().getResidencyAllocations().begin(), getCommandStreamReceiver().getResidencyAllocations().end(), [](const auto allocation) { return allocation->flushL3Required; })) { + if (std::any_of(getCommandStreamReceiver().getResidencyAllocations().begin(), getCommandStreamReceiver().getResidencyAllocations().end(), [](const auto allocation) { return allocation->isFlushL3Required(); })) { allocNeedsFlushDC = true; } } diff --git a/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl b/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl index ef45ff3528..0da4739ed2 100644 --- a/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl +++ b/runtime/command_stream/command_stream_receiver_simulated_common_hw.inl @@ -107,7 +107,7 @@ void CommandStreamReceiverSimulatedCommonHw::setupContext(OsContext & template bool CommandStreamReceiverSimulatedCommonHw::getParametersForWriteMemory(GraphicsAllocation &graphicsAllocation, uint64_t &gpuAddress, void *&cpuAddress, size_t &size) const { - cpuAddress = ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.allocationOffset)); + cpuAddress = ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.getAllocationOffset())); gpuAddress = GmmHelper::decanonize(graphicsAllocation.getGpuAddress()); size = graphicsAllocation.getUnderlyingBufferSize(); if (graphicsAllocation.gmm && graphicsAllocation.gmm->isRenderCompressed) { diff --git a/runtime/helpers/cache_policy.cpp b/runtime/helpers/cache_policy.cpp index 22fed7dd0d..ba34d18a7f 100644 --- a/runtime/helpers/cache_policy.cpp +++ b/runtime/helpers/cache_policy.cpp @@ -18,7 +18,7 @@ bool isL3Capable(void *ptr, size_t size) { } bool isL3Capable(const OCLRT::GraphicsAllocation &graphicsAllocation) { - auto ptr = ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.allocationOffset)); + auto ptr = ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.getAllocationOffset())); return isL3Capable(ptr, graphicsAllocation.getUnderlyingBufferSize()); } diff --git a/runtime/indirect_heap/indirect_heap.h b/runtime/indirect_heap/indirect_heap.h index f59a27dc08..0426ef29ac 100644 --- a/runtime/indirect_heap/indirect_heap.h +++ b/runtime/indirect_heap/indirect_heap.h @@ -70,7 +70,7 @@ inline uint64_t IndirectHeap::getHeapGpuStartOffset() const { inline uint64_t IndirectHeap::getHeapGpuBase() const { if (this->canBeUtilizedAs4GbHeap) { - return this->graphicsAllocation->gpuBaseAddress; + return this->graphicsAllocation->getGpuBaseAddress(); } else { return this->graphicsAllocation->getGpuAddress(); } diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index 23f5e0a4e7..d4ed0c6150 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -2196,7 +2196,7 @@ void Kernel::getAllocationsForCacheFlush(CacheFlushAllocationsVec &out) const { } bool Kernel::allocationForCacheFlush(GraphicsAllocation *argAllocation) const { - return argAllocation->flushL3Required || argAllocation->isMemObjectsAllocationWithWritableFlags(); + return argAllocation->isFlushL3Required() || argAllocation->isMemObjectsAllocationWithWritableFlags(); } void Kernel::addAllocationToCacheFlushVector(uint32_t argIndex, GraphicsAllocation *argAllocation) { diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index ad82d4ead1..20fcac0658 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -382,7 +382,7 @@ Buffer *Buffer::createSubBuffer(cl_mem_flags flags, uint64_t Buffer::setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing) { // Subbuffers have offset that graphicsAllocation is not aware of uintptr_t addressToPatch = ((set32BitAddressing) ? static_cast(graphicsAllocation->getGpuAddressToPatch()) : static_cast(graphicsAllocation->getGpuAddress())) + this->offset; - DEBUG_BREAK_IF(!(graphicsAllocation->isLocked() || (addressToPatch != 0) || (graphicsAllocation->gpuBaseAddress != 0) || + DEBUG_BREAK_IF(!(graphicsAllocation->isLocked() || (addressToPatch != 0) || (graphicsAllocation->getGpuBaseAddress() != 0) || (this->getCpuAddress() == nullptr && this->getGraphicsAllocation()->peekSharedHandle()))); patchWithRequiredSize(memory, patchSize, addressToPatch); diff --git a/runtime/memory_manager/graphics_allocation.cpp b/runtime/memory_manager/graphics_allocation.cpp index fb80678f82..cc9e03dcd9 100644 --- a/runtime/memory_manager/graphics_allocation.cpp +++ b/runtime/memory_manager/graphics_allocation.cpp @@ -19,23 +19,25 @@ void GraphicsAllocation::setAllocationType(AllocationType allocationType) { GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, bool multiOsContextCapable) - : gpuBaseAddress(baseAddress), - size(sizeIn), + : size(sizeIn), cpuPtr(cpuPtrIn), + gpuBaseAddress(baseAddress), gpuAddress(gpuAddress), memoryPool(pool), - allocationType(allocationType), - multiOsContextCapable(multiOsContextCapable) {} + allocationType(allocationType) { + allocationInfo.flags.multiOsContextCapable = 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) {} + allocationType(allocationType) { + sharingInfo.sharedHandle = sharedHandleIn; + allocationInfo.flags.multiOsContextCapable = multiOsContextCapable; +} GraphicsAllocation::~GraphicsAllocation() = default; diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 735293916c..100c981b69 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -49,42 +49,33 @@ struct AllocationProperties; class GraphicsAllocation : public IDNode { public: - OsHandleStorage fragmentsStorage; - bool is32BitAllocation = false; - uint64_t gpuBaseAddress = 0; - Gmm *gmm = nullptr; - uint64_t allocationOffset = 0u; - void *driverAllocatedCpuPointer = nullptr; - DevicesBitfield devicesBitfield = {}; - bool flushL3Required = false; - enum class AllocationType { UNKNOWN = 0, + BUFFER, BUFFER_COMPRESSED, BUFFER_HOST_MEMORY, - BUFFER, - IMAGE, - TAG_BUFFER, - LINEAR_STREAM, - FILL_PATTERN, - PIPE, - PROFILING_TAG_BUFFER, - TIMESTAMP_PACKET_TAG_BUFFER, COMMAND_BUFFER, - PRINTF_SURFACE, - GLOBAL_SURFACE, - PRIVATE_SURFACE, CONSTANT_SURFACE, - SCRATCH_SURFACE, - INSTRUCTION_HEAP, - INDIRECT_OBJECT_HEAP, - SURFACE_STATE_HEAP, DYNAMIC_STATE_HEAP, - SHARED_RESOURCE_COPY, - SVM, - KERNEL_ISA, - INTERNAL_HEAP, EXTERNAL_HOST_PTR, + FILL_PATTERN, + GLOBAL_SURFACE, + IMAGE, + INDIRECT_OBJECT_HEAP, + INSTRUCTION_HEAP, + INTERNAL_HEAP, + KERNEL_ISA, + LINEAR_STREAM, + PIPE, + PRINTF_SURFACE, + PRIVATE_SURFACE, + PROFILING_TAG_BUFFER, + SCRATCH_SURFACE, + SHARED_RESOURCE_COPY, + SURFACE_STATE_HEAP, + SVM, + TAG_BUFFER, + TIMESTAMP_PACKET_TAG_BUFFER, UNDECIDED, }; @@ -97,49 +88,72 @@ class GraphicsAllocation : public IDNode { GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, bool multiOsContextCapable); void *getUnderlyingBuffer() const { return cpuPtr; } + void *getDriverAllocatedCpuPtr() const { return driverAllocatedCpuPointer; } + void setDriverAllocatedCpuPtr(void *allocatedCpuPtr) { driverAllocatedCpuPointer = allocatedCpuPtr; } + void setCpuPtrAndGpuAddress(void *cpuPtr, uint64_t gpuAddress) { this->cpuPtr = cpuPtr; this->gpuAddress = gpuAddress; } size_t getUnderlyingBufferSize() const { return size; } - uint64_t getGpuAddress() { + void setSize(size_t size) { this->size = size; } + + uint64_t getAllocationOffset() const { + return allocationOffset; + } + void setAllocationOffset(uint64_t offset) { + allocationOffset = offset; + } + + uint64_t getGpuBaseAddress() const { + return gpuBaseAddress; + } + void setGpuBaseAddress(uint64_t baseAddress) { + gpuBaseAddress = baseAddress; + } + uint64_t getGpuAddress() const { DEBUG_BREAK_IF(gpuAddress < gpuBaseAddress); return gpuAddress + allocationOffset; } - uint64_t getGpuAddressToPatch() const { DEBUG_BREAK_IF(gpuAddress < gpuBaseAddress); return gpuAddress + allocationOffset - gpuBaseAddress; } - bool isCoherent() const { return coherent; } - void setCoherent(bool coherentIn) { this->coherent = coherentIn; } - void setSize(size_t size) { this->size = size; } - osHandle peekSharedHandle() { return sharedHandle; } - - void setAllocationType(AllocationType allocationType); - AllocationType getAllocationType() const { return allocationType; } - - void setAubWritable(bool writable) { aubWritable = writable; } - bool isAubWritable() const { return aubWritable; } - void setAllocDumpable(bool dumpable) { allocDumpable = dumpable; } - bool isAllocDumpable() const { return allocDumpable; } - bool isMemObjectsAllocationWithWritableFlags() const { return memObjectsAllocationWithWritableFlags; } - void setMemObjectsAllocationWithWritableFlags(bool newValue) { memObjectsAllocationWithWritableFlags = newValue; } - - void setEvictable(bool evictable) { this->evictable = evictable; } - bool peekEvictable() const { return evictable; } - void lock(void *ptr) { this->lockedPtr = ptr; } void unlock() { this->lockedPtr = nullptr; } bool isLocked() const { return lockedPtr != nullptr; } void *getLockedPtr() const { return lockedPtr; } - void incReuseCount() { reuseCount++; } - void decReuseCount() { reuseCount--; } - uint32_t peekReuseCount() const { return reuseCount; } + bool isCoherent() const { return allocationInfo.flags.coherent; } + void setCoherent(bool coherentIn) { this->allocationInfo.flags.coherent = coherentIn; } + void setEvictable(bool evictable) { allocationInfo.flags.evictable = evictable; } + bool peekEvictable() const { return allocationInfo.flags.evictable; } + bool isFlushL3Required() const { return allocationInfo.flags.flushL3Required; } + void setFlushL3Required(bool flushL3Required) { this->allocationInfo.flags.flushL3Required = flushL3Required; } + bool isMultiOsContextCapable() const { return allocationInfo.flags.multiOsContextCapable; } + bool is32BitAllocation() const { return allocationInfo.flags.is32BitAllocation; } + void set32BitAllocation(bool is32BitAllocation) { allocationInfo.flags.is32BitAllocation = is32BitAllocation; } + + void setAubWritable(bool writable) { aubInfo.aubWritable = writable; } + bool isAubWritable() const { return aubInfo.aubWritable; } + void setAllocDumpable(bool dumpable) { aubInfo.allocDumpable = dumpable; } + bool isAllocDumpable() const { return aubInfo.allocDumpable; } + bool isMemObjectsAllocationWithWritableFlags() const { return aubInfo.memObjectsAllocationWithWritableFlags; } + void setMemObjectsAllocationWithWritableFlags(bool newValue) { aubInfo.memObjectsAllocationWithWritableFlags = newValue; } + + void incReuseCount() { sharingInfo.reuseCount++; } + void decReuseCount() { sharingInfo.reuseCount--; } + uint32_t peekReuseCount() const { return sharingInfo.reuseCount; } + osHandle peekSharedHandle() const { return sharingInfo.sharedHandle; } + + void setAllocationType(AllocationType allocationType); + AllocationType getAllocationType() const { return allocationType; } + MemoryPool::Type getMemoryPool() const { return memoryPool; } + bool isUsed() const { return registeredContextsNum > 0; } + bool isUsedByManyOsContexts() const { return registeredContextsNum > 1u; } 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; } @@ -151,10 +165,7 @@ class GraphicsAllocation : public IDNode { void updateResidencyTaskCount(uint32_t newTaskCount, uint32_t contextId) { usageInfos[contextId].residencyTaskCount = newTaskCount; } uint32_t getResidencyTaskCount(uint32_t contextId) const { return usageInfos[contextId].residencyTaskCount; } void releaseResidencyInOsContext(uint32_t contextId) { updateResidencyTaskCount(objectNotResident, contextId); } - bool isResidencyTaskCountBelow(uint32_t taskCount, uint32_t contextId) { return !isResident(contextId) || getResidencyTaskCount(contextId) < taskCount; } - - bool isMultiOsContextCapable() const { return multiOsContextCapable; } - bool isUsedByManyOsContexts() const { return registeredContextsNum > 1u; } + bool isResidencyTaskCountBelow(uint32_t taskCount, uint32_t contextId) const { return !isResident(contextId) || getResidencyTaskCount(contextId) < taskCount; } virtual std::string getAllocationInfoString() const; @@ -167,33 +178,69 @@ class GraphicsAllocation : public IDNode { } static DevicesBitfield createBitfieldFromProperties(const AllocationProperties &properties); + Gmm *gmm = nullptr; + OsHandleStorage fragmentsStorage; + DevicesBitfield devicesBitfield = {}; + protected: - constexpr static uint32_t objectNotResident = (uint32_t)-1; - constexpr static uint32_t objectNotUsed = (uint32_t)-1; + constexpr static uint32_t objectNotResident = std::numeric_limits::max(); + constexpr static uint32_t objectNotUsed = std::numeric_limits::max(); struct UsageInfo { uint32_t taskCount = objectNotUsed; uint32_t residencyTaskCount = objectNotResident; uint32_t inspectionId = 0u; }; + struct AubInfo { + bool aubWritable = true; + bool allocDumpable = false; + bool memObjectsAllocationWithWritableFlags = false; + }; + struct SharingInfo { + uint32_t reuseCount = 0; + osHandle sharedHandle = Sharing::nonSharedResource; + }; + struct AllocationInfo { + union { + struct { + uint32_t coherent : 1; + uint32_t evictable : 1; + uint32_t flushL3Required : 1; + uint32_t is32BitAllocation : 1; + uint32_t multiOsContextCapable : 1; + uint32_t reserved : 27; + } flags; + uint32_t allFlags = 0u; + }; + static_assert(sizeof(AllocationInfo::flags) == sizeof(AllocationInfo::allFlags), ""); + AllocationInfo() { + flags.coherent = false; + flags.evictable = true; + flags.flushL3Required = false; + flags.is32BitAllocation = false; + flags.multiOsContextCapable = false; + } + }; + + uint64_t allocationOffset = 0u; + void *driverAllocatedCpuPointer = nullptr; //this variable can only be modified from SubmissionAggregator friend class SubmissionAggregator; size_t size = 0; void *cpuPtr = nullptr; + uint64_t gpuBaseAddress = 0; uint64_t gpuAddress = 0; - bool coherent = false; - osHandle sharedHandle = Sharing::nonSharedResource; void *lockedPtr = nullptr; - uint32_t reuseCount = 0; // GraphicsAllocation can be reused by shared resources - bool evictable = true; + MemoryPool::Type memoryPool = MemoryPool::MemoryNull; AllocationType allocationType = AllocationType::UNKNOWN; - bool aubWritable = true; - bool allocDumpable = false; - bool memObjectsAllocationWithWritableFlags = false; + + AllocationInfo allocationInfo; + AubInfo aubInfo; + SharingInfo sharingInfo; + std::array usageInfos; std::atomic registeredContextsNum{0}; - bool multiOsContextCapable = false; }; } // namespace OCLRT diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 3948012f5a..717f3aae9d 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -374,7 +374,7 @@ HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, const if (allocation) { if (useInternal32BitAllocator(allocation->getAllocationType())) { return internalHeapIndex; - } else if (allocation->is32BitAllocation) { + } else if (allocation->is32BitAllocation()) { return HeapIndex::HEAP_EXTERNAL; } } diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index af2e7abd3b..3563dbb4ed 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -112,7 +112,7 @@ class MemoryManager { } else { auto allocation = allocateGraphicsMemoryForNonSvmHostPtr(size, ptr); if (allocation) { - allocation->flushL3Required = requiresL3Flush; + allocation->setFlushL3Required(requiresL3Flush); } return allocation; } @@ -245,7 +245,7 @@ class MemoryManager { auto allocation = allocateGraphicsMemory(allocationData); if (allocation) { allocation->devicesBitfield = allocationData.devicesBitfield; - allocation->flushL3Required = allocationData.flags.flushL3; + allocation->setFlushL3Required(allocationData.flags.flushL3); status = AllocationStatus::Success; } return allocation; diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index a4529449c8..bc9e4fcd9b 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -63,7 +63,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForNonSvmHost memoryAllocation = new MemoryAllocation(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, nullptr, cpuPtr, reinterpret_cast(alignedPtr), size, counter, MemoryPool::System4KBPages, false); - memoryAllocation->allocationOffset = offsetInPage; + memoryAllocation->setAllocationOffset(offsetInPage); memoryAllocation->uncacheable = false; counter++; @@ -90,8 +90,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con uint64_t offset = static_cast(reinterpret_cast(allocationData.hostPtr) & MemoryConstants::pageMask); MemoryAllocation *memAlloc = new MemoryAllocation(allocationData.type, nullptr, const_cast(allocationData.hostPtr), GmmHelper::canonize(gpuVirtualAddress + offset), allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, false); - memAlloc->is32BitAllocation = true; - memAlloc->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase()); + memAlloc->set32BitAllocation(true); + memAlloc->setGpuBaseAddress(GmmHelper::canonize(allocator32Bit->getBase())); memAlloc->sizeToFree = allocationSize; counter++; @@ -110,8 +110,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con if (ptrAlloc != nullptr) { memoryAllocation = new MemoryAllocation(allocationData.type, ptrAlloc, ptrAlloc, GmmHelper::canonize(gpuAddress), allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, false); - memoryAllocation->is32BitAllocation = true; - memoryAllocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase()); + memoryAllocation->set32BitAllocation(true); + memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(allocator32Bit->getBase())); memoryAllocation->sizeToFree = allocationSize; } counter++; @@ -122,7 +122,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedH auto graphicsAllocation = new MemoryAllocation(GraphicsAllocation::AllocationType::UNDECIDED, nullptr, reinterpret_cast(1), 1, 4096u, static_cast(handle), MemoryPool::SystemCpuInaccessible, false); graphicsAllocation->setSharedHandle(handle); - graphicsAllocation->is32BitAllocation = requireSpecificBitness; + graphicsAllocation->set32BitAllocation(requireSpecificBitness); return graphicsAllocation; } @@ -163,12 +163,12 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo return; } - if (gfxAllocation->is32BitAllocation) { + if (gfxAllocation->is32BitAllocation()) { auto gpuAddressToFree = gfxAllocation->getGpuAddress() & ~MemoryConstants::pageMask; allocator32Bit->free(gpuAddressToFree, static_cast(gfxAllocation)->sizeToFree); } - alignedFreeWrapper(gfxAllocation->driverAllocatedCpuPointer); + alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr()); delete gfxAllocation; } diff --git a/runtime/memory_manager/os_agnostic_memory_manager.h b/runtime/memory_manager/os_agnostic_memory_manager.h index 73baf1d171..6631dd6600 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.h +++ b/runtime/memory_manager/os_agnostic_memory_manager.h @@ -18,7 +18,7 @@ class MemoryAllocation : public GraphicsAllocation { size_t sizeToFree = 0; bool uncacheable = false; - void setSharedHandle(osHandle handle) { this->sharedHandle = handle; } + void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; } MemoryAllocation(AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count, MemoryPool::Type pool, bool multiOsContextCapable) : GraphicsAllocation(allocationType, pMem, gpuAddress, 0u, memSize, pool, multiOsContextCapable), @@ -67,7 +67,7 @@ class OsAgnosticMemoryManager : public MemoryManager { GraphicsAllocation *allocateGraphicsMemory64kb(AllocationData allocationData) override; GraphicsAllocation *allocateGraphicsMemoryForImageImpl(const AllocationData &allocationData, std::unique_ptr gmm) override; - void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override { return ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.allocationOffset)); } + void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override { return ptrOffset(graphicsAllocation.getUnderlyingBuffer(), static_cast(graphicsAllocation.getAllocationOffset())); } void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override {} GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override; GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override; diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 6547acae06..cd01424182 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -261,7 +261,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithAlignment(const Alloc emitPinningRequest(bo, allocationData); auto allocation = new DrmAllocation(allocationData.type, bo, res, bo->gpuAddress, cSize, MemoryPool::System4KBPages, allocationData.flags.multiOsContextCapable); - allocation->driverAllocatedCpuPointer = limitedGpuAddressRangeAllocator ? res : nullptr; + allocation->setDriverAllocatedCpuPtr(limitedGpuAddressRangeAllocator ? res : nullptr); return allocation; } @@ -300,8 +300,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(size_t s bo->setAllocationType(allocType); auto allocation = new DrmAllocation(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, bo, alignedPtr, gpuVirtualAddress, size, MemoryPool::System4KBPages, false); - allocation->allocationOffset = offsetInPage; - allocation->gpuBaseAddress = 0; + allocation->setAllocationOffset(offsetInPage); return allocation; } @@ -377,8 +376,8 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio bo->setAllocationType(allocatorType); auto allocation = new DrmAllocation(allocationData.type, bo, const_cast(allocationData.hostPtr), ptrOffset(gpuVirtualAddress, inputPointerOffset), allocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing, false); - allocation->is32BitAllocation = true; - allocation->gpuBaseAddress = allocatorToUse->getBase(); + allocation->set32BitAllocation(true); + allocation->setGpuBaseAddress(allocatorToUse->getBase()); return allocation; } @@ -421,9 +420,9 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio auto allocation = new DrmAllocation(allocationData.type, bo, ptrAlloc, res, alignedAllocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing, false); - allocation->is32BitAllocation = true; - allocation->gpuBaseAddress = allocatorToUse->getBase(); - allocation->driverAllocatedCpuPointer = limitedGpuAddressRangeAllocator ? ptrAlloc : nullptr; + allocation->set32BitAllocation(true); + allocation->setGpuBaseAddress(allocatorToUse->getBase()); + allocation->setDriverAllocatedCpuPtr(limitedGpuAddressRangeAllocator ? ptrAlloc : nullptr); return allocation; } @@ -495,10 +494,10 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o handle, MemoryPool::SystemCpuInaccessible, false); if (requireSpecificBitness && this->force32bitAllocations) { - drmAllocation->is32BitAllocation = true; - drmAllocation->gpuBaseAddress = allocator32Bit->getBase(); + drmAllocation->set32BitAllocation(true); + drmAllocation->setGpuBaseAddress(allocator32Bit->getBase()); } else if (this->limitedGpuAddressRangeAllocator.get()) { - drmAllocation->gpuBaseAddress = this->limitedGpuAddressRangeAllocator->getBase(); + drmAllocation->setGpuBaseAddress(this->limitedGpuAddressRangeAllocator->getBase()); } return drmAllocation; } @@ -557,7 +556,7 @@ void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) if (input->gmm) delete input->gmm; - alignedFreeWrapper(gfxAllocation->driverAllocatedCpuPointer); + alignedFreeWrapper(gfxAllocation->getDriverAllocatedCpuPtr()); if (gfxAllocation->fragmentsStorage.fragmentCount) { cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation); diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index 28f6f91f85..027eb1c260 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -94,7 +94,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const } auto wddmAllocation = std::make_unique(allocationData.type, pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages, allocationData.flags.multiOsContextCapable); - wddmAllocation->driverAllocatedCpuPointer = pSysMem; + wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); gmm = new Gmm(pSysMem, sizeAligned, allocationData.flags.uncacheable); @@ -116,7 +116,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(si auto alignedSize = alignSizeWholePage(cpuPtr, size); auto wddmAllocation = std::make_unique(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, cpuPtr, size, nullptr, MemoryPool::System4KBPages, false); - wddmAllocation->allocationOffset = offsetInPage; + wddmAllocation->setAllocationOffset(offsetInPage); auto gmm = new Gmm(alignedPtr, alignedSize, false); @@ -150,7 +150,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(const AllocationPr } auto allocation = new WddmAllocation(properties.allocationType, ptr, properties.size, reserve, MemoryPool::System4KBPages, false); - allocation->allocationOffset = offset; + allocation->setAllocationOffset(offset); Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false); allocation->gmm = gmm; @@ -189,9 +189,9 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All auto wddmAllocation = std::make_unique(allocationData.type, const_cast(ptrAligned), sizeAligned, nullptr, MemoryPool::System4KBPagesWith32BitGpuAddressing, false); - wddmAllocation->driverAllocatedCpuPointer = pSysMem; - wddmAllocation->is32BitAllocation = true; - wddmAllocation->allocationOffset = offset; + wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); + wddmAllocation->set32BitAllocation(true); + wddmAllocation->setAllocationOffset(offset); wddmAllocation->setAllocationType(allocationData.type); gmm = new Gmm(ptrAligned, sizeAligned, false); @@ -203,9 +203,8 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All return nullptr; } - wddmAllocation->is32BitAllocation = true; auto baseAddress = useInternal32BitAllocator(allocationData.type) ? getInternalHeapBaseAddress() : allocator32Bit->getBase(); - wddmAllocation->gpuBaseAddress = GmmHelper::canonize(baseAddress); + wddmAllocation->setGpuBaseAddress(GmmHelper::canonize(baseAddress)); DebugManager.logAllocation(wddmAllocation.get()); return wddmAllocation.release(); @@ -232,8 +231,8 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl } allocation->setReservedAddress(ptr); } else if (requireSpecificBitness && this->force32bitAllocations) { - allocation->is32BitAllocation = true; - allocation->gpuBaseAddress = GmmHelper::canonize(allocator32Bit->getBase()); + allocation->set32BitAllocation(true); + allocation->setGpuBaseAddress(GmmHelper::canonize(allocator32Bit->getBase())); } status = wddm->mapGpuVirtualAddress(allocation.get(), ptr); DEBUG_BREAK_IF(!status); @@ -313,7 +312,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation } if (input->peekSharedHandle() == false && - input->driverAllocatedCpuPointer == nullptr && + input->getDriverAllocatedCpuPtr() == nullptr && input->fragmentsStorage.fragmentCount > 0) { cleanGraphicsMemoryCreatedFromHostPtr(gfxAllocation); } else { @@ -328,7 +327,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation } auto status = tryDeferDeletions(allocationHandles, allocationCount, resourceHandle); DEBUG_BREAK_IF(!status); - alignedFreeWrapper(input->driverAllocatedCpuPointer); + alignedFreeWrapper(input->getDriverAllocatedCpuPtr()); } wddm->releaseReservedAddress(input->getReservedAddress()); delete gfxAllocation; @@ -427,7 +426,7 @@ void WddmMemoryManager::obtainGpuAddressFromFragments(WddmAllocation *allocation gpuPtr = handleStorage.fragmentStorageData[i].osHandleStorage->gpuPtr; } } - allocation->allocationOffset = reinterpret_cast(hostPtr) & MemoryConstants::pageMask; + allocation->setAllocationOffset(reinterpret_cast(hostPtr) & MemoryConstants::pageMask); allocation->setGpuAddress(gpuPtr); } } diff --git a/runtime/program/process_gen_binary.cpp b/runtime/program/process_gen_binary.cpp index 41735cc63b..cde98f5dc4 100644 --- a/runtime/program/process_gen_binary.cpp +++ b/runtime/program/process_gen_binary.cpp @@ -896,7 +896,7 @@ cl_int Program::parseProgramScopePatchList() { auto patch = *(SPatchGlobalPointerProgramBinaryInfo *)pPatch; if ((patch.GlobalBufferIndex == 0) && (patch.BufferIndex == 0) && (patch.BufferType == PROGRAM_SCOPE_GLOBAL_BUFFER)) { void *pPtr = (void *)((uintptr_t)globalSurface->getUnderlyingBuffer() + (uintptr_t)patch.GlobalPointerOffset); - if (globalSurface->is32BitAllocation) { + if (globalSurface->is32BitAllocation()) { *reinterpret_cast(pPtr) += static_cast(globalSurface->getGpuAddressToPatch()); } else { *reinterpret_cast(pPtr) += reinterpret_cast(globalSurface->getUnderlyingBuffer()); @@ -919,7 +919,7 @@ cl_int Program::parseProgramScopePatchList() { auto patch = *(SPatchConstantPointerProgramBinaryInfo *)pPatch; if ((patch.ConstantBufferIndex == 0) && (patch.BufferIndex == 0) && (patch.BufferType == PROGRAM_SCOPE_CONSTANT_BUFFER)) { void *pPtr = (uintptr_t *)((uintptr_t)constantSurface->getUnderlyingBuffer() + (uintptr_t)patch.ConstantPointerOffset); - if (constantSurface->is32BitAllocation) { + if (constantSurface->is32BitAllocation()) { *reinterpret_cast(pPtr) += static_cast(constantSurface->getGpuAddressToPatch()); } else { *reinterpret_cast(pPtr) += reinterpret_cast(constantSurface->getUnderlyingBuffer()); diff --git a/runtime/sharings/gl/gl_buffer.cpp b/runtime/sharings/gl/gl_buffer.cpp index aef5d72b4e..b6865cf615 100644 --- a/runtime/sharings/gl/gl_buffer.cpp +++ b/runtime/sharings/gl/gl_buffer.cpp @@ -47,7 +47,7 @@ void GlBuffer::synchronizeObject(UpdateData &updateData) { updateData.sharedHandle = bufferInfo.globalShareHandle; updateData.synchronizationStatus = SynchronizeStatus::ACQUIRE_SUCCESFUL; - updateData.memObject->getGraphicsAllocation()->allocationOffset = bufferInfo.bufferOffset; + updateData.memObject->getGraphicsAllocation()->setAllocationOffset(bufferInfo.bufferOffset); if (currentSharedHandle != updateData.sharedHandle) { updateData.updateData = new CL_GL_BUFFER_INFO(bufferInfo); @@ -72,7 +72,7 @@ void GlBuffer::resolveGraphicsAllocationChange(osHandle currentSharedHandle, Upd memObject->resetGraphicsAllocation(newGraphicsAllocation); if (updateData->synchronizationStatus == SynchronizeStatus::ACQUIRE_SUCCESFUL) { - memObject->getGraphicsAllocation()->allocationOffset = bufferInfo->bufferOffset; + memObject->getGraphicsAllocation()->setAllocationOffset(bufferInfo->bufferOffset); } } } diff --git a/runtime/sharings/gl/gl_texture.cpp b/runtime/sharings/gl/gl_texture.cpp index 8f186b4c53..644028930d 100644 --- a/runtime/sharings/gl/gl_texture.cpp +++ b/runtime/sharings/gl/gl_texture.cpp @@ -148,7 +148,7 @@ void GlTexture::synchronizeObject(UpdateData &updateData) { } else { sharingFunctions->acquireSharedTexture(&resourceInfo); // Set texture buffer offset acquired from OpenGL layer in graphics allocation - updateData.memObject->getGraphicsAllocation()->allocationOffset = resourceInfo.textureBufferOffset; + updateData.memObject->getGraphicsAllocation()->setAllocationOffset(resourceInfo.textureBufferOffset); } updateData.sharedHandle = resourceInfo.globalShareHandle; updateData.synchronizationStatus = SynchronizeStatus::ACQUIRE_SUCCESFUL; diff --git a/unit_tests/command_queue/command_queue_tests.cpp b/unit_tests/command_queue/command_queue_tests.cpp index 50d9505bdf..dc2adc8f3e 100644 --- a/unit_tests/command_queue/command_queue_tests.cpp +++ b/unit_tests/command_queue/command_queue_tests.cpp @@ -414,9 +414,9 @@ TEST_P(CommandQueueIndirectHeapTest, givenIndirectObjectHeapWhenItIsQueriedForIn auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), 8192); if (this->GetParam() == IndirectHeap::INDIRECT_OBJECT) { - EXPECT_TRUE(indirectHeap.getGraphicsAllocation()->is32BitAllocation); + EXPECT_TRUE(indirectHeap.getGraphicsAllocation()->is32BitAllocation()); } else { - EXPECT_FALSE(indirectHeap.getGraphicsAllocation()->is32BitAllocation); + EXPECT_FALSE(indirectHeap.getGraphicsAllocation()->is32BitAllocation()); } } diff --git a/unit_tests/command_queue/enqueue_kernel_2_tests.cpp b/unit_tests/command_queue/enqueue_kernel_2_tests.cpp index 7fd2efcc8e..6166314cec 100644 --- a/unit_tests/command_queue/enqueue_kernel_2_tests.cpp +++ b/unit_tests/command_queue/enqueue_kernel_2_tests.cpp @@ -471,9 +471,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueKernelWithScratch, givenDeviceForcing32bitAll enqueueKernel(mockKernel); auto graphicsAllocation = csr->getScratchAllocation(); - EXPECT_TRUE(graphicsAllocation->is32BitAllocation); + EXPECT_TRUE(graphicsAllocation->is32BitAllocation()); auto graphicsAddress = (uint64_t)graphicsAllocation->getGpuAddress(); - auto baseAddress = graphicsAllocation->gpuBaseAddress; + auto baseAddress = graphicsAllocation->getGpuBaseAddress(); // All state should be programmed before walker auto itorCmd = find(itorPipelineSelect, itorWalker); diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp index 911db97aed..a7fc5f8ebd 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -490,7 +490,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu graphicsAddress = (uint64_t)graphicsAllocationScratch->getGpuAddressToPatch(); if (pDevice->getDeviceInfo().force32BitAddressess == true && is64bit) { - EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation); + EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation()); EXPECT_EQ((uint64_t)graphicsAllocationScratch->getGpuAddress() - GSHaddress, graphicsAddress); } else { EXPECT_EQ((uint64_t)graphicsAllocationScratch->getUnderlyingBuffer(), graphicsAddress); @@ -600,7 +600,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer graphicsAddress = (uint64_t)graphicsAllocationScratch->getGpuAddressToPatch(); if (pDevice->getDeviceInfo().force32BitAddressess == true && is64bit) { - EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation); + EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation()); EXPECT_EQ((uint64_t)graphicsAllocationScratch->getGpuAddress() - GSHaddress, graphicsAddress); } else { EXPECT_EQ((uint64_t)graphicsAllocationScratch->getUnderlyingBuffer(), graphicsAddress); diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index 9ab12e0ae9..5b43705d8c 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -229,7 +229,7 @@ TEST_F(CommandStreamReceiverTest, givenForced32BitAddressingWhenDebugSurfaceIsAl auto *memoryManager = commandStreamReceiver->getMemoryManager(); memoryManager->setForce32BitAllocations(true); auto allocation = commandStreamReceiver->allocateDebugSurface(1024); - EXPECT_FALSE(allocation->is32BitAllocation); + EXPECT_FALSE(allocation->is32BitAllocation()); } HWTEST_F(CommandStreamReceiverTest, givenDefaultCommandStreamReceiverThenDefaultDispatchingPolicyIsImmediateSubmission) { diff --git a/unit_tests/d3d_sharing/d3d_tests.cpp b/unit_tests/d3d_sharing/d3d_tests.cpp index 4b06dd115c..bcf53b8818 100644 --- a/unit_tests/d3d_sharing/d3d_tests.cpp +++ b/unit_tests/d3d_sharing/d3d_tests.cpp @@ -1266,7 +1266,7 @@ TYPED_TEST_P(D3DTests, inForced32BitAddressingBufferCreatedHas32BitAllocation) { auto *allocation = buffer->getGraphicsAllocation(); EXPECT_NE(nullptr, allocation); - EXPECT_TRUE(allocation->is32BitAllocation); + EXPECT_TRUE(allocation->is32BitAllocation()); } REGISTER_TYPED_TEST_CASE_P(D3DTests, diff --git a/unit_tests/gen_common/gen_commands_common_validation.h b/unit_tests/gen_common/gen_commands_common_validation.h index 2c84f13d53..bdb0e5753b 100644 --- a/unit_tests/gen_common/gen_commands_common_validation.h +++ b/unit_tests/gen_common/gen_commands_common_validation.h @@ -43,7 +43,7 @@ void validateStateBaseAddress(uint64_t internalHeapBase, IndirectHeap *pDSH, // Stateless accesses require GSH.base to be 0. EXPECT_EQ(expectedGeneralStateHeapBaseAddress, cmd->getGeneralStateBaseAddress()); EXPECT_EQ(static_cast(reinterpret_cast(pSSH->getCpuBase())), cmd->getSurfaceStateBaseAddress()); - EXPECT_EQ(pIOH->getGraphicsAllocation()->gpuBaseAddress, cmd->getIndirectObjectBaseAddress()); + EXPECT_EQ(pIOH->getGraphicsAllocation()->getGpuBaseAddress(), cmd->getIndirectObjectBaseAddress()); EXPECT_EQ(internalHeapBase, cmd->getInstructionBaseAddress()); // Verify all sizes are getting programmed diff --git a/unit_tests/helpers/dirty_state_helpers_tests.cpp b/unit_tests/helpers/dirty_state_helpers_tests.cpp index a80dc800e5..d10cbfe6d8 100644 --- a/unit_tests/helpers/dirty_state_helpers_tests.cpp +++ b/unit_tests/helpers/dirty_state_helpers_tests.cpp @@ -115,8 +115,8 @@ TEST(DirtyStateHelpers, givenDirtyStateHelperWhenTwoDifferentIndirectHeapsAreChe MockGraphicsAllocation firstHeapAllocation(reinterpret_cast(0x1234), 4192); MockGraphicsAllocation secondHeapAllocation(reinterpret_cast(0x9345), 1234); uint64_t commonBase = 0x8123456; - firstHeapAllocation.gpuBaseAddress = commonBase; - secondHeapAllocation.gpuBaseAddress = commonBase; + firstHeapAllocation.setGpuBaseAddress(commonBase); + secondHeapAllocation.setGpuBaseAddress(commonBase); IndirectHeap firstHeap(&firstHeapAllocation, true); IndirectHeap secondHeap(&secondHeapAllocation, true); diff --git a/unit_tests/helpers/kernel_commands_tests.cpp b/unit_tests/helpers/kernel_commands_tests.cpp index 4a70848d39..6002babe4d 100644 --- a/unit_tests/helpers/kernel_commands_tests.cpp +++ b/unit_tests/helpers/kernel_commands_tests.cpp @@ -1277,7 +1277,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, KernelCommandsTest, givenCacheFlushAfterWalkerEnable char buff[MemoryConstants::pageSize * 2]; MockGraphicsAllocation svmAllocation1{alignUp(buff, MemoryConstants::pageSize), MemoryConstants::pageSize}; - svmAllocation1.flushL3Required = true; + svmAllocation1.setFlushL3Required(true); mockKernelWithInternal->mockKernel->kernelSvmGfxAllocations.push_back(&svmAllocation1); MockGraphicsAllocation svmAllocation2{alignUp(buff, MemoryConstants::pageSize), MemoryConstants::pageSize}; mockKernelWithInternal->mockKernel->kernelSvmGfxAllocations.push_back(&svmAllocation2); diff --git a/unit_tests/indirect_heap/indirect_heap_tests.cpp b/unit_tests/indirect_heap/indirect_heap_tests.cpp index 8c7d9a98c0..a241895e27 100644 --- a/unit_tests/indirect_heap/indirect_heap_tests.cpp +++ b/unit_tests/indirect_heap/indirect_heap_tests.cpp @@ -89,7 +89,7 @@ TEST_F(IndirectHeapTest, givenIndirectHeapWhenGetCpuBaseIsCalledThenCpuAddressIs TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhenAskedForHeapGpuStartOffsetThenZeroIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x3000); MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); - graphicsAllocation.gpuBaseAddress = 4096u; + graphicsAllocation.setGpuBaseAddress(4096u); IndirectHeap indirectHeap(&graphicsAllocation, false); EXPECT_EQ(0u, indirectHeap.getHeapGpuStartOffset()); @@ -98,7 +98,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhen TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAskedForHeapGpuStartOffsetThenZeroIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x3000); MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); - graphicsAllocation.gpuBaseAddress = 4096u; + graphicsAllocation.setGpuBaseAddress(4096u); IndirectHeap indirectHeap(&graphicsAllocation, true); EXPECT_EQ(8192u, indirectHeap.getHeapGpuStartOffset()); @@ -107,7 +107,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAsk TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAskedForHeapBaseThenGpuBaseIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); - graphicsAllocation.gpuBaseAddress = 4096u; + graphicsAllocation.setGpuBaseAddress(4096u); IndirectHeap indirectHeap(&graphicsAllocation, true); EXPECT_EQ(4096u, indirectHeap.getHeapGpuBase()); @@ -116,7 +116,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAsk TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhenAskedForHeapBaseThenGpuAddressIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); - graphicsAllocation.gpuBaseAddress = 4096u; + graphicsAllocation.setGpuBaseAddress(4096u); IndirectHeap indirectHeap(&graphicsAllocation, false); EXPECT_EQ(8192u, indirectHeap.getHeapGpuBase()); @@ -125,7 +125,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhen TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhenAskedForHeapSizeThenGraphicsAllocationSizeInPagesIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); - graphicsAllocation.gpuBaseAddress = 4096u; + graphicsAllocation.setGpuBaseAddress(4096u); IndirectHeap indirectHeap(&graphicsAllocation, false); EXPECT_EQ(1u, indirectHeap.getHeapSizeInPages()); @@ -134,7 +134,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhen TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAskedForHeapSizeThen4GbSizeInPagesIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); - graphicsAllocation.gpuBaseAddress = 4096u; + graphicsAllocation.setGpuBaseAddress(4096u); IndirectHeap indirectHeap(&graphicsAllocation, true); EXPECT_EQ(MemoryConstants::sizeOf4GBinPageEntities, indirectHeap.getHeapSizeInPages()); diff --git a/unit_tests/kernel/kernel_arg_buffer_tests.cpp b/unit_tests/kernel/kernel_arg_buffer_tests.cpp index 68dc128835..860ee702d0 100644 --- a/unit_tests/kernel/kernel_arg_buffer_tests.cpp +++ b/unit_tests/kernel/kernel_arg_buffer_tests.cpp @@ -172,7 +172,7 @@ TEST_F(KernelArgBufferTest, given32BitDeviceWhenArgPassedIsNullThenOnly4BytesAre TEST_F(KernelArgBufferTest, givenWritebleBufferWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { auto buffer = std::make_unique(); buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(true); - buffer->mockGfxAllocation.flushL3Required = false; + buffer->mockGfxAllocation.setFlushL3Required(false); auto val = static_cast(buffer.get()); auto pVal = &val; @@ -185,7 +185,7 @@ TEST_F(KernelArgBufferTest, givenWritebleBufferWhenSettingAsArgThenExpectAllocat TEST_F(KernelArgBufferTest, givenCacheFlushBufferWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { auto buffer = std::make_unique(); buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(false); - buffer->mockGfxAllocation.flushL3Required = true; + buffer->mockGfxAllocation.setFlushL3Required(true); auto val = static_cast(buffer.get()); auto pVal = &val; @@ -198,7 +198,7 @@ TEST_F(KernelArgBufferTest, givenCacheFlushBufferWhenSettingAsArgThenExpectAlloc TEST_F(KernelArgBufferTest, givenNoCacheFlushBufferWhenSettingAsArgThenNotExpectAllocationInCacheFlushVector) { auto buffer = std::make_unique(); buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(false); - buffer->mockGfxAllocation.flushL3Required = false; + buffer->mockGfxAllocation.setFlushL3Required(false); auto val = static_cast(buffer.get()); auto pVal = &val; diff --git a/unit_tests/kernel/kernel_arg_svm_tests.cpp b/unit_tests/kernel/kernel_arg_svm_tests.cpp index 2919e544fe..e7bad3c109 100644 --- a/unit_tests/kernel/kernel_arg_svm_tests.cpp +++ b/unit_tests/kernel/kernel_arg_svm_tests.cpp @@ -420,7 +420,7 @@ TEST_F(KernelArgSvmTest, givenWritebleSvmAllocationWhenSettingAsArgThenExpectAll MockGraphicsAllocation svmAlloc(svmPtr, svmSize); svmAlloc.setMemObjectsAllocationWithWritableFlags(true); - svmAlloc.flushL3Required = false; + svmAlloc.setFlushL3Required(false); auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc); EXPECT_EQ(CL_SUCCESS, retVal); @@ -435,7 +435,7 @@ TEST_F(KernelArgSvmTest, givenCacheFlushSvmAllocationWhenSettingAsArgThenExpectA MockGraphicsAllocation svmAlloc(svmPtr, svmSize); svmAlloc.setMemObjectsAllocationWithWritableFlags(false); - svmAlloc.flushL3Required = true; + svmAlloc.setFlushL3Required(true); auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc); EXPECT_EQ(CL_SUCCESS, retVal); @@ -450,7 +450,7 @@ TEST_F(KernelArgSvmTest, givenNoCacheFlushSvmAllocationWhenSettingAsArgThenNotEx MockGraphicsAllocation svmAlloc(svmPtr, svmSize); svmAlloc.setMemObjectsAllocationWithWritableFlags(false); - svmAlloc.flushL3Required = false; + svmAlloc.setFlushL3Required(false); auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc); EXPECT_EQ(CL_SUCCESS, retVal); @@ -465,7 +465,7 @@ TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingKernelExecInfoThen MockGraphicsAllocation svmAlloc(svmPtr, svmSize); svmAlloc.setMemObjectsAllocationWithWritableFlags(true); - svmAlloc.flushL3Required = false; + svmAlloc.setFlushL3Required(false); pKernel->setKernelExecInfo(&svmAlloc); EXPECT_TRUE(pKernel->svmAllocationsRequireCacheFlush); @@ -479,7 +479,7 @@ TEST_F(KernelArgSvmTest, givenCacheFlushSvmAllocationWhenSettingKernelExecInfoTh MockGraphicsAllocation svmAlloc(svmPtr, svmSize); svmAlloc.setMemObjectsAllocationWithWritableFlags(false); - svmAlloc.flushL3Required = true; + svmAlloc.setFlushL3Required(true); pKernel->setKernelExecInfo(&svmAlloc); EXPECT_TRUE(pKernel->svmAllocationsRequireCacheFlush); @@ -493,7 +493,7 @@ TEST_F(KernelArgSvmTest, givenNoCacheFlushReadOnlySvmAllocationWhenSettingKernel MockGraphicsAllocation svmAlloc(svmPtr, svmSize); svmAlloc.setMemObjectsAllocationWithWritableFlags(false); - svmAlloc.flushL3Required = false; + svmAlloc.setFlushL3Required(false); pKernel->setKernelExecInfo(&svmAlloc); EXPECT_FALSE(pKernel->svmAllocationsRequireCacheFlush); diff --git a/unit_tests/kernel/kernel_image_arg_tests.cpp b/unit_tests/kernel/kernel_image_arg_tests.cpp index 721934394a..2909e89021 100644 --- a/unit_tests/kernel/kernel_image_arg_tests.cpp +++ b/unit_tests/kernel/kernel_image_arg_tests.cpp @@ -264,7 +264,7 @@ TEST_F(KernelImageArgTest, givenKernelWithSharedImageWhenSetArgCalledThenUsingSh TEST_F(KernelImageArgTest, givenWritebleImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { MockImageBase image; image.graphicsAllocation->setMemObjectsAllocationWithWritableFlags(true); - image.graphicsAllocation->flushL3Required = false; + image.graphicsAllocation->setFlushL3Required(false); cl_mem imageObj = ℑ @@ -276,7 +276,7 @@ TEST_F(KernelImageArgTest, givenWritebleImageWhenSettingAsArgThenExpectAllocatio TEST_F(KernelImageArgTest, givenCacheFlushImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { MockImageBase image; image.graphicsAllocation->setMemObjectsAllocationWithWritableFlags(false); - image.graphicsAllocation->flushL3Required = true; + image.graphicsAllocation->setFlushL3Required(true); cl_mem imageObj = ℑ @@ -288,7 +288,7 @@ TEST_F(KernelImageArgTest, givenCacheFlushImageWhenSettingAsArgThenExpectAllocat TEST_F(KernelImageArgTest, givenNoCacheFlushImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) { MockImageBase image; image.graphicsAllocation->setMemObjectsAllocationWithWritableFlags(false); - image.graphicsAllocation->flushL3Required = false; + image.graphicsAllocation->setFlushL3Required(false); cl_mem imageObj = ℑ diff --git a/unit_tests/kernel/kernel_tests.cpp b/unit_tests/kernel/kernel_tests.cpp index cd803bae5a..a866f64892 100644 --- a/unit_tests/kernel/kernel_tests.cpp +++ b/unit_tests/kernel/kernel_tests.cpp @@ -710,7 +710,7 @@ TEST_F(KernelPrivateSurfaceTest, given32BitDeviceWhenKernelIsCreatedThenPrivateS ASSERT_EQ(CL_SUCCESS, pKernel->initialize()); - EXPECT_TRUE(pKernel->getPrivateSurface()->is32BitAllocation); + EXPECT_TRUE(pKernel->getPrivateSurface()->is32BitAllocation()); delete pKernel; } @@ -2379,7 +2379,7 @@ TEST(KernelTest, whenAllocationRequiringCacheFlushThenAssignAllocationPointerToC kernel.mockKernel->kernelArgRequiresCacheFlush.resize(1); mockAllocation.setMemObjectsAllocationWithWritableFlags(false); - mockAllocation.flushL3Required = true; + mockAllocation.setFlushL3Required(true); kernel.mockKernel->addAllocationToCacheFlushVector(0, &mockAllocation); EXPECT_EQ(&mockAllocation, kernel.mockKernel->kernelArgRequiresCacheFlush[0]); @@ -2429,7 +2429,7 @@ TEST(KernelTest, whenAllocationWriteableThenAssignAllocationPointerToCacheFlushV kernel.mockKernel->kernelArgRequiresCacheFlush.resize(1); mockAllocation.setMemObjectsAllocationWithWritableFlags(true); - mockAllocation.flushL3Required = false; + mockAllocation.setFlushL3Required(false); kernel.mockKernel->addAllocationToCacheFlushVector(0, &mockAllocation); EXPECT_EQ(&mockAllocation, kernel.mockKernel->kernelArgRequiresCacheFlush[0]); @@ -2443,7 +2443,7 @@ TEST(KernelTest, whenAllocationReadOnlyNonFlushRequiredThenAssignNullPointerToCa kernel.mockKernel->kernelArgRequiresCacheFlush[0] = reinterpret_cast(0x1); mockAllocation.setMemObjectsAllocationWithWritableFlags(false); - mockAllocation.flushL3Required = false; + mockAllocation.setFlushL3Required(false); kernel.mockKernel->addAllocationToCacheFlushVector(0, &mockAllocation); EXPECT_EQ(nullptr, kernel.mockKernel->kernelArgRequiresCacheFlush[0]); diff --git a/unit_tests/mem_obj/buffer_set_arg_tests.cpp b/unit_tests/mem_obj/buffer_set_arg_tests.cpp index b62571b120..5b151cec84 100644 --- a/unit_tests/mem_obj/buffer_set_arg_tests.cpp +++ b/unit_tests/mem_obj/buffer_set_arg_tests.cpp @@ -183,7 +183,7 @@ TEST_F(BufferSetArgTest, setKernelArgBufferFor32BitAddressing) { auto tokenSize = pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size; uintptr_t gpuBase = (uintptr_t)buffer->getGraphicsAllocation()->getGpuAddress() >> 2; - buffer->getGraphicsAllocation()->gpuBaseAddress = gpuBase; + buffer->getGraphicsAllocation()->setGpuBaseAddress(gpuBase); buffer->setArgStateless(pKernelArg, tokenSize, true); EXPECT_EQ((uintptr_t)buffer->getGraphicsAllocation()->getGpuAddress() - gpuBase, (uintptr_t)*pKernelArg); diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index f975081576..a2a974163b 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -1283,7 +1283,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatAddressIsForcedTo32bitW retVal); EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_TRUE(is64bit ? buffer->getGraphicsAllocation()->is32BitAllocation : true); + EXPECT_TRUE(is64bit ? buffer->getGraphicsAllocation()->is32BitAllocation() : true); using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; RENDER_SURFACE_STATE surfaceState = {}; diff --git a/unit_tests/mem_obj/image_set_arg_tests.cpp b/unit_tests/mem_obj/image_set_arg_tests.cpp index fd7ce86300..7ee05c94e6 100644 --- a/unit_tests/mem_obj/image_set_arg_tests.cpp +++ b/unit_tests/mem_obj/image_set_arg_tests.cpp @@ -224,7 +224,7 @@ HWTEST_F(ImageSetArgTest, givenOffsetedBufferWhenSetKernelArgImageIscalledThenFu pKernelInfo->kernelArgInfo[0].offsetHeap)); auto graphicsAllocation = srcImage->getGraphicsAllocation(); - graphicsAllocation->gpuBaseAddress = 12345u; + graphicsAllocation->setGpuBaseAddress(12345u); srcImage->setImageArg(const_cast(surfaceState), false, 0); diff --git a/unit_tests/mem_obj/zero_copy_tests.cpp b/unit_tests/mem_obj/zero_copy_tests.cpp index 8a82c5f53c..29548a1c04 100644 --- a/unit_tests/mem_obj/zero_copy_tests.cpp +++ b/unit_tests/mem_obj/zero_copy_tests.cpp @@ -113,7 +113,7 @@ TEST(ZeroCopyBufferTestWithSharedContext, GivenContextThatIsSharedWhenAskedForBu EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_TRUE(buffer->isMemObjZeroCopy()) << "Zero Copy not handled properly"; - if (buffer->getGraphicsAllocation()->is32BitAllocation == false) { + if (buffer->getGraphicsAllocation()->is32BitAllocation() == false) { EXPECT_EQ(host_ptr, buffer->getGraphicsAllocation()->getUnderlyingBuffer()); } } @@ -193,7 +193,7 @@ TEST(ZeroCopyBufferWith32BitAddressing, GivenDeviceSupporting32BitAddressingWhen EXPECT_TRUE(buffer->isMemObjZeroCopy()); if (is64bit) { - EXPECT_TRUE(buffer->getGraphicsAllocation()->is32BitAllocation); + EXPECT_TRUE(buffer->getGraphicsAllocation()->is32BitAllocation()); } alignedFree(host_ptr); } diff --git a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl index 6601c276af..90de6831d7 100644 --- a/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl +++ b/unit_tests/memory_manager/memory_manager_allocate_in_preferred_pool_tests.inl @@ -174,10 +174,10 @@ TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedType auto allocation = memoryManager.allocateGraphicsMemory(allocData); ASSERT_NE(nullptr, allocation); if (is64bit) { - EXPECT_TRUE(allocation->is32BitAllocation); + EXPECT_TRUE(allocation->is32BitAllocation()); EXPECT_EQ(MemoryPool::System4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool()); } else { - EXPECT_FALSE(allocation->is32BitAllocation); + EXPECT_FALSE(allocation->is32BitAllocation()); EXPECT_EQ(MemoryPool::System4KBPages, allocation->getMemoryPool()); } @@ -197,7 +197,7 @@ TEST(MemoryManagerTest, givenForced32BitEnabledWhenGraphicsMemoryWihtoutAllow32B auto allocation = memoryManager.allocateGraphicsMemory(allocData); ASSERT_NE(nullptr, allocation); - EXPECT_FALSE(allocation->is32BitAllocation); + EXPECT_FALSE(allocation->is32BitAllocation()); memoryManager.freeGraphicsMemory(allocation); } @@ -214,7 +214,7 @@ TEST(MemoryManagerTest, givenForced32BitDisabledWhenGraphicsMemoryWith32BitFlagF auto allocation = memoryManager.allocateGraphicsMemory(allocData); ASSERT_NE(nullptr, allocation); - EXPECT_FALSE(allocation->is32BitAllocation); + EXPECT_FALSE(allocation->is32BitAllocation()); memoryManager.freeGraphicsMemory(allocation); } @@ -282,9 +282,9 @@ TEST(MemoryManagerTest, givenForced32BitAndEnabled64kbPagesWhenGraphicsMemoryMus auto allocation = memoryManager.allocateGraphicsMemory(allocData); ASSERT_NE(nullptr, allocation); if (is64bit) { - EXPECT_TRUE(allocation->is32BitAllocation); + EXPECT_TRUE(allocation->is32BitAllocation()); } else { - EXPECT_FALSE(allocation->is32BitAllocation); + EXPECT_FALSE(allocation->is32BitAllocation()); } memoryManager.freeGraphicsMemory(allocation); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 58644f3aad..5e682a1d59 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -67,7 +67,7 @@ TEST(GraphicsAllocationTest, Ctor) { uint64_t expectedGpuAddr = static_cast(reinterpret_cast(gfxAllocation.getUnderlyingBuffer())); EXPECT_EQ(expectedGpuAddr, gfxAllocation.getGpuAddress()); - EXPECT_EQ(0u, gfxAllocation.gpuBaseAddress); + EXPECT_EQ(0u, gfxAllocation.getGpuBaseAddress()); } TEST(GraphicsAllocationTest, Ctor2) { @@ -78,7 +78,7 @@ TEST(GraphicsAllocationTest, Ctor2) { uint64_t expectedGpuAddr = static_cast(reinterpret_cast(gfxAllocation.getUnderlyingBuffer())); EXPECT_EQ(expectedGpuAddr, gfxAllocation.getGpuAddress()); - EXPECT_EQ(0u, gfxAllocation.gpuBaseAddress); + EXPECT_EQ(0u, gfxAllocation.getGpuBaseAddress()); EXPECT_EQ(sharedHandle, gfxAllocation.peekSharedHandle()); } @@ -351,7 +351,7 @@ TEST_F(MemoryAllocatorTest, givenMemoryManagerWhenAskedFor32bitAllocationThen32b EXPECT_NE(nullptr, allocation); EXPECT_NE(nullptr, allocation->getUnderlyingBuffer()); EXPECT_EQ(size, allocation->getUnderlyingBufferSize()); - EXPECT_TRUE(allocation->is32BitAllocation); + EXPECT_TRUE(allocation->is32BitAllocation()); memoryManager->freeGraphicsMemory(allocation); } @@ -379,7 +379,7 @@ TEST_F(MemoryAllocatorTest, givenMemoryManagerWhenAskedFor32bitAllocationWithPtr EXPECT_NE(nullptr, allocation); EXPECT_NE(nullptr, allocation->getUnderlyingBuffer()); EXPECT_EQ(size, allocation->getUnderlyingBufferSize()); - EXPECT_TRUE(allocation->is32BitAllocation); + EXPECT_TRUE(allocation->is32BitAllocation()); EXPECT_EQ(ptr, allocation->getUnderlyingBuffer()); EXPECT_NE(0u, allocation->getGpuAddress()); @@ -500,7 +500,7 @@ TEST_F(MemoryAllocatorTest, given32BitDeviceWhenPrintfSurfaceIsCreatedThen32BitA auto allocationAddress = printfAllocation->getGpuAddressToPatch(); uint32_t allocationAddress32bit = (uint32_t)(uintptr_t)allocationAddress; - EXPECT_TRUE(printfAllocation->is32BitAllocation); + EXPECT_TRUE(printfAllocation->is32BitAllocation()); EXPECT_EQ(allocationAddress32bit, *ptr32Bit); for (int i = 4; i < 8; i++) { EXPECT_EQ(50, kernel.mockKernel->mockCrossThreadData[i]); @@ -808,7 +808,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenLockUnlockCalledThenReturnCp EXPECT_FALSE(allocation->isLocked()); auto ptr = memoryManager.lockResource(allocation); - EXPECT_EQ(ptrOffset(allocation->getUnderlyingBuffer(), static_cast(allocation->allocationOffset)), ptr); + EXPECT_EQ(ptrOffset(allocation->getUnderlyingBuffer(), static_cast(allocation->getAllocationOffset())), ptr); EXPECT_TRUE(allocation->isLocked()); memoryManager.unlockResource(allocation); EXPECT_FALSE(allocation->isLocked()); @@ -825,13 +825,13 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationCon auto graphicsAddress = graphicsAllocation->getGpuAddress(); auto graphicsAddressToPatch = graphicsAllocation->getGpuAddressToPatch(); - graphicsAllocation->allocationOffset = 4; + graphicsAllocation->setAllocationOffset(4); auto offsetedGraphicsAddress = graphicsAllocation->getGpuAddress(); auto offsetedGraphicsAddressToPatch = graphicsAllocation->getGpuAddressToPatch(); - EXPECT_EQ(offsetedGraphicsAddress, graphicsAddress + graphicsAllocation->allocationOffset); - EXPECT_EQ(offsetedGraphicsAddressToPatch, graphicsAddressToPatch + graphicsAllocation->allocationOffset); + EXPECT_EQ(offsetedGraphicsAddress, graphicsAddress + graphicsAllocation->getAllocationOffset()); + EXPECT_EQ(offsetedGraphicsAddressToPatch, graphicsAddressToPatch + graphicsAllocation->getAllocationOffset()); memoryManager.freeGraphicsMemory(graphicsAllocation); } @@ -1040,7 +1040,7 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenAllocateGraphicsMe auto allocation = memoryManager.allocateGraphicsMemoryForNonSvmHostPtr(13, hostPtr); EXPECT_NE(nullptr, allocation); EXPECT_EQ(13u, allocation->getUnderlyingBufferSize()); - EXPECT_EQ(1u, allocation->allocationOffset); + EXPECT_EQ(1u, allocation->getAllocationOffset()); memoryManager.freeGraphicsMemory(allocation); } @@ -1056,7 +1056,7 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenReducedGpuAddressSpaceWhenAllocat auto allocation = memoryManager.allocateGraphicsMemoryForHostPtr(13, hostPtr, false, requiresL3Flush); EXPECT_NE(nullptr, allocation); EXPECT_EQ(0u, allocation->fragmentsStorage.fragmentCount); - EXPECT_EQ(requiresL3Flush, allocation->flushL3Required); + EXPECT_EQ(requiresL3Flush, allocation->isFlushL3Required()); memoryManager.freeGraphicsMemory(allocation); } @@ -1070,7 +1070,7 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenFullGpuAddressSpaceWhenAllocateGr auto allocation = memoryManager.allocateGraphicsMemoryForHostPtr(13, hostPtr, true, requiresL3Flush); EXPECT_NE(nullptr, allocation); EXPECT_EQ(1u, allocation->fragmentsStorage.fragmentCount); - EXPECT_FALSE(allocation->flushL3Required); + EXPECT_FALSE(allocation->isFlushL3Required()); EXPECT_EQ(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, allocation->getAllocationType()); memoryManager.freeGraphicsMemory(allocation); @@ -1088,7 +1088,7 @@ TEST_P(OsAgnosticMemoryManagerWithParams, givenDisabledHostPtrTrackingWhenAlloca auto allocation = memoryManager.allocateGraphicsMemoryForHostPtr(13, hostPtr, true, requiresL3Flush); EXPECT_NE(nullptr, allocation); EXPECT_EQ(0u, allocation->fragmentsStorage.fragmentCount); - EXPECT_EQ(requiresL3Flush, allocation->flushL3Required); + EXPECT_EQ(requiresL3Flush, allocation->isFlushL3Required()); memoryManager.freeGraphicsMemory(allocation); } @@ -1623,21 +1623,21 @@ TEST(OsContextTest, givenOsContextWithNumberOfSupportedDevicesWhenConstructingTh TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false}; - allocation.is32BitAllocation = true; + allocation.set32BitAllocation(true); allocation.setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA); EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0])); } TEST(HeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false}; - allocation.is32BitAllocation = false; + allocation.set32BitAllocation(false); allocation.setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA); EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0])); } TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) { GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false}; - allocation.is32BitAllocation = true; + allocation.set32BitAllocation(true); EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectHeap(&allocation, nullptr, *platformDevices[0])); } diff --git a/unit_tests/mocks/mock_wddm.cpp b/unit_tests/mocks/mock_wddm.cpp index fdcdad3bf3..f0a88f1f60 100644 --- a/unit_tests/mocks/mock_wddm.cpp +++ b/unit_tests/mocks/mock_wddm.cpp @@ -90,7 +90,7 @@ bool WddmMock::destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext) allocationCount = 1; } auto success = destroyAllocations(allocationHandles, allocationCount, resourceHandle); - ::alignedFree(alloc->driverAllocatedCpuPointer); + ::alignedFree(alloc->getDriverAllocatedCpuPtr()); releaseReservedAddress(reserveAddress); return success; } diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index 65c9390fd1..e877f00ed8 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -772,9 +772,9 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32 } auto bo = allocation->getBO(); EXPECT_GE(bo->peekUnmapSize(), 0u); - EXPECT_TRUE(allocation->is32BitAllocation); + EXPECT_TRUE(allocation->is32BitAllocation()); - EXPECT_EQ(memoryManager->allocator32Bit->getBase(), allocation->gpuBaseAddress); + EXPECT_EQ(memoryManager->allocator32Bit->getBase(), allocation->getGpuBaseAddress()); EXPECT_EQ(bo->peekAllocationType(), StorageAllocatorType::BIT32_ALLOCATOR_EXTERNAL); @@ -844,7 +844,7 @@ TEST_F(DrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferAllocationThen EXPECT_TRUE(buffer->isMemObjZeroCopy()); auto bufferAddress = buffer->getGraphicsAllocation()->getGpuAddress(); - auto baseAddress = buffer->getGraphicsAllocation()->gpuBaseAddress; + auto baseAddress = buffer->getGraphicsAllocation()->getGpuBaseAddress(); uintptr_t address64bit = (uintptr_t)bufferAddress; @@ -887,11 +887,11 @@ TEST_F(DrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFromHos uintptr_t address64bitOnGpu = (uintptr_t)bufferAddress; if (is32BitOsAllocatorAvailable) { - auto baseAddress = buffer->getGraphicsAllocation()->gpuBaseAddress; + auto baseAddress = buffer->getGraphicsAllocation()->getGpuBaseAddress(); EXPECT_LT(address64bitOnGpu - baseAddress, max32BitAddress); } - EXPECT_TRUE(drmAllocation->is32BitAllocation); + EXPECT_TRUE(drmAllocation->is32BitAllocation()); auto allocationCpuPtr = (uintptr_t)drmAllocation->getUnderlyingBuffer(); auto allocationPageOffset = allocationCpuPtr - alignDown(allocationCpuPtr, MemoryConstants::pageSize); @@ -953,13 +953,13 @@ TEST_F(DrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFrom64B uintptr_t address64bit = (uintptr_t)bufferAddress; if (is32BitOsAllocatorAvailable) { - auto baseAddress = buffer->getGraphicsAllocation()->gpuBaseAddress; + auto baseAddress = buffer->getGraphicsAllocation()->getGpuBaseAddress(); EXPECT_LT(address64bit - baseAddress, max32BitAddress); } auto drmAllocation = static_cast(buffer->getGraphicsAllocation()); - EXPECT_TRUE(drmAllocation->is32BitAllocation); + EXPECT_TRUE(drmAllocation->is32BitAllocation()); auto allocationCpuPtr = (uintptr_t)drmAllocation->getUnderlyingBuffer(); auto allocationPageOffset = allocationCpuPtr - alignDown(allocationCpuPtr, MemoryConstants::pageSize); @@ -1124,8 +1124,8 @@ TEST_F(DrmMemoryManagerTest, GivenSizeAbove2GBWhenUseHostPtrAndAllocHostPtrAreCr if (is32BitOsAllocatorAvailable && buffer) { auto bufferPtr = buffer->getGraphicsAllocation()->getGpuAddress(); - EXPECT_TRUE(buffer->getGraphicsAllocation()->is32BitAllocation); - auto baseAddress = buffer->getGraphicsAllocation()->gpuBaseAddress; + EXPECT_TRUE(buffer->getGraphicsAllocation()->is32BitAllocation()); + auto baseAddress = buffer->getGraphicsAllocation()->getGpuBaseAddress(); EXPECT_LT((uintptr_t)(bufferPtr - baseAddress), max32BitAddress); } @@ -1166,8 +1166,8 @@ TEST_F(DrmMemoryManagerTest, GivenSizeAbove2GBWhenAllocHostPtrAndUseHostPtrAreCr if (is32BitOsAllocatorAvailable && buffer) { auto bufferPtr = buffer->getGraphicsAllocation()->getGpuAddress(); - EXPECT_TRUE(buffer->getGraphicsAllocation()->is32BitAllocation); - auto baseAddress = buffer->getGraphicsAllocation()->gpuBaseAddress; + EXPECT_TRUE(buffer->getGraphicsAllocation()->is32BitAllocation()); + auto baseAddress = buffer->getGraphicsAllocation()->getGpuBaseAddress(); EXPECT_LT((uintptr_t)(bufferPtr - baseAddress), max32BitAddress); } @@ -1714,7 +1714,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesWhenReuseCrea } } -TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBitnessRequiredIsCreatedThenItIs32BitAllocation) { +TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBitnessRequiredIsCreatedThenItis32BitAllocation) { mock->ioctl_expected.primeFdToHandle = 1; mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; @@ -1724,7 +1724,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi this->mock->outputHandle = 2u; auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, true); auto drmAllocation = static_cast(graphicsAllocation); - EXPECT_TRUE(graphicsAllocation->is32BitAllocation); + EXPECT_TRUE(graphicsAllocation->is32BitAllocation()); EXPECT_EQ(1, lseekCalledCount); EXPECT_EQ(BIT32_ALLOCATOR_EXTERNAL, drmAllocation->getBO()->peekAllocationType()); memoryManager->freeGraphicsMemory(graphicsAllocation); @@ -1743,7 +1743,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleIsCre auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, false); auto drmAllocation = static_cast(graphicsAllocation); - EXPECT_FALSE(graphicsAllocation->is32BitAllocation); + EXPECT_FALSE(graphicsAllocation->is32BitAllocation()); EXPECT_EQ(1, lseekCalledCount); if (memoryManager->getDrmLimitedRangeAllocator() != nullptr) { @@ -1769,7 +1769,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenBufferFromSharedHandl osHandle handle = 1u; this->mock->outputHandle = 2u; auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, false); - EXPECT_FALSE(graphicsAllocation->is32BitAllocation); + EXPECT_FALSE(graphicsAllocation->is32BitAllocation()); auto drmAllocation = static_cast(graphicsAllocation); EXPECT_EQ(INTERNAL_ALLOCATOR_WITH_DYNAMIC_BITRANGE, drmAllocation->getBO()->peekAllocationType()); EXPECT_EQ(1, lseekCalledCount); @@ -1786,7 +1786,7 @@ TEST_F(DrmMemoryManagerTest, givenNon32BitAddressingWhenBufferFromSharedHandleIs this->mock->outputHandle = 2u; auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, true); auto drmAllocation = static_cast(graphicsAllocation); - EXPECT_FALSE(graphicsAllocation->is32BitAllocation); + EXPECT_FALSE(graphicsAllocation->is32BitAllocation()); EXPECT_EQ(1, lseekCalledCount); if (memoryManager->getDrmLimitedRangeAllocator() != nullptr) { @@ -2177,7 +2177,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit EXPECT_NE(nullptr, drmAllocation->getUnderlyingBuffer()); EXPECT_EQ(bufferSize, drmAllocation->getUnderlyingBufferSize()); - EXPECT_TRUE(drmAllocation->is32BitAllocation); + EXPECT_TRUE(drmAllocation->is32BitAllocation()); auto gpuPtr = drmAllocation->getGpuAddress(); @@ -2187,7 +2187,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit EXPECT_GE(gpuPtr, heapBase); EXPECT_LE(gpuPtr, heapBase + heapSize); - EXPECT_EQ(drmAllocation->gpuBaseAddress, heapBase); + EXPECT_EQ(drmAllocation->getGpuBaseAddress(), heapBase); auto bo = drmAllocation->getBO(); EXPECT_TRUE(bo->peekIsAllocated()); @@ -2214,10 +2214,10 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc EXPECT_NE(nullptr, drmAllocation->getUnderlyingBuffer()); EXPECT_EQ(bufferSize, drmAllocation->getUnderlyingBufferSize()); - ASSERT_NE(nullptr, drmAllocation->driverAllocatedCpuPointer); - EXPECT_EQ(drmAllocation->driverAllocatedCpuPointer, drmAllocation->getUnderlyingBuffer()); + ASSERT_NE(nullptr, drmAllocation->getDriverAllocatedCpuPtr()); + EXPECT_EQ(drmAllocation->getDriverAllocatedCpuPtr(), drmAllocation->getUnderlyingBuffer()); - EXPECT_TRUE(drmAllocation->is32BitAllocation); + EXPECT_TRUE(drmAllocation->is32BitAllocation()); auto gpuPtr = drmAllocation->getGpuAddress(); @@ -2227,7 +2227,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc EXPECT_GE(gpuPtr, heapBase); EXPECT_LE(gpuPtr, heapBase + heapSize); - EXPECT_EQ(drmAllocation->gpuBaseAddress, heapBase); + EXPECT_EQ(drmAllocation->getGpuBaseAddress(), heapBase); auto bo = drmAllocation->getBO(); EXPECT_TRUE(bo->peekIsAllocated()); @@ -2251,7 +2251,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForExternalAlloc ASSERT_NE(nullptr, drmAllocation); EXPECT_NE(nullptr, drmAllocation->getUnderlyingBuffer()); - EXPECT_TRUE(drmAllocation->is32BitAllocation); + EXPECT_TRUE(drmAllocation->is32BitAllocation()); memoryManager->freeGraphicsMemory(drmAllocation); } @@ -2281,7 +2281,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit EXPECT_EQ(ptr, drmAllocation->getUnderlyingBuffer()); EXPECT_EQ(bufferSize, drmAllocation->getUnderlyingBufferSize()); - EXPECT_TRUE(drmAllocation->is32BitAllocation); + EXPECT_TRUE(drmAllocation->is32BitAllocation()); auto gpuPtr = drmAllocation->getGpuAddress(); @@ -2291,7 +2291,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit EXPECT_GE(gpuPtr, heapBase); EXPECT_LE(gpuPtr, heapBase + heapSize); - EXPECT_EQ(drmAllocation->gpuBaseAddress, heapBase); + EXPECT_EQ(drmAllocation->getGpuBaseAddress(), heapBase); auto bo = drmAllocation->getBO(); EXPECT_FALSE(bo->peekIsAllocated()); @@ -2717,9 +2717,9 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForN auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(13, hostPtr); EXPECT_NE(nullptr, allocation); - EXPECT_EQ(0x5001u, reinterpret_cast(allocation->getUnderlyingBuffer()) + allocation->allocationOffset); + EXPECT_EQ(0x5001u, reinterpret_cast(allocation->getUnderlyingBuffer()) + allocation->getAllocationOffset()); EXPECT_EQ(13u, allocation->getUnderlyingBufferSize()); - EXPECT_EQ(1u, allocation->allocationOffset); + EXPECT_EQ(1u, allocation->getAllocationOffset()); memoryManager->freeGraphicsMemory(allocation); } @@ -2985,9 +2985,9 @@ TEST_F(DrmMemoryManagerTest, givenDisabledHostPtrTrackingWhenAllocateGraphicsMem auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(13, hostPtr); EXPECT_NE(nullptr, allocation); - EXPECT_EQ(0x5001u, reinterpret_cast(allocation->getUnderlyingBuffer()) + allocation->allocationOffset); + EXPECT_EQ(0x5001u, reinterpret_cast(allocation->getUnderlyingBuffer()) + allocation->getAllocationOffset()); EXPECT_EQ(13u, allocation->getUnderlyingBufferSize()); - EXPECT_EQ(1u, allocation->allocationOffset); + EXPECT_EQ(1u, allocation->getAllocationOffset()); memoryManager->freeGraphicsMemory(allocation); } diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index fccca6f266..3f5e07a1df 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -263,7 +263,7 @@ TEST_F(Wddm20Tests, createAllocation32bit) { Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); allocation.gmm = gmm; - allocation.is32BitAllocation = true; // mark 32 bit allocation + allocation.set32BitAllocation(true); // mark 32 bit allocation auto status = wddm->createAllocation(&allocation); diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index e0ef456256..6803130e92 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -228,7 +228,7 @@ TEST_F(WddmMemoryManagerSimpleTest, EXPECT_NE(nullptr, allocation); EXPECT_EQ(reinterpret_cast(0x5001), allocation->getUnderlyingBuffer()); EXPECT_EQ(13u, allocation->getUnderlyingBufferSize()); - EXPECT_EQ(1u, allocation->allocationOffset); + EXPECT_EQ(1u, allocation->getAllocationOffset()); memoryManager->freeGraphicsMemory(allocation); } @@ -385,10 +385,10 @@ TEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleReturns32BitAllocW auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, true); ASSERT_NE(nullptr, gpuAllocation); if (is64bit) { - EXPECT_TRUE(gpuAllocation->is32BitAllocation); + EXPECT_TRUE(gpuAllocation->is32BitAllocation()); uint64_t base = memoryManager->allocator32Bit->getBase(); - EXPECT_EQ(GmmHelper::canonize(base), gpuAllocation->gpuBaseAddress); + EXPECT_EQ(GmmHelper::canonize(base), gpuAllocation->getGpuBaseAddress()); } memoryManager->freeGraphicsMemory(gpuAllocation); @@ -406,10 +406,10 @@ TEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleDoesNotReturn32Bit auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, false); ASSERT_NE(nullptr, gpuAllocation); - EXPECT_FALSE(gpuAllocation->is32BitAllocation); + EXPECT_FALSE(gpuAllocation->is32BitAllocation()); if (is64bit) { uint64_t base = 0; - EXPECT_EQ(base, gpuAllocation->gpuBaseAddress); + EXPECT_EQ(base, gpuAllocation->getGpuBaseAddress()); } memoryManager->freeGraphicsMemory(gpuAllocation); @@ -748,7 +748,7 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotDoT void *alignedPtr = alignDown(misalignedPtr, MemoryConstants::allocationAlignment); uint64_t offset = ptrDiff(misalignedPtr, alignedPtr); - EXPECT_EQ(offset, gpuAllocation->allocationOffset); + EXPECT_EQ(offset, gpuAllocation->getAllocationOffset()); memoryManager->freeGraphicsMemory(gpuAllocation); } @@ -758,7 +758,7 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemorySetsCannonizedGpuBaseAddress) { ASSERT_NE(nullptr, gpuAllocation); uint64_t cannonizedAddress = GmmHelper::canonize(wddm->getExternalHeapBase()); - EXPECT_EQ(cannonizedAddress, gpuAllocation->gpuBaseAddress); + EXPECT_EQ(cannonizedAddress, gpuAllocation->getGpuBaseAddress()); memoryManager->freeGraphicsMemory(gpuAllocation); } @@ -874,7 +874,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) { auto wddmAllocation = static_cast(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP)); ASSERT_NE(nullptr, wddmAllocation); - EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress())); + EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress())); EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); @@ -884,8 +884,8 @@ TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocatio EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd); - EXPECT_NE(nullptr, wddmAllocation->driverAllocatedCpuPointer); - EXPECT_TRUE(wddmAllocation->is32BitAllocation); + EXPECT_NE(nullptr, wddmAllocation->getDriverAllocatedCpuPtr()); + EXPECT_TRUE(wddmAllocation->is32BitAllocation()); memoryManager->freeGraphicsMemory(wddmAllocation); } @@ -893,7 +893,7 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe auto ptr = reinterpret_cast(0x1000000); auto wddmAllocation = static_cast(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP)); ASSERT_NE(nullptr, wddmAllocation); - EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress())); + EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress())); EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); @@ -903,8 +903,8 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd); - EXPECT_EQ(nullptr, wddmAllocation->driverAllocatedCpuPointer); - EXPECT_TRUE(wddmAllocation->is32BitAllocation); + EXPECT_EQ(nullptr, wddmAllocation->getDriverAllocatedCpuPtr()); + EXPECT_TRUE(wddmAllocation->is32BitAllocation()); memoryManager->freeGraphicsMemory(wddmAllocation); } @@ -1038,7 +1038,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati EXPECT_EQ(ptr, allocation->getUnderlyingBuffer()); EXPECT_EQ(size, allocation->getUnderlyingBufferSize()); EXPECT_EQ(gpuAdress, allocation->getGpuAddress()); - EXPECT_EQ(0ULL, allocation->allocationOffset); + EXPECT_EQ(0ULL, allocation->getAllocationOffset()); memoryManager->freeGraphicsMemory(allocation); } @@ -1075,7 +1075,7 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati EXPECT_EQ(allocationPtr, allocation->getUnderlyingBuffer()); EXPECT_EQ(size, allocation->getUnderlyingBufferSize()); EXPECT_EQ(gpuAdress + offset, allocation->getGpuAddress()); // getGpuAddress returns gpuAddress + allocationOffset - EXPECT_EQ(offset, allocation->allocationOffset); + EXPECT_EQ(offset, allocation->getAllocationOffset()); memoryManager->freeGraphicsMemory(allocation); } diff --git a/unit_tests/program/program_data_tests.cpp b/unit_tests/program/program_data_tests.cpp index 9db3bf1a6d..f887b53634 100644 --- a/unit_tests/program/program_data_tests.cpp +++ b/unit_tests/program/program_data_tests.cpp @@ -214,7 +214,7 @@ TEST_F(ProgramDataTest, GivenDeviceForcing32BitMessagesWhenConstAllocationIsPres EXPECT_EQ(0, memcmp(constValue, reinterpret_cast(pProgram->getConstantSurface()->getUnderlyingBuffer()), constSize)); if (is64bit) { - EXPECT_TRUE(pProgram->getConstantSurface()->is32BitAllocation); + EXPECT_TRUE(pProgram->getConstantSurface()->is32BitAllocation()); } } @@ -370,7 +370,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { auto globalSurface = pProgram->getGlobalSurface(); - if (!globalSurface->is32BitAllocation) { + if (!globalSurface->is32BitAllocation()) { EXPECT_NE(0, memcmp(&pGlobalPointerValue, reinterpret_cast(pProgram->getGlobalSurface()->getUnderlyingBuffer()), globalPointerSize)); ptr = pGlobalPointerValue + reinterpret_cast(pProgram->getGlobalSurface()->getUnderlyingBuffer()); EXPECT_EQ(0, memcmp(&ptr, reinterpret_cast(pProgram->getGlobalSurface()->getUnderlyingBuffer()), globalPointerSize)); @@ -408,7 +408,7 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa EXPECT_NE(nullptr, pProgram->getGlobalSurface()); EXPECT_EQ(0, memcmp(globalValue, reinterpret_cast(pProgram->getGlobalSurface()->getUnderlyingBuffer()), globalSize)); if (is64bit) { - EXPECT_TRUE(pProgram->getGlobalSurface()->is32BitAllocation); + EXPECT_TRUE(pProgram->getGlobalSurface()->is32BitAllocation()); } delete[] pAllocateGlobalMemorySurface; @@ -478,7 +478,7 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { // once finally constant buffer offset gets patched - the patch value depends on the bitness of the compute kernel auto patchOffsetValueStorage = std::unique_ptr(new uint64_t); // 4bytes for 32-bit compute kernel, full 8byte for 64-bit compute kernel uint64_t *patchOffsetValue = patchOffsetValueStorage.get(); - if (pProgram->getConstantSurface()->is32BitAllocation || (sizeof(void *) == 4)) { + if (pProgram->getConstantSurface()->is32BitAllocation() || (sizeof(void *) == 4)) { reinterpret_cast(patchOffsetValue)[0] = static_cast(pProgram->getConstantSurface()->getGpuAddressToPatch()); reinterpret_cast(patchOffsetValue)[1] = 0; // just pad with 0 } else { @@ -615,7 +615,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantB MockBuffer constantSurface; ASSERT_LT(8U, constantSurface.getSize()); prog->setConstantSurface(&constantSurface.mockGfxAllocation); - constantSurface.mockGfxAllocation.is32BitAllocation = true; + constantSurface.mockGfxAllocation.set32BitAllocation(true); uint32_t *constantSurfaceStorage = reinterpret_cast(constantSurface.getCpuAddress()); uint32_t sentinel = 0x17192329U; constantSurfaceStorage[0] = 0U; @@ -624,7 +624,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantB uint32_t expectedAddr = static_cast(constantSurface.getGraphicsAllocation()->getGpuAddressToPatch()); EXPECT_EQ(expectedAddr, constantSurfaceStorage[0]); EXPECT_EQ(sentinel, constantSurfaceStorage[1]); - constantSurface.mockGfxAllocation.is32BitAllocation = false; + constantSurface.mockGfxAllocation.set32BitAllocation(false); prog->setConstantSurface(nullptr); } @@ -657,7 +657,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeGlobalPoi MockBuffer globalSurface; ASSERT_LT(8U, globalSurface.getSize()); prog->setGlobalSurface(&globalSurface.mockGfxAllocation); - globalSurface.mockGfxAllocation.is32BitAllocation = true; + globalSurface.mockGfxAllocation.set32BitAllocation(true); uint32_t *globalSurfaceStorage = reinterpret_cast(globalSurface.getCpuAddress()); uint32_t sentinel = 0x17192329U; globalSurfaceStorage[0] = 0U; @@ -666,6 +666,6 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeGlobalPoi uint32_t expectedAddr = static_cast(globalSurface.getGraphicsAllocation()->getGpuAddressToPatch()); EXPECT_EQ(expectedAddr, globalSurfaceStorage[0]); EXPECT_EQ(sentinel, globalSurfaceStorage[1]); - globalSurface.mockGfxAllocation.is32BitAllocation = false; + globalSurface.mockGfxAllocation.set32BitAllocation(false); prog->setGlobalSurface(nullptr); } diff --git a/unit_tests/program/program_tests.cpp b/unit_tests/program/program_tests.cpp index 546376e473..cc5e532290 100644 --- a/unit_tests/program/program_tests.cpp +++ b/unit_tests/program/program_tests.cpp @@ -639,16 +639,16 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi auto graphicsAllocation = kernelInfo->getGraphicsAllocation(); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_TRUE(graphicsAllocation->is32BitAllocation); + EXPECT_TRUE(graphicsAllocation->is32BitAllocation()); EXPECT_EQ(graphicsAllocation->getUnderlyingBufferSize(), kernelInfo->heapInfo.pKernelHeader->KernelHeapSize); 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->gpuBaseAddress); + EXPECT_EQ(0u, graphicsAllocation->getGpuBaseAddress()); } else { - EXPECT_NE(0u, graphicsAllocation->gpuBaseAddress); + EXPECT_NE(0u, graphicsAllocation->getGpuBaseAddress()); } } diff --git a/unit_tests/sharings/gl/gl_sharing_tests.cpp b/unit_tests/sharings/gl/gl_sharing_tests.cpp index 755933bd12..42dd1b0874 100644 --- a/unit_tests/sharings/gl/gl_sharing_tests.cpp +++ b/unit_tests/sharings/gl/gl_sharing_tests.cpp @@ -150,7 +150,7 @@ TEST_F(glSharingTests, givenContextAnd32BitAddressingWhenClCreateFromGlBufferIsC ASSERT_EQ(CL_SUCCESS, retVal); ASSERT_NE(nullptr, glBuffer); - EXPECT_TRUE(castToObject(glBuffer)->getGraphicsAllocation()->is32BitAllocation); + EXPECT_TRUE(castToObject(glBuffer)->getGraphicsAllocation()->is32BitAllocation()); retVal = clReleaseMemObject(glBuffer); EXPECT_EQ(CL_SUCCESS, retVal); diff --git a/unit_tests/sharings/gl/gl_texture_tests.cpp b/unit_tests/sharings/gl/gl_texture_tests.cpp index a66f804983..77cb3a1c8b 100644 --- a/unit_tests/sharings/gl/gl_texture_tests.cpp +++ b/unit_tests/sharings/gl/gl_texture_tests.cpp @@ -393,7 +393,7 @@ TEST_F(GlSharingTextureTests, verifyGlTextureBufferOffset) { EXPECT_EQ(CL_SUCCESS, retVal); auto memObj = castToObject(glImage); EXPECT_NE(memObj, nullptr); - EXPECT_EQ(memObj->getGraphicsAllocation()->allocationOffset, 0u); + EXPECT_EQ(memObj->getGraphicsAllocation()->getAllocationOffset(), 0u); retVal = clEnqueueReleaseGLObjects(commandQueue, 1, &glImage, 0, nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, retVal); @@ -403,7 +403,7 @@ TEST_F(GlSharingTextureTests, verifyGlTextureBufferOffset) { EXPECT_EQ(CL_SUCCESS, retVal); memObj = castToObject(glImage); EXPECT_NE(memObj, nullptr); - EXPECT_EQ(memObj->getGraphicsAllocation()->allocationOffset, 0x660u); + EXPECT_EQ(memObj->getGraphicsAllocation()->getAllocationOffset(), 0x660u); retVal = clEnqueueReleaseGLObjects(commandQueue, 1, &glImage, 0, nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, retVal);