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

@ -7,7 +7,7 @@
set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/eviction_status.h
${CMAKE_CURRENT_SOURCE_DIR}/residency_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_operations_handler.h
)
set_property(GLOBAL PROPERTY NEO_CORE_MEMORY_MANAGER ${NEO_CORE_MEMORY_MANAGER})

View File

@ -11,10 +11,10 @@ namespace NEO {
class GraphicsAllocation;
class ResidencyHandler {
class MemoryOperationsHandler {
public:
ResidencyHandler() = default;
virtual ~ResidencyHandler() = default;
MemoryOperationsHandler() = default;
virtual ~MemoryOperationsHandler() = default;
virtual bool makeResident(GraphicsAllocation &gfxAllocation) = 0;
virtual bool evict(GraphicsAllocation &gfxAllocation) = 0;

View File

@ -0,0 +1,14 @@
#
# Copyright (C) 2018-2019 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_OS_INTERFACE_AUB
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler.h
)
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_AUB ${NEO_CORE_OS_INTERFACE_AUB})
add_subdirectories()

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "core/os_interface/aub_memory_operations_handler.h"
#include "runtime/aub_mem_dump/aub_mem_dump.h"
#include "runtime/memory_manager/graphics_allocation.h"
#include <algorithm>
namespace NEO {
AubMemoryOperationsHandler::AubMemoryOperationsHandler(aub_stream::AubManager *aubManager) {
this->aubManager = aubManager;
}
bool AubMemoryOperationsHandler::makeResident(GraphicsAllocation &gfxAllocation) {
if (!aubManager) {
return false;
}
auto lock = acquireLock(resourcesLock);
int hint = AubMemDump::DataTypeHintValues::TraceNotype;
aubManager->writeMemory(gfxAllocation.getGpuAddress(), gfxAllocation.getUnderlyingBuffer(), gfxAllocation.getUnderlyingBufferSize(), gfxAllocation.storageInfo.getMemoryBanks(), hint, gfxAllocation.getUsedPageSize());
residentAllocations.push_back(&gfxAllocation);
return true;
}
bool AubMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
auto lock = acquireLock(resourcesLock);
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
if (itor == residentAllocations.end()) {
return false;
} else {
residentAllocations.erase(itor, itor + 1);
return true;
}
}
bool AubMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
auto lock = acquireLock(resourcesLock);
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
if (itor == residentAllocations.end()) {
return false;
} else {
return true;
}
}
void AubMemoryOperationsHandler::setAubManager(aub_stream::AubManager *aubManager) {
this->aubManager = aubManager;
}
} // namespace NEO

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/memory_manager/memory_operations_handler.h"
#include "core/utilities/spinlock.h"
#include "third_party/aub_stream/headers/aub_manager.h"
#include <mutex>
#include <vector>
namespace NEO {
class AubMemoryOperationsHandler : public MemoryOperationsHandler {
public:
AubMemoryOperationsHandler(aub_stream::AubManager *aubManager);
~AubMemoryOperationsHandler() override = default;
bool makeResident(GraphicsAllocation &gfxAllocation) override;
bool evict(GraphicsAllocation &gfxAllocation) override;
bool isResident(GraphicsAllocation &gfxAllocation) override;
void setAubManager(aub_stream::AubManager *aubManager);
protected:
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock) {
return std::unique_lock<SpinLock>{lock};
}
aub_stream::AubManager *aubManager = nullptr;
std::vector<GraphicsAllocation *> residentAllocations;
SpinLock resourcesLock;
};
} // namespace NEO

View File

