fix: aub residency in HW+AUB mode

Related-To: NEO-9230
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2023-11-27 13:47:52 +00:00
committed by Compute-Runtime-Automation
parent 6c4e46f6a6
commit 06ec4c3a82
40 changed files with 857 additions and 85 deletions

View File

@@ -40,7 +40,7 @@ TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFro
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]); auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
mock->setupIoctlHelper(defaultHwInfo->platform.eProductFamily); mock->setupIoctlHelper(defaultHwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment); auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment);
@@ -112,7 +112,7 @@ TEST(DrmMemoryManagerTest, givenMultipleThreadsWhenSharedAllocationIsCreatedThen
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]); auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
mock->setupIoctlHelper(defaultHwInfo->platform.eProductFamily); mock->setupIoctlHelper(defaultHwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment); auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment);

View File

@@ -29,7 +29,7 @@ struct ClCreateCommandQueueWithPropertiesLinux : public UltCommandStreamReceiver
auto osInterface = new OSInterface(); auto osInterface = new OSInterface();
osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface.reset(osInterface); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface.reset(osInterface);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex, false);
executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment)); executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex)); mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));

View File

@@ -16,6 +16,8 @@
#include "shared/source/helpers/options.h" #include "shared/source/helpers/options.h"
#include "shared/source/utilities/spinlock.h" #include "shared/source/utilities/spinlock.h"
#include "aubstream/allocation_params.h"
#include <atomic> #include <atomic>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@@ -245,6 +247,7 @@ class CommandStreamReceiver {
virtual bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation); virtual bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation) { return writeMemory(gfxAllocation, false, 0, 0); } MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation) { return writeMemory(gfxAllocation, false, 0, 0); }
virtual bool writeMemory(GraphicsAllocation &gfxAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) { return false; } virtual bool writeMemory(GraphicsAllocation &gfxAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) { return false; }
virtual void writeMemoryAub(aub_stream::AllocationParams &allocationParams){};
virtual bool isMultiOsContextCapable() const = 0; virtual bool isMultiOsContextCapable() const = 0;

View File

@@ -7,6 +7,7 @@
#pragma once #pragma once
#include "shared/source/command_stream/command_stream_receiver_hw.h" #include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/helpers/hardware_context_controller.h"
#include "shared/source/memory_manager/memory_banks.h" #include "shared/source/memory_manager/memory_banks.h"
#include "aub_mapper_common.h" #include "aub_mapper_common.h"
@@ -20,7 +21,6 @@ struct AubStream;
namespace NEO { namespace NEO {
class AddressMapper; class AddressMapper;
class GraphicsAllocation; class GraphicsAllocation;
class HardwareContextController;
template <typename GfxFamily> template <typename GfxFamily>
class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<GfxFamily> { class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<GfxFamily> {
protected: protected:
@@ -59,6 +59,9 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
virtual void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) = 0; virtual void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) = 0;
virtual void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) = 0; virtual void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) = 0;
virtual void writeMMIO(uint32_t offset, uint32_t value) = 0; virtual void writeMMIO(uint32_t offset, uint32_t value) = 0;
void writeMemoryAub(aub_stream::AllocationParams &allocationParams) override {
hardwareContextController->writeMemory(allocationParams);
}
virtual void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) = 0; virtual void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) = 0;
virtual bool isAubWritable(GraphicsAllocation &graphicsAllocation) const = 0; virtual bool isAubWritable(GraphicsAllocation &graphicsAllocation) const = 0;

View File

@@ -7,9 +7,13 @@
#include "shared/source/os_interface/aub_memory_operations_handler.h" #include "shared/source/os_interface/aub_memory_operations_handler.h"
#include "shared/source/aub/aub_helper.h"
#include "shared/source/aub_mem_dump/aub_mem_dump.h" #include "shared/source/aub_mem_dump/aub_mem_dump.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/device/device.h"
#include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/cache_settings_helper.h"
#include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/memory_manager/graphics_allocation.h"
#include "aubstream/allocation_params.h" #include "aubstream/allocation_params.h"
@@ -29,7 +33,12 @@ MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(Device *device,
auto lock = acquireLock(resourcesLock); auto lock = acquireLock(resourcesLock);
int hint = AubMemDump::DataTypeHintValues::TraceNotype; int hint = AubMemDump::DataTypeHintValues::TraceNotype;
for (const auto &allocation : gfxAllocations) { for (const auto &allocation : gfxAllocations) {
aub_stream::AllocationParams params(allocation->getGpuAddress(), if (!isAubWritable(*allocation, device)) {
continue;
}
uint64_t gpuAddress = device ? device->getGmmHelper()->decanonize(allocation->getGpuAddress()) : allocation->getGpuAddress();
aub_stream::AllocationParams params(gpuAddress,
allocation->getUnderlyingBuffer(), allocation->getUnderlyingBuffer(),
allocation->getUnderlyingBufferSize(), allocation->getUnderlyingBufferSize(),
allocation->storageInfo.getMemoryBanks(), allocation->storageInfo.getMemoryBanks(),
@@ -43,10 +52,19 @@ MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(Device *device,
params.additionalParams.uncached = CacheSettingsHelper::isUncachedType(gmm->resourceParams.Usage); params.additionalParams.uncached = CacheSettingsHelper::isUncachedType(gmm->resourceParams.Usage);
} }
aubManager->writeMemory2(params); if (allocation->storageInfo.cloningOfPageTables || !allocation->isAllocatedInLocalMemoryPool()) {
aubManager->writeMemory2(params);
} else {
device->getDefaultEngine().commandStreamReceiver->writeMemoryAub(params);
}
if (!allocation->getAubInfo().writeMemoryOnly) { if (!allocation->getAubInfo().writeMemoryOnly) {
residentAllocations.push_back(allocation); residentAllocations.push_back(allocation);
} }
if (AubHelper::isOneTimeAubWritableAllocationType(allocation->getAllocationType())) {
setAubWritable(false, *allocation, device);
}
} }
return MemoryOperationsStatus::SUCCESS; return MemoryOperationsStatus::SUCCESS;
} }
@@ -79,8 +97,44 @@ MemoryOperationsStatus AubMemoryOperationsHandler::isResident(Device *device, Gr
return MemoryOperationsStatus::SUCCESS; return MemoryOperationsStatus::SUCCESS;
} }
} }
void AubMemoryOperationsHandler::setAubManager(aub_stream::AubManager *aubManager) { void AubMemoryOperationsHandler::setAubManager(aub_stream::AubManager *aubManager) {
this->aubManager = aubManager; this->aubManager = aubManager;
} }
bool AubMemoryOperationsHandler::isAubWritable(GraphicsAllocation &graphicsAllocation, Device *device) const {
if (!device) {
return false;
}
auto bank = static_cast<uint32_t>(getMemoryBanksBitfield(&graphicsAllocation, device).to_ulong());
if (bank == 0u || graphicsAllocation.storageInfo.cloningOfPageTables) {
bank = GraphicsAllocation::defaultBank;
}
return graphicsAllocation.isAubWritable(bank);
}
void AubMemoryOperationsHandler::setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation, Device *device) {
if (!device) {
return;
}
auto bank = static_cast<uint32_t>(getMemoryBanksBitfield(&graphicsAllocation, device).to_ulong());
if (bank == 0u || graphicsAllocation.storageInfo.cloningOfPageTables) {
bank = GraphicsAllocation::defaultBank;
}
graphicsAllocation.setAubWritable(writable, bank);
}
DeviceBitfield AubMemoryOperationsHandler::getMemoryBanksBitfield(GraphicsAllocation *allocation, Device *device) const {
if (allocation->getMemoryPool() == MemoryPool::LocalMemory) {
if (allocation->storageInfo.memoryBanks.any()) {
if (allocation->storageInfo.cloningOfPageTables ||
device->getDefaultEngine().commandStreamReceiver->isMultiOsContextCapable()) {
return allocation->storageInfo.memoryBanks;
}
}
return device->getDeviceBitfield();
}
return {};
}
} // namespace NEO } // namespace NEO

View File

