Add new wddm eviction parameter

Related-To: NEO-7179

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2022-07-18 13:25:50 +00:00
committed by Compute-Runtime-Automation
parent a12c138c16
commit d19cab1fb3
10 changed files with 50 additions and 18 deletions

View File

@@ -70,7 +70,7 @@ void WddmResidencyController::trimResidency(const D3DDDI_TRIMRESIDENCYSET_FLAGS
if (wddmAllocation->fragmentsStorage.fragmentCount == 0) {
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "Evict allocation: default handle =", wddmAllocation->getDefaultHandle(), "lastFence =", wddmAllocation->getResidencyData().getFenceValueForContextId(osContextId));
this->wddm.evict(&wddmAllocation->getHandles()[0], wddmAllocation->getNumGmms(), sizeToTrim);
this->wddm.evict(&wddmAllocation->getHandles()[0], wddmAllocation->getNumGmms(), sizeToTrim, false);
}
for (uint32_t allocationId = 0; allocationId < wddmAllocation->fragmentsStorage.fragmentCount; allocationId++) {
@@ -84,7 +84,7 @@ void WddmResidencyController::trimResidency(const D3DDDI_TRIMRESIDENCYSET_FLAGS
}
}
if (fragmentsToEvict != 0) {
this->wddm.evict((D3DKMT_HANDLE *)fragmentEvictHandles, fragmentsToEvict, sizeToTrim);
this->wddm.evict((D3DKMT_HANDLE *)fragmentEvictHandles, fragmentsToEvict, sizeToTrim, false);
}
wddmAllocation->getResidencyData().resident[osContextId] = false;
@@ -129,7 +129,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) {
}
if (wddmAllocation->fragmentsStorage.fragmentCount == 0) {
this->wddm.evict(&wddmAllocation->getHandles()[0], wddmAllocation->getNumGmms(), sizeToTrim);
this->wddm.evict(&wddmAllocation->getHandles()[0], wddmAllocation->getNumGmms(), sizeToTrim, true);
sizeEvicted = wddmAllocation->getAlignedSize();
} else {
auto &fragmentStorageData = wddmAllocation->fragmentsStorage.fragmentStorageData;
@@ -140,7 +140,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) {
}
if (fragmentsToEvict != 0) {
this->wddm.evict((D3DKMT_HANDLE *)fragmentEvictHandles, fragmentsToEvict, sizeToTrim);
this->wddm.evict((D3DKMT_HANDLE *)fragmentEvictHandles, fragmentsToEvict, sizeToTrim, true);
for (uint32_t allocationId = 0; allocationId < wddmAllocation->fragmentsStorage.fragmentCount; allocationId++) {
if (fragmentStorageData[allocationId].residency->getFenceValueForContextId(osContextId) <= monitoredFence.lastSubmittedFence) {

View File

@@ -359,13 +359,14 @@ std::vector<std::unique_ptr<HwDeviceId>> Wddm::discoverDevices(ExecutionEnvironm
return hwDeviceIds;
}
bool Wddm::evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim) {
bool Wddm::evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim, bool evictNeeded) {
NTSTATUS status = STATUS_SUCCESS;
D3DKMT_EVICT evict = {};
evict.AllocationList = handleList;
evict.hDevice = device;
evict.NumAllocations = numOfHandles;
evict.NumBytesToTrim = 0;
evict.Flags.EvictOnlyIfNecessary = evictNeeded ? 0 : 1;
status = getGdi()->evict(&evict);

View File

@@ -70,7 +70,7 @@ class Wddm : public DriverModel {
static Wddm *createWddm(std::unique_ptr<HwDeviceIdWddm> &&hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment);
bool init();
MOCKABLE_VIRTUAL bool evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
MOCKABLE_VIRTUAL bool evict(const D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim, bool evictNeeded);
MOCKABLE_VIRTUAL bool makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t totalSize);
MOCKABLE_VIRTUAL bool mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_VIRTUAL_ADDRESS preferredAddress, D3DGPU_VIRTUAL_ADDRESS &gpuPtr);
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
* Copyright (C) 2019-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -36,7 +36,7 @@ MemoryOperationsStatus WddmResidentAllocationsContainer::evictAllResourcesNoLock
}
uint64_t sizeToTrim = 0;
uint32_t evictedResources = static_cast<uint32_t>(resourcesToEvict.size());
bool success = wddm->evict(resourcesToEvict.data(), evictedResources, sizeToTrim);
bool success = wddm->evict(resourcesToEvict.data(), evictedResources, sizeToTrim, true);
return success ? MemoryOperationsStatus::SUCCESS : MemoryOperationsStatus::FAILED;
}
@@ -54,7 +54,7 @@ MemoryOperationsStatus WddmResidentAllocationsContainer::evictResources(const D3
UNRECOVERABLE_IF(distance + count > resourceHandles.size());
resourceHandles.erase(position, position + count);
uint64_t sizeToTrim = 0;
if (!wddm->evict(handles, count, sizeToTrim)) {
if (!wddm->evict(handles, count, sizeToTrim, true)) {
return MemoryOperationsStatus::FAILED;
}
return MemoryOperationsStatus::SUCCESS;