Update UltDeviceFactory

Use MockMemoryManager by default in UltDeviceFactory.

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2021-01-12 21:39:04 +00:00
committed by Compute-Runtime-Automation
parent a8fe9b7630
commit 2d033f5dea
10 changed files with 36 additions and 46 deletions

View File

@@ -10,6 +10,7 @@
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/unit_test/mocks/ult_device_factory.h"
#include "shared/test/unit_test/tests_configuration.h"
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
@@ -25,8 +26,8 @@ decltype(&createCommandStream) MockDevice::createCommandStreamReceiverFunc = cre
MockDevice::MockDevice()
: MockDevice(new MockExecutionEnvironment(), 0u) {
initializeMemoryManager();
CommandStreamReceiver *commandStreamReceiver = createCommandStream(*this->executionEnvironment, this->getRootDeviceIndex(), this->getDeviceBitfield());
UltDeviceFactory::initializeMemoryManager(*executionEnvironment);
CommandStreamReceiver *commandStreamReceiver = createCommandStream(*executionEnvironment, this->getRootDeviceIndex(), this->getDeviceBitfield());
commandStreamReceivers.resize(1);
commandStreamReceivers[0].reset(commandStreamReceiver);
this->engines.resize(1);
@@ -41,7 +42,7 @@ const char *MockDevice::getProductAbbrev() const {
MockDevice::MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex)
: RootDevice(executionEnvironment, rootDeviceIndex) {
initializeMemoryManager();
UltDeviceFactory::initializeMemoryManager(*executionEnvironment);
this->osTime = MockOSTime::create();
this->engineGroups.resize(static_cast<uint32_t>(EngineGroupType::MaxEngineGroups));
auto &hwInfo = getHardwareInfo();
@@ -89,15 +90,6 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint3
}
}
void MockDevice::initializeMemoryManager() const {
if (executionEnvironment->memoryManager == nullptr) {
auto &hwInfo = getHardwareInfo();
bool enableLocalMemory = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getEnableLocalMemory(hwInfo);
bool aubUsage = (testMode == TestMode::AubTests) || (testMode == TestMode::AubTestsWithTbx);
executionEnvironment->memoryManager.reset(new MockMemoryManager(false, enableLocalMemory, aubUsage, *executionEnvironment));
}
}
MockAlignedMallocManagerDevice::MockAlignedMallocManagerDevice(ExecutionEnvironment *executionEnvironment, uint32_t internalDeviceIndex) : MockDevice(executionEnvironment, internalDeviceIndex) {
executionEnvironment->memoryManager.reset(new MockAllocSysMemAgnosticMemoryManager(*executionEnvironment));
}

View File

@@ -128,9 +128,6 @@ class MockDevice : public RootDevice {
}
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
private:
void initializeMemoryManager() const;
};
template <>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,6 +12,8 @@
#include "shared/test/unit_test/helpers/variable_backup.h"
#include "shared/test/unit_test/mocks/mock_device.h"
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
using namespace NEO;
UltDeviceFactory::UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevicesCount)
@@ -22,12 +24,14 @@ UltDeviceFactory::UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevice
DebugManagerStateRestore restorer;
VariableBackup<bool> createSingleDeviceBackup{&MockDevice::createSingleDevice, false};
VariableBackup<decltype(DeviceFactory::createRootDeviceFunc)> createRootDeviceFuncBackup{&DeviceFactory::createRootDeviceFunc};
VariableBackup<decltype(DeviceFactory::createMemoryManagerFunc)> createMemoryManagerFuncBackup{&DeviceFactory::createMemoryManagerFunc};
DebugManager.flags.CreateMultipleRootDevices.set(rootDevicesCount);
DebugManager.flags.CreateMultipleSubDevices.set(subDevicesCount);
createRootDeviceFuncBackup = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr<Device> {
return std::unique_ptr<Device>(MockDevice::create<MockDevice>(&executionEnvironment, rootDeviceIndex));
};
createMemoryManagerFuncBackup = UltDeviceFactory::initializeMemoryManager;
auto createdDevices = DeviceFactory::createDevices(executionEnvironment);
@@ -46,7 +50,7 @@ UltDeviceFactory::~UltDeviceFactory() {
}
}
void NEO::UltDeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment, uint32_t rootDevicesCount) {
void UltDeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment, uint32_t rootDevicesCount) {
uint32_t numRootDevices = rootDevicesCount;
executionEnvironment.prepareRootDeviceEnvironments(numRootDevices);
for (auto i = 0u; i < numRootDevices; i++) {
@@ -59,3 +63,11 @@ void NEO::UltDeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &exec
executionEnvironment.calculateMaxOsContextCount();
DeviceFactory::createMemoryManagerFunc(executionEnvironment);
}
bool UltDeviceFactory::initializeMemoryManager(ExecutionEnvironment &executionEnvironment) {
if (executionEnvironment.memoryManager == nullptr) {
bool enableLocalMemory = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*defaultHwInfo);
bool aubUsage = (testMode == TestMode::AubTests) || (testMode == TestMode::AubTestsWithTbx);
executionEnvironment.memoryManager.reset(new MockMemoryManager(false, enableLocalMemory, aubUsage, executionEnvironment));
}
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -20,6 +20,7 @@ struct UltDeviceFactory {
~UltDeviceFactory();
static void prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment, uint32_t rootDevicesCount);
static bool initializeMemoryManager(ExecutionEnvironment &executionEnvironment);
std::vector<MockDevice *> rootDevices;
std::vector<SubDevice *> subDevices;