@@ -1,11 +1,12 @@
/* /*
* Copyright (C) 2019-2022 Intel Corporation * Copyright (C) 2019-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
*/ */
#pragma once #pragma once
#include "shared/source/helpers/device_bitfield.h"
#include "shared/source/memory_manager/memory_operations_handler.h" #include "shared/source/memory_manager/memory_operations_handler.h"
#include "shared/source/utilities/spinlock.h" #include "shared/source/utilities/spinlock.h"
@@ -30,7 +31,11 @@ class AubMemoryOperationsHandler : public MemoryOperationsHandler {
void setAubManager(aub_stream::AubManager *aubManager); void setAubManager(aub_stream::AubManager *aubManager);
bool isAubWritable(GraphicsAllocation &graphicsAllocation, Device *device) const;
void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation, Device *device);
protected: protected:
DeviceBitfield getMemoryBanksBitfield(GraphicsAllocation *allocation, Device *device) const;
[[nodiscard]] MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock) { [[nodiscard]] MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock) {
return std::unique_lock<SpinLock>{lock}; return std::unique_lock<SpinLock>{lock};
} }

View File

@@ -38,6 +38,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_create.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_with_aub_dump.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_create_multi_host_allocation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_create_multi_host_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers_checks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_wrappers_checks.cpp

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019-2022 Intel Corporation * Copyright (C) 2019-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -25,7 +25,7 @@ class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
virtual MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) = 0; virtual MemoryOperationsStatus evictUnusedAllocations(bool waitForCompletion, bool isLockNeeded) = 0;
static std::unique_ptr<DrmMemoryOperationsHandler> create(Drm &drm, uint32_t rootDeviceIndex); static std::unique_ptr<DrmMemoryOperationsHandler> create(Drm &drm, uint32_t rootDeviceIndex, bool withAubDump);
uint32_t getRootDeviceIndex() const { uint32_t getRootDeviceIndex() const {
return this->rootDeviceIndex; return this->rootDeviceIndex;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2022 Intel Corporation * Copyright (C) 2020-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -8,18 +8,28 @@
#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h" #include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h" #include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_with_aub_dump.h"
#include "shared/source/os_interface/linux/drm_neo.h" #include "shared/source/os_interface/linux/drm_neo.h"
namespace NEO { namespace NEO {
std::unique_ptr<DrmMemoryOperationsHandler> DrmMemoryOperationsHandler::create(Drm &drm, uint32_t rootDeviceIndex) { std::unique_ptr<DrmMemoryOperationsHandler> DrmMemoryOperationsHandler::create(Drm &drm, uint32_t rootDeviceIndex, bool withAubDump) {
bool useVmBind = drm.isVmBindAvailable(); bool useVmBind = drm.isVmBindAvailable();
auto rootDeviceEnv = drm.getRootDeviceEnvironment().executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get();
if (useVmBind) { if (useVmBind) {
return std::make_unique<DrmMemoryOperationsHandlerBind>(drm.getRootDeviceEnvironment(), rootDeviceIndex); if (withAubDump) {
return std::make_unique<DrmMemoryOperationsHandlerWithAubDump<DrmMemoryOperationsHandlerBind>>(*rootDeviceEnv, rootDeviceIndex);
} else {
return std::make_unique<DrmMemoryOperationsHandlerBind>(drm.getRootDeviceEnvironment(), rootDeviceIndex);
}
} }
return std::make_unique<DrmMemoryOperationsHandlerDefault>(rootDeviceIndex); if (withAubDump) {
return std::make_unique<DrmMemoryOperationsHandlerWithAubDump<DrmMemoryOperationsHandlerDefault>>(*rootDeviceEnv, rootDeviceIndex);
} else {
return std::make_unique<DrmMemoryOperationsHandlerDefault>(rootDeviceIndex);
}
} }
} // namespace NEO } // namespace NEO

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2022 Intel Corporation * Copyright (C) 2020-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -12,9 +12,11 @@
namespace NEO { namespace NEO {
class OsContextLinux; class OsContextLinux;
struct RootDeviceEnvironment;
class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler { class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler {
public: public:
DrmMemoryOperationsHandlerDefault(uint32_t rootDeviceIndex); DrmMemoryOperationsHandlerDefault(uint32_t rootDeviceIndex);
DrmMemoryOperationsHandlerDefault(const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t rootDeviceIndex) : DrmMemoryOperationsHandlerDefault(rootDeviceIndex) {}
~DrmMemoryOperationsHandlerDefault() override; ~DrmMemoryOperationsHandlerDefault() override;
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override; MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override;

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/aub/aub_center.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/os_interface/aub_memory_operations_handler.h"
namespace NEO {
class Drm;
template <typename BaseOperationsHandler>
class DrmMemoryOperationsHandlerWithAubDump : public BaseOperationsHandler {
public:
DrmMemoryOperationsHandlerWithAubDump(RootDeviceEnvironment &rootDeviceEnvironment, uint32_t rootDeviceIndex)
: BaseOperationsHandler(rootDeviceEnvironment, rootDeviceIndex) {
if (!rootDeviceEnvironment.aubCenter) {
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
auto hardwareInfo = rootDeviceEnvironment.getMutableHardwareInfo();
auto localMemoryEnabled = gfxCoreHelper.getEnableLocalMemory(*hardwareInfo);
rootDeviceEnvironment.initGmm();
rootDeviceEnvironment.initAubCenter(localMemoryEnabled, "", static_cast<CommandStreamReceiverType>(CommandStreamReceiverType::CSR_HW_WITH_AUB));
}
const auto aubCenter = rootDeviceEnvironment.aubCenter.get();
aubMemoryOperationsHandler = std::make_unique<AubMemoryOperationsHandler>(aubCenter->getAubManager());
};
~DrmMemoryOperationsHandlerWithAubDump() override = default;
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override {
aubMemoryOperationsHandler->makeResident(device, gfxAllocations);
return BaseOperationsHandler::makeResident(device, gfxAllocations);
}
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override {
aubMemoryOperationsHandler->evict(device, gfxAllocation);
return BaseOperationsHandler::evict(device, gfxAllocation);
}
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override {
aubMemoryOperationsHandler->isResident(device, gfxAllocation);
return BaseOperationsHandler::isResident(device, gfxAllocation);
}
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override {
aubMemoryOperationsHandler->makeResidentWithinOsContext(osContext, gfxAllocations, evictable);
return BaseOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable);
}
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
aubMemoryOperationsHandler->evictWithinOsContext(osContext, gfxAllocation);
return BaseOperationsHandler::evictWithinOsContext(osContext, gfxAllocation);
}
protected:
std::unique_ptr<AubMemoryOperationsHandler> aubMemoryOperationsHandler;
};
} // namespace NEO

View File

@@ -5,6 +5,7 @@
* *
*/ */
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h" #include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
#include "shared/source/os_interface/linux/drm_neo.h" #include "shared/source/os_interface/linux/drm_neo.h"
@@ -50,7 +51,9 @@ bool initDrmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootD
if (productHelper.configureHwInfoDrm(hardwareInfo, hardwareInfo, *rootDeviceEnv)) { if (productHelper.configureHwInfoDrm(hardwareInfo, hardwareInfo, *rootDeviceEnv)) {
return false; return false;
} }
rootDeviceEnv->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex);
const bool isCsrHwWithAub = DebugManager.flags.SetCommandStreamReceiver.get() == CommandStreamReceiverType::CSR_HW_WITH_AUB;
rootDeviceEnv->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex, isCsrHwWithAub);
[[maybe_unused]] bool result = rootDeviceEnv->initAilConfiguration(); [[maybe_unused]] bool result = rootDeviceEnv->initAilConfiguration();
DEBUG_BREAK_IF(!result); DEBUG_BREAK_IF(!result);

View File

@@ -111,6 +111,8 @@ set(NEO_CORE_OS_INTERFACE_WDDM
${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_engine_mapper.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler_with_aub_dump.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_allocations_container.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_allocations_container.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller.cpp

View File

@@ -21,7 +21,10 @@ bool initWddmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, RootDeviceEnv
if (!wddm->init()) { if (!wddm->init()) {
return false; return false;
} }
rootDeviceEnv->memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
const bool isCsrHwWithAub = DebugManager.flags.SetCommandStreamReceiver.get() == CommandStreamReceiverType::CSR_HW_WITH_AUB;
rootDeviceEnv->memoryOperationsInterface = WddmMemoryOperationsHandler::create(wddm, rootDeviceEnv, isCsrHwWithAub);
return true; return true;
} }
} // namespace NEO } // namespace NEO

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019-2021 Intel Corporation * Copyright (C) 2019-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -12,6 +12,7 @@
namespace NEO { namespace NEO {
struct RootDeviceEnvironment;
class Wddm; class Wddm;
class WddmResidentAllocationsContainer; class WddmResidentAllocationsContainer;
@@ -20,6 +21,8 @@ class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
WddmMemoryOperationsHandler(Wddm *wddm); WddmMemoryOperationsHandler(Wddm *wddm);
~WddmMemoryOperationsHandler() override; ~WddmMemoryOperationsHandler() override;
static std::unique_ptr<WddmMemoryOperationsHandler> create(Wddm *wddm, RootDeviceEnvironment *rootDeviceEnvironment, bool withAubDump);
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override; MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override; MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override; MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
#include "shared/source/os_interface/windows/wddm_memory_operations_handler_with_aub_dump.h"
namespace NEO {
std::unique_ptr<WddmMemoryOperationsHandler> WddmMemoryOperationsHandler::create(Wddm *wddm, RootDeviceEnvironment *rootDeviceEnvironment, bool withAubDump) {
if (withAubDump) {
return std::make_unique<WddmMemoryOperationsHandlerWithAubDump<WddmMemoryOperationsHandler>>(wddm, *rootDeviceEnvironment);
} else {
return std::make_unique<WddmMemoryOperationsHandler>(wddm);
}
}
} // namespace NEO

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/aub/aub_center.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/os_interface/aub_memory_operations_handler.h"
namespace NEO {
class Wddm;
template <typename BaseOperationsHandler>
class WddmMemoryOperationsHandlerWithAubDump : public BaseOperationsHandler {
public:
WddmMemoryOperationsHandlerWithAubDump(Wddm *wddm, RootDeviceEnvironment &rootDeviceEnvironment)
: BaseOperationsHandler(wddm) {
if (!rootDeviceEnvironment.aubCenter) {
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
auto hardwareInfo = rootDeviceEnvironment.getMutableHardwareInfo();
auto localMemoryEnabled = gfxCoreHelper.getEnableLocalMemory(*hardwareInfo);
rootDeviceEnvironment.initGmm();
rootDeviceEnvironment.initAubCenter(localMemoryEnabled, "", static_cast<CommandStreamReceiverType>(CommandStreamReceiverType::CSR_HW_WITH_AUB));
}
const auto aubCenter = rootDeviceEnvironment.aubCenter.get();
aubMemoryOperationsHandler = std::make_unique<AubMemoryOperationsHandler>(aubCenter->getAubManager());
};
~WddmMemoryOperationsHandlerWithAubDump() override = default;
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override {
aubMemoryOperationsHandler->makeResident(device, gfxAllocations);
return BaseOperationsHandler::makeResident(device, gfxAllocations);
}
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override {
aubMemoryOperationsHandler->evict(device, gfxAllocation);
return BaseOperationsHandler::evict(device, gfxAllocation);
}
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override {
aubMemoryOperationsHandler->isResident(device, gfxAllocation);
return BaseOperationsHandler::isResident(device, gfxAllocation);
}
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override {
aubMemoryOperationsHandler->makeResidentWithinOsContext(osContext, gfxAllocations, evictable);
return BaseOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable);
}
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
aubMemoryOperationsHandler->evictWithinOsContext(osContext, gfxAllocation);
return BaseOperationsHandler::evictWithinOsContext(osContext, gfxAllocation);
}
protected:
std::unique_ptr<AubMemoryOperationsHandler> aubMemoryOperationsHandler;
};
} // namespace NEO

View File

@@ -23,6 +23,7 @@ set(NEO_CORE_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_csr.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_csr.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_file_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_file_stream.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_memory_operations_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_subcapture_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_subcapture_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_bindless_heaps_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_bindless_heaps_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_builtins.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_builtins.h

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/os_interface/aub_memory_operations_handler.h"
#include "shared/source/utilities/arrayref.h"
namespace NEO {
class Device;
class GraphicsAllocation;
class OsContext;
struct MockAubMemoryOperationsHandler : public AubMemoryOperationsHandler {
using AubMemoryOperationsHandler::AubMemoryOperationsHandler;
using AubMemoryOperationsHandler::getMemoryBanksBitfield;
using AubMemoryOperationsHandler::residentAllocations;
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override {
makeResidentCalled = true;
return AubMemoryOperationsHandler::makeResident(device, gfxAllocations);
}
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override {
evictCalled = true;
return AubMemoryOperationsHandler::evict(device, gfxAllocation);
}
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override {
isResidentCalled = true;
return AubMemoryOperationsHandler::isResident(device, gfxAllocation);
}
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override {
makeResidentWithinOsContextCalled = true;
return AubMemoryOperationsHandler::makeResidentWithinOsContext(osContext, gfxAllocations, evictable);
}
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
evictWithinOsContextCalled = true;
return AubMemoryOperationsHandler::evictWithinOsContext(osContext, gfxAllocation);
}
bool makeResidentCalled = false;
bool evictCalled = false;
bool isResidentCalled = false;
bool makeResidentWithinOsContextCalled = false;
bool evictWithinOsContextCalled = false;
};
} // namespace NEO

View File

@@ -43,6 +43,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
using CommandStreamReceiver::internalAllocationStorage; using CommandStreamReceiver::internalAllocationStorage;
using CommandStreamReceiver::latestFlushedTaskCount; using CommandStreamReceiver::latestFlushedTaskCount;
using CommandStreamReceiver::latestSentTaskCount; using CommandStreamReceiver::latestSentTaskCount;
using CommandStreamReceiver::localMemoryEnabled;
using CommandStreamReceiver::newResources; using CommandStreamReceiver::newResources;
using CommandStreamReceiver::numClients; using CommandStreamReceiver::numClients;
using CommandStreamReceiver::osContext; using CommandStreamReceiver::osContext;
@@ -78,6 +79,10 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
void updateTagFromWait() override{}; void updateTagFromWait() override{};
bool isUpdateTagFromWaitEnabled() override { return false; }; bool isUpdateTagFromWaitEnabled() override { return false; };
void writeMemoryAub(aub_stream::AllocationParams &allocationParams) override {
writeMemoryAubCalled++;
}
bool isMultiOsContextCapable() const override { return multiOsContextCapable; } bool isMultiOsContextCapable() const override { return multiOsContextCapable; }
bool isGpuHangDetected() const override { bool isGpuHangDetected() const override {
@@ -206,6 +211,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
int *flushBatchedSubmissionsCallCounter = nullptr; int *flushBatchedSubmissionsCallCounter = nullptr;
uint32_t waitForCompletionWithTimeoutCalled = 0; uint32_t waitForCompletionWithTimeoutCalled = 0;
uint32_t fillReusableAllocationsListCalled = 0; uint32_t fillReusableAllocationsListCalled = 0;
uint32_t writeMemoryAubCalled = 0;
uint32_t makeResidentCalledTimes = 0; uint32_t makeResidentCalledTimes = 0;
uint32_t downloadAllocationsCalledCount = 0; uint32_t downloadAllocationsCalledCount = 0;
int hostPtrSurfaceCreationMutexLockCount = 0; int hostPtrSurfaceCreationMutexLockCount = 0;

View File

@@ -78,7 +78,7 @@ class DrmBufferObjectFixture {
void setUp() { void setUp() {
this->mock = std::make_unique<DrmClass>(*executionEnvironment.rootDeviceEnvironments[0]); this->mock = std::make_unique<DrmClass>(*executionEnvironment.rootDeviceEnvironments[0]);
ASSERT_NE(nullptr, this->mock); ASSERT_NE(nullptr, this->mock);
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u, false);
osContext.reset(new OsContextLinux(*this->mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor())); osContext.reset(new OsContextLinux(*this->mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor()));
this->mock->reset(); this->mock->reset();
bo = new TestedBufferObject(0, this->mock.get()); bo = new TestedBufferObject(0, this->mock.get());

View File

@@ -46,7 +46,7 @@ class DrmCommandStreamTest : public ::testing::Test {
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper(); gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
@@ -126,7 +126,7 @@ class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
mock = new DrmType(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]); mock = new DrmType(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, rootDeviceIndex); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, rootDeviceIndex, false);
csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment, rootDeviceIndex, 1); csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment, rootDeviceIndex, 1);
ASSERT_NE(nullptr, csr); ASSERT_NE(nullptr, csr);
@@ -207,7 +207,7 @@ class DrmCommandStreamEnhancedWithFailingExecTemplate : public ::testing::Test {
mock = new T(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]); mock = new T(*executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, rootDeviceIndex); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, rootDeviceIndex, false);
csr = new TestedDrmCommandStreamReceiverWithFailingExec<GfxFamily>(*executionEnvironment, rootDeviceIndex, 1); csr = new TestedDrmCommandStreamReceiverWithFailingExec<GfxFamily>(*executionEnvironment, rootDeviceIndex, 1);
ASSERT_NE(nullptr, csr); ASSERT_NE(nullptr, csr);

View File

@@ -25,7 +25,7 @@ void DrmMemoryManagerBasic::SetUp() {
executionEnvironment.rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[i]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[i]);
executionEnvironment.rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, i); executionEnvironment.rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, i, false);
executionEnvironment.rootDeviceEnvironments[i]->initGmm(); executionEnvironment.rootDeviceEnvironments[i]->initGmm();
} }
} }
@@ -51,7 +51,7 @@ void DrmMemoryManagerFixture::setUp(DrmMockCustom *mock, bool localMemoryEnabled
rootDeviceEnvironment->setHwInfoAndInitHelpers(defaultHwInfo.get()); rootDeviceEnvironment->setHwInfoAndInitHelpers(defaultHwInfo.get());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>(); rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(new DrmMockCustom(*rootDeviceEnvironment))); rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(new DrmMockCustom(*rootDeviceEnvironment)));
rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*rootDeviceEnvironment->osInterface->getDriverModel()->as<Drm>(), i); rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*rootDeviceEnvironment->osInterface->getDriverModel()->as<Drm>(), i, false);
rootDeviceEnvironment->builtins.reset(new MockBuiltins); rootDeviceEnvironment->builtins.reset(new MockBuiltins);
rootDeviceEnvironment->initGmm(); rootDeviceEnvironment->initGmm();
} }
@@ -135,7 +135,7 @@ void DrmMemoryManagerFixtureWithoutQuietIoctlExpectation::setUp(bool enableLocal
rootDeviceEnvironment->setHwInfoAndInitHelpers(defaultHwInfo.get()); rootDeviceEnvironment->setHwInfoAndInitHelpers(defaultHwInfo.get());
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>(); rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(new DrmMockCustom(*rootDeviceEnvironment))); rootDeviceEnvironment->osInterface->setDriverModel(std::unique_ptr<DriverModel>(new DrmMockCustom(*rootDeviceEnvironment)));
rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*rootDeviceEnvironment->osInterface->getDriverModel()->as<Drm>(), i); rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*rootDeviceEnvironment->osInterface->getDriverModel()->as<Drm>(), i, false);
rootDeviceEnvironment->initGmm(); rootDeviceEnvironment->initGmm();
i++; i++;
} }
@@ -146,7 +146,7 @@ void DrmMemoryManagerFixtureWithoutQuietIoctlExpectation::setUp(bool enableLocal
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0}; regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, 0};
regionInfo[1].probedSize = 16 * GB; regionInfo[1].probedSize = 16 * GB;
mock->memoryInfo.reset(new MockedMemoryInfo(regionInfo, *mock)); mock->memoryInfo.reset(new MockedMemoryInfo(regionInfo, *mock));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
memoryManager.reset(new TestedDrmMemoryManager(enableLocalMem, false, false, *executionEnvironment)); memoryManager.reset(new TestedDrmMemoryManager(enableLocalMem, false, false, *executionEnvironment));
ASSERT_NE(nullptr, memoryManager); ASSERT_NE(nullptr, memoryManager);

