Add residency mechanism to OS interface
Change-Id: I323ca856d3c901bdc4d5961cdefa42685b53d4d9 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
parent
775336df92
commit
f01c1d2d49
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Copyright (C) 2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_COMMAND_STREAM
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption_mode.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_COMMAND_STREAM ${NEO_CORE_COMMAND_STREAM})
|
|
@ -8,6 +8,7 @@ set(NEO_CORE_HELPERS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/basic_math.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/interlocked_max.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/non_copyable_or_moveable.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ptr_math.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/string.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vec.h
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
namespace NEO {
|
||||
class NonCopyableOrMovableClass {
|
||||
public:
|
||||
NonCopyableOrMovableClass() = default;
|
||||
NonCopyableOrMovableClass(const NonCopyableOrMovableClass &) = delete;
|
||||
NonCopyableOrMovableClass &operator=(const NonCopyableOrMovableClass &) = delete;
|
||||
|
||||
NonCopyableOrMovableClass(NonCopyableOrMovableClass &&) = delete;
|
||||
NonCopyableOrMovableClass &operator=(NonCopyableOrMovableClass &&) = delete;
|
||||
};
|
||||
} // namespace NEO
|
|
@ -0,0 +1,13 @@
|
|||
#
|
||||
# Copyright (C) 2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_MEMORY_MANAGER ${NEO_CORE_MEMORY_MANAGER})
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
enum class EvictionStatus : uint32_t {
|
||||
SUCCESS = 0,
|
||||
FAILED,
|
||||
NOT_APPLIED,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
} // namespace NEO
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class GraphicsAllocation;
|
||||
|
||||
class ResidencyHandler {
|
||||
public:
|
||||
ResidencyHandler() = default;
|
||||
virtual ~ResidencyHandler() = default;
|
||||
|
||||
virtual bool makeResident(GraphicsAllocation &gfxAllocation) = 0;
|
||||
virtual bool evict(GraphicsAllocation &gfxAllocation) = 0;
|
||||
virtual bool isResident(GraphicsAllocation &gfxAllocation) = 0;
|
||||
};
|
||||
} // namespace NEO
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Copyright (C) 2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_UTILITIES_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spinlock_tests.cpp
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_UTILITIES_TESTS ${NEO_CORE_UTILITIES_TESTS})
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
#include "core/utilities/spinlock.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Copyright (C) 2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_UTILITIES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spinlock.h
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_UTILITIES ${NEO_CORE_UTILITIES})
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "core/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include <atomic>
|
||||
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/helpers/non_copyable_or_moveable.h"
|
||||
#include "runtime/gen_common/aub_mapper_base.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "runtime/memory_manager/graphics_allocation.h"
|
||||
|
||||
namespace NEO {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/helpers/non_copyable_or_moveable.h"
|
||||
#include "core/helpers/vec.h"
|
||||
#include "runtime/built_ins/sip.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
#include "built_in_ops.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ set(RUNTIME_SRCS_COMMAND_STREAM
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/preemption.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption_mode.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controller.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controller.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controller_base.cpp
|
||||
|
@ -51,6 +50,10 @@ set(RUNTIME_SRCS_COMMAND_STREAM
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/tbx_stream.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/thread_arbitration_policy.h
|
||||
)
|
||||
|
||||
get_property(NEO_CORE_COMMAND_STREAM GLOBAL PROPERTY NEO_CORE_COMMAND_STREAM)
|
||||
list(APPEND RUNTIME_SRCS_COMMAND_STREAM ${NEO_CORE_COMMAND_STREAM})
|
||||
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_COMMAND_STREAM})
|
||||
set_property(GLOBAL PROPERTY RUNTIME_SRCS_COMMAND_STREAM ${RUNTIME_SRCS_COMMAND_STREAM})
|
||||
add_subdirectories()
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/utilities/spinlock.h"
|
||||
#include "runtime/aub/aub_center.h"
|
||||
#include "runtime/command_stream/aub_command_stream_receiver.h"
|
||||
#include "runtime/gen_common/aub_mapper.h"
|
||||
|
@ -13,7 +14,6 @@
|
|||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "runtime/memory_manager/page_table.h"
|
||||
#include "runtime/memory_manager/physical_address_allocator.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
|
||||
#include "command_stream_receiver_simulated_hw.h"
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
#include "runtime/command_stream/linear_stream.h"
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
|
||||
#include "sku_info.h"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "core/utilities/spinlock.h"
|
||||
#include "runtime/command_queue/command_queue.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/context/context.h"
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include "runtime/memory_manager/surface.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/program/program.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
#include "ocl_igc_shared/gtpin/gtpin_ocl_interface.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
#include "runtime/helpers/kmd_notify_properties.h"
|
||||
|
||||
#include "engine_node.h"
|
||||
|
|
|
@ -77,14 +77,4 @@ struct MapInfo {
|
|||
uint32_t mipLevel = 0;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
class NonCopyableOrMovableClass {
|
||||
public:
|
||||
NonCopyableOrMovableClass() = default;
|
||||
NonCopyableOrMovableClass(const NonCopyableOrMovableClass &) = delete;
|
||||
NonCopyableOrMovableClass &operator=(const NonCopyableOrMovableClass &) = delete;
|
||||
|
||||
NonCopyableOrMovableClass(NonCopyableOrMovableClass &&) = delete;
|
||||
NonCopyableOrMovableClass &operator=(NonCopyableOrMovableClass &&) = delete;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/helpers/non_copyable_or_moveable.h"
|
||||
#include "runtime/helpers/csr_deps.h"
|
||||
#include "runtime/helpers/hardware_commands_helper.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "runtime/utilities/tag_allocator.h"
|
||||
|
||||
#include <atomic>
|
||||
|
|
|
@ -53,6 +53,9 @@ set(RUNTIME_SRCS_MEMORY_MANAGER
|
|||
get_property(NEO_UNIFIED_MEMORY GLOBAL PROPERTY NEO_UNIFIED_MEMORY)
|
||||
list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_UNIFIED_MEMORY})
|
||||
|
||||
get_property(NEO_CORE_MEMORY_MANAGER GLOBAL PROPERTY NEO_CORE_MEMORY_MANAGER)
|
||||
list(APPEND RUNTIME_SRCS_MEMORY_MANAGER ${NEO_CORE_MEMORY_MANAGER})
|
||||
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_MEMORY_MANAGER})
|
||||
set_property(GLOBAL PROPERTY RUNTIME_SRCS_MEMORY_MANAGER ${RUNTIME_SRCS_MEMORY_MANAGER})
|
||||
add_subdirectories()
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/helpers/non_copyable_or_moveable.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
#include "common/helpers/bit_helpers.h"
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
#include "public/cl_ext_private.h"
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/engine_control.h"
|
||||
#include "runtime/memory_manager/allocation_properties.h"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "core/unified_memory/unified_memory.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
#include "core/utilities/spinlock.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
|
|
|
@ -29,8 +29,10 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo_create.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_query.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}/engine_info.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/memory_manager/residency_handler.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class DrmResidencyHandler : public ResidencyHandler {
|
||||
public:
|
||||
DrmResidencyHandler();
|
||||
~DrmResidencyHandler() override = default;
|
||||
|
||||
bool makeResident(GraphicsAllocation &gfxAllocation) override;
|
||||
bool evict(GraphicsAllocation &gfxAllocation) override;
|
||||
bool isResident(GraphicsAllocation &gfxAllocation) override;
|
||||
};
|
||||
} // namespace NEO
|
|
@ -27,4 +27,8 @@ uint32_t OSInterface::getDeviceHandle() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ResidencyHandler *OSInterface::getResidencyInterface() const {
|
||||
return osInterfaceImpl->getResidencyInterface();
|
||||
}
|
||||
|
||||
} // namespace NEO
|
|
@ -6,16 +6,19 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/linux/drm_residency_handler.h"
|
||||
#include "runtime/os_interface/os_interface.h"
|
||||
|
||||
#include "drm_neo.h"
|
||||
|
||||
namespace NEO {
|
||||
class Drm;
|
||||
|
||||
class OSInterface::OSInterfaceImpl {
|
||||
public:
|
||||
OSInterfaceImpl() {
|
||||
drm = nullptr;
|
||||
residencyInterface = std::make_unique<DrmResidencyHandler>();
|
||||
}
|
||||
Drm *getDrm() const {
|
||||
return drm;
|
||||
|
@ -24,7 +27,12 @@ class OSInterface::OSInterfaceImpl {
|
|||
this->drm = drm;
|
||||
}
|
||||
|
||||
DrmResidencyHandler *getResidencyInterface() const {
|
||||
return residencyInterface.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
Drm *drm;
|
||||
std::unique_ptr<DrmResidencyHandler> residencyInterface;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace NEO {
|
||||
|
||||
class ResidencyHandler;
|
||||
|
||||
class OSInterface {
|
||||
|
||||
public:
|
||||
|
@ -25,6 +27,7 @@ class OSInterface {
|
|||
static bool osEnableLocalMemory;
|
||||
static bool are64kbPagesEnabled();
|
||||
unsigned int getDeviceHandle() const;
|
||||
ResidencyHandler *getResidencyInterface() const;
|
||||
|
||||
protected:
|
||||
OSInterfaceImpl *osInterfaceImpl = nullptr;
|
||||
|
|
|
@ -58,8 +58,12 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_allocations_container.cpp
|
||||
${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}/windows_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows_inc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h
|
||||
|
|
|
@ -9,6 +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"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -26,6 +27,10 @@ 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 {
|
||||
|
@ -57,6 +62,7 @@ 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,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
namespace NEO {
|
||||
class Wddm;
|
||||
class WddmResidencyHandler;
|
||||
|
||||
class OSInterface::OSInterfaceImpl {
|
||||
public:
|
||||
|
@ -29,6 +30,9 @@ 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);
|
||||
|
@ -36,5 +40,6 @@ class OSInterface::OSInterfaceImpl {
|
|||
|
||||
protected:
|
||||
std::unique_ptr<Wddm> wddm;
|
||||
std::unique_ptr<WddmResidencyHandler> residencyInterface;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
#include "runtime/os_interface/windows/wddm_engine_mapper.h"
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/sku_info/operations/sku_info_receiver.h"
|
||||
|
||||
|
@ -52,6 +53,7 @@ Wddm::Wddm() {
|
|||
adapterLuid.LowPart = 0;
|
||||
kmDafListener = std::unique_ptr<KmDafListener>(new KmDafListener);
|
||||
gdi = std::unique_ptr<Gdi>(new Gdi());
|
||||
temporaryResources = std::make_unique<WddmResidentAllocationsContainer>(this);
|
||||
}
|
||||
|
||||
Wddm::~Wddm() {
|
||||
|
@ -630,7 +632,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
|
|||
void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock) {
|
||||
|
||||
if (applyMakeResidentPriorToLock) {
|
||||
applyBlockingMakeResident(handle);
|
||||
temporaryResources->makeResidentResource(handle);
|
||||
}
|
||||
|
||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||
|
@ -919,68 +921,10 @@ bool Wddm::configureDeviceAddressSpaceImpl() {
|
|||
return gmmMemory->configureDevice(adapter, device, gdi->escape, svmSize, featureTable->ftrL3IACoherency, gfxPartition, minAddress);
|
||||
}
|
||||
|
||||
EvictionStatus Wddm::evictAllTemporaryResources() {
|
||||
decltype(temporaryResources) resourcesToEvict;
|
||||
auto lock = acquireLock(temporaryResourcesLock);
|
||||
temporaryResources.swap(resourcesToEvict);
|
||||
if (resourcesToEvict.empty()) {
|
||||
return EvictionStatus::NOT_APPLIED;
|
||||
}
|
||||
uint64_t sizeToTrim = 0;
|
||||
bool error = false;
|
||||
for (auto &handle : resourcesToEvict) {
|
||||
if (!evict(&handle, 1, sizeToTrim)) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
return error ? EvictionStatus::FAILED : EvictionStatus::SUCCESS;
|
||||
}
|
||||
|
||||
EvictionStatus Wddm::evictTemporaryResource(const D3DKMT_HANDLE &handle) {
|
||||
auto lock = acquireLock(temporaryResourcesLock);
|
||||
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), handle);
|
||||
if (position == temporaryResources.end()) {
|
||||
return EvictionStatus::NOT_APPLIED;
|
||||
}
|
||||
*position = temporaryResources.back();
|
||||
temporaryResources.pop_back();
|
||||
uint64_t sizeToTrim = 0;
|
||||
if (!evict(&handle, 1, sizeToTrim)) {
|
||||
return EvictionStatus::FAILED;
|
||||
}
|
||||
return EvictionStatus::SUCCESS;
|
||||
}
|
||||
void Wddm::applyBlockingMakeResident(const D3DKMT_HANDLE &handle) {
|
||||
bool madeResident = false;
|
||||
while (!(madeResident = makeResident(&handle, 1, false, nullptr))) {
|
||||
if (evictAllTemporaryResources() == EvictionStatus::SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
if (!makeResident(&handle, 1, false, nullptr)) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return;
|
||||
};
|
||||
break;
|
||||
}
|
||||
DEBUG_BREAK_IF(!madeResident);
|
||||
auto lock = acquireLock(temporaryResourcesLock);
|
||||
temporaryResources.push_back(handle);
|
||||
lock.unlock();
|
||||
void Wddm::waitOnPagingFenceFromCpu() {
|
||||
while (currentPagingFenceValue > *getPagingFenceAddress())
|
||||
;
|
||||
}
|
||||
void Wddm::removeTemporaryResource(const D3DKMT_HANDLE &handle) {
|
||||
auto lock = acquireLock(temporaryResourcesLock);
|
||||
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), handle);
|
||||
if (position == temporaryResources.end()) {
|
||||
return;
|
||||
}
|
||||
*position = temporaryResources.back();
|
||||
temporaryResources.pop_back();
|
||||
}
|
||||
std::unique_lock<SpinLock> Wddm::acquireLock(SpinLock &lock) {
|
||||
return std::unique_lock<SpinLock>{lock};
|
||||
}
|
||||
|
||||
void Wddm::updatePagingFenceValue(uint64_t newPagingFenceValue) {
|
||||
interlockedMax(currentPagingFenceValue, newPagingFenceValue);
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
#include "core/memory_manager/eviction_status.h"
|
||||
#include "core/utilities/spinlock.h"
|
||||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/memory_manager/gfx_partition.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
|
||||
#include "sku_info.h"
|
||||
|
||||
|
@ -28,6 +29,7 @@ class SettingsReader;
|
|||
class WddmAllocation;
|
||||
class WddmInterface;
|
||||
class WddmResidencyController;
|
||||
class WddmResidentAllocationsContainer;
|
||||
|
||||
struct AllocationStorageData;
|
||||
struct HardwareInfo;
|
||||
|
@ -37,13 +39,6 @@ struct OsHandleStorage;
|
|||
|
||||
enum class HeapIndex : uint32_t;
|
||||
|
||||
enum class EvictionStatus {
|
||||
SUCCESS,
|
||||
FAILED,
|
||||
NOT_APPLIED,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
class Wddm {
|
||||
public:
|
||||
typedef HRESULT(WINAPI *CreateDXGIFactoryFcn)(REFIID riid, void **ppFactory);
|
||||
|
@ -140,15 +135,14 @@ class Wddm {
|
|||
MOCKABLE_VIRTUAL uint64_t *getPagingFenceAddress() {
|
||||
return pagingFenceAddress;
|
||||
}
|
||||
MOCKABLE_VIRTUAL EvictionStatus evictAllTemporaryResources();
|
||||
MOCKABLE_VIRTUAL EvictionStatus evictTemporaryResource(const D3DKMT_HANDLE &handle);
|
||||
MOCKABLE_VIRTUAL void applyBlockingMakeResident(const D3DKMT_HANDLE &handle);
|
||||
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock);
|
||||
MOCKABLE_VIRTUAL void removeTemporaryResource(const D3DKMT_HANDLE &handle);
|
||||
WddmResidentAllocationsContainer *getTemporaryResourcesContainer() {
|
||||
return temporaryResources.get();
|
||||
}
|
||||
void updatePagingFenceValue(uint64_t newPagingFenceValue);
|
||||
GmmMemory *getGmmMemory() const {
|
||||
return gmmMemory.get();
|
||||
}
|
||||
void waitOnPagingFenceFromCpu();
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Gdi> gdi;
|
||||
|
@ -198,7 +192,6 @@ class Wddm {
|
|||
|
||||
std::unique_ptr<KmDafListener> kmDafListener;
|
||||
std::unique_ptr<WddmInterface> wddmInterface;
|
||||
std::vector<D3DKMT_HANDLE> temporaryResources;
|
||||
SpinLock temporaryResourcesLock;
|
||||
std::unique_ptr<WddmResidentAllocationsContainer> temporaryResources;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "runtime/os_interface/windows/wddm_memory_manager.h"
|
||||
|
||||
#include "core/helpers/ptr_math.h"
|
||||
#include "core/memory_manager/residency_handler.h"
|
||||
#include "runtime/command_stream/command_stream_receiver_hw.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "runtime/os_interface/windows/os_interface.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 "runtime/os_interface/windows/wddm_residency_controller.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
|
||||
|
@ -289,7 +291,7 @@ void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocatio
|
|||
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
||||
wddm->unlockResource(wddmAllocation.getDefaultHandle());
|
||||
if (wddmAllocation.needsMakeResidentBeforeLock) {
|
||||
auto evictionStatus = wddm->evictTemporaryResource(wddmAllocation.getDefaultHandle());
|
||||
auto evictionStatus = wddm->getTemporaryResourcesContainer()->evictResource(wddmAllocation.getDefaultHandle());
|
||||
DEBUG_BREAK_IF(evictionStatus == EvictionStatus::FAILED);
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +299,7 @@ void WddmMemoryManager::freeAssociatedResourceImpl(GraphicsAllocation &graphicsA
|
|||
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
|
||||
if (wddmAllocation.needsMakeResidentBeforeLock) {
|
||||
for (auto i = 0u; i < wddmAllocation.getNumHandles(); i++) {
|
||||
wddm->removeTemporaryResource(wddmAllocation.getHandles()[i]);
|
||||
wddm->getTemporaryResourcesContainer()->removeResource(wddmAllocation.getHandles()[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,6 +314,8 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
|||
residencyController.removeFromTrimCandidateListIfUsed(input, true);
|
||||
}
|
||||
|
||||
executionEnvironment.osInterface->getResidencyInterface()->evict(*input);
|
||||
|
||||
auto defaultGmm = gfxAllocation->getDefaultGmm();
|
||||
if (defaultGmm) {
|
||||
if (defaultGmm->isRenderCompressed && wddm->getPageTableManager()) {
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
|
||||
#include "runtime/os_interface/windows/wddm/wddm.h"
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace NEO {
|
||||
WddmResidentAllocationsContainer::~WddmResidentAllocationsContainer() {
|
||||
evictAllResources();
|
||||
}
|
||||
|
||||
bool WddmResidentAllocationsContainer::isAllocationResident(const D3DKMT_HANDLE &handle) {
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
auto position = std::find(resourceHandles.begin(), resourceHandles.end(), handle);
|
||||
return position != resourceHandles.end();
|
||||
}
|
||||
|
||||
EvictionStatus WddmResidentAllocationsContainer::evictAllResources() {
|
||||
decltype(resourceHandles) resourcesToEvict;
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
resourceHandles.swap(resourcesToEvict);
|
||||
if (resourcesToEvict.empty()) {
|
||||
return EvictionStatus::NOT_APPLIED;
|
||||
}
|
||||
uint64_t sizeToTrim = 0;
|
||||
uint32_t evictedResources = static_cast<uint32_t>(resourcesToEvict.size());
|
||||
bool success = wddm->evict(resourcesToEvict.data(), evictedResources, sizeToTrim);
|
||||
return success ? EvictionStatus::SUCCESS : EvictionStatus::FAILED;
|
||||
}
|
||||
|
||||
EvictionStatus WddmResidentAllocationsContainer::evictResource(const D3DKMT_HANDLE &handle) {
|
||||
return evictResources(&handle, 1u);
|
||||
}
|
||||
|
||||
EvictionStatus WddmResidentAllocationsContainer::evictResources(const D3DKMT_HANDLE *handles, const uint32_t count) {
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
auto position = std::find(resourceHandles.begin(), resourceHandles.end(), handles[0]);
|
||||
if (position == resourceHandles.end()) {
|
||||
return EvictionStatus::NOT_APPLIED;
|
||||
}
|
||||
auto distance = static_cast<size_t>(std::distance(resourceHandles.begin(), position));
|
||||
UNRECOVERABLE_IF(distance + count > resourceHandles.size());
|
||||
resourceHandles.erase(position, position + count);
|
||||
uint64_t sizeToTrim = 0;
|
||||
if (!wddm->evict(handles, count, sizeToTrim)) {
|
||||
return EvictionStatus::FAILED;
|
||||
}
|
||||
return EvictionStatus::SUCCESS;
|
||||
}
|
||||
|
||||
bool WddmResidentAllocationsContainer::makeResidentResource(const D3DKMT_HANDLE &handle) {
|
||||
return makeResidentResources(&handle, 1u);
|
||||
}
|
||||
|
||||
bool WddmResidentAllocationsContainer::makeResidentResources(const D3DKMT_HANDLE *handles, const uint32_t count) {
|
||||
bool madeResident = false;
|
||||
while (!(madeResident = wddm->makeResident(handles, count, false, nullptr))) {
|
||||
if (evictAllResources() == EvictionStatus::SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
if (!wddm->makeResident(handles, count, false, nullptr)) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return false;
|
||||
};
|
||||
break;
|
||||
}
|
||||
DEBUG_BREAK_IF(!madeResident);
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
resourceHandles.push_back(handles[i]);
|
||||
}
|
||||
lock.unlock();
|
||||
wddm->waitOnPagingFenceFromCpu();
|
||||
return madeResident;
|
||||
}
|
||||
|
||||
void WddmResidentAllocationsContainer::removeResource(const D3DKMT_HANDLE &handle) {
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
auto position = std::find(resourceHandles.begin(), resourceHandles.end(), handle);
|
||||
if (position == resourceHandles.end()) {
|
||||
return;
|
||||
}
|
||||
*position = resourceHandles.back();
|
||||
resourceHandles.pop_back();
|
||||
}
|
||||
|
||||
} // namespace NEO
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/memory_manager/eviction_status.h"
|
||||
#include "core/utilities/spinlock.h"
|
||||
#include "runtime/os_interface/windows/windows_defs.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class Wddm;
|
||||
|
||||
class WddmResidentAllocationsContainer {
|
||||
public:
|
||||
WddmResidentAllocationsContainer(Wddm *wddm) : wddm(wddm) {}
|
||||
virtual ~WddmResidentAllocationsContainer();
|
||||
|
||||
bool isAllocationResident(const D3DKMT_HANDLE &handle);
|
||||
MOCKABLE_VIRTUAL EvictionStatus evictAllResources();
|
||||
MOCKABLE_VIRTUAL EvictionStatus evictResource(const D3DKMT_HANDLE &handle);
|
||||
EvictionStatus evictResources(const D3DKMT_HANDLE *handles, const uint32_t count);
|
||||
MOCKABLE_VIRTUAL bool makeResidentResource(const D3DKMT_HANDLE &handle);
|
||||
bool makeResidentResources(const D3DKMT_HANDLE *handles, const uint32_t count);
|
||||
MOCKABLE_VIRTUAL void removeResource(const D3DKMT_HANDLE &handle);
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock) {
|
||||
return std::unique_lock<SpinLock>{lock};
|
||||
}
|
||||
|
||||
Wddm *wddm;
|
||||
std::vector<D3DKMT_HANDLE> resourceHandles;
|
||||
SpinLock resourcesLock;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
#include "runtime/os_interface/windows/wddm_residency_controller.h"
|
||||
|
||||
#include "core/utilities/spinlock.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
#include "runtime/os_interface/windows/wddm/wddm.h"
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
#include "runtime/os_interface/windows/wddm_memory_manager.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -341,7 +342,7 @@ bool WddmResidencyController::makeResidentResidencyAllocations(ResidencyContaine
|
|||
this->setMemoryBudgetExhausted();
|
||||
const bool trimmingDone = this->trimResidencyToBudget(bytesToTrim);
|
||||
if (!trimmingDone) {
|
||||
auto evictionStatus = wddm.evictAllTemporaryResources();
|
||||
auto evictionStatus = wddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
if (evictionStatus == EvictionStatus::SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/utilities/spinlock.h"
|
||||
#include "runtime/memory_manager/residency_container.h"
|
||||
#include "runtime/os_interface/windows/windows_defs.h"
|
||||
#include "runtime/os_interface/windows/windows_wrapper.h"
|
||||
#include "runtime/utilities/spinlock.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/windows/wddm_residency_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 {
|
||||
|
||||
WddmResidencyHandler::WddmResidencyHandler(Wddm *wddm) : wddm(wddm) {
|
||||
residentAllocations = std::make_unique<WddmResidentAllocationsContainer>(wddm);
|
||||
}
|
||||
|
||||
bool WddmResidencyHandler::makeResident(GraphicsAllocation &gfxAllocation) {
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
return residentAllocations->makeResidentResources(wddmAllocation.getHandles().data(), wddmAllocation.getNumHandles());
|
||||
}
|
||||
|
||||
bool WddmResidencyHandler::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) {
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
return residentAllocations->isAllocationResident(wddmAllocation.getDefaultHandle());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/memory_manager/residency_handler.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Wddm;
|
||||
class WddmResidentAllocationsContainer;
|
||||
|
||||
class WddmResidencyHandler : public ResidencyHandler {
|
||||
public:
|
||||
WddmResidencyHandler(Wddm *wddm);
|
||||
~WddmResidencyHandler() override = default;
|
||||
|
||||
bool makeResident(GraphicsAllocation &gfxAllocation) override;
|
||||
bool evict(GraphicsAllocation &gfxAllocation) override;
|
||||
bool isResident(GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
protected:
|
||||
Wddm *wddm;
|
||||
std::unique_ptr<WddmResidentAllocationsContainer> residentAllocations;
|
||||
};
|
||||
} // namespace NEO
|
|
@ -24,12 +24,14 @@ set(RUNTIME_SRCS_UTILITIES_BASE
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/range.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/reference_tracked_object.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spinlock.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/stackvec.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tag_allocator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/timer_util.h
|
||||
)
|
||||
|
||||
get_property(NEO_CORE_UTILITIES GLOBAL PROPERTY NEO_CORE_UTILITIES)
|
||||
list(APPEND RUNTIME_SRCS_UTILITIES_BASE ${NEO_CORE_UTILITIES})
|
||||
|
||||
set(RUNTIME_SRCS_UTILITIES_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/directory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/timer_util.cpp
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include "runtime/os_interface/windows/os_time_win.h"
|
||||
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d9types.h>
|
||||
|
||||
#include "Windows.h"
|
||||
#include "d3d10.h"
|
||||
#include "umKmInc/sharedata.h"
|
||||
#include <d3d10.h>
|
||||
#include <d3dkmthk.h>
|
||||
|
||||
#define DECL_FUNCTIONS() \
|
||||
|
|
|
@ -85,6 +85,8 @@ if(WIN32)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_interface23.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_wddm_residency_allocations_container.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mock_helpers.h
|
||||
${IGDRCL_SRC_tests_mock_wddm}
|
||||
)
|
||||
else()
|
||||
|
@ -115,4 +117,4 @@ target_compile_definitions(igdrcl_mocks PRIVATE MOCKABLE_VIRTUAL=virtual $<TARGE
|
|||
|
||||
set_target_properties(igdrcl_mocks PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(igdrcl_mocks PROPERTIES FOLDER "test mocks")
|
||||
create_project_source_tree(igdrcl_mocks)
|
||||
create_project_source_tree(igdrcl_mocks ${IGDRCL_SOURCE_DIR})
|
||||
|
|
|
@ -11,11 +11,16 @@
|
|||
#include "runtime/os_interface/windows/gdi_interface.h"
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
#include "unit_tests/mock_gdi/mock_gdi.h"
|
||||
#include "unit_tests/mocks/mock_wddm_residency_allocations_container.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
WddmMock::WddmMock() : Wddm() {
|
||||
this->temporaryResources = std::make_unique<MockWddmResidentAllocationsContainer>(this);
|
||||
}
|
||||
|
||||
WddmMock::~WddmMock() {
|
||||
EXPECT_EQ(0, reservedAddresses.size());
|
||||
}
|
||||
|
@ -250,33 +255,6 @@ VOID *WddmMock::registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback
|
|||
return Wddm::registerTrimCallback(callback, residencyController);
|
||||
}
|
||||
|
||||
EvictionStatus WddmMock::evictAllTemporaryResources() {
|
||||
evictAllTemporaryResourcesResult.called++;
|
||||
evictAllTemporaryResourcesResult.status = Wddm::evictAllTemporaryResources();
|
||||
return evictAllTemporaryResourcesResult.status;
|
||||
}
|
||||
|
||||
EvictionStatus WddmMock::evictTemporaryResource(const D3DKMT_HANDLE &handle) {
|
||||
evictTemporaryResourceResult.called++;
|
||||
evictTemporaryResourceResult.status = Wddm::evictTemporaryResource(handle);
|
||||
return evictTemporaryResourceResult.status;
|
||||
}
|
||||
|
||||
void WddmMock::applyBlockingMakeResident(const D3DKMT_HANDLE &handle) {
|
||||
applyBlockingMakeResidentResult.called++;
|
||||
return Wddm::applyBlockingMakeResident(handle);
|
||||
}
|
||||
|
||||
void WddmMock::removeTemporaryResource(const D3DKMT_HANDLE &handle) {
|
||||
removeTemporaryResourceResult.called++;
|
||||
return Wddm::removeTemporaryResource(handle);
|
||||
}
|
||||
|
||||
std::unique_lock<SpinLock> WddmMock::acquireLock(SpinLock &lock) {
|
||||
acquireLockResult.called++;
|
||||
acquireLockResult.uint64ParamPassed = reinterpret_cast<uint64_t>(&lock);
|
||||
return Wddm::acquireLock(lock);
|
||||
}
|
||||
D3DGPU_VIRTUAL_ADDRESS WddmMock::reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size) {
|
||||
reserveGpuVirtualAddressResult.called++;
|
||||
return Wddm::reserveGpuVirtualAddress(minimumAddress, maximumAddress, size);
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
#include "runtime/memory_manager/host_ptr_defines.h"
|
||||
#include "runtime/os_interface/windows/wddm/wddm.h"
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
#include "runtime/os_interface/windows/windows_defs.h"
|
||||
#include "unit_tests/mocks/wddm_mock_helpers.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
|
@ -19,33 +21,6 @@
|
|||
namespace NEO {
|
||||
class GraphicsAllocation;
|
||||
|
||||
namespace WddmMockHelpers {
|
||||
struct CallResult {
|
||||
uint32_t called = 0;
|
||||
uint64_t uint64ParamPassed = -1;
|
||||
bool success = false;
|
||||
uint64_t commandBufferSubmitted = 0u;
|
||||
void *commandHeaderSubmitted = nullptr;
|
||||
void *cpuPtrPassed = nullptr;
|
||||
};
|
||||
struct MakeResidentCall : CallResult {
|
||||
std::vector<D3DKMT_HANDLE> handlePack;
|
||||
uint32_t handleCount = 0;
|
||||
};
|
||||
struct EvictCallResult : CallResult {
|
||||
EvictionStatus status = EvictionStatus::UNKNOWN;
|
||||
};
|
||||
struct KmDafLockCall : CallResult {
|
||||
std::vector<D3DKMT_HANDLE> lockedAllocations;
|
||||
};
|
||||
struct WaitFromCpuResult : CallResult {
|
||||
const MonitoredFence *monitoredFence = nullptr;
|
||||
};
|
||||
struct FreeGpuVirtualAddressCall : CallResult {
|
||||
uint64_t sizePassed = -1;
|
||||
};
|
||||
} // namespace WddmMockHelpers
|
||||
|
||||
class WddmMock : public Wddm {
|
||||
public:
|
||||
using Wddm::adapter;
|
||||
|
@ -59,10 +34,9 @@ class WddmMock : public Wddm {
|
|||
using Wddm::pagingFenceAddress;
|
||||
using Wddm::pagingQueue;
|
||||
using Wddm::temporaryResources;
|
||||
using Wddm::temporaryResourcesLock;
|
||||
using Wddm::wddmInterface;
|
||||
|
||||
WddmMock() : Wddm(){};
|
||||
WddmMock();
|
||||
~WddmMock();
|
||||
|
||||
bool makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) override;
|
||||
|
@ -98,11 +72,6 @@ class WddmMock : public Wddm {
|
|||
int virtualFree(void *ptr, size_t size, unsigned long flags) override;
|
||||
void releaseReservedAddress(void *reservedAddress) override;
|
||||
VOID *registerTrimCallback(PFND3DKMT_TRIMNOTIFICATIONCALLBACK callback, WddmResidencyController &residencyController) override;
|
||||
EvictionStatus evictAllTemporaryResources() override;
|
||||
EvictionStatus evictTemporaryResource(const D3DKMT_HANDLE &handle) override;
|
||||
void applyBlockingMakeResident(const D3DKMT_HANDLE &handle) override;
|
||||
void removeTemporaryResource(const D3DKMT_HANDLE &handle) override;
|
||||
std::unique_lock<SpinLock> acquireLock(SpinLock &lock) override;
|
||||
D3DGPU_VIRTUAL_ADDRESS reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size) override;
|
||||
bool reserveValidAddressRange(size_t size, void *&reservedMem);
|
||||
PLATFORM *getGfxPlatform() { return gfxPlatform.get(); }
|
||||
|
@ -137,11 +106,6 @@ class WddmMock : public Wddm {
|
|||
WddmMockHelpers::WaitFromCpuResult waitFromCpuResult;
|
||||
WddmMockHelpers::CallResult releaseReservedAddressResult;
|
||||
WddmMockHelpers::CallResult reserveValidAddressRangeResult;
|
||||
WddmMockHelpers::EvictCallResult evictAllTemporaryResourcesResult;
|
||||
WddmMockHelpers::EvictCallResult evictTemporaryResourceResult;
|
||||
WddmMockHelpers::CallResult applyBlockingMakeResidentResult;
|
||||
WddmMockHelpers::CallResult removeTemporaryResourceResult;
|
||||
WddmMockHelpers::CallResult acquireLockResult;
|
||||
WddmMockHelpers::CallResult registerTrimCallbackResult;
|
||||
WddmMockHelpers::CallResult getPagingFenceAddressResult;
|
||||
WddmMockHelpers::CallResult reserveGpuVirtualAddressResult;
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
#include "unit_tests/mocks/wddm_mock_helpers.h"
|
||||
|
||||
namespace NEO {
|
||||
class Wddm;
|
||||
|
||||
class MockWddmResidentAllocationsContainer : public WddmResidentAllocationsContainer {
|
||||
public:
|
||||
using WddmResidentAllocationsContainer::resourceHandles;
|
||||
using WddmResidentAllocationsContainer::resourcesLock;
|
||||
|
||||
MockWddmResidentAllocationsContainer(Wddm *wddm) : WddmResidentAllocationsContainer(wddm) {}
|
||||
virtual ~MockWddmResidentAllocationsContainer() = default;
|
||||
|
||||
bool makeResidentResource(const D3DKMT_HANDLE &handle) override {
|
||||
makeResidentResult.called++;
|
||||
makeResidentResult.success = WddmResidentAllocationsContainer::makeResidentResource(handle);
|
||||
return makeResidentResult.success;
|
||||
}
|
||||
|
||||
EvictionStatus evictAllResources() override {
|
||||
evictAllResourcesResult.called++;
|
||||
evictAllResourcesResult.status = WddmResidentAllocationsContainer::evictAllResources();
|
||||
return evictAllResourcesResult.status;
|
||||
}
|
||||
|
||||
EvictionStatus evictResource(const D3DKMT_HANDLE &handle) override {
|
||||
evictResourceResult.called++;
|
||||
evictResourceResult.status = WddmResidentAllocationsContainer::evictResource(handle);
|
||||
return evictResourceResult.status;
|
||||
}
|
||||
|
||||
std::unique_lock<SpinLock> acquireLock(SpinLock &lock) override {
|
||||
acquireLockResult.called++;
|
||||
acquireLockResult.uint64ParamPassed = reinterpret_cast<uint64_t>(&lock);
|
||||
return WddmResidentAllocationsContainer::acquireLock(lock);
|
||||
}
|
||||
|
||||
void removeResource(const D3DKMT_HANDLE &handle) override {
|
||||
removeResourceResult.called++;
|
||||
WddmResidentAllocationsContainer::removeResource(handle);
|
||||
}
|
||||
|
||||
WddmMockHelpers::CallResult makeResidentResult;
|
||||
WddmMockHelpers::CallResult acquireLockResult;
|
||||
WddmMockHelpers::CallResult removeResourceResult;
|
||||
WddmMockHelpers::EvictCallResult evictAllResourcesResult;
|
||||
WddmMockHelpers::EvictCallResult evictResourceResult;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/memory_manager/eviction_status.h"
|
||||
#include "runtime/os_interface/windows/windows_defs.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
namespace WddmMockHelpers {
|
||||
struct CallResult {
|
||||
uint32_t called = 0;
|
||||
uint64_t uint64ParamPassed = -1;
|
||||
bool success = false;
|
||||
uint64_t commandBufferSubmitted = 0u;
|
||||
void *commandHeaderSubmitted = nullptr;
|
||||
void *cpuPtrPassed = nullptr;
|
||||
};
|
||||
struct MakeResidentCall : CallResult {
|
||||
std::vector<D3DKMT_HANDLE> handlePack;
|
||||
uint32_t handleCount = 0;
|
||||
};
|
||||
struct EvictCallResult : CallResult {
|
||||
EvictionStatus status = EvictionStatus::UNKNOWN;
|
||||
};
|
||||
struct KmDafLockCall : CallResult {
|
||||
std::vector<D3DKMT_HANDLE> lockedAllocations;
|
||||
};
|
||||
struct WaitFromCpuResult : CallResult {
|
||||
const MonitoredFence *monitoredFence = nullptr;
|
||||
};
|
||||
struct FreeGpuVirtualAddressCall : CallResult {
|
||||
uint64_t sizePassed = -1;
|
||||
};
|
||||
} // namespace WddmMockHelpers
|
||||
|
||||
} // namespace NEO
|
|
@ -27,6 +27,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_mock.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo_create.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_residency_handler_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_linux_tests.h
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/linux/drm_residency_handler.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct DrmResidencyHandlerTest : public ::testing::Test {
|
||||
void SetUp() {
|
||||
drmResidencyHandler = std::make_unique<DrmResidencyHandler>();
|
||||
}
|
||||
|
||||
MockGraphicsAllocation graphicsAllocation;
|
||||
std::unique_ptr<DrmResidencyHandler> drmResidencyHandler;
|
||||
};
|
||||
|
||||
TEST_F(DrmResidencyHandlerTest, whenMakingResidentAllocaionExpectMakeResidentFail) {
|
||||
EXPECT_FALSE(drmResidencyHandler->makeResident(graphicsAllocation));
|
||||
EXPECT_FALSE(drmResidencyHandler->isResident(graphicsAllocation));
|
||||
}
|
||||
|
||||
TEST_F(DrmResidencyHandlerTest, whenEvictingResidentAllocationExpectEvictFalse) {
|
||||
EXPECT_FALSE(drmResidencyHandler->makeResident(graphicsAllocation));
|
||||
EXPECT_FALSE(drmResidencyHandler->evict(graphicsAllocation));
|
||||
EXPECT_FALSE(drmResidencyHandler->isResident(graphicsAllocation));
|
||||
}
|
|
@ -24,4 +24,9 @@ TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenDeviceHandleQueriedthenZeroIsRetu
|
|||
EXPECT_EQ(0u, osInterface.getDeviceHandle());
|
||||
}
|
||||
|
||||
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenResidencyInterfaceRetrievedThenCreatedObjectReturned) {
|
||||
OSInterface osInterface;
|
||||
EXPECT_NE(nullptr, osInterface.getResidencyInterface());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -41,6 +41,7 @@ set(IGDRCL_SRCS_tests_os_interface_windows
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_allocate_in_device_pool_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_handler_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_registry_reader.cpp
|
||||
)
|
||||
if(WIN32)
|
||||
|
|
|
@ -11,6 +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/sharings/gl/gl_arb_sync_event.h"
|
||||
#include "runtime/sharings/gl/gl_sharing.h"
|
||||
#include "unit_tests/mocks/gl/mock_gl_sharing.h"
|
||||
|
|
|
@ -21,7 +21,7 @@ TEST_F(OsInterfaceTest, GivenWindowsWhenCreateEentIsCalledThenValidEventHandleIs
|
|||
EXPECT_EQ(TRUE, ret);
|
||||
}
|
||||
|
||||
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedAndTrimCallbackIsRegistered) {
|
||||
TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInitializedTrimCallbackIsRegisteredResidencyHandlerCreated) {
|
||||
auto wddm = new WddmMock;
|
||||
OSInterface osInterface;
|
||||
osInterface.get()->setWddm(wddm);
|
||||
|
@ -33,4 +33,5 @@ TEST(OsContextTest, givenWddmWhenCreateOsContextAfterInitWddmThenOsContextIsInit
|
|||
EXPECT_TRUE(osContext->isInitialized());
|
||||
EXPECT_EQ(osContext->getWddm(), wddm);
|
||||
EXPECT_EQ(1u, wddm->registerTrimCallbackResult.called);
|
||||
EXPECT_NE(nullptr, osInterface.getResidencyInterface());
|
||||
}
|
||||
|
|
|
@ -757,164 +757,176 @@ TEST_F(Wddm20Tests, givenNullTrimCallbackHandleWhenUnregisteringTrimCallbackThen
|
|||
using WddmLockWithMakeResidentTests = Wddm20Tests;
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationThatDoesntNeedMakeResidentBeforeLockWhenLockThenDontStoreItOrCallMakeResident) {
|
||||
EXPECT_TRUE(wddm->temporaryResources.empty());
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
||||
wddm->lockResource(ALLOCATION_HANDLE, false);
|
||||
EXPECT_TRUE(wddm->temporaryResources.empty());
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
||||
wddm->unlockResource(ALLOCATION_HANDLE);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationThatNeedsMakeResidentBeforeLockWhenLockThenCallBlockingMakeResident) {
|
||||
wddm->lockResource(ALLOCATION_HANDLE, true);
|
||||
EXPECT_EQ(1u, wddm->applyBlockingMakeResidentResult.called);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->makeResidentResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenAcquireUniqueLock) {
|
||||
wddm->applyBlockingMakeResident(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&mockTemporaryResources->resourcesLock), mockTemporaryResources->acquireLockResult.uint64ParamPassed);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenCallMakeResidentAndStoreAllocation) {
|
||||
wddm->applyBlockingMakeResident(ALLOCATION_HANDLE);
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, wddm->temporaryResources.back());
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenWaitForCurrentPagingFenceValue) {
|
||||
wddm->mockPagingFence = 0u;
|
||||
wddm->currentPagingFenceValue = 3u;
|
||||
wddm->applyBlockingMakeResident(ALLOCATION_HANDLE);
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
||||
EXPECT_EQ(3u, wddm->mockPagingFence);
|
||||
EXPECT_EQ(3u, wddm->getPagingFenceAddressResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm;
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||
EXPECT_EQ(2u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(0x1);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
||||
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||
EXPECT_EQ(0u, gmockWddm.temporaryResources.size());
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->resourceHandles.size());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(0x1);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Return(false)).WillOnce(::testing::Return(true));
|
||||
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
||||
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||
EXPECT_EQ(1u, gmockWddm.temporaryResources.size());
|
||||
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation;
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(0x1);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.applyBlockingMakeResident(allocation.handle);
|
||||
EXPECT_EQ(2u, gmockWddm.temporaryResources.size());
|
||||
EXPECT_EQ(0x2, gmockWddm.temporaryResources.back());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingAllTemporaryResourcesThenEvictionIsNotApplied) {
|
||||
wddm->evictAllTemporaryResources();
|
||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictAllTemporaryResourcesResult.status);
|
||||
wddm->getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, mockTemporaryResources->evictAllResourcesResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesThenAcquireTemporaryResourcesLock) {
|
||||
wddm->evictAllTemporaryResources();
|
||||
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||
wddm->getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(1u, mockTemporaryResources->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&mockTemporaryResources->resourcesLock), mockTemporaryResources->acquireLockResult.uint64ParamPassed);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) {
|
||||
MockWddmAllocation allocation;
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(allocation.handle);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.evictAllTemporaryResources();
|
||||
EXPECT_EQ(1u, gmockWddm.evictAllTemporaryResourcesResult.called);
|
||||
EXPECT_EQ(EvictionStatus::SUCCESS, gmockWddm.evictAllTemporaryResourcesResult.status);
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(EvictionStatus::SUCCESS, mockTemporaryResources->evictAllResourcesResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesThenCallEvictForEachAllocationAndCleanList) {
|
||||
GmockWddm gmockWddm;
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
constexpr uint32_t numAllocations = 3u;
|
||||
for (auto i = 0u; i < numAllocations; i++) {
|
||||
gmockWddm.temporaryResources.push_back(i);
|
||||
mockTemporaryResources->resourceHandles.push_back(i);
|
||||
}
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(true));
|
||||
gmockWddm.evictAllTemporaryResources();
|
||||
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesAndOneOfThemFailsThenReturnFail) {
|
||||
GmockWddm gmockWddm;
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
constexpr uint32_t numAllocations = 3u;
|
||||
for (auto i = 0u; i < numAllocations; i++) {
|
||||
gmockWddm.temporaryResources.push_back(i);
|
||||
mockTemporaryResources->resourceHandles.push_back(i);
|
||||
}
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(3).WillOnce(::testing::Return(false)).WillRepeatedly(::testing::Return(true));
|
||||
gmockWddm.evictAllTemporaryResources();
|
||||
EXPECT_EQ(EvictionStatus::FAILED, gmockWddm.evictAllTemporaryResourcesResult.status);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(EvictionStatus::FAILED, mockTemporaryResources->evictAllResourcesResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingTemporaryResourceThenEvictionIsNotApplied) {
|
||||
wddm->evictTemporaryResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictTemporaryResourceResult.status);
|
||||
wddm->getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, mockTemporaryResources->evictResourceResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenAcquireTemporaryResourcesLock) {
|
||||
wddm->evictTemporaryResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(1u, wddm->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&wddm->temporaryResourcesLock), wddm->acquireLockResult.uint64ParamPassed);
|
||||
wddm->getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&mockTemporaryResources->resourcesLock), mockTemporaryResources->acquireLockResult.uint64ParamPassed);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingNonExistingTemporaryResourceThenEvictIsNotAppliedAndTemporaryResourcesAreRestored) {
|
||||
wddm->temporaryResources.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_FALSE(wddm->temporaryResources.empty());
|
||||
wddm->evictTemporaryResource(ALLOCATION_HANDLE + 1);
|
||||
EXPECT_FALSE(wddm->temporaryResources.empty());
|
||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, wddm->evictTemporaryResourceResult.status);
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_FALSE(mockTemporaryResources->resourceHandles.empty());
|
||||
wddm->getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE + 1);
|
||||
EXPECT_FALSE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(EvictionStatus::NOT_APPLIED, mockTemporaryResources->evictResourceResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictFailsThenReturnFail) {
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(ALLOCATION_HANDLE);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
gmockWddm.evictTemporaryResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
||||
EXPECT_EQ(EvictionStatus::FAILED, gmockWddm.evictTemporaryResourceResult.status);
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(EvictionStatus::FAILED, mockTemporaryResources->evictResourceResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictSucceedThenReturnSuccess) {
|
||||
GmockWddm gmockWddm;
|
||||
gmockWddm.temporaryResources.push_back(ALLOCATION_HANDLE);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.evictTemporaryResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(gmockWddm.temporaryResources.empty());
|
||||
EXPECT_EQ(EvictionStatus::SUCCESS, gmockWddm.evictTemporaryResourceResult.status);
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(EvictionStatus::SUCCESS, mockTemporaryResources->evictResourceResult.status);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheList) {
|
||||
wddm->temporaryResources.push_back(0x1);
|
||||
wddm->temporaryResources.push_back(0x2);
|
||||
wddm->temporaryResources.push_back(0x3);
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
mockTemporaryResources->resourceHandles.push_back(0x2);
|
||||
mockTemporaryResources->resourceHandles.push_back(0x3);
|
||||
|
||||
wddm->evictTemporaryResource(0x2);
|
||||
wddm->getTemporaryResourcesContainer()->evictResource(0x2);
|
||||
|
||||
EXPECT_EQ(2u, wddm->temporaryResources.size());
|
||||
EXPECT_EQ(0x1, wddm->temporaryResources.front());
|
||||
EXPECT_EQ(0x3, wddm->temporaryResources.back());
|
||||
EXPECT_EQ(2u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x1, mockTemporaryResources->resourceHandles.front());
|
||||
EXPECT_EQ(0x3, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBeforeLockThenLockWithBlockingMakeResident) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "runtime/platform/platform.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_wddm.h"
|
||||
#include "unit_tests/mocks/mock_wddm_residency_allocations_container.h"
|
||||
#include "unit_tests/os_interface/windows/gdi_dll_fixture.h"
|
||||
#include "unit_tests/os_interface/windows/mock_gdi_interface.h"
|
||||
|
||||
|
@ -23,7 +24,7 @@
|
|||
|
||||
namespace NEO {
|
||||
struct WddmFixture : ::testing::Test {
|
||||
void SetUp() {
|
||||
void SetUp() override {
|
||||
executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
wddm = static_cast<WddmMock *>(Wddm::createWddm());
|
||||
executionEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
|
@ -35,6 +36,7 @@ struct WddmFixture : ::testing::Test {
|
|||
auto hwInfo = *platformDevices[0];
|
||||
wddm->init(hwInfo);
|
||||
osContext = std::make_unique<OsContextWin>(*osInterface->get()->getWddm(), 0u, 1u, HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances()[0], preemptionMode, false);
|
||||
mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(wddm->temporaryResources.get());
|
||||
}
|
||||
|
||||
WddmMock *wddm = nullptr;
|
||||
|
@ -43,6 +45,7 @@ struct WddmFixture : ::testing::Test {
|
|||
ExecutionEnvironment *executionEnvironment;
|
||||
|
||||
MockGdi *gdi = nullptr;
|
||||
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
||||
};
|
||||
|
||||
struct WddmFixtureWithMockGdiDll : public GdiDllFixture {
|
||||
|
|
|
@ -1637,28 +1637,28 @@ TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingLockedAllocationThatDoesntNeed
|
|||
memoryManager->lockResource(allocation);
|
||||
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(0u, wddm->evictTemporaryResourceResult.called);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
|
||||
}
|
||||
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingNotLockedAllocationThatDoesntNeedMakeResidentBeforeLockThenDontEvictAllocationFromWddmTemporaryResources) {
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||
EXPECT_FALSE(allocation->isLocked());
|
||||
EXPECT_FALSE(allocation->needsMakeResidentBeforeLock);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(0u, wddm->evictTemporaryResourceResult.called);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
|
||||
}
|
||||
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingLockedAllocationThatNeedsMakeResidentBeforeLockThenRemoveTemporaryResource) {
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||
allocation->needsMakeResidentBeforeLock = true;
|
||||
memoryManager->lockResource(allocation);
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(1u, wddm->removeTemporaryResourceResult.called);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->removeResourceResult.called);
|
||||
}
|
||||
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingNotLockedAllocationThatNeedsMakeResidentBeforeLockThenDontEvictAllocationFromWddmTemporaryResources) {
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||
allocation->needsMakeResidentBeforeLock = true;
|
||||
EXPECT_FALSE(allocation->isLocked());
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(0u, wddm->evictTemporaryResourceResult.called);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->evictResourceResult.called);
|
||||
}
|
||||
TEST_F(WddmMemoryManagerSimpleTest, whenDestroyingAllocationWithReservedGpuVirtualAddressThenReleaseTheAddress) {
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}));
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_gmm_page_table_mngr.h"
|
||||
#include "unit_tests/mocks/mock_wddm_residency_allocations_container.h"
|
||||
#include "unit_tests/os_interface/windows/mock_gdi_interface.h"
|
||||
#include "unit_tests/os_interface/windows/mock_wddm_memory_manager.h"
|
||||
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
||||
|
@ -61,6 +62,7 @@ class MockWddmMemoryManagerFixture {
|
|||
1, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]), false);
|
||||
|
||||
osContext->incRefInternal();
|
||||
mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(wddm->getTemporaryResourcesContainer());
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
|
@ -70,6 +72,7 @@ class MockWddmMemoryManagerFixture {
|
|||
ExecutionEnvironment *executionEnvironment;
|
||||
std::unique_ptr<MockWddmMemoryManager> memoryManager;
|
||||
WddmMock *wddm = nullptr;
|
||||
MockWddmResidentAllocationsContainer *mockTemporaryResources;
|
||||
OsContext *osContext = nullptr;
|
||||
MockGdi *gdi = nullptr;
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "core/memory_manager/residency_handler.h"
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/windows/wddm_residency_handler.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_allocation_properties.h"
|
||||
#include "unit_tests/mocks/mock_wddm.h"
|
||||
#include "unit_tests/os_interface/windows/mock_wddm_allocation.h"
|
||||
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct WddmResidencyHandlerTest : public WddmTest {
|
||||
void SetUp() override {
|
||||
WddmTest::SetUp();
|
||||
wddmResidencyHandler = std::make_unique<WddmResidencyHandler>(wddm);
|
||||
wddmAllocation.handle = 0x2;
|
||||
}
|
||||
|
||||
std::unique_ptr<WddmResidencyHandler> wddmResidencyHandler;
|
||||
MockWddmAllocation wddmAllocation;
|
||||
};
|
||||
|
||||
TEST_F(WddmResidencyHandlerTest, whenMakingResidentAllocaionExpectMakeResidentCalled) {
|
||||
EXPECT_TRUE(wddmResidencyHandler->makeResident(wddmAllocation));
|
||||
EXPECT_TRUE(wddmResidencyHandler->isResident(wddmAllocation));
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyHandlerTest, whenEvictingResidentAllocationExpectEvictCalled) {
|
||||
EXPECT_TRUE(wddmResidencyHandler->makeResident(wddmAllocation));
|
||||
EXPECT_TRUE(wddmResidencyHandler->evict(wddmAllocation));
|
||||
EXPECT_FALSE(wddmResidencyHandler->isResident(wddmAllocation));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
@ -19,9 +19,12 @@ set(IGDRCL_SRCS_tests_utilities
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/numeric_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/reference_tracked_object_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/spinlock_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tag_allocator_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/timer_util_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vec_tests.cpp
|
||||
)
|
||||
|
||||
get_property(NEO_CORE_UTILITIES_TESTS GLOBAL PROPERTY NEO_CORE_UTILITIES_TESTS)
|
||||
list(APPEND IGDRCL_SRCS_tests_utilities ${NEO_CORE_UTILITIES_TESTS})
|
||||
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_utilities})
|
||||
|
|
Loading…
Reference in New Issue