@ -0,0 +1,14 @@
#
# Copyright (C) 2018-2019 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_OS_INTERFACE_AUB_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler_tests.h
)
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_AUB_TESTS ${NEO_CORE_OS_INTERFACE_AUB_TESTS})
add_subdirectories()

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "core/unit_tests/os_interface/aub_memory_operations_handler_tests.h"
#include "runtime/aub_mem_dump/aub_mem_dump.h"
#include "unit_tests/mocks/mock_aub_manager.h"
TEST_F(AubMemoryOperationsHandlerTests, givenNullPtrAsAubManagerWhenMakeResidentCalledThenFalseReturned) {
getMemoryOperationsHandler()->setAubManager(nullptr);
auto memoryOperationsInterface = getMemoryOperationsHandler();
bool result = memoryOperationsInterface->makeResident(allocation);
EXPECT_FALSE(result);
}
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThenTrueReturnedAndWriteCalled) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
bool result = memoryOperationsInterface->makeResident(allocation);
EXPECT_TRUE(result);
EXPECT_TRUE(aubManager.writeMemoryCalled);
}
TEST_F(AubMemoryOperationsHandlerTests, givenAllocationWhenMakeResidentCalledThenTraceNotypeHintReturned) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
memoryOperationsInterface->makeResident(allocation);
EXPECT_EQ(aubManager.hintToWriteMemory, AubMemDump::DataTypeHintValues::TraceNotype);
}
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenIsResidentCalledThenFalseReturned) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
bool result = memoryOperationsInterface->isResident(allocation);
EXPECT_FALSE(result);
}
TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenIsResidentCalledThenTrueReturned) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
memoryOperationsInterface->makeResident(allocation);
bool result = memoryOperationsInterface->isResident(allocation);
EXPECT_TRUE(result);
}
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenEvictCalledThenFalseReturned) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
bool result = memoryOperationsInterface->evict(allocation);
EXPECT_FALSE(result);
}
TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenEvictCalledThenTrueReturned) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
memoryOperationsInterface->makeResident(allocation);
bool result = memoryOperationsInterface->evict(allocation);
EXPECT_TRUE(result);
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/os_interface/aub_memory_operations_handler.h"
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/device_factory.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
#include "gtest/gtest.h"
using namespace NEO;
class AubMemoryOperationsHandlerTests : public ::testing::Test {
public:
void SetUp() override {
DebugManager.flags.SetCommandStreamReceiver.set(2);
residencyHandler = std::unique_ptr<AubMemoryOperationsHandler>(new AubMemoryOperationsHandler(nullptr));
}
AubMemoryOperationsHandler *getMemoryOperationsHandler() {
return residencyHandler.get();
}
MockGraphicsAllocation allocation;
DebugManagerStateRestore dbgRestore;
std::unique_ptr<AubMemoryOperationsHandler> residencyHandler;
};

View File

@ -7,6 +7,7 @@
#include "runtime/execution_environment/execution_environment.h"
#include "core/memory_manager/memory_operations_handler.h"
#include "runtime/aub/aub_center.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/built_ins/sip.h"
@ -127,5 +128,4 @@ EngineControl *ExecutionEnvironment::getEngineControlForSpecialCsr() {
}
return engine;
}
} // namespace NEO

View File

@ -26,6 +26,7 @@ class GmmHelper;
class MemoryManager;
class SourceLevelDebugger;
class OSInterface;
class MemoryOperationsHandler;
struct EngineControl;
struct HardwareInfo;
@ -63,6 +64,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
EngineControl *getEngineControlForSpecialCsr();
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<MemoryOperationsHandler> memoryOperationsInterface;
std::unique_ptr<MemoryManager> memoryManager;
std::unique_ptr<AubCenter> aubCenter;
CsrContainer commandStreamReceivers;

View File

@ -31,6 +31,9 @@ set(RUNTIME_SRCS_OS_INTERFACE_BASE
${CMAKE_CURRENT_SOURCE_DIR}/print.h
)
get_property(NEO_CORE_OS_INTERFACE_AUB GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_AUB)
list(APPEND RUNTIME_SRCS_OS_INTERFACE_BASE ${NEO_CORE_OS_INTERFACE_AUB})
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_OS_INTERFACE_BASE})
set_property(GLOBAL PROPERTY RUNTIME_SRCS_OS_INTERFACE_BASE ${RUNTIME_SRCS_OS_INTERFACE_BASE})
add_subdirectories()

View File

@ -5,6 +5,8 @@
*
*/
#include "core/os_interface/aub_memory_operations_handler.h"
#include "runtime/aub/aub_center.h"
#include "runtime/device/device.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/debug_settings_manager.h"
@ -34,7 +36,12 @@ bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, Execu
numDevices = totalDeviceCount;
DeviceFactory::numDevices = numDevices;
auto csr = DebugManager.flags.SetCommandStreamReceiver.get();
if (csr > 0) {
executionEnvironment.initAubCenter(DebugManager.flags.EnableLocalMemory.get(), "", static_cast<CommandStreamReceiverType>(csr));
auto aubCenter = executionEnvironment.aubCenter.get();
executionEnvironment.memoryOperationsInterface = std::make_unique<AubMemoryOperationsHandler>(aubCenter->getAubManager());
}
return true;
}

View File

@ -31,8 +31,8 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_null_device.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_query.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/engine_info.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp

View File

@ -11,6 +11,7 @@
#include "runtime/helpers/options.h"
#include "runtime/os_interface/device_factory.h"
#include "runtime/os_interface/hw_info_config.h"
#include "runtime/os_interface/linux/drm_memory_operations_handler.h"
#include "runtime/os_interface/linux/drm_neo.h"
#include "runtime/os_interface/linux/os_interface.h"
@ -35,6 +36,7 @@ bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executi
return false;
}
executionEnvironment.memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
executionEnvironment.osInterface.reset(new OSInterface());
executionEnvironment.osInterface->get()->setDrm(drm);

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/os_interface/linux/drm_memory_operations_handler.h"
namespace NEO {
DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() {
}
bool DrmMemoryOperationsHandler::makeResident(GraphicsAllocation &gfxAllocation) {
return false;
}
bool DrmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
return false;
}
bool DrmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
return false;
}
} // namespace NEO

View File

@ -6,14 +6,14 @@
*/
#pragma once
#include "core/memory_manager/residency_handler.h"
#include "core/memory_manager/memory_operations_handler.h"
namespace NEO {
class DrmResidencyHandler : public ResidencyHandler {
class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
public:
DrmResidencyHandler();
~DrmResidencyHandler() override = default;
DrmMemoryOperationsHandler();
~DrmMemoryOperationsHandler() override = default;
bool makeResident(GraphicsAllocation &gfxAllocation) override;
bool evict(GraphicsAllocation &gfxAllocation) override;

View File

@ -1,27 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/os_interface/linux/drm_residency_handler.h"
namespace NEO {
DrmResidencyHandler::DrmResidencyHandler() {
}
bool DrmResidencyHandler::makeResident(GraphicsAllocation &gfxAllocation) {
return false;
}
bool DrmResidencyHandler::evict(GraphicsAllocation &gfxAllocation) {
return false;
}
bool DrmResidencyHandler::isResident(GraphicsAllocation &gfxAllocation) {
return false;
}
} // namespace NEO

View File

@ -27,8 +27,4 @@ uint32_t OSInterface::getDeviceHandle() const {
return 0;
}
ResidencyHandler *OSInterface::getResidencyInterface() const {
return osInterfaceImpl->getResidencyInterface();
}
} // namespace NEO
} // namespace NEO

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include "runtime/os_interface/linux/drm_residency_handler.h"
#include "runtime/os_interface/linux/drm_memory_operations_handler.h"
#include "runtime/os_interface/os_interface.h"
#include "drm_neo.h"
@ -18,7 +18,6 @@ class OSInterface::OSInterfaceImpl {
public:
OSInterfaceImpl() {
drm = nullptr;
residencyInterface = std::make_unique<DrmResidencyHandler>();
}
Drm *getDrm() const {
return drm;
@ -27,12 +26,7 @@ class OSInterface::OSInterfaceImpl {
this->drm = drm;
}
DrmResidencyHandler *getResidencyInterface() const {
return residencyInterface.get();
}
protected:
Drm *drm;
std::unique_ptr<DrmResidencyHandler> residencyInterface;
};
} // namespace NEO

View File

@ -9,8 +9,6 @@
namespace NEO {
class ResidencyHandler;
class OSInterface {
public:
@ -27,7 +25,6 @@ class OSInterface {
static bool osEnableLocalMemory;
static bool are64kbPagesEnabled();
unsigned int getDeviceHandle() const;
ResidencyHandler *getResidencyInterface() const;
protected:
OSInterfaceImpl *osInterfaceImpl = nullptr;

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;

View File

@ -25,6 +25,7 @@
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_execution_environment.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/mocks/mock_memory_operations_handler.h"
#include "unit_tests/utilities/destructor_counted.h"
using namespace NEO;
@ -193,7 +194,7 @@ static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector<std::unique_ptr
sizeof(std::unique_ptr<CommandStreamReceiver>) +
sizeof(std::mutex) +
sizeof(std::unique_ptr<HardwareInfo>) +
(is64bit ? 80 : 44),
(is64bit ? 88 : 48),
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) {
@ -202,12 +203,15 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
struct MockExecutionEnvironment : ExecutionEnvironment {
using ExecutionEnvironment::gmmHelper;
};
struct GmmHelperMock : public DestructorCounted<GmmHelper, 8> {
struct GmmHelperMock : public DestructorCounted<GmmHelper, 9> {
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, hwInfo) {}
};
struct OsInterfaceMock : public DestructorCounted<OSInterface, 7> {
struct OsInterfaceMock : public DestructorCounted<OSInterface, 8> {
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct MemoryOperationsHandlerMock : public DestructorCounted<MockMemoryOperationsHandler, 7> {
MemoryOperationsHandlerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 6> {
MemoryMangerMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
};
@ -235,6 +239,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
executionEnvironment->commandStreamReceivers.resize(1);
executionEnvironment->gmmHelper = std::make_unique<GmmHelperMock>(destructorId, platformDevices[0]);
executionEnvironment->osInterface = std::make_unique<OsInterfaceMock>(destructorId);
executionEnvironment->memoryOperationsInterface = std::make_unique<MemoryOperationsHandlerMock>(destructorId);
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId, *executionEnvironment);
executionEnvironment->aubCenter = std::make_unique<AubCenterMock>(destructorId);
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CommandStreamReceiverMock>(destructorId, *executionEnvironment));
@ -244,7 +249,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
executionEnvironment->sourceLevelDebugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
executionEnvironment.reset(nullptr);
EXPECT_EQ(9u, destructorId);
EXPECT_EQ(10u, destructorId);
}
TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {

View File

@ -56,6 +56,7 @@ set(IGDRCL_SRCS_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/mock_lrca_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_context.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_ostime.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_physical_address_allocator.h

View File

@ -0,0 +1,23 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/memory_manager/memory_operations_handler.h"
namespace NEO {
class GraphicsAllocation;
class MockMemoryOperationsHandler : public MemoryOperationsHandler {
public:
MockMemoryOperationsHandler() {}
virtual ~MockMemoryOperationsHandler() {}
bool makeResident(GraphicsAllocation &gfxAllocation) { return false; }
bool evict(GraphicsAllocation &gfxAllocation) { return false; }
bool isResident(GraphicsAllocation &gfxAllocation) { return false; }
};
} // namespace NEO

View File

@ -19,6 +19,10 @@ set(IGDRCL_SRCS_tests_os_interface_base
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_gen_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_tests.cpp
)
get_property(NEO_CORE_OS_INTERFACE_AUB_TESTS GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_AUB_TESTS)
list(APPEND IGDRCL_SRCS_tests_os_interface_base ${NEO_CORE_OS_INTERFACE_AUB_TESTS})
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_os_interface_base})
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_os_interface_base ${IGDRCL_SRCS_tests_os_interface_base})
add_subdirectories()

View File

@ -11,6 +11,7 @@
#include "runtime/helpers/options.h"
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/device_factory.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/os_interface/os_library.h"
#include "runtime/platform/platform.h"
@ -169,4 +170,4 @@ TEST_F(DeviceFactoryTest, givenGetDevicesCallWhenItIsDoneThenOsInterfaceIsAlloca
bool success = DeviceFactory::getDevices(numDevices, *executionEnvironment);
EXPECT_TRUE(success);
EXPECT_NE(nullptr, executionEnvironment->osInterface);
}
}

View File

@ -29,6 +29,7 @@ HWTEST_F(DrmCommandStreamMMTest, MMwithPinBB) {
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setDrm(&mock);
executionEnvironment.memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
DrmCommandStreamReceiver<FamilyType> csr(executionEnvironment, gemCloseWorkerMode::gemCloseWorkerInactive);

View File

@ -43,6 +43,7 @@ class DrmCommandStreamFixture {
executionEnvironment.setHwInfo(*platformDevices);
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setDrm(mock.get());
executionEnvironment.memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
osContext = std::make_unique<OsContextLinux>(*mock, 0u, 1, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0],
PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]), false);