View File

@@ -36,7 +36,7 @@ class DrmMemoryManagerWithSubDevicesPrelimTest : public ::testing::Test {
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
memoryManager = new TestedDrmMemoryManager(true, false, false, *executionEnvironment); memoryManager = new TestedDrmMemoryManager(true, false, false, *executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager); executionEnvironment->memoryManager.reset(memoryManager);
@@ -75,7 +75,7 @@ class DrmMemoryManagerLocalMemoryPrelimTest : public ::testing::Test {
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
memoryManager = new TestedDrmMemoryManager(localMemoryEnabled, false, false, *executionEnvironment); memoryManager = new TestedDrmMemoryManager(localMemoryEnabled, false, false, *executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager); executionEnvironment->memoryManager.reset(memoryManager);

View File

@@ -7,14 +7,17 @@
#include "shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.h" #include "shared/test/unit_test/os_interface/aub_memory_operations_handler_tests.h"
#include "shared/source/aub/aub_helper.h"
#include "shared/source/aub_mem_dump/aub_mem_dump.h" #include "shared/source/aub_mem_dump/aub_mem_dump.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_aub_manager.h" #include "shared/test/common/mocks/mock_aub_manager.h"
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_gmm.h" #include "shared/test/common/mocks/mock_gmm.h"
TEST_F(AubMemoryOperationsHandlerTests, givenNullPtrAsAubManagerWhenMakeResidentCalledThenFalseReturned) { TEST_F(AubMemoryOperationsHandlerTests, givenNullPtrAsAubManagerWhenMakeResidentCalledThenFalseReturned) {
getMemoryOperationsHandler()->setAubManager(nullptr); getMemoryOperationsHandler()->setAubManager(nullptr);
auto memoryOperationsInterface = getMemoryOperationsHandler(); auto memoryOperationsInterface = getMemoryOperationsHandler();
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::DEVICE_UNINITIALIZED); EXPECT_EQ(result, MemoryOperationsStatus::DEVICE_UNINITIALIZED);
} }
@@ -22,7 +25,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThe
MockAubManager aubManager; MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager); getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler(); auto memoryOperationsInterface = getMemoryOperationsHandler();
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called); EXPECT_TRUE(aubManager.writeMemory2Called);
@@ -32,7 +35,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThe
aubManager.writeMemory2Called = false; aubManager.writeMemory2Called = false;
result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called); EXPECT_TRUE(aubManager.writeMemory2Called);
@@ -41,6 +44,32 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThe
EXPECT_EQ(2u, memoryOperationsInterface->residentAllocations.size()); EXPECT_EQ(2u, memoryOperationsInterface->residentAllocations.size());
} }
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerAndAllocationOfOneTimeAubWritableAllocationTypeWhenMakeResidentCalledTwoTimesThenWriteMemoryOnce) {
ASSERT_TRUE(AubHelper::isOneTimeAubWritableAllocationType(AllocationType::BUFFER));
allocPtr->setAllocationType(AllocationType::BUFFER);
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called);
auto itor = std::find(memoryOperationsInterface->residentAllocations.begin(), memoryOperationsInterface->residentAllocations.end(), allocPtr);
EXPECT_NE(memoryOperationsInterface->residentAllocations.end(), itor);
EXPECT_EQ(1u, memoryOperationsInterface->residentAllocations.size());
aubManager.writeMemory2Called = false;
result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_FALSE(aubManager.writeMemory2Called);
itor = std::find(memoryOperationsInterface->residentAllocations.begin(), memoryOperationsInterface->residentAllocations.end(), allocPtr);
EXPECT_NE(memoryOperationsInterface->residentAllocations.end(), itor);
EXPECT_EQ(1u, memoryOperationsInterface->residentAllocations.size());
}
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnWriteOnlyAllocationThenTrueReturnedAndWriteCalled) { TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnWriteOnlyAllocationThenTrueReturnedAndWriteCalled) {
MockAubManager aubManager; MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager); getMemoryOperationsHandler()->setAubManager(&aubManager);
@@ -48,7 +77,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnW
allocPtr->setWriteMemoryOnly(true); allocPtr->setWriteMemoryOnly(true);
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called); EXPECT_TRUE(aubManager.writeMemory2Called);
@@ -57,7 +86,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnW
EXPECT_EQ(0u, memoryOperationsInterface->residentAllocations.size()); EXPECT_EQ(0u, memoryOperationsInterface->residentAllocations.size());
aubManager.writeMemory2Called = false; aubManager.writeMemory2Called = false;
result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called); EXPECT_TRUE(aubManager.writeMemory2Called);
@@ -66,6 +95,34 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnW
EXPECT_EQ(0u, memoryOperationsInterface->residentAllocations.size()); EXPECT_EQ(0u, memoryOperationsInterface->residentAllocations.size());
} }
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerAndAllocationInLocalMemoryPoolWithoutPageTablesCloningWhenMakeResidentCalledThenWriteMemoryAubIsCalled) {
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
allocPtr = &allocation;
allocPtr->storageInfo.cloningOfPageTables = false;
DeviceBitfield deviceBitfield(1);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_FALSE(aubManager.writeMemory2Called);
EXPECT_EQ(1u, csr->writeMemoryAubCalled);
auto itor = std::find(memoryOperationsInterface->residentAllocations.begin(), memoryOperationsInterface->residentAllocations.end(), allocPtr);
EXPECT_NE(memoryOperationsInterface->residentAllocations.end(), itor);
EXPECT_EQ(1u, memoryOperationsInterface->residentAllocations.size());
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnCompressedAllocationThenPassCorrectParams) { TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnCompressedAllocationThenPassCorrectParams) {
MockAubManager aubManager; MockAubManager aubManager;
aubManager.storeAllocationParams = true; aubManager.storeAllocationParams = true;
@@ -78,7 +135,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnC
gmm.isCompressionEnabled = true; gmm.isCompressionEnabled = true;
allocPtr->setDefaultGmm(&gmm); allocPtr->setDefaultGmm(&gmm);
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called); EXPECT_TRUE(aubManager.writeMemory2Called);
@@ -102,7 +159,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnU
gmm.isCompressionEnabled = false; gmm.isCompressionEnabled = false;
allocPtr->setDefaultGmm(&gmm); allocPtr->setDefaultGmm(&gmm);
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(aubManager.writeMemory2Called); EXPECT_TRUE(aubManager.writeMemory2Called);
@@ -115,7 +172,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAllocationWhenMakeResidentCalledThe
MockAubManager aubManager; MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager); getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler(); auto memoryOperationsInterface = getMemoryOperationsHandler();
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(aubManager.hintToWriteMemory, AubMemDump::DataTypeHintValues::TraceNotype); EXPECT_EQ(aubManager.hintToWriteMemory, AubMemDump::DataTypeHintValues::TraceNotype);
} }
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenIsResidentCalledThenFalseReturned) { TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenIsResidentCalledThenFalseReturned) {
@@ -129,7 +186,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenIsResidentCal
MockAubManager aubManager; MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager); getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler(); auto memoryOperationsInterface = getMemoryOperationsHandler();
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
auto result = memoryOperationsInterface->isResident(nullptr, allocation); auto result = memoryOperationsInterface->isResident(nullptr, allocation);
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
} }
@@ -144,7 +201,203 @@ TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenEvictCalledTh
MockAubManager aubManager; MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager); getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler(); auto memoryOperationsInterface = getMemoryOperationsHandler();
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1)); memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
auto result = memoryOperationsInterface->evict(nullptr, allocation); auto result = memoryOperationsInterface->evict(nullptr, allocation);
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS); EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
} }
TEST_F(AubMemoryOperationsHandlerTests, givenLocalMemoryAndNonLocalMemoryAllocationWithStorageInfoNonZeroWhenGetMemoryBanksBitfieldThenBanksBitfieldForSystemMemoryIsReturned) {
auto executionEnvironment = device->getExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&hardwareInfo);
executionEnvironment->initializeMemoryManager();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::System64KBPages, false, false, MemoryManager::maxOsContextCount);
allocation.storageInfo.memoryBanks = 0x3u;
DeviceBitfield deviceBitfield(1);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(*osContext);
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
auto banksBitfield = memoryOperationsInterface->getMemoryBanksBitfield(&allocation, device.get());
EXPECT_TRUE(banksBitfield.none());
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenLocalMemoryNoncloneableAllocationWithManyBanksWhenGetMemoryBanksBitfieldThenSingleMemoryBankIsReturned) {
auto executionEnvironment = device->getExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&hardwareInfo);
executionEnvironment->initializeMemoryManager();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
allocation.storageInfo.memoryBanks = 0x3u;
allocation.storageInfo.cloningOfPageTables = false;
DeviceBitfield deviceBitfield(0x1u);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(*osContext);
EXPECT_FALSE(csr->isMultiOsContextCapable());
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
if (csr->isLocalMemoryEnabled()) {
auto banksBitfield = memoryOperationsInterface->getMemoryBanksBitfield(&allocation, device.get());
EXPECT_EQ(0x1lu, banksBitfield.to_ulong());
}
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenLocalMemoryCloneableAllocationWithManyBanksWhenGetMemoryBanksBitfieldThenAllMemoryBanksAreReturned) {
auto executionEnvironment = device->getExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&hardwareInfo);
executionEnvironment->initializeMemoryManager();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
allocation.storageInfo.memoryBanks = 0x3u;
allocation.storageInfo.cloningOfPageTables = true;
DeviceBitfield deviceBitfield(1);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(*osContext);
EXPECT_FALSE(csr->isMultiOsContextCapable());
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
if (csr->isLocalMemoryEnabled()) {
auto banksBitfield = memoryOperationsInterface->getMemoryBanksBitfield(&allocation, device.get());
EXPECT_EQ(0x3lu, banksBitfield.to_ulong());
}
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenLocalMemoryNoncloneableAllocationWithManyBanksWhenGetMemoryBanksBitfieldThenAllMemoryBanksAreReturned) {
auto executionEnvironment = device->getExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(&hardwareInfo);
executionEnvironment->initializeMemoryManager();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
allocation.storageInfo.memoryBanks = 0x3u;
allocation.storageInfo.cloningOfPageTables = false;
DeviceBitfield deviceBitfield(0b11);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
csr->multiOsContextCapable = true;
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(*osContext);
EXPECT_TRUE(csr->isMultiOsContextCapable());
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
if (csr->isLocalMemoryEnabled()) {
auto banksBitfield = memoryOperationsInterface->getMemoryBanksBitfield(&allocation, device.get());
EXPECT_EQ(0x3lu, banksBitfield.to_ulong());
}
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenGfxAllocationAndNoDeviceWhenSetAubWritableToTrueThenAllocationWritablePropertyIsNotSet) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
memoryOperationsInterface->setAubWritable(true, allocation, device.get());
ASSERT_TRUE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
memoryOperationsInterface->setAubWritable(false, allocation, nullptr);
EXPECT_TRUE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
}
TEST_F(AubMemoryOperationsHandlerTests, givenGfxAllocationAndNoDeviceWhenIsAubWritableWithoutDeviceIsCalledThenReturnFalse) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
memoryOperationsInterface->setAubWritable(true, allocation, device.get());
ASSERT_TRUE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
EXPECT_FALSE(memoryOperationsInterface->isAubWritable(allocation, nullptr));
}
TEST_F(AubMemoryOperationsHandlerTests, givenGfxAllocationWhenSetAubWritableToTrueThenAllocationIsAubWritable) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
memoryOperationsInterface->setAubWritable(true, allocation, device.get());
EXPECT_TRUE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
memoryOperationsInterface->setAubWritable(false, allocation, device.get());
EXPECT_FALSE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
}
TEST_F(AubMemoryOperationsHandlerTests, givenGfxAllocationWhenSetAubWritableForNonDefaultBankThenWritablePropertyIsSetCorrectly) {
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
MemoryAllocation allocation(0, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000u,
MemoryConstants::pageSize, 0, MemoryPool::LocalMemory, false, false, MemoryManager::maxOsContextCount);
allocation.storageInfo.cloningOfPageTables = false;
device->deviceBitfield = 0b1111;
memoryOperationsInterface->setAubWritable(true, allocation, device.get());
EXPECT_TRUE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
device->deviceBitfield = 0b0000;
memoryOperationsInterface->setAubWritable(false, allocation, device.get());
EXPECT_FALSE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
device->deviceBitfield = 0b1000;
EXPECT_TRUE(memoryOperationsInterface->isAubWritable(allocation, device.get()));
}

View File

@@ -11,23 +11,24 @@
#include "shared/source/os_interface/aub_memory_operations_handler.h" #include "shared/source/os_interface/aub_memory_operations_handler.h"
#include "shared/source/os_interface/device_factory.h" #include "shared/source/os_interface/device_factory.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_aub_memory_operations_handler.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
using namespace NEO; using namespace NEO;
struct MockAubMemoryOperationsHandler : public AubMemoryOperationsHandler {
using AubMemoryOperationsHandler::AubMemoryOperationsHandler;
using AubMemoryOperationsHandler::residentAllocations;
};
class AubMemoryOperationsHandlerTests : public ::testing::Test { class AubMemoryOperationsHandlerTests : public ::testing::Test {
public: public:
void SetUp() override { void SetUp() override {
DebugManager.flags.SetCommandStreamReceiver.set(2); DebugManager.flags.SetCommandStreamReceiver.set(2);
residencyHandler = std::unique_ptr<MockAubMemoryOperationsHandler>(new MockAubMemoryOperationsHandler(nullptr)); residencyHandler = std::unique_ptr<MockAubMemoryOperationsHandler>(new MockAubMemoryOperationsHandler(nullptr));
hardwareInfo = *defaultHwInfo;
device.reset(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hardwareInfo, 0));
allocPtr = &allocation; allocPtr = &allocation;
} }
@@ -38,5 +39,7 @@ class AubMemoryOperationsHandlerTests : public ::testing::Test {
MockGraphicsAllocation allocation; MockGraphicsAllocation allocation;
GraphicsAllocation *allocPtr; GraphicsAllocation *allocPtr;
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
HardwareInfo hardwareInfo = {};
std::unique_ptr<MockAubMemoryOperationsHandler> residencyHandler; std::unique_ptr<MockAubMemoryOperationsHandler> residencyHandler;
std::unique_ptr<NEO::MockDevice> device;
}; };

