Add new CSR to ExecutionEnvironment

Change-Id: I5d6b58b5c185bf283ae529ebb21a4cbc8e9f198c
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-02-15 09:25:08 +01:00
committed by sys_ocldev
parent 7f98db617c
commit ba681035f8
8 changed files with 43 additions and 13 deletions

View File

@@ -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})

View File

@@ -43,6 +43,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
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<ExecutionEnvironment>
std::unique_ptr<MemoryManager> memoryManager;
std::unique_ptr<AubCenter> aubCenter;
CsrContainer commandStreamReceivers;
std::unique_ptr<CommandStreamReceiver> specialCommandStreamReceiver;
std::unique_ptr<BuiltIns> builtins;
std::unique_ptr<CompilerInterface> compilerInterface;
std::unique_ptr<SourceLevelDebugger> sourceLevelDebugger;

View File

@@ -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

View File

@@ -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));
}

View File

@@ -11,7 +11,7 @@
#include "engine_node.h"
namespace OCLRT {
constexpr uint32_t maxOsContextCount = 4u * static_cast<uint32_t>(EngineInstanceConstants::numGpgpuEngineInstances);
constexpr uint32_t maxOsContextCount = (4u * static_cast<uint32_t>(EngineInstanceConstants::numGpgpuEngineInstances)) + 1;
struct ResidencyData {
ResidencyData() {

View File

@@ -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) {

View File

@@ -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<MockHardwareContext *>(hwContextControler.hardwareContexts[0].get());
auto mockHwContext1 = static_cast<MockHardwareContext *>(hwContextControler.hardwareContexts[1].get());
EXPECT_EQ(0u, mockHwContext0->deviceIndex);
EXPECT_EQ(1u, mockHwContext1->deviceIndex);
}
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseAllContexts) {

View File

@@ -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<std::unique_ptr<CommandStreamReceiver>>) + 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<std::unique_ptr<CommandStreamReceiver>>) +
sizeof(std::unique_ptr<CommandStreamReceiver>) +
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<GmmHelper, 7> {
struct GmmHelperMock : public DestructorCounted<GmmHelper, 8> {
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, hwInfo) {}
};
struct OsInterfaceMock : public DestructorCounted<OSInterface, 6> {
struct OsInterfaceMock : public DestructorCounted<OSInterface, 7> {
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 5> {
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 6> {
MemoryMangerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct AubCenterMock : public DestructorCounted<AubCenter, 4> {
struct AubCenterMock : public DestructorCounted<AubCenter, 5> {
AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {}
};
struct CommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 3> {
struct CommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 4> {
CommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
};
struct SpecialCommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 3> {
SpecialCommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
};
struct BuiltinsMock : public DestructorCounted<BuiltIns, 2> {
BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
@@ -215,12 +222,13 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId);
executionEnvironment->aubCenter = std::make_unique<AubCenterMock>(destructorId);
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CommandStreamReceiverMock>(destructorId, *executionEnvironment));
executionEnvironment->specialCommandStreamReceiver = std::make_unique<SpecialCommandStreamReceiverMock>(destructorId, *executionEnvironment);
executionEnvironment->builtins = std::make_unique<BuiltinsMock>(destructorId);
executionEnvironment->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
executionEnvironment->sourceLevelDebugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
executionEnvironment.reset(nullptr);
EXPECT_EQ(8u, destructorId);
EXPECT_EQ(9u, destructorId);
}
TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {