Reverse logic of creating Memory Manager - part 2

-remove MM initialization from Device::CreateEngines method

Change-Id: Iaee268b002cb0f0a4edd07907c12da6dd6076b3a
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz 2019-03-08 12:18:02 +01:00
parent 8e49c8f67a
commit 4386d10e40
9 changed files with 31 additions and 19 deletions

View File

@ -164,15 +164,12 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo) {
bool Device::createEngines(const HardwareInfo *pHwInfo) {
auto defaultEngineType = getChosenEngineType(*pHwInfo);
auto &hwHelper = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily);
auto &gpgpuEngines = hwHelper.getGpgpuEngineInstances();
auto enableLocalMemory = hwHelper.getEnableLocalMemory(*pHwInfo);
auto &gpgpuEngines = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances();
for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngines.size(); deviceCsrIndex++) {
if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, getDeviceIndex(), deviceCsrIndex)) {
return false;
}
executionEnvironment->initializeMemoryManager(getEnabled64kbPages(), enableLocalMemory);
auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[getDeviceIndex()][deviceCsrIndex].get();

View File

@ -14,8 +14,8 @@
using namespace OCLRT;
TEST(CheckVerifyMemoryRelatedApiConstants, givenVerifyMemoryRelatedApiConstantsWhenVerifyingTheirValueThenCorrectValuesAreReturned) {
EXPECT_EQ(CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual, CL_MEM_COMPARE_EQUAL);
EXPECT_EQ(CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual, CL_MEM_COMPARE_NOT_EQUAL);
EXPECT_EQ(AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual, CL_MEM_COMPARE_EQUAL);
EXPECT_EQ(AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual, CL_MEM_COMPARE_NOT_EQUAL);
}
struct clEnqueueVerifyMemorySettings {

View File

@ -49,12 +49,10 @@ HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetTo
if (csrType < CommandStreamReceiverType::CSR_TYPES_NUM) {
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
} else {
EXPECT_EQ(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
EXPECT_EQ(nullptr, executionEnvironment->memoryManager.get());
}
EXPECT_NE(nullptr, executionEnvironment->memoryManager.get());
}
static CommandStreamReceiverType commandStreamReceiverTypes[] = {

View File

@ -159,8 +159,8 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqu
const size_t numDevices = 2;
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size());
auto device1 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 1u));
auto device1 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto &registeredEngines = executionEnvironment.memoryManager->getRegisteredEngines();
EXPECT_EQ(numGpgpuEngines * numDevices, registeredEngines.size());
@ -182,8 +182,8 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqu
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment, 1u));
auto device = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
EXPECT_EQ(0u, device->getDeviceIndex());
EXPECT_EQ(1u, device2->getDeviceIndex());

View File

@ -104,6 +104,7 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManage
TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillAvailable) {
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
executionEnvironment->incRefInternal();
executionEnvironment->initializeMemoryManager(false, false);
std::unique_ptr<Device> device(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 0u));
device.reset(nullptr);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);

View File

@ -7,6 +7,8 @@
#include "unit_tests/helpers/execution_environment_helper.h"
#include "runtime/device/device.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/os_interface/device_factory.h"
namespace OCLRT {
@ -16,6 +18,9 @@ ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo) {
size_t numDevicesReturned = 0;
hwInfo = nullptr;
DeviceFactory::getDevices(&hwInfo, numDevicesReturned, *executionEnvironment);
bool enableLocalMemory = HwHelper::get(hwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
executionEnvironment->initializeMemoryManager(Device::getEnabled64kbPages(*hwInfo), enableLocalMemory);
return executionEnvironment;
}
} // namespace OCLRT

View File

@ -8,7 +8,6 @@
#include "unit_tests/mocks/mock_device.h"
#include "runtime/device/driver_info.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/os_interface/os_context.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/mocks/mock_ostime.h"
@ -33,6 +32,7 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executi
this->mockMemoryManager.reset(new OsAgnosticMemoryManager(false, enableLocalMemory, aubUsage, *executionEnvironment));
this->osTime = MockOSTime::create();
mockWaTable = *hwInfo.pWaTable;
executionEnvironment->initializeMemoryManager(getEnabled64kbPages(hwInfo), enableLocalMemory);
}
void MockDevice::setOSTime(OSTime *osTime) {

View File

@ -7,6 +7,7 @@
#pragma once
#include "runtime/device/device.h"
#include "runtime/helpers/hw_helper.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
@ -113,7 +114,17 @@ class MockDevice : public Device {
template <>
inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const HardwareInfo *pHwInfo) {
return Device::create<Device>(pHwInfo, new ExecutionEnvironment, 0u);
auto executionEnvironment = new ExecutionEnvironment();
bool enableLocalMemory = false;
bool enable64kbPages = false;
if (pHwInfo != nullptr) {
enableLocalMemory = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*pHwInfo);
enable64kbPages = getEnabled64kbPages(*pHwInfo);
}
executionEnvironment->initializeMemoryManager(enable64kbPages, enableLocalMemory);
return Device::create<Device>(pHwInfo, executionEnvironment, 0u);
}
class FailDevice : public MockDevice {

View File

@ -531,12 +531,12 @@ TEST(SourceLevelDebugger, givenTwoDevicesWhenSecondIsCreatedThenNotCreatingNewSo
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
executionEnvironment->incRefInternal();
std::unique_ptr<Device> device1(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 0u));
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment.get(), 0u));
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
EXPECT_TRUE(interceptor.initCalled);
interceptor.initCalled = false;
std::unique_ptr<Device> device2(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 1u));
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment.get(), 1u));
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
EXPECT_FALSE(interceptor.initCalled);
}
@ -550,9 +550,9 @@ TEST(SourceLevelDebugger, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheS
DebuggerLibrary::setDebuggerActive(true);
auto executionEnvironment = new ExecutionEnvironment;
std::unique_ptr<Device> device1(Device::create<OCLRT::Device>(nullptr, executionEnvironment, 0u));
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 0u));
auto sourceLevelDebugger = device1->getSourceLevelDebugger();
std::unique_ptr<Device> device2(Device::create<OCLRT::Device>(nullptr, executionEnvironment, 1u));
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 1u));
EXPECT_EQ(sourceLevelDebugger, device2->getSourceLevelDebugger());
}
}