View File

@@ -21,6 +21,7 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_mapper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_bindless_heap_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_bindless_heap_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_with_aub_dump_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_impl.h ${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_os_memory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_pci_speed_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_pci_speed_info_tests.cpp

View File

@@ -231,7 +231,7 @@ TEST(DrmBufferObjectSimpleTest, givenInvalidBoWhenValidateHostptrIsCalledThenErr
std::unique_ptr<uint32_t[]> buff(new uint32_t[256]); std::unique_ptr<uint32_t[]> buff(new uint32_t[256]);
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0])); std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u, false);
OsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor()); OsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());
ASSERT_NE(nullptr, mock.get()); ASSERT_NE(nullptr, mock.get());
std::unique_ptr<TestedBufferObject> bo(new TestedBufferObject(0u, mock.get())); std::unique_ptr<TestedBufferObject> bo(new TestedBufferObject(0u, mock.get()));
@@ -256,7 +256,7 @@ TEST(DrmBufferObjectSimpleTest, givenInvalidBoWhenPinIsCalledThenErrorIsReturned
std::unique_ptr<uint32_t[]> buff(new uint32_t[256]); std::unique_ptr<uint32_t[]> buff(new uint32_t[256]);
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0])); std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u, false);
OsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor()); OsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());
ASSERT_NE(nullptr, mock.get()); ASSERT_NE(nullptr, mock.get());
std::unique_ptr<TestedBufferObject> bo(new TestedBufferObject(0u, mock.get())); std::unique_ptr<TestedBufferObject> bo(new TestedBufferObject(0u, mock.get()));
@@ -407,7 +407,7 @@ TEST(DrmBufferObject, givenDrmIoctlReturnsErrorNotSupportedThenBufferObjectRetur
drm->errnoRetVal = EOPNOTSUPP; drm->errnoRetVal = EOPNOTSUPP;
drm->baseErrno = false; drm->baseErrno = false;
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -436,7 +436,7 @@ TEST(DrmBufferObject, givenPerContextVmRequiredWhenBoBoundAndUnboundThenCorrectB
EXPECT_TRUE(drm->isPerContextVMRequired()); EXPECT_TRUE(drm->isPerContextVMRequired());
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -480,7 +480,7 @@ TEST(DrmBufferObject, givenPrintBOBindingResultWhenBOBindAndUnbindSucceedsThenPr
drm->latestCreatedVmId = 1; drm->latestCreatedVmId = 1;
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -538,7 +538,7 @@ TEST(DrmBufferObject, givenPrintBOBindingResultWhenBOBindAndUnbindFailsThenPrint
drm->latestCreatedVmId = 1; drm->latestCreatedVmId = 1;
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -590,7 +590,7 @@ TEST(DrmBufferObject, givenDrmWhenBindOperationFailsThenFenceValueNotGrow) {
drm->ioctlHelper.reset(ioctlHelper.release()); drm->ioctlHelper.reset(ioctlHelper.release());
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
uint64_t initFenceValue = 10u; uint64_t initFenceValue = 10u;
drm->fenceVal[0] = initFenceValue; drm->fenceVal[0] = initFenceValue;
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -622,7 +622,7 @@ TEST(DrmBufferObject, givenDrmWhenBindOperationSucceedsThenFenceValueGrow) {
drm->ioctlHelper.reset(ioctlHelper.release()); drm->ioctlHelper.reset(ioctlHelper.release());
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
uint64_t initFenceValue = 10u; uint64_t initFenceValue = 10u;
drm->fenceVal[0] = initFenceValue; drm->fenceVal[0] = initFenceValue;
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -654,7 +654,7 @@ TEST(DrmBufferObject, givenDrmWhenUnBindOperationFailsThenFenceValueNotGrow) {
drm->ioctlHelper.reset(ioctlHelper.release()); drm->ioctlHelper.reset(ioctlHelper.release());
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
uint64_t initFenceValue = 10u; uint64_t initFenceValue = 10u;
drm->fenceVal[0] = initFenceValue; drm->fenceVal[0] = initFenceValue;
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
@@ -686,7 +686,7 @@ TEST(DrmBufferObject, givenDrmWhenUnBindOperationSucceedsThenFenceValueGrow) {
drm->ioctlHelper.reset(ioctlHelper.release()); drm->ioctlHelper.reset(ioctlHelper.release());
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
uint64_t initFenceValue = 10u; uint64_t initFenceValue = 10u;
drm->fenceVal[0] = initFenceValue; drm->fenceVal[0] = initFenceValue;
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0)); std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));

View File

@@ -46,7 +46,7 @@ HWTEST_F(DrmCommandStreamMMTest, GivenForcePinThenMemoryManagerCreatesPinBb) {
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
DrmCommandStreamReceiver<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive); DrmCommandStreamReceiver<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
@@ -87,7 +87,7 @@ HWTEST_F(DrmCommandStreamMMTest, givenExecutionEnvironmentWithMoreThanOneRootDev
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initGmm(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initGmm();
auto drm = new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]); auto drm = new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
} }
auto memoryManager = new TestedDrmMemoryManager(false, true, false, executionEnvironment); auto memoryManager = new TestedDrmMemoryManager(false, true, false, executionEnvironment);

View File

@@ -312,7 +312,7 @@ class DrmCommandStreamForceTileTest : public ::testing::Test {
mock->setupIoctlHelper(hwInfo->platform.eProductFamily); mock->setupIoctlHelper(hwInfo->platform.eProductFamily);
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
mock->createVirtualMemoryAddressSpace(GfxCoreHelper::getSubDevicesCount(hwInfo)); mock->createVirtualMemoryAddressSpace(GfxCoreHelper::getSubDevicesCount(hwInfo));
@@ -425,7 +425,7 @@ struct DrmImplicitScalingCommandStreamTest : ::testing::Test {
executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo.get()); executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(hwInfo.get());
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment->rootDeviceEnvironments[0]->initGmm(); executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto &gfxCoreHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>(); auto &gfxCoreHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();

View File

@@ -43,7 +43,7 @@ struct DrmCommandStreamMultiTileMemExecFixture {
mock = new DrmMockCustom(*executionEnvironment->rootDeviceEnvironments[0]); mock = new DrmMockCustom(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0, false);
memoryManager = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive, memoryManager = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
DebugManager.flags.EnableForcePin.get(), DebugManager.flags.EnableForcePin.get(),

View File

@@ -67,7 +67,7 @@ class DrmGemCloseWorkerFixture {
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drmMock)); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drmMock));
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drmMock, 0u); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drmMock, 0u, false);
this->mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive, this->mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
false, false,

