diff --git a/runtime/execution_environment/CMakeLists.txt b/runtime/execution_environment/CMakeLists.txt index 5a7bc9a087..0c2d79943b 100644 --- a/runtime/execution_environment/CMakeLists.txt +++ b/runtime/execution_environment/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2018 Intel Corporation +# Copyright (C) 2018-2019 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -8,6 +8,7 @@ set(RUNTIME_SRCS_EXECUTION_ENVIRONMENT ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment.h ${CMAKE_CURRENT_SOURCE_DIR}/execution_environment.cpp + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/execution_environment_initialize.cpp ) target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_EXECUTION_ENVIRONMENT}) set_property(GLOBAL PROPERTY RUNTIME_SRCS_EXECUTION_ENVIRONMENT ${RUNTIME_SRCS_EXECUTION_ENVIRONMENT}) diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index 604f79991c..393a3c1d21 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -43,6 +43,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject MOCKABLE_VIRTUAL void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType); void initGmm(const HardwareInfo *hwInfo); bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex, uint32_t deviceCsrIndex); + void initializeSpecialCommandStreamReceiver(const HardwareInfo &hwInfo); void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex, uint32_t deviceCsrIndex); void initSourceLevelDebugger(const HardwareInfo &hwInfo); @@ -54,6 +55,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject std::unique_ptr memoryManager; std::unique_ptr aubCenter; CsrContainer commandStreamReceivers; + std::unique_ptr specialCommandStreamReceiver; std::unique_ptr builtins; std::unique_ptr compilerInterface; std::unique_ptr sourceLevelDebugger; diff --git a/runtime/execution_environment/execution_environment_initialize.cpp b/runtime/execution_environment/execution_environment_initialize.cpp new file mode 100644 index 0000000000..d28289de50 --- /dev/null +++ b/runtime/execution_environment/execution_environment_initialize.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/execution_environment/execution_environment.h" + +namespace OCLRT { +void ExecutionEnvironment::initializeSpecialCommandStreamReceiver(const HardwareInfo &hwInfo) { +} + +} // namespace OCLRT diff --git a/runtime/helpers/hardware_context_controller.cpp b/runtime/helpers/hardware_context_controller.cpp index 1972a651a0..6c568121fe 100644 --- a/runtime/helpers/hardware_context_controller.cpp +++ b/runtime/helpers/hardware_context_controller.cpp @@ -19,7 +19,7 @@ HardwareContextController::HardwareContextController(aub_stream::AubManager &aub HardwareContextController::HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t engineIndex, uint32_t flags) { - UNRECOVERABLE_IF(osContext.getNumDevicesSupported() < 2); + DEBUG_BREAK_IF(osContext.getNumDevicesSupported() < 2); for (uint32_t deviceIndex = 0; deviceIndex < osContext.getNumDevicesSupported(); deviceIndex++) { hardwareContexts.emplace_back(aubManager.createHardwareContext(deviceIndex, engineIndex, flags)); } diff --git a/runtime/memory_manager/residency.h b/runtime/memory_manager/residency.h index 3eeb853587..7a36aba766 100644 --- a/runtime/memory_manager/residency.h +++ b/runtime/memory_manager/residency.h @@ -11,7 +11,7 @@ #include "engine_node.h" namespace OCLRT { -constexpr uint32_t maxOsContextCount = 4u * static_cast(EngineInstanceConstants::numGpgpuEngineInstances); +constexpr uint32_t maxOsContextCount = (4u * static_cast(EngineInstanceConstants::numGpgpuEngineInstances)) + 1; struct ResidencyData { ResidencyData() { diff --git a/runtime/platform/platform.cpp b/runtime/platform/platform.cpp index 92b39f5f31..f935dc7995 100644 --- a/runtime/platform/platform.cpp +++ b/runtime/platform/platform.cpp @@ -168,6 +168,7 @@ bool Platform::initialize() { return false; } } + executionEnvironment->initializeSpecialCommandStreamReceiver(*hwInfo); const bool sourceLevelDebuggerActive = executionEnvironment->sourceLevelDebugger && executionEnvironment->sourceLevelDebugger->isDebuggerActive(); if (devices[0]->getPreemptionMode() == PreemptionMode::MidThread || sourceLevelDebuggerActive) { diff --git a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp index 8f4007a880..7ec98f6e21 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -1123,12 +1123,16 @@ TEST_F(HardwareContextContainerTests, givenDeviceIndexWhenOsContextWithMultipleD EXPECT_THROW(HardwareContextController(aubManager, osContext, deviceIndex, 0, 0), std::exception); } -TEST_F(HardwareContextContainerTests, givenOsContextWithoutMultipleDevicesSupportedWhenNoDeviceIndexPassedThenAbort) { +TEST_F(HardwareContextContainerTests, givenOsContextWithMultipleDevicesSupportedThenInitialzeHwContextsWithValidIndexes) { MockAubManager aubManager; - uint32_t numSupportedDevices = 1; + uint32_t numSupportedDevices = 2; OsContext osContext(nullptr, 1, numSupportedDevices, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled); - EXPECT_THROW(HardwareContextController(aubManager, osContext, 0, 0), std::exception); + HardwareContextController hwContextControler(aubManager, osContext, 0, 0); + auto mockHwContext0 = static_cast(hwContextControler.hardwareContexts[0].get()); + auto mockHwContext1 = static_cast(hwContextControler.hardwareContexts[1].get()); + EXPECT_EQ(0u, mockHwContext0->deviceIndex); + EXPECT_EQ(1u, mockHwContext1->deviceIndex); } TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseAllContexts) { diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index a8d3ae938d..e8ee286a4b 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -175,7 +175,11 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI executionEnvironment->initializeMemoryManager(false, false, 0, 0); EXPECT_NE(nullptr, executionEnvironment->memoryManager); } -static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector>) + sizeof(std::mutex) + (is64bit ? 80 : 44), "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); +static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector>) + + sizeof(std::unique_ptr) + + sizeof(std::mutex) + + (is64bit ? 80 : 44), + "New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct"); TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) { uint32_t destructorId = 0u; @@ -183,21 +187,24 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe struct MockExecutionEnvironment : ExecutionEnvironment { using ExecutionEnvironment::gmmHelper; }; - struct GmmHelperMock : public DestructorCounted { + struct GmmHelperMock : public DestructorCounted { GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, hwInfo) {} }; - struct OsInterfaceMock : public DestructorCounted { + struct OsInterfaceMock : public DestructorCounted { OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {} }; - struct MemoryMangerMock : public DestructorCounted { + struct MemoryMangerMock : public DestructorCounted { MemoryMangerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {} }; - struct AubCenterMock : public DestructorCounted { + struct AubCenterMock : public DestructorCounted { AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {} }; - struct CommandStreamReceiverMock : public DestructorCounted { + struct CommandStreamReceiverMock : public DestructorCounted { CommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {} }; + struct SpecialCommandStreamReceiverMock : public DestructorCounted { + SpecialCommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {} + }; struct BuiltinsMock : public DestructorCounted { BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {} }; @@ -215,12 +222,13 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe executionEnvironment->memoryManager = std::make_unique(destructorId); executionEnvironment->aubCenter = std::make_unique(destructorId); executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique(destructorId, *executionEnvironment)); + executionEnvironment->specialCommandStreamReceiver = std::make_unique(destructorId, *executionEnvironment); executionEnvironment->builtins = std::make_unique(destructorId); executionEnvironment->compilerInterface = std::make_unique(destructorId); executionEnvironment->sourceLevelDebugger = std::make_unique(destructorId); executionEnvironment.reset(nullptr); - EXPECT_EQ(8u, destructorId); + EXPECT_EQ(9u, destructorId); } TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {