Skip to content

Commit ba68103

Browse files
Add new CSR to ExecutionEnvironment
Change-Id: I5d6b58b5c185bf283ae529ebb21a4cbc8e9f198c Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent 7f98db6 commit ba68103

File tree

8 files changed

+43
-13
lines changed

8 files changed

+43
-13
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018 Intel Corporation
2+
# Copyright (C) 2018-2019 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -8,6 +8,7 @@ set(RUNTIME_SRCS_EXECUTION_ENVIRONMENT
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/execution_environment.h
1010
${CMAKE_CURRENT_SOURCE_DIR}/execution_environment.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/execution_environment_initialize.cpp
1112
)
1213
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_EXECUTION_ENVIRONMENT})
1314
set_property(GLOBAL PROPERTY RUNTIME_SRCS_EXECUTION_ENVIRONMENT ${RUNTIME_SRCS_EXECUTION_ENVIRONMENT})

runtime/execution_environment/execution_environment.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
4343
MOCKABLE_VIRTUAL void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType);
4444
void initGmm(const HardwareInfo *hwInfo);
4545
bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo, uint32_t deviceIndex, uint32_t deviceCsrIndex);
46+
void initializeSpecialCommandStreamReceiver(const HardwareInfo &hwInfo);
4647
void initializeMemoryManager(bool enable64KBpages, bool enableLocalMemory, uint32_t deviceIndex, uint32_t deviceCsrIndex);
4748
void initSourceLevelDebugger(const HardwareInfo &hwInfo);
4849

@@ -54,6 +55,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
5455
std::unique_ptr<MemoryManager> memoryManager;
5556
std::unique_ptr<AubCenter> aubCenter;
5657
CsrContainer commandStreamReceivers;
58+
std::unique_ptr<CommandStreamReceiver> specialCommandStreamReceiver;
5759
std::unique_ptr<BuiltIns> builtins;
5860
std::unique_ptr<CompilerInterface> compilerInterface;
5961
std::unique_ptr<SourceLevelDebugger> sourceLevelDebugger;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "runtime/execution_environment/execution_environment.h"
9+
10+
namespace OCLRT {
11+
void ExecutionEnvironment::initializeSpecialCommandStreamReceiver(const HardwareInfo &hwInfo) {
12+
}
13+
14+
} // namespace OCLRT

runtime/helpers/hardware_context_controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ HardwareContextController::HardwareContextController(aub_stream::AubManager &aub
1919

2020
HardwareContextController::HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext,
2121
uint32_t engineIndex, uint32_t flags) {
22-
UNRECOVERABLE_IF(osContext.getNumDevicesSupported() < 2);
22+
DEBUG_BREAK_IF(osContext.getNumDevicesSupported() < 2);
2323
for (uint32_t deviceIndex = 0; deviceIndex < osContext.getNumDevicesSupported(); deviceIndex++) {
2424
hardwareContexts.emplace_back(aubManager.createHardwareContext(deviceIndex, engineIndex, flags));
2525
}

runtime/memory_manager/residency.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "engine_node.h"
1212
namespace OCLRT {
1313

14-
constexpr uint32_t maxOsContextCount = 4u * static_cast<uint32_t>(EngineInstanceConstants::numGpgpuEngineInstances);
14+
constexpr uint32_t maxOsContextCount = (4u * static_cast<uint32_t>(EngineInstanceConstants::numGpgpuEngineInstances)) + 1;
1515

1616
struct ResidencyData {
1717
ResidencyData() {

runtime/platform/platform.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ bool Platform::initialize() {
168168
return false;
169169
}
170170
}
171+
executionEnvironment->initializeSpecialCommandStreamReceiver(*hwInfo);
171172

172173
const bool sourceLevelDebuggerActive = executionEnvironment->sourceLevelDebugger && executionEnvironment->sourceLevelDebugger->isDebuggerActive();
173174
if (devices[0]->getPreemptionMode() == PreemptionMode::MidThread || sourceLevelDebuggerActive) {

unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,16 @@ TEST_F(HardwareContextContainerTests, givenDeviceIndexWhenOsContextWithMultipleD
11231123
EXPECT_THROW(HardwareContextController(aubManager, osContext, deviceIndex, 0, 0), std::exception);
11241124
}
11251125

1126-
TEST_F(HardwareContextContainerTests, givenOsContextWithoutMultipleDevicesSupportedWhenNoDeviceIndexPassedThenAbort) {
1126+
TEST_F(HardwareContextContainerTests, givenOsContextWithMultipleDevicesSupportedThenInitialzeHwContextsWithValidIndexes) {
11271127
MockAubManager aubManager;
1128-
uint32_t numSupportedDevices = 1;
1128+
uint32_t numSupportedDevices = 2;
11291129
OsContext osContext(nullptr, 1, numSupportedDevices, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
11301130

1131-
EXPECT_THROW(HardwareContextController(aubManager, osContext, 0, 0), std::exception);
1131+
HardwareContextController hwContextControler(aubManager, osContext, 0, 0);
1132+
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextControler.hardwareContexts[0].get());
1133+
auto mockHwContext1 = static_cast<MockHardwareContext *>(hwContextControler.hardwareContexts[1].get());
1134+
EXPECT_EQ(0u, mockHwContext0->deviceIndex);
1135+
EXPECT_EQ(1u, mockHwContext1->deviceIndex);
11321136
}
11331137

11341138
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseAllContexts) {

unit_tests/execution_environment/execution_environment_tests.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,29 +175,36 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerI
175175
executionEnvironment->initializeMemoryManager(false, false, 0, 0);
176176
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
177177
}
178-
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");
178+
static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector<std::unique_ptr<CommandStreamReceiver>>) +
179+
sizeof(std::unique_ptr<CommandStreamReceiver>) +
180+
sizeof(std::mutex) +
181+
(is64bit ? 80 : 44),
182+
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
179183

180184
TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) {
181185
uint32_t destructorId = 0u;
182186

183187
struct MockExecutionEnvironment : ExecutionEnvironment {
184188
using ExecutionEnvironment::gmmHelper;
185189
};
186-
struct GmmHelperMock : public DestructorCounted<GmmHelper, 7> {
190+
struct GmmHelperMock : public DestructorCounted<GmmHelper, 8> {
187191
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, hwInfo) {}
188192
};
189-
struct OsInterfaceMock : public DestructorCounted<OSInterface, 6> {
193+
struct OsInterfaceMock : public DestructorCounted<OSInterface, 7> {
190194
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
191195
};
192-
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 5> {
196+
struct MemoryMangerMock : public DestructorCounted<MockMemoryManager, 6> {
193197
MemoryMangerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
194198
};
195-
struct AubCenterMock : public DestructorCounted<AubCenter, 4> {
199+
struct AubCenterMock : public DestructorCounted<AubCenter, 5> {
196200
AubCenterMock(uint32_t &destructorId) : DestructorCounted(destructorId, platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB) {}
197201
};
198-
struct CommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 3> {
202+
struct CommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 4> {
199203
CommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
200204
};
205+
struct SpecialCommandStreamReceiverMock : public DestructorCounted<MockCommandStreamReceiver, 3> {
206+
SpecialCommandStreamReceiverMock(uint32_t &destructorId, ExecutionEnvironment &executionEnvironment) : DestructorCounted(destructorId, executionEnvironment) {}
207+
};
201208
struct BuiltinsMock : public DestructorCounted<BuiltIns, 2> {
202209
BuiltinsMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
203210
};
@@ -215,12 +222,13 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
215222
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId);
216223
executionEnvironment->aubCenter = std::make_unique<AubCenterMock>(destructorId);
217224
executionEnvironment->commandStreamReceivers[0].push_back(std::make_unique<CommandStreamReceiverMock>(destructorId, *executionEnvironment));
225+
executionEnvironment->specialCommandStreamReceiver = std::make_unique<SpecialCommandStreamReceiverMock>(destructorId, *executionEnvironment);
218226
executionEnvironment->builtins = std::make_unique<BuiltinsMock>(destructorId);
219227
executionEnvironment->compilerInterface = std::make_unique<CompilerInterfaceMock>(destructorId);
220228
executionEnvironment->sourceLevelDebugger = std::make_unique<SourceLevelDebuggerMock>(destructorId);
221229

222230
executionEnvironment.reset(nullptr);
223-
EXPECT_EQ(8u, destructorId);
231+
EXPECT_EQ(9u, destructorId);
224232
}
225233

226234
TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {

0 commit comments

Comments
 (0)