View File

@@ -105,7 +105,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenMultiRootDeviceEnvironmentAnd
mock->ioctlCallsCount = 0; mock->ioctlCallsCount = 0;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);
@@ -155,7 +155,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenMultiRootDeviceEnvironmentAnd
mock->ioctlCallsCount = 0; mock->ioctlCallsCount = 0;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);
@@ -196,7 +196,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenMultiRootDeviceEnvironmentAnd
mock->fdToHandleRetVal = -1; mock->fdToHandleRetVal = -1;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);
@@ -236,7 +236,7 @@ TEST_F(DrmMemoryManagerUsmSharedHandlePrelimTest, givenMultiRootDeviceEnvironmen
mock->fdToHandleRetVal = -1; mock->fdToHandleRetVal = -1;
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(true, false, false, *executionEnvironment); auto memoryManager = std::make_unique<TestedDrmMemoryManager>(true, false, false, *executionEnvironment);
@@ -267,7 +267,7 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenMultiRootDeviceEnvironmentAnd
mock->fdToHandleRetVal = -1; mock->fdToHandleRetVal = -1;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);

View File

@@ -69,7 +69,7 @@ class DrmMemoryManagerLocalMemoryTest : public ::testing::Test {
mock->memoryInfo.reset(new MockMemoryInfo(*mock)); mock->memoryInfo.reset(new MockMemoryInfo(*mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, rootDeviceIndex)); device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, rootDeviceIndex));
memoryManager = std::make_unique<TestedDrmMemoryManager>(localMemoryEnabled, false, false, *executionEnvironment); memoryManager = std::make_unique<TestedDrmMemoryManager>(localMemoryEnabled, false, false, *executionEnvironment);
@@ -161,7 +161,7 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMem
mock->ioctlCallsCount = 0; mock->ioctlCallsCount = 0;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);
@@ -208,7 +208,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndMemory
mock->fdToHandleRetVal = -1; mock->fdToHandleRetVal = -1;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);
@@ -268,7 +268,7 @@ TEST_F(DrmMemoryManagerUsmSharedHandleTest, givenMultiRootDeviceEnvironmentAndMe
mock->fdToHandleRetVal = -1; mock->fdToHandleRetVal = -1;
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
rootDeviceIndices.pushUnique(rootDeviceIndex); rootDeviceIndices.pushUnique(rootDeviceIndex);
@@ -300,7 +300,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenMultiRootDeviceEnvironmentAndNoMemo
mock->fdToHandleRetVal = -1; mock->fdToHandleRetVal = -1;
executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
executionEnvironment->rootDeviceEnvironments[i]->initGmm(); executionEnvironment->rootDeviceEnvironments[i]->initGmm();
rootDeviceIndices.pushUnique(i); rootDeviceIndices.pushUnique(i);
@@ -470,7 +470,7 @@ class DrmMemoryManagerLocalMemoryMemoryBankTest : public ::testing::Test {
mock->memoryInfo.reset(new MockMemoryInfo(*mock)); mock->memoryInfo.reset(new MockMemoryInfo(*mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock)); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u); executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u, false);
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(),
executionEnvironment, executionEnvironment,

