From 9924fa34de0451b9c8eaf1372d7abcd9678b9b99 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 23 Oct 2019 16:17:06 +0200 Subject: [PATCH] Make root device environments a vector Change-Id: I62addd87606c8c87e3b9db53c9179bd5f09df30b Signed-off-by: Mateusz Jablonski --- runtime/execution_environment/execution_environment.h | 2 +- runtime/os_interface/device_factory.cpp | 8 ++++---- runtime/os_interface/linux/device_factory_linux.cpp | 8 ++++---- runtime/os_interface/windows/device_factory_win.cpp | 8 ++++---- .../execution_environment/execution_environment_tests.cpp | 2 +- unit_tests/os_interface/device_factory_tests.cpp | 1 + 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index aae6bbbf81..00a854694f 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -55,10 +55,10 @@ class ExecutionEnvironment : public ReferenceTrackedObject MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface(); BuiltIns *getBuiltIns(); - std::unique_ptr rootDeviceEnvironments; std::unique_ptr osInterface; std::unique_ptr memoryOperationsInterface; std::unique_ptr memoryManager; + std::vector rootDeviceEnvironments; std::unique_ptr aubCenter; CsrContainer commandStreamReceivers; std::unique_ptr builtins; diff --git a/runtime/os_interface/device_factory.cpp b/runtime/os_interface/device_factory.cpp index ac212f105a..c5c84d5815 100644 --- a/runtime/os_interface/device_factory.cpp +++ b/runtime/os_interface/device_factory.cpp @@ -15,12 +15,12 @@ namespace NEO { bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, ExecutionEnvironment &executionEnvironment) { - auto totalDeviceCount = 1u; + auto numRootDevices = 1u; if (DebugManager.flags.CreateMultipleRootDevices.get()) { - totalDeviceCount = DebugManager.flags.CreateMultipleRootDevices.get(); + numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get(); } - executionEnvironment.rootDeviceEnvironments = std::make_unique(totalDeviceCount); + executionEnvironment.rootDeviceEnvironments.resize(numRootDevices); auto productFamily = DebugManager.flags.ProductFamilyOverride.get(); auto hwInfoConst = *platformDevices; @@ -37,7 +37,7 @@ bool DeviceFactory::getDevicesForProductFamilyOverride(size_t &numDevices, Execu HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily); hwConfig->configureHardwareCustom(hardwareInfo, nullptr); - numDevices = totalDeviceCount; + numDevices = numRootDevices; DeviceFactory::numDevices = numDevices; auto csr = DebugManager.flags.SetCommandStreamReceiver.get(); if (csr > 0) { diff --git a/runtime/os_interface/linux/device_factory_linux.cpp b/runtime/os_interface/linux/device_factory_linux.cpp index f01caf53ce..83d5daa69a 100644 --- a/runtime/os_interface/linux/device_factory_linux.cpp +++ b/runtime/os_interface/linux/device_factory_linux.cpp @@ -20,13 +20,13 @@ size_t DeviceFactory::numDevices = 0; bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executionEnvironment) { unsigned int devNum = 0; - size_t requiredDeviceCount = 1; + size_t numRootDevices = 1; if (DebugManager.flags.CreateMultipleRootDevices.get()) { - requiredDeviceCount = DebugManager.flags.CreateMultipleRootDevices.get(); + numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get(); } - executionEnvironment.rootDeviceEnvironments = std::make_unique(requiredDeviceCount); + executionEnvironment.rootDeviceEnvironments.resize(numRootDevices); Drm *drm = Drm::create(devNum); if (!drm) { @@ -44,7 +44,7 @@ bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executi return false; } - numDevices = requiredDeviceCount; + numDevices = numRootDevices; DeviceFactory::numDevices = numDevices; return true; diff --git a/runtime/os_interface/windows/device_factory_win.cpp b/runtime/os_interface/windows/device_factory_win.cpp index f2c49a336c..e3039f8c97 100644 --- a/runtime/os_interface/windows/device_factory_win.cpp +++ b/runtime/os_interface/windows/device_factory_win.cpp @@ -23,12 +23,12 @@ size_t DeviceFactory::numDevices = 0; bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executionEnvironment) { numDevices = 0; - auto totalDeviceCount = 1u; + auto numRootDevices = 1u; if (DebugManager.flags.CreateMultipleRootDevices.get()) { - totalDeviceCount = DebugManager.flags.CreateMultipleRootDevices.get(); + numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get(); } - executionEnvironment.rootDeviceEnvironments = std::make_unique(totalDeviceCount); + executionEnvironment.rootDeviceEnvironments.resize(numRootDevices); auto hardwareInfo = executionEnvironment.getMutableHardwareInfo(); std::unique_ptr wddm(Wddm::createWddm()); @@ -40,7 +40,7 @@ bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executi executionEnvironment.osInterface = std::make_unique(); executionEnvironment.osInterface->get()->setWddm(wddm.release()); - numDevices = totalDeviceCount; + numDevices = numRootDevices; DeviceFactory::numDevices = numDevices; return true; diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index 4cde3346bb..647f3a8e3d 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -189,7 +189,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector>) + sizeof(std::mutex) + sizeof(std::unique_ptr) + - sizeof(std::unique_ptr) + + sizeof(std::vector) + (is64bit ? 88 : 48), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); diff --git a/unit_tests/os_interface/device_factory_tests.cpp b/unit_tests/os_interface/device_factory_tests.cpp index 1cb85ad683..e0169b4479 100644 --- a/unit_tests/os_interface/device_factory_tests.cpp +++ b/unit_tests/os_interface/device_factory_tests.cpp @@ -148,6 +148,7 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenGetDevicesI ASSERT_TRUE(success); EXPECT_EQ(requiredDeviceCount, numDevices); + EXPECT_EQ(requiredDeviceCount, executionEnvironment->rootDeviceEnvironments.size()); } TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenGetDevicesForProductFamilyOverrideIsCalledThenNumberOfReturnedDevicesIsEqualToDebugVariable) {