fix: reorder members in BufferObject class

Related-To: HSD-13011781488
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-03-25 10:39:49 +00:00
committed by Compute-Runtime-Automation
parent fd34df899c
commit 6af9856e33
9 changed files with 37 additions and 36 deletions

View File

@@ -515,7 +515,7 @@ bool DrmAllocation::setMemPrefetch(Drm *drm, SubDeviceIdsVec &subDeviceIds) {
}
} else {
auto bo = this->getBO();
if (bo->isChunked) {
if (bo->isChunked()) {
auto drm = bo->peekDrm();
success = prefetchBOWithChunking(const_cast<Drm *>(drm));
} else {

View File

@@ -81,7 +81,7 @@ BufferObject::BufferObject(uint32_t rootDeviceIndex, Drm *drm, uint64_t patIndex
: BufferObject(rootDeviceIndex, drm, patIndex, BufferObjectHandleWrapper{handle}, size, maxOsContextCount) {}
BufferObject::BufferObject(uint32_t rootDeviceIndex, Drm *drm, uint64_t patIndex, BufferObjectHandleWrapper &&handle, size_t size, size_t maxOsContextCount)
: drm(drm), refCount(1), rootDeviceIndex(rootDeviceIndex), handle(std::move(handle)), size(size) {
: drm(drm), handle(std::move(handle)), size(size), refCount(1), rootDeviceIndex(rootDeviceIndex) {
auto ioctlHelper = drm->getIoctlHelper();
this->tilingMode = ioctlHelper->getDrmParamValue(DrmParam::tilingNone);

View File

@@ -223,9 +223,11 @@ class BufferObject {
static constexpr int gpuHangDetected{-7171};
uint32_t getOsContextId(OsContext *osContext);
std::vector<std::array<bool, EngineLimits::maxHandleCount>> bindInfo;
bool isChunked = false;
const auto &getBindInfo() const { return bindInfo; }
void setChunked(bool chunked) { this->chunked = chunked; }
bool isChunked() const { return this->chunked; }
protected:
MOCKABLE_VIRTUAL MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded);
@@ -233,35 +235,34 @@ class BufferObject {
void printBOBindingResult(OsContext *osContext, uint32_t vmHandleId, bool bind, int retVal);
Drm *drm = nullptr;
bool perContextVmsUsed = false;
std::atomic<uint32_t> refCount;
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
uint32_t tilingMode;
BufferObjectHandleWrapper handle; // i915 gem object handle
bool isReused = false;
bool boHandleShared = false;
bool allowCapture = false;
bool requiresImmediateBinding = false;
bool requiresExplicitResidency = false;
void *lockedAddress = nullptr; // CPU side virtual address
bool requiresLocked = false;
BOType boType = BOType::legacy;
uint64_t size;
uint64_t size = 0;
uint64_t unmapSize = 0;
uint64_t patIndex = CommonConstants::unsupportedPatIndex;
uint64_t userptr = 0u;
CacheRegion cacheRegion = CacheRegion::defaultRegion;
CachePolicy cachePolicy = CachePolicy::writeBack;
StackVec<uint32_t, 2> bindExtHandles;
bool colourWithBind = false;
size_t colourChunk = 0;
std::vector<uint64_t> bindAddresses;
private:
uint64_t gpuAddress = 0llu;
std::vector<uint64_t> bindAddresses;
std::vector<std::array<bool, EngineLimits::maxHandleCount>> bindInfo;
StackVec<uint32_t, 2> bindExtHandles;
BOType boType = BOType::legacy;
std::atomic<uint32_t> refCount;
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
uint32_t tilingMode = 0;
CachePolicy cachePolicy = CachePolicy::writeBack;
CacheRegion cacheRegion = CacheRegion::defaultRegion;
bool colourWithBind = false;
bool perContextVmsUsed = false;
bool boHandleShared = false;
bool allowCapture = false;
bool requiresImmediateBinding = false;
bool requiresExplicitResidency = false;
bool requiresLocked = false;
bool chunked = false;
bool isReused = false;
};
} // namespace NEO

View File

@@ -2024,7 +2024,7 @@ bool DrmMemoryManager::createDrmChunkedAllocation(Drm *drm, DrmAllocation *alloc
allocation->getBufferObjectToModify(0) = bo;
bo->isChunked = 1;
bo->setChunked(true);
storageInfo.isChunked = true;
storageInfo.numOfChunks = numOfChunks;
@@ -2480,7 +2480,7 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
bo->setAddress(castToUint64(currentAddress));
bo->isChunked = useChunking;
bo->setChunked(useChunking);
bos.push_back(bo.release());

View File

@@ -65,7 +65,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsConte
bo = drmAllocation->getBO();
}
if (!bo->bindInfo[bo->getOsContextId(osContext)][drmIterator]) {
if (!bo->getBindInfo()[bo->getOsContextId(osContext)][drmIterator]) {
bo->requireExplicitLockedMemory(drmAllocation->isLockedMemory());
int result = drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true);
if (result) {

View File

@@ -6417,7 +6417,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenAllocati
auto bo = bos[handleId];
auto contextId = bo->getOsContextId(osContext);
ASSERT_NE(nullptr, bo);
EXPECT_FALSE(bo->bindInfo[contextId][handleId]);
EXPECT_FALSE(bo->getBindInfo()[contextId][handleId]);
}
EXPECT_EQ(0u, allocation->getGpuAddress());
memoryManager->freeGraphicsMemory(allocation);

View File

@@ -570,7 +570,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest,
auto size = 4096u;
BufferObjects bos;
MockBufferObject mockBo(device->getRootDeviceIndex(), mock, 3, 0, 0, 1);
mockBo.isChunked = 1;
mockBo.setChunked(true);
mockBo.setSize(1024);
bos.push_back(&mockBo);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -71,7 +71,7 @@ TEST(DrmVmBindTest,
for (auto requireResidency : {false, true}) {
MockBufferObject bo(0, &drm, 3, 0, 0, 1);
bo.isChunked = true;
bo.setChunked(true);
bo.requireExplicitResidency(requireResidency);
OsContextLinux osContext(drm, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());

View File

@@ -573,7 +573,7 @@ TEST_F(IoctlHelperPrelimFixture,
drm->ioctlCallsCount = 0;
MockBufferObject bo(0u, drm.get(), 3, 0, 0, 1);
bo.isChunked = 1;
bo.setChunked(true);
bo.setSize(1024);
MockDrmAllocation allocation(0u, AllocationType::buffer, MemoryPool::localMemory);
allocation.bufferObjects[0] = &bo;
@@ -602,7 +602,7 @@ TEST_F(IoctlHelperPrelimFixture,
drm->ioctlCallsCount = 0;
MockBufferObject bo(0u, drm.get(), 3, 0, 0, 1);
bo.isChunked = 1;
bo.setChunked(true);
bo.setSize(1024);
MockDrmAllocation allocation(0u, AllocationType::buffer, MemoryPool::localMemory);
allocation.bufferObjects[0] = &bo;