View File

@@ -3779,7 +3779,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryCallSequenceTest, givenDrmMemoryManagerAn
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
TestedDrmMemoryManager memoryManger(executionEnvironment); TestedDrmMemoryManager memoryManger(executionEnvironment);
@@ -3804,7 +3804,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
TestedDrmMemoryManager memoryManger(executionEnvironment); TestedDrmMemoryManager memoryManger(executionEnvironment);
@@ -3831,7 +3831,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
TestedDrmMemoryManager memoryManger(executionEnvironment); TestedDrmMemoryManager memoryManger(executionEnvironment);
@@ -3864,7 +3864,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
TestedDrmMemoryManager memoryManger(executionEnvironment); TestedDrmMemoryManager memoryManger(executionEnvironment);
@@ -3888,7 +3888,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAnd
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]);
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
executionEnvironment.rootDeviceEnvironments[0]->initGmm(); executionEnvironment.rootDeviceEnvironments[0]->initGmm();
TestedDrmMemoryManager memoryManger(executionEnvironment); TestedDrmMemoryManager memoryManger(executionEnvironment);
@@ -4114,7 +4114,7 @@ TEST(DrmMemoryManager, givenEnabledResourceRegistrationWhenSshIsAllocatedThenItI
auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]); auto mockDrm = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm)); executionEnvironment->rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mockDrm));
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mockDrm, 0u); executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mockDrm, 0u, false);
executionEnvironment->memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment); executionEnvironment->memoryManager = std::make_unique<TestedDrmMemoryManager>(false, false, false, *executionEnvironment);
for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) { for (uint32_t i = 3; i < 3 + static_cast<uint32_t>(DrmResourceClass::MaxSize); i++) {
@@ -4820,7 +4820,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInDevicePoolIs
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
TestedDrmMemoryManager memoryManager(executionEnvironment); TestedDrmMemoryManager memoryManager(executionEnvironment);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success; MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData; AllocationData allocData;
@@ -4841,7 +4841,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenDeviceHeapIsDepletedTh
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
auto mockGfxPartition = std::make_unique<MockGfxPartition>(); auto mockGfxPartition = std::make_unique<MockGfxPartition>();
mockGfxPartition->init(hwInfo->capabilityTable.gpuAddressSpace, reservedCpuAddressRangeSize, 0, 1, false, 0u); mockGfxPartition->init(hwInfo->capabilityTable.gpuAddressSpace, reservedCpuAddressRangeSize, 0, 1, false, 0u);
@@ -4866,7 +4866,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInLocalDeviceM
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
TestedDrmMemoryManager memoryManager(executionEnvironment); TestedDrmMemoryManager memoryManager(executionEnvironment);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success; MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData; AllocationData allocData;
@@ -4884,7 +4884,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenLockResourceIsCalledOn
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
TestedDrmMemoryManager memoryManager(executionEnvironment); TestedDrmMemoryManager memoryManager(executionEnvironment);
DrmAllocation drmAllocation(0, AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory); DrmAllocation drmAllocation(0, AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
@@ -4899,7 +4899,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCa
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>(); executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]); auto drm = Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]);
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm)); executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, 0u, false);
TestedDrmMemoryManager memoryManager(executionEnvironment); TestedDrmMemoryManager memoryManager(executionEnvironment);
auto drmAllocation = new DrmAllocation(0, AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory); auto drmAllocation = new DrmAllocation(0, AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
#include "shared/source/os_interface/linux/drm_memory_operations_handler_with_aub_dump.h"
#include "shared/test/common/mocks/mock_aub_memory_operations_handler.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/test_macros/test.h"
#include <memory>
using namespace NEO;
template <typename BaseMemoryOperationsHandler>
class DrmMemoryOperationsHandlerWithAubDumpMock : public DrmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler> {
public:
using DrmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler>::aubMemoryOperationsHandler;
using DrmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler>::residency;
DrmMemoryOperationsHandlerWithAubDumpMock(RootDeviceEnvironment &rootDeviceEnvironment, uint32_t rootDeviceIndex)
: DrmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler>(rootDeviceEnvironment, rootDeviceIndex) {
aubMemoryOperationsHandler = std::make_unique<MockAubMemoryOperationsHandler>(nullptr);
}
};
struct DrmMemoryOperationsHandlerWithAubDumpTest : public ::testing::Test {
void SetUp() override {
device.reset(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(defaultHwInfo.get(), 0));
device->executionEnvironment->prepareRootDeviceEnvironments(1);
device->executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
auto rootDeviceEnv = device->executionEnvironment->rootDeviceEnvironments[0].get();
drmMemoryOperationsHandlerWithAubDumpMock = std::make_unique<DrmMemoryOperationsHandlerWithAubDumpMock<DrmMemoryOperationsHandlerDefault>>(*rootDeviceEnv, 0);
mockAubMemoryOperationsHandler = static_cast<MockAubMemoryOperationsHandler *>(drmMemoryOperationsHandlerWithAubDumpMock->aubMemoryOperationsHandler.get());
allocationPtr = &graphicsAllocation;
}
MockGraphicsAllocation graphicsAllocation;
GraphicsAllocation *allocationPtr;
std::unique_ptr<DrmMemoryOperationsHandlerWithAubDumpMock<DrmMemoryOperationsHandlerDefault>> drmMemoryOperationsHandlerWithAubDumpMock;
MockAubMemoryOperationsHandler *mockAubMemoryOperationsHandler;
std::unique_ptr<NEO::MockDevice> device;
};
TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenMakingAllocationResidentThenAllocationIsResident) {
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandlerWithAubDumpMock->residency.find(allocationPtr) != drmMemoryOperationsHandlerWithAubDumpMock->residency.end());
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenEvictingResidentAllocationThenAllocationIsNotResident) {
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 0u);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 1u);
EXPECT_TRUE(drmMemoryOperationsHandlerWithAubDumpMock->residency.find(allocationPtr) != drmMemoryOperationsHandlerWithAubDumpMock->residency.end());
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, graphicsAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
EXPECT_EQ(drmMemoryOperationsHandlerWithAubDumpMock->residency.size(), 0u);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->evictCalled);
}
TEST_F(DrmMemoryOperationsHandlerWithAubDumpTest, whenConstructingDrmMemoryOperationsHandlerWithAubDumpWithoutAubCenterThenAubCenterIsInitialized) {
auto rootDeviceEnv = device->executionEnvironment->rootDeviceEnvironments[0].get();
rootDeviceEnv->aubCenter.reset();
ASSERT_EQ(nullptr, rootDeviceEnv->aubCenter.get());
auto drmMemoryOperationsHandlerWithAubDump = std::make_unique<DrmMemoryOperationsHandlerWithAubDumpMock<DrmMemoryOperationsHandlerDefault>>(*rootDeviceEnv, 0);
EXPECT_NE(nullptr, rootDeviceEnv->aubCenter.get());
}

View File