View File

@ -71,6 +71,7 @@ class DrmGemCloseWorkerFixture {
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setDrm(drmMock);
executionEnvironment.memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
this->mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
false,

View File

@ -25,6 +25,7 @@ class DrmMemoryManagerBasic : public ::testing::Test {
void SetUp() override {
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setDrm(Drm::get(0));
executionEnvironment.memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
}
MockExecutionEnvironment executionEnvironment;

View File

@ -5,7 +5,7 @@
*
*/
#include "runtime/os_interface/linux/drm_residency_handler.h"
#include "runtime/os_interface/linux/drm_memory_operations_handler.h"
#include "test.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
@ -13,22 +13,22 @@
using namespace NEO;
struct DrmResidencyHandlerTest : public ::testing::Test {
struct DrmMemoryOperationsHandlerTest : public ::testing::Test {
void SetUp() override {
drmResidencyHandler = std::make_unique<DrmResidencyHandler>();
drmMemoryOperationsHandler = std::make_unique<DrmMemoryOperationsHandler>();
}
MockGraphicsAllocation graphicsAllocation;
std::unique_ptr<DrmResidencyHandler> drmResidencyHandler;
std::unique_ptr<DrmMemoryOperationsHandler> drmMemoryOperationsHandler;
};
TEST_F(DrmResidencyHandlerTest, whenMakingResidentAllocaionExpectMakeResidentFail) {
EXPECT_FALSE(drmResidencyHandler->makeResident(graphicsAllocation));
EXPECT_FALSE(drmResidencyHandler->isResident(graphicsAllocation));
TEST_F(DrmMemoryOperationsHandlerTest, whenMakingResidentAllocaionExpectMakeResidentFail) {
EXPECT_FALSE(drmMemoryOperationsHandler->makeResident(graphicsAllocation));
EXPECT_FALSE(drmMemoryOperationsHandler->isResident(graphicsAllocation));
}
TEST_F(DrmResidencyHandlerTest, whenEvictingResidentAllocationExpectEvictFalse) {
EXPECT_FALSE(drmResidencyHandler->makeResident(graphicsAllocation));
EXPECT_FALSE(drmResidencyHandler->evict(graphicsAllocation));
EXPECT_FALSE(drmResidencyHandler->isResident(graphicsAllocation));
TEST_F(DrmMemoryOperationsHandlerTest, whenEvictingResidentAllocationExpectEvictFalse) {
EXPECT_FALSE(drmMemoryOperationsHandler->makeResident(graphicsAllocation));
EXPECT_FALSE(drmMemoryOperationsHandler->evict(graphicsAllocation));
EXPECT_FALSE(drmMemoryOperationsHandler->isResident(graphicsAllocation));
}

View File

@ -23,10 +23,4 @@ TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenDeviceHandleQueriedthenZeroIsRetu
OSInterface osInterface;
EXPECT_EQ(0u, osInterface.getDeviceHandle());
}
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenResidencyInterfaceRetrievedThenCreatedObjectReturned) {
OSInterface osInterface;
EXPECT_NE(nullptr, osInterface.getResidencyInterface());
}
} // namespace NEO

View File

@ -5,6 +5,7 @@
*
*/
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/os_interface/os_time.h"
@ -561,4 +562,4 @@ TEST_F(PerformanceCountersTest, givenRenderCoreFamilyThenMetricsLibraryGenIdenti
const auto &hwInfo = device->getHardwareInfo();
const auto gen = hwInfo.platform.eRenderCoreFamily;
EXPECT_NE(ClientGen::Unknown, static_cast<ClientGen>(HwHelper::get(gen).getMetricsLibraryGenId()));
}
}

View File

@ -24,6 +24,7 @@
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm_device_command_stream.h"
#include "runtime/os_interface/windows/wddm_memory_manager.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "runtime/os_interface/windows/wddm_residency_controller.h"
#include "runtime/platform/platform.h"
#include "test.h"
@ -63,7 +64,6 @@ class WddmCommandStreamFixture {
memoryManager = new MockWddmMemoryManager(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
wddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
csr = new WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
device.reset(MockDevice::create<MockDevice>(executionEnvironment, 0u));
@ -803,6 +803,7 @@ HWTEST_F(WddmSimpleTest, givenDefaultWddmCsrWhenItIsCreatedThenBatchingIsTurnedO
auto wddm = Wddm::createWddm();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
std::unique_ptr<MockWddmCsr<FamilyType>> mockCsr(new MockWddmCsr<FamilyType>(*executionEnvironment));
EXPECT_EQ(DispatchMode::BatchedDispatch, mockCsr->dispatchMode);
}
@ -811,6 +812,7 @@ HWTEST_F(WddmDefaultTest, givenFtrWddmHwQueuesFlagWhenCreatingCsrThenPickWddmVer
auto wddm = Wddm::createWddm();
pDevice->executionEnvironment->osInterface = std::make_unique<OSInterface>();
pDevice->executionEnvironment->osInterface->get()->setWddm(wddm);
pDevice->executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
WddmCommandStreamReceiver<FamilyType> wddmCsr(*pDevice->executionEnvironment);
auto wddmFromCsr = wddmCsr.peekWddm();

View File

@ -11,7 +11,7 @@
#include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/os_interface.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"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "unit_tests/mocks/gl/mock_gl_sharing.h"

View File

@ -21,7 +21,7 @@ TEST_F(OsInterfaceTest, GivenWindowsWhenCreateEentIsCalledThenValidEventHandleIs
EXPECT_EQ(TRUE, ret);
}
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedTrimCallbackIsRegisteredResidencyHandlerCreated) {
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedTrimCallbackIsRegisteredMemoryOperationsHandlerCreated) {
auto wddm = new WddmMock;
OSInterface osInterface;
osInterface.get()->setWddm(wddm);
@ -33,5 +33,4 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit
EXPECT_TRUE(osContext->isInitialized());
EXPECT_EQ(osContext->getWddm(), wddm);
EXPECT_EQ(1u, wddm->registerTrimCallbackResult.called);
EXPECT_NE(nullptr, osInterface.getResidencyInterface());
}

View File

@ -13,6 +13,7 @@
#include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/mocks/mock_wddm.h"
@ -29,6 +30,7 @@ struct WddmFixture : ::testing::Test {
wddm = static_cast<WddmMock *>(Wddm::createWddm());
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
osInterface = executionEnvironment->osInterface.get();
gdi = new MockGdi();
wddm->gdi.reset(gdi);
@ -55,6 +57,7 @@ struct WddmFixtureWithMockGdiDll : public GdiDllFixture {
wddm = static_cast<WddmMock *>(Wddm::createWddm());
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
osInterface = executionEnvironment->osInterface.get();
}

View File

@ -47,6 +47,7 @@ void WddmMemoryManagerFixture::SetUp() {
executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(*executionEnvironment);
}
@ -1297,6 +1298,7 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI
auto executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
auto wddm = new WddmMock();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
auto hwInfoMock = *platformDevices[0];
wddm->init(hwInfoMock);
MockWddmMemoryManager memoryManager(*executionEnvironment);
@ -1624,6 +1626,7 @@ TEST(WddmMemoryManagerCleanupTest, givenUsedTagAllocationInWddmMemoryManagerWhen
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setWddm(wddm);
executionEnvironment.memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
executionEnvironment.commandStreamReceivers.resize(1);
executionEnvironment.commandStreamReceivers[0].push_back(std::unique_ptr<CommandStreamReceiver>(csr));
executionEnvironment.memoryManager = std::make_unique<WddmMemoryManager>(executionEnvironment);

View File

@ -8,6 +8,7 @@
#pragma once
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "test.h"
#include "unit_tests/helpers/execution_environment_helper.h"
#include "unit_tests/mocks/mock_context.h"
@ -56,6 +57,7 @@ class MockWddmMemoryManagerFixture {
executionEnvironment->osInterface.reset(new OSInterface());
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(*executionEnvironment);
osContext = memoryManager->createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0],
@ -101,6 +103,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
auto hwInfo = *platformDevices[0];
wddm->init(hwInfo);
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
osInterface = executionEnvironment->osInterface.get();
memoryManager = new (std::nothrow) MockWddmMemoryManager(*executionEnvironment);
//assert we have memory manager
@ -162,6 +165,7 @@ class MockWddmMemoryManagerTest : public ::testing::Test {
executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
wddm = new WddmMock();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
}
HardwareInfo *hwInfo;

View File

@ -32,6 +32,7 @@ class WddmPreemptionTests : public Test<WddmFixtureWithMockGdiDll> {
wddm = static_cast<WddmMock *>(Wddm::createWddm());
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
osInterface = executionEnvironment->osInterface.get();
auto regReader = new RegistryReaderMock();
wddm->registryReader.reset(regReader);

View File

@ -5,7 +5,7 @@
*
*/
#include "core/memory_manager/residency_handler.h"
#include "core/memory_manager/memory_operations_handler.h"
#include "runtime/command_stream/preemption.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/hw_helper.h"
@ -14,6 +14,7 @@
#include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "runtime/os_interface/windows/wddm_residency_controller.h"
#include "runtime/platform/platform.h"
#include "test.h"
@ -94,6 +95,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(*executionEnvironment);
osContext = memoryManager->createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], 1, preemptionMode, false);
@ -126,6 +128,7 @@ struct WddmResidencyControllerWithGdiAndMemoryManagerTest : ::testing::Test {
executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
executionEnvironment->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(*executionEnvironment);
osContext = memoryManager->createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0],

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 "test.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
#include "unit_tests/mocks/mock_wddm.h"
@ -14,24 +14,24 @@
using namespace NEO;
struct WddmResidencyHandlerTest : public WddmTest {
struct WddmMemoryOperationsHandlerTest : public WddmTest {
void SetUp() override {
WddmTest::SetUp();
wddmResidencyHandler = std::make_unique<WddmResidencyHandler>(wddm);
wddmMemoryOperationsHandler = std::make_unique<WddmMemoryOperationsHandler>(wddm);
wddmAllocation.handle = 0x2;
}
std::unique_ptr<WddmResidencyHandler> wddmResidencyHandler;
std::unique_ptr<WddmMemoryOperationsHandler> wddmMemoryOperationsHandler;
MockWddmAllocation wddmAllocation;
};
TEST_F(WddmResidencyHandlerTest, whenMakingResidentAllocaionExpectMakeResidentCalled) {
EXPECT_TRUE(wddmResidencyHandler->makeResident(wddmAllocation));
EXPECT_TRUE(wddmResidencyHandler->isResident(wddmAllocation));
TEST_F(WddmMemoryOperationsHandlerTest, whenMakingResidentAllocaionExpectMakeResidentCalled) {
EXPECT_TRUE(wddmMemoryOperationsHandler->makeResident(wddmAllocation));
EXPECT_TRUE(wddmMemoryOperationsHandler->isResident(wddmAllocation));
}
TEST_F(WddmResidencyHandlerTest, whenEvictingResidentAllocationExpectEvictCalled) {
EXPECT_TRUE(wddmResidencyHandler->makeResident(wddmAllocation));
EXPECT_TRUE(wddmResidencyHandler->evict(wddmAllocation));
EXPECT_FALSE(wddmResidencyHandler->isResident(wddmAllocation));
TEST_F(WddmMemoryOperationsHandlerTest, whenEvictingResidentAllocationExpectEvictCalled) {
EXPECT_TRUE(wddmMemoryOperationsHandler->makeResident(wddmAllocation));
EXPECT_TRUE(wddmMemoryOperationsHandler->evict(wddmAllocation));
EXPECT_FALSE(wddmMemoryOperationsHandler->isResident(wddmAllocation));
}

View File

@ -7,9 +7,9 @@
add_executable(igdrcl_tbx_tests
${CMAKE_CURRENT_SOURCE_DIR}/main_tbx.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tbx_tests_configuration.cpp
${IGDRCL_SOURCE_DIR}/runtime/aub/aub_stream_interface.cpp
${IGDRCL_SOURCE_DIR}/runtime/dll/create_command_stream.cpp
${IGDRCL_SOURCE_DIR}/runtime/dll${BRANCH_DIR_SUFFIX}/get_devices.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/aub_stream_mocks/aub_stream_interface_mock.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/libult/os_interface.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/options.cpp
$<TARGET_OBJECTS:igdrcl_libult>