Calculate a maxOsContextCount variable

Change-Id: I7b2f7733be74abf4ae299396d616b249b67de58e
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-12-17 08:11:16 +01:00
committed by sys_ocldev
parent 1021d8c6d2
commit eac48002ab
30 changed files with 110 additions and 64 deletions

View File

@@ -15,7 +15,7 @@ struct OsHandle {
BufferObject *bo = nullptr;
};
using BufferObjects = std::array<BufferObject *, maxHandleCount>;
using BufferObjects = std::array<BufferObject *, EngineLimits::maxHandleCount>;
class DrmAllocation : public GraphicsAllocation {
public:

View File

@@ -9,6 +9,7 @@
#include "core/gmm_helper/gmm_helper.h"
#include "core/helpers/aligned_memory.h"
#include "core/helpers/preamble.h"
#include "core/memory_manager/residency.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/gmm_helper/page_table_mngr.h"
#include "runtime/helpers/flush_stamp.h"

View File

@@ -12,6 +12,7 @@
#include "core/helpers/options.h"
#include "core/helpers/ptr_math.h"
#include "core/memory_manager/host_ptr_manager.h"
#include "core/memory_manager/residency.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
@@ -538,7 +539,7 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf
}
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
if (gfxAllocation->getGmm(handleId)) {
delete gfxAllocation->getGmm(handleId);
}

View File

@@ -9,6 +9,7 @@
#define UMDF_USING_NTSTATUS
#include "core/helpers/aligned_memory.h"
#include "core/memory_manager/graphics_allocation.h"
#include "core/memory_manager/residency.h"
#include "core/os_interface/windows/windows_wrapper.h"
#include <d3dkmthk.h>
@@ -26,23 +27,19 @@ constexpr size_t trimListUnusedPosition = std::numeric_limits<size_t>::max();
class WddmAllocation : public GraphicsAllocation {
public:
WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool)
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool) {
trimCandidateListPositions.fill(trimListUnusedPosition);
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
reservedAddressRangeInfo.addressPtr = reservedAddr;
reservedAddressRangeInfo.rangeSize = sizeIn;
}
WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, uint32_t shareable)
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), shareable(shareable) {
trimCandidateListPositions.fill(trimListUnusedPosition);
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), shareable(shareable), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
reservedAddressRangeInfo.addressPtr = reservedAddr;
reservedAddressRangeInfo.rangeSize = sizeIn;
}
WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool)
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool) {
trimCandidateListPositions.fill(trimListUnusedPosition);
}
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {}
void *getAlignedCpuPtr() const {
return alignDown(this->cpuPtr, MemoryConstants::pageSize);
@@ -55,7 +52,7 @@ class WddmAllocation : public GraphicsAllocation {
ResidencyData &getResidencyData() {
return residency;
}
const std::array<D3DKMT_HANDLE, maxHandleCount> &getHandles() const { return handles; }
const std::array<D3DKMT_HANDLE, EngineLimits::maxHandleCount> &getHandles() const { return handles; }
D3DKMT_HANDLE &getHandleToModify(uint32_t handleIndex) { return handles[handleIndex]; }
D3DKMT_HANDLE getDefaultHandle() const { return handles[0]; }
void setDefaultHandle(D3DKMT_HANDLE handle) {
@@ -94,8 +91,8 @@ class WddmAllocation : public GraphicsAllocation {
}
return ss.str();
}
std::array<D3DKMT_HANDLE, maxHandleCount> handles{};
std::array<D3DKMT_HANDLE, EngineLimits::maxHandleCount> handles{};
ResidencyData residency;
std::array<size_t, maxOsContextCount> trimCandidateListPositions;
std::vector<size_t> trimCandidateListPositions;
};
} // namespace NEO

View File

@@ -341,7 +341,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
DEBUG_BREAK_IF(!status);
}
}
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
delete gfxAllocation->getGmm(handleId);
}
@@ -450,7 +450,7 @@ void WddmMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uint32_t
for (unsigned int i = 0; i < maxFragmentsCount; i++) {
if (handleStorage.fragmentStorageData[i].freeTheFragment) {
handles[allocationCount++] = handleStorage.fragmentStorageData[i].osHandleStorage->handle;
std::fill_n(handleStorage.fragmentStorageData[i].residency->resident, maxOsContextCount, false);
std::fill(handleStorage.fragmentStorageData[i].residency->resident.begin(), handleStorage.fragmentStorageData[i].residency->resident.end(), false);
}
}

View File

@@ -7,12 +7,9 @@
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
#include "engine_limits.h"
namespace NEO {
WddmMemoryOperationsHandler::WddmMemoryOperationsHandler(Wddm *wddm) : wddm(wddm) {

View File

@@ -300,7 +300,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) {
bool WddmResidencyController::makeResidentResidencyAllocations(const ResidencyContainer &allocationsForResidency) {
const size_t residencyCount = allocationsForResidency.size();
std::unique_ptr<D3DKMT_HANDLE[]> handlesForResidency(new D3DKMT_HANDLE[residencyCount * maxFragmentsCount * maxHandleCount]);
std::unique_ptr<D3DKMT_HANDLE[]> handlesForResidency(new D3DKMT_HANDLE[residencyCount * maxFragmentsCount * EngineLimits::maxHandleCount]);
uint32_t totalHandlesCount = 0;
auto lock = this->acquireLock();