Minor renaming in a scope of multi os context allocations:

shareable -> multiOsContextCapable
resetTaskCount -> releaseUsageInOsContext
resetResidencyTaskCount -> releaseResidencyInOsContext
isUsedByContext -> isUsedByOsContext

Change-Id: If824246a0e393b962bd12f8c63d429a0fcfcda25
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-01-07 09:29:49 +01:00
committed by sys_ocldev
parent b962e721fd
commit aee69779fa
23 changed files with 92 additions and 92 deletions

View File

@@ -746,7 +746,7 @@ template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.isResident(this->osContext->getContextId())) {
this->getEvictionAllocations().push_back(&gfxAllocation);
gfxAllocation.resetResidencyTaskCount(this->osContext->getContextId());
gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId());
}
}

View File

@@ -87,7 +87,7 @@ void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
}
}
gfxAllocation.resetResidencyTaskCount(this->osContext->getContextId());
gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId());
}
void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -20,10 +20,10 @@ bool DeferrableAllocationDeletion::apply() {
for (auto &deviceCsrs : memoryManager.getCommandStreamReceivers()) {
for (auto &csr : deviceCsrs) {
auto contextId = csr->getOsContext().getContextId();
if (graphicsAllocation.isUsedByContext(contextId)) {
if (graphicsAllocation.isUsedByOsContext(contextId)) {
auto currentContextTaskCount = *csr->getTagAddress();
if (graphicsAllocation.getTaskCount(contextId) <= currentContextTaskCount) {
graphicsAllocation.resetTaskCount(contextId);
graphicsAllocation.releaseUsageInOsContext(contextId);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -16,19 +16,19 @@ bool GraphicsAllocation::isL3Capable() {
}
return false;
}
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, uint32_t osContextCount, bool shareable) : gpuBaseAddress(baseAddress),
size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(gpuAddress),
shareable(shareable) {
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, uint32_t osContextCount, bool multiOsContextCapable) : gpuBaseAddress(baseAddress),
size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(gpuAddress),
multiOsContextCapable(multiOsContextCapable) {
usageInfos.resize(maxOsContextCount);
}
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, uint32_t osContextCount, bool shareable) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(castToUint64(cpuPtrIn)),
sharedHandle(sharedHandleIn),
shareable(shareable) {
GraphicsAllocation::GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, uint32_t osContextCount, bool multiOsContextCapable) : size(sizeIn),
cpuPtr(cpuPtrIn),
gpuAddress(castToUint64(cpuPtrIn)),
sharedHandle(sharedHandleIn),
multiOsContextCapable(multiOsContextCapable) {
usageInfos.resize(maxOsContextCount);
}
GraphicsAllocation::~GraphicsAllocation() = default;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -71,9 +71,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
GraphicsAllocation &operator=(const GraphicsAllocation &) = delete;
GraphicsAllocation(const GraphicsAllocation &) = delete;
GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, uint32_t osContextCount, bool isShareable);
GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, uint32_t osContextCount, bool multiOsContextCapable);
GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, uint32_t osContextCount, bool isShareable);
GraphicsAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, uint32_t osContextCount, bool multiOsContextCapable);
void *getUnderlyingBuffer() const { return cpuPtr; }
void setCpuPtrAndGpuAddress(void *cpuPtr, uint64_t gpuAddress) {
@@ -121,19 +121,19 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
return memoryPool;
}
bool isUsed() const { return registeredContextsNum > 0; }
bool isUsedByContext(uint32_t contextId) const { return objectNotUsed != getTaskCount(contextId); }
bool isUsedByOsContext(uint32_t contextId) const { return objectNotUsed != getTaskCount(contextId); }
void updateTaskCount(uint32_t newTaskCount, uint32_t contextId);
uint32_t getTaskCount(uint32_t contextId) const { return usageInfos[contextId].taskCount; }
void resetTaskCount(uint32_t contextId) { updateTaskCount(objectNotUsed, contextId); }
void releaseUsageInOsContext(uint32_t contextId) { updateTaskCount(objectNotUsed, contextId); }
uint32_t getInspectionId(uint32_t contextId) { return usageInfos[contextId].inspectionId; }
void setInspectionId(uint32_t newInspectionId, uint32_t contextId) { usageInfos[contextId].inspectionId = newInspectionId; }
void updateResidencyTaskCount(uint32_t newTaskCount, uint32_t contextId) { usageInfos[contextId].residencyTaskCount = newTaskCount; }
uint32_t getResidencyTaskCount(uint32_t contextId) const { return usageInfos[contextId].residencyTaskCount; }
void resetResidencyTaskCount(uint32_t contextId) { updateResidencyTaskCount(objectNotResident, contextId); }
void releaseResidencyInOsContext(uint32_t contextId) { updateResidencyTaskCount(objectNotResident, contextId); }
bool isResidencyTaskCountBelow(uint32_t taskCount, uint32_t contextId) { return !isResident(contextId) || getResidencyTaskCount(contextId) < taskCount; }
bool isShareable() const { return shareable; }
bool isMultiOsContextCapable() const { return multiOsContextCapable; }
protected:
constexpr static uint32_t objectNotResident = (uint32_t)-1;
@@ -162,6 +162,6 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
bool memObjectsAllocationWithWritableFlags = false;
std::vector<UsageInfo> usageInfos;
std::atomic<uint32_t> registeredContextsNum{0};
bool shareable = false;
bool multiOsContextCapable = false;
};
} // namespace OCLRT

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -145,7 +145,7 @@ void MemoryManager::checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocatio
auto osContextId = csr->getOsContext().getContextId();
auto allocationTaskCount = gfxAllocation->getTaskCount(osContextId);
if (gfxAllocation->isUsedByContext(osContextId) &&
if (gfxAllocation->isUsedByOsContext(osContextId) &&
allocationTaskCount > *csr->getTagAddress()) {
csr->getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(gfxAllocation), TEMPORARY_ALLOCATION);
return;
@@ -194,7 +194,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
bool forcePin = properties.flags.forcePin;
bool uncacheable = properties.flags.uncacheable;
bool mustBeZeroCopy = false;
bool shareable = properties.flags.shareable;
bool multiOsContextCapable = properties.flags.multiOsContextCapable;
switch (properties.allocationType) {
case GraphicsAllocation::AllocationType::BUFFER:
@@ -263,7 +263,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
allocationData.flags.uncacheable = uncacheable;
allocationData.flags.flushL3 = properties.flags.flushL3RequiredForRead | properties.flags.flushL3RequiredForWrite;
allocationData.flags.preferRenderCompressed = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED == properties.allocationType;
allocationData.flags.shareable = shareable;
allocationData.flags.multiOsContextCapable = multiOsContextCapable;
if (allocationData.flags.mustBeZeroCopy) {
allocationData.flags.useSystemMemory = true;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -48,7 +48,7 @@ struct AllocationProperties {
uint32_t flushL3RequiredForWrite : 1;
uint32_t forcePin : 1;
uint32_t uncacheable : 1;
uint32_t shareable : 1;
uint32_t multiOsContextCapable : 1;
uint32_t reserved : 26;
} flags;
uint32_t allFlags = 0;
@@ -208,7 +208,7 @@ class MemoryManager {
uint32_t uncacheable : 1;
uint32_t flushL3 : 1;
uint32_t preferRenderCompressed : 1;
uint32_t shareable : 1;
uint32_t multiOsContextCapable : 1;
uint32_t reserved : 22;
} flags;
uint32_t allFlags = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -37,7 +37,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment
if (fakeBigAllocations && allocationData.size > bigAllocation) {
memoryAllocation = new MemoryAllocation(nullptr, (void *)dummyAddress, static_cast<uint64_t>(dummyAddress), allocationData.size, counter,
MemoryPool::System4KBPages, this->getOsContextCount(), allocationData.flags.shareable);
MemoryPool::System4KBPages, this->getOsContextCount(), allocationData.flags.multiOsContextCapable);
counter++;
memoryAllocation->uncacheable = allocationData.flags.uncacheable;
return memoryAllocation;
@@ -45,7 +45,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment
auto ptr = allocateSystemMemory(sizeAligned, allocationData.alignment ? alignUp(allocationData.alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
if (ptr != nullptr) {
memoryAllocation = new MemoryAllocation(ptr, ptr, reinterpret_cast<uint64_t>(ptr), allocationData.size, counter, MemoryPool::System4KBPages,
this->getOsContextCount(), allocationData.flags.shareable);
this->getOsContextCount(), allocationData.flags.multiOsContextCapable);
if (!memoryAllocation) {
alignedFreeWrapper(ptr);
return nullptr;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -21,8 +21,8 @@ class MemoryAllocation : public GraphicsAllocation {
void setSharedHandle(osHandle handle) { this->sharedHandle = handle; }
MemoryAllocation(void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count, MemoryPool::Type pool, uint32_t osContextCount, bool isShareable) : GraphicsAllocation(pMem, gpuAddress, 0u, memSize, osContextCount, isShareable),
id(count) {
MemoryAllocation(void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count, MemoryPool::Type pool, uint32_t osContextCount, bool multiOsContextCapable) : GraphicsAllocation(pMem, gpuAddress, 0u, memSize, osContextCount, multiOsContextCapable),
id(count) {
this->driverAllocatedCpuPointer = driverAllocatedCpuPointer;
overrideMemoryPool(pool);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -17,13 +17,13 @@ struct OsHandle {
class DrmAllocation : public GraphicsAllocation {
public:
DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, MemoryPool::Type pool, uint32_t osContextsCount, bool isShareable) : GraphicsAllocation(ptrIn, castToUint64(ptrIn), 0llu, sizeIn, osContextsCount, isShareable), bo(bo) {
DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, MemoryPool::Type pool, uint32_t osContextsCount, bool multiOsContextCapable) : GraphicsAllocation(ptrIn, castToUint64(ptrIn), 0llu, sizeIn, osContextsCount, multiOsContextCapable), bo(bo) {
this->memoryPool = pool;
}
DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, uint32_t osContextsCount, bool isShareable) : GraphicsAllocation(ptrIn, sizeIn, sharedHandle, osContextsCount, isShareable), bo(bo) {
DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, uint32_t osContextsCount, bool multiOsContextCapable) : GraphicsAllocation(ptrIn, sizeIn, sharedHandle, osContextsCount, multiOsContextCapable), bo(bo) {
this->memoryPool = pool;
}
DrmAllocation(BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool, uint32_t osContextsCount, bool isShareable) : GraphicsAllocation(ptrIn, gpuAddress, 0, sizeIn, osContextsCount, isShareable), bo(bo) {
DrmAllocation(BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool, uint32_t osContextsCount, bool multiOsContextCapable) : GraphicsAllocation(ptrIn, gpuAddress, 0, sizeIn, osContextsCount, multiOsContextCapable), bo(bo) {
this->memoryPool = pool;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -139,7 +139,7 @@ void DrmCommandStreamReceiver<GfxFamily>::makeNonResident(GraphicsAllocation &gf
}
}
}
gfxAllocation.resetResidencyTaskCount(this->osContext->getContextId());
gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId());
}
template <typename GfxFamily>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -232,7 +232,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithAlignment(const Alloc
if (forcePinEnabled && pinBB != nullptr && allocationData.flags.forcePin && allocationData.size >= this->pinThreshold) {
pinBB->pin(&bo, 1, getDefaultCommandStreamReceiver(0)->getOsContext().get()->getDrmContextId());
}
return new DrmAllocation(bo, res, cSize, MemoryPool::System4KBPages, getOsContextCount(), allocationData.flags.shareable);
return new DrmAllocation(bo, res, cSize, MemoryPool::System4KBPages, getOsContextCount(), allocationData.flags.multiOsContextCapable);
}
DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -31,8 +31,8 @@ class WddmAllocation : public GraphicsAllocation {
D3DKMT_HANDLE resourceHandle = 0u; // used by shared resources
D3DGPU_VIRTUAL_ADDRESS gpuPtr; // set by mapGpuVA
WddmAllocation(void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, size_t osContextsCount, bool isShareable)
: GraphicsAllocation(cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, static_cast<uint32_t>(osContextsCount), isShareable),
WddmAllocation(void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, size_t osContextsCount, bool multiOsContextCapable)
: GraphicsAllocation(cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, static_cast<uint32_t>(osContextsCount), multiOsContextCapable),
handle(0),
gpuPtr(0),
trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) {
@@ -40,8 +40,8 @@ class WddmAllocation : public GraphicsAllocation {
this->memoryPool = pool;
}
WddmAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, size_t osContextsCount, bool isShareable)
: GraphicsAllocation(cpuPtrIn, sizeIn, sharedHandle, static_cast<uint32_t>(osContextsCount), isShareable),
WddmAllocation(void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, size_t osContextsCount, bool multiOsContextCapable)
: GraphicsAllocation(cpuPtrIn, sizeIn, sharedHandle, static_cast<uint32_t>(osContextsCount), multiOsContextCapable),
handle(0),
gpuPtr(0),
trimCandidateListPositions(osContextsCount, trimListUnusedPosition) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -67,7 +67,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(AllocationData
size_t sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize64k);
Gmm *gmm = nullptr;
auto wddmAllocation = std::make_unique<WddmAllocation>(nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages, getOsContextCount(), !!allocationData.flags.shareable);
auto wddmAllocation = std::make_unique<WddmAllocation>(nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages, getOsContextCount(), !!allocationData.flags.multiOsContextCapable);
gmm = new Gmm(nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true);
wddmAllocation->gmm = gmm;
@@ -98,7 +98,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const
return nullptr;
}
auto wddmAllocation = std::make_unique<WddmAllocation>(pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages, getOsContextCount(), allocationData.flags.shareable);
auto wddmAllocation = std::make_unique<WddmAllocation>(pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages, getOsContextCount(), allocationData.flags.multiOsContextCapable);
wddmAllocation->driverAllocatedCpuPointer = pSysMem;
gmm = new Gmm(pSysMem, sizeAligned, allocationData.flags.uncacheable);