@@ -707,7 +707,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, WhenVmBindAvaialableThenMemoryManager
TEST_F(DrmMemoryOperationsHandlerBindTest, givenNoVmBindSupportInDrmWhenCheckForSupportThenDefaultResidencyHandlerIsReturned) { TEST_F(DrmMemoryOperationsHandlerBindTest, givenNoVmBindSupportInDrmWhenCheckForSupportThenDefaultResidencyHandlerIsReturned) {
mock->bindAvailable = false; mock->bindAvailable = false;
auto handler = DrmMemoryOperationsHandler::create(*mock, 0u); auto handler = DrmMemoryOperationsHandler::create(*mock, 0u, false);
mock->context.vmBindCalled = 0u; mock->context.vmBindCalled = 0u;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize}); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
@@ -722,7 +722,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenVmBindSupportAndNoMultiTileWhenC
DebugManager.flags.CreateMultipleSubDevices.set(1u); DebugManager.flags.CreateMultipleSubDevices.set(1u);
mock->bindAvailable = false; mock->bindAvailable = false;
auto handler = DrmMemoryOperationsHandler::create(*mock, 0u); auto handler = DrmMemoryOperationsHandler::create(*mock, 0u, false);
mock->context.vmBindCalled = 0u; mock->context.vmBindCalled = 0u;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize}); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
@@ -736,7 +736,7 @@ TEST_F(DrmMemoryOperationsHandlerBindTest, givenVmBindSupportAndNoMultiTileWhenC
TEST_F(DrmMemoryOperationsHandlerBindTest, givenDisabledVmBindWhenCreateDrmHandlerThenVmBindIsNotUsed) { TEST_F(DrmMemoryOperationsHandlerBindTest, givenDisabledVmBindWhenCreateDrmHandlerThenVmBindIsNotUsed) {
mock->context.vmBindReturn = 0; mock->context.vmBindReturn = 0;
mock->bindAvailable = false; mock->bindAvailable = false;
auto handler = DrmMemoryOperationsHandler::create(*mock, 0u); auto handler = DrmMemoryOperationsHandler::create(*mock, 0u, false);
mock->context.vmBindCalled = false; mock->context.vmBindCalled = false;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize}); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});

View File

@@ -23,7 +23,7 @@ using namespace NEO;
TEST(OSContextLinux, givenReinitializeContextWhenContextIsInitThenContextIsStillIinitializedAfter) { TEST(OSContextLinux, givenReinitializeContextWhenContextIsInitThenContextIsStillIinitializedAfter) {
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0])); std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u, false);
OsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor()); OsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());
EXPECT_NO_THROW(osContext.reInitializeContext()); EXPECT_NO_THROW(osContext.reInitializeContext());
EXPECT_NO_THROW(osContext.ensureContextInitialized()); EXPECT_NO_THROW(osContext.ensureContextInitialized());
@@ -43,7 +43,7 @@ TEST(OSContextLinux, givenInitializeContextWhenContextCreateIoctlFailsThenContex
TEST(OSContextLinux, givenOsContextLinuxWhenQueryingForOfflineDumpContextIdThenCorrectValueIsReturned) { TEST(OSContextLinux, givenOsContextLinuxWhenQueryingForOfflineDumpContextIdThenCorrectValueIsReturned) {
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0])); std::unique_ptr<DrmMockCustom> mock(new DrmMockCustom(*executionEnvironment.rootDeviceEnvironments[0]));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u); executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock.get(), 0u, false);
MockOsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor()); MockOsContextLinux osContext(*mock, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());
osContext.drmContextIds.clear(); osContext.drmContextIds.clear();

View File

@@ -49,6 +49,7 @@ if(WIN32 OR(UNIX AND NOT DISABLE_WDDM_LINUX))
${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_shared_allocations_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_shared_allocations_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_operations_handler_with_aub_dump_tests.cpp
) )
endif() endif()

View File

@@ -0,0 +1,124 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/windows/wddm_memory_operations_handler_with_aub_dump.h"
#include "shared/source/utilities/stackvec.h"
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
#include "shared/test/common/mocks/mock_aub_memory_operations_handler.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/mocks/windows/mock_wddm_allocation.h"
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
#include "shared/test/common/test_macros/hw_test.h"
using namespace NEO;
template <typename BaseMemoryOperationsHandler>
class WddmMemoryOperationsHandlerWithAubDumpMock : public WddmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler> {
public:
using WddmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler>::aubMemoryOperationsHandler;
WddmMemoryOperationsHandlerWithAubDumpMock(Wddm *wddm, RootDeviceEnvironment &rootDeviceEnvironment)
: WddmMemoryOperationsHandlerWithAubDump<BaseMemoryOperationsHandler>(wddm, rootDeviceEnvironment) {
aubMemoryOperationsHandler = std::make_unique<MockAubMemoryOperationsHandler>(nullptr);
}
};
struct WddmMemoryOperationsHandlerWithAubDumpTest : public WddmTest {
void SetUp() override {
WddmTest::SetUp();
wddmMemoryOperationsHandlerWithAubDumpMock = std::make_unique<WddmMemoryOperationsHandlerWithAubDumpMock<WddmMemoryOperationsHandler>>(wddm, *rootDeviceEnvironment);
mockAubMemoryOperationsHandler = static_cast<MockAubMemoryOperationsHandler *>(wddmMemoryOperationsHandlerWithAubDumpMock->aubMemoryOperationsHandler.get());
wddmAllocation = std::make_unique<MockWddmAllocation>(rootDeviceEnvironment->getGmmHelper());
wddmFragmentedAllocation = std::make_unique<MockWddmAllocation>(rootDeviceEnvironment->getGmmHelper());
wddmAllocation->handle = 0x2u;
osHandleStorageFirst = std::make_unique<OsHandleWin>();
osHandleStorageSecond = std::make_unique<OsHandleWin>();
wddmFragmentedAllocation->fragmentsStorage.fragmentCount = 2;
wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[0].osHandleStorage = osHandleStorageFirst.get();
static_cast<OsHandleWin *>(wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[0].osHandleStorage)->handle = 0x3u;
wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[1].osHandleStorage = osHandleStorageSecond.get();
static_cast<OsHandleWin *>(wddmFragmentedAllocation->fragmentsStorage.fragmentStorageData[1].osHandleStorage)->handle = 0x4u;
allocationPtr = wddmAllocation.get();
allocationData.push_back(wddmAllocation.get());
allocationData.push_back(wddmFragmentedAllocation.get());
}
std::unique_ptr<WddmMemoryOperationsHandlerWithAubDumpMock<WddmMemoryOperationsHandler>> wddmMemoryOperationsHandlerWithAubDumpMock;
std::unique_ptr<MockWddmAllocation> wddmAllocation;
std::unique_ptr<MockWddmAllocation> wddmFragmentedAllocation;
std::unique_ptr<OsHandleWin> osHandleStorageFirst;
std::unique_ptr<OsHandleWin> osHandleStorageSecond;
GraphicsAllocation *allocationPtr;
StackVec<GraphicsAllocation *, 2> allocationData;
MockAubMemoryOperationsHandler *mockAubMemoryOperationsHandler;
};
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, givenRegularAllocationWhenMakingResidentAllocationThenMakeResidentCalled) {
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, givenFragmentedAllocationWhenMakingResidentAllocationThenMakeResidentCalled) {
allocationPtr = wddmFragmentedAllocation.get();
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, givenVariousAllocationsWhenMakingResidentAllocationThenMakeResidentCalled) {
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(allocationData)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, givenRegularAllocationWhenEvictingResidentAllocationThenEvictCalled) {
wddm->callBaseEvict = true;
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(0u, gdi->getEvictArg().Flags.EvictOnlyIfNecessary);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, givenFragmentedAllocationWhenEvictingResidentAllocationThenEvictCalled) {
allocationPtr = wddmFragmentedAllocation.get();
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, givenVariousAllocationsWhenEvictingResidentAllocationThenEvictCalled) {
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(allocationData)), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, *wddmAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->evict(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
EXPECT_EQ(wddmMemoryOperationsHandlerWithAubDumpMock->isResident(nullptr, *wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
EXPECT_TRUE(mockAubMemoryOperationsHandler->makeResidentCalled);
EXPECT_TRUE(mockAubMemoryOperationsHandler->isResidentCalled);
}
TEST_F(WddmMemoryOperationsHandlerWithAubDumpTest, whenConstructingWddmMemoryOperationsHandlerWithAubDumpWithoutAubCenterThenAubCenterIsInitialized) {
rootDeviceEnvironment->aubCenter.reset();
ASSERT_EQ(nullptr, rootDeviceEnvironment->aubCenter.get());
auto wddmMemoryOperationsHandlerWithAubDump = std::make_unique<WddmMemoryOperationsHandlerWithAubDump<WddmMemoryOperationsHandler>>(wddm, *rootDeviceEnvironment);
EXPECT_NE(nullptr, rootDeviceEnvironment->aubCenter.get());
}