Add residency handler for TBX

Change-Id: I6c01d065ff3372fe7583ed50ed51595ebeb53e54
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2019-08-21 10:53:07 +02:00
committed by sys_ocldev
parent cb4e5576cb
commit 7a5bc461eb
49 changed files with 382 additions and 118 deletions

View File

@@ -63,8 +63,8 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_allocations_container.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/windows_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/windows_inc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h

View File

@@ -14,6 +14,7 @@
#include "runtime/os_interface/hw_info_config.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
namespace NEO {
@@ -32,6 +33,7 @@ bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executi
auto totalDeviceCount = DeviceHelper::getDevicesCount(hardwareInfo);
executionEnvironment.memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm.get());
executionEnvironment.osInterface.reset(new OSInterface());
executionEnvironment.osInterface->get()->setWddm(wddm.release());

View File

@@ -9,7 +9,7 @@
#include "runtime/os_interface/windows/sys_calls.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_residency_handler.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
namespace NEO {
@@ -27,10 +27,6 @@ uint32_t OSInterface::getDeviceHandle() const {
return static_cast<uint32_t>(osInterfaceImpl->getDeviceHandle());
}
ResidencyHandler *OSInterface::getResidencyInterface() const {
return osInterfaceImpl->getResidencyInterface();
}
OSInterface::OSInterfaceImpl::OSInterfaceImpl() = default;
D3DKMT_HANDLE OSInterface::OSInterfaceImpl::getAdapterHandle() const {
@@ -62,7 +58,6 @@ Wddm *OSInterface::OSInterfaceImpl::getWddm() const {
void OSInterface::OSInterfaceImpl::setWddm(Wddm *wddm) {
this->wddm.reset(wddm);
this->residencyInterface = std::make_unique<WddmResidencyHandler>(wddm);
}
HANDLE OSInterface::OSInterfaceImpl::createEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState,

View File

@@ -8,6 +8,7 @@
#pragma once
#include "runtime/os_interface/os_interface.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/windows_wrapper.h"
#include "profileapi.h"
@@ -18,7 +19,7 @@
namespace NEO {
class Wddm;
class WddmResidencyHandler;
class WddmMemoryOperationsHandler;
class OSInterface::OSInterfaceImpl {
public:
@@ -30,9 +31,6 @@ class OSInterface::OSInterfaceImpl {
D3DKMT_HANDLE getDeviceHandle() const;
PFND3DKMT_ESCAPE getEscapeHandle() const;
uint32_t getHwContextId() const;
WddmResidencyHandler *getResidencyInterface() const {
return residencyInterface.get();
}
MOCKABLE_VIRTUAL HANDLE createEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState,
LPCSTR lpName);
@@ -40,6 +38,5 @@ class OSInterface::OSInterfaceImpl {
protected:
std::unique_ptr<Wddm> wddm;
std::unique_ptr<WddmResidencyHandler> residencyInterface;
};
} // namespace NEO

View File

@@ -9,7 +9,7 @@
#include "core/helpers/aligned_memory.h"
#include "core/helpers/ptr_math.h"
#include "core/memory_manager/residency_handler.h"
#include "core/memory_manager/memory_operations_handler.h"
#include "runtime/command_stream/command_stream_receiver_hw.h"
#include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
@@ -314,7 +314,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
residencyController.removeFromTrimCandidateListIfUsed(input, true);
}
executionEnvironment.osInterface->getResidencyInterface()->evict(*input);
executionEnvironment.memoryOperationsInterface->evict(*input);
auto defaultGmm = gfxAllocation->getDefaultGmm();
if (defaultGmm) {

View File

@@ -5,7 +5,7 @@
*
*/
#include "runtime/os_interface/windows/wddm_residency_handler.h"
#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"
@@ -15,22 +15,22 @@
namespace NEO {
WddmResidencyHandler::WddmResidencyHandler(Wddm *wddm) : wddm(wddm) {
WddmMemoryOperationsHandler::WddmMemoryOperationsHandler(Wddm *wddm) : wddm(wddm) {
residentAllocations = std::make_unique<WddmResidentAllocationsContainer>(wddm);
}
bool WddmResidencyHandler::makeResident(GraphicsAllocation &gfxAllocation) {
bool WddmMemoryOperationsHandler::makeResident(GraphicsAllocation &gfxAllocation) {
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
return residentAllocations->makeResidentResources(wddmAllocation.getHandles().data(), wddmAllocation.getNumHandles());
}
bool WddmResidencyHandler::evict(GraphicsAllocation &gfxAllocation) {
bool WddmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
auto result = residentAllocations->evictResources(wddmAllocation.getHandles().data(), wddmAllocation.getNumHandles());
return result == EvictionStatus::SUCCESS;
}
bool WddmResidencyHandler::isResident(GraphicsAllocation &gfxAllocation) {
bool WddmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
return residentAllocations->isAllocationResident(wddmAllocation.getDefaultHandle());
}

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "core/memory_manager/residency_handler.h"
#include "core/memory_manager/memory_operations_handler.h"
#include <memory>
@@ -15,10 +15,10 @@ namespace NEO {
class Wddm;
class WddmResidentAllocationsContainer;
class WddmResidencyHandler : public ResidencyHandler {
class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
public:
WddmResidencyHandler(Wddm *wddm);
~WddmResidencyHandler() override = default;
WddmMemoryOperationsHandler(Wddm *wddm);
~WddmMemoryOperationsHandler() override = default;
bool makeResident(GraphicsAllocation &gfxAllocation) override;
bool evict(GraphicsAllocation &gfxAllocation) override;