Initialize SipKernel after all devices are created
Change-Id: Iec5de27fd1e5106c78de0bc5c1861a894162b274 Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
parent
76f5420700
commit
ef33c57245
|
@ -8,7 +8,6 @@
|
|||
#include "runtime/device/device.h"
|
||||
#include "hw_cmds.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/sip.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/command_stream/device_command_stream.h"
|
||||
#include "runtime/command_stream/experimental_command_buffer.h"
|
||||
|
@ -17,7 +16,6 @@
|
|||
#include "runtime/device/device_vector.h"
|
||||
#include "runtime/device/driver_info.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/built_ins_helper.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
|
@ -162,8 +160,6 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
|
|||
return false;
|
||||
}
|
||||
commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation);
|
||||
auto sipType = SipKernel::getSipKernelType(pHwInfo->pPlatform->eRenderCoreFamily, pDevice->isSourceLevelDebuggerActive());
|
||||
initSipKernel(sipType, *pDevice);
|
||||
}
|
||||
|
||||
if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/gtpin/gtpin_notify.h"
|
||||
#include "runtime/helpers/built_ins_helper.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
#include "runtime/helpers/get_info.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include "runtime/event/async_events_handler.h"
|
||||
#include "runtime/sharings/sharing_factory.h"
|
||||
#include "runtime/platform/extensions.h"
|
||||
#include "runtime/source_level_debugger/source_level_debugger.h"
|
||||
#include "CL/cl_ext.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
@ -166,6 +168,12 @@ bool Platform::initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
const bool sourceLevelDebuggerActive = executionEnvironment->sourceLevelDebugger && executionEnvironment->sourceLevelDebugger->isDebuggerActive();
|
||||
if (devices[0]->getPreemptionMode() == PreemptionMode::MidThread || sourceLevelDebuggerActive) {
|
||||
auto sipType = SipKernel::getSipKernelType(devices[0]->getHardwareInfo().pPlatform->eRenderCoreFamily, devices[0]->isSourceLevelDebuggerActive());
|
||||
initSipKernel(sipType, *devices[0]);
|
||||
}
|
||||
|
||||
CommandStreamReceiverType csrType = this->devices[0]->getEngine(0).commandStreamReceiver->getType();
|
||||
if (csrType != CommandStreamReceiverType::CSR_HW) {
|
||||
executionEnvironment->initAubCenter(&hwInfo[0], this->devices[0]->getEnableLocalMemory(), "aubfile");
|
||||
|
|
|
@ -224,7 +224,7 @@ TEST(Device_GetCaps, givenForcePreemptionModeDebugVariableWhenCreateDeviceThenSe
|
|||
}
|
||||
}
|
||||
|
||||
TEST(Device_GetCaps, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSipKernelIsCreated) {
|
||||
TEST(Device_GetCaps, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSipKernelIsNotCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
{
|
||||
auto builtIns = new MockBuiltins();
|
||||
|
@ -236,7 +236,7 @@ TEST(Device_GetCaps, givenDeviceWithMidThreadPreemptionWhenDeviceIsCreatedThenSi
|
|||
executionEnvironment->builtins.reset(builtIns);
|
||||
auto device = std::unique_ptr<Device>(MockDevice::createWithExecutionEnvironment<MockDevice>(platformDevices[0], executionEnvironment, 0u));
|
||||
ASSERT_EQ(builtIns, device->getExecutionEnvironment()->getBuiltIns());
|
||||
EXPECT_TRUE(builtIns->getSipKernelCalled);
|
||||
EXPECT_FALSE(builtIns->getSipKernelCalled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/fixtures/platform_fixture.h"
|
||||
#include "unit_tests/mocks/mock_async_event_handler.h"
|
||||
#include "unit_tests/mocks/mock_builtins.h"
|
||||
#include "unit_tests/mocks/mock_csr.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_source_level_debugger.h"
|
||||
#include "unit_tests/libult/create_command_stream.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
@ -79,6 +81,63 @@ TEST_F(PlatformTest, hasAsyncEventsHandler) {
|
|||
EXPECT_NE(nullptr, pPlatform->getAsyncEventsHandler());
|
||||
}
|
||||
|
||||
TEST_F(PlatformTest, givenMidThreadPreemptionWhenInitializingPlatformThenCallGetSipKernel) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
||||
|
||||
auto builtIns = new MockBuiltins();
|
||||
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
||||
|
||||
ASSERT_FALSE(builtIns->getSipKernelCalled);
|
||||
pPlatform->initialize();
|
||||
EXPECT_TRUE(builtIns->getSipKernelCalled);
|
||||
EXPECT_EQ(SipKernelType::Csr, builtIns->getSipKernelType);
|
||||
}
|
||||
|
||||
TEST_F(PlatformTest, givenDisabledPreemptionAndNoSourceLevelDebuggerWhenInitializingPlatformThenDoNotCallGetSipKernel) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
||||
|
||||
auto builtIns = new MockBuiltins();
|
||||
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
||||
|
||||
ASSERT_FALSE(builtIns->getSipKernelCalled);
|
||||
pPlatform->initialize();
|
||||
EXPECT_FALSE(builtIns->getSipKernelCalled);
|
||||
EXPECT_EQ(SipKernelType::COUNT, builtIns->getSipKernelType);
|
||||
}
|
||||
|
||||
TEST_F(PlatformTest, givenDisabledPreemptionInactiveSourceLevelDebuggerWhenInitializingPlatformThenDoNotCallGetSipKernel) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
||||
|
||||
auto builtIns = new MockBuiltins();
|
||||
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
||||
auto sourceLevelDebugger = new MockSourceLevelDebugger();
|
||||
sourceLevelDebugger->setActive(false);
|
||||
pPlatform->peekExecutionEnvironment()->sourceLevelDebugger.reset(sourceLevelDebugger);
|
||||
|
||||
ASSERT_FALSE(builtIns->getSipKernelCalled);
|
||||
pPlatform->initialize();
|
||||
EXPECT_FALSE(builtIns->getSipKernelCalled);
|
||||
EXPECT_EQ(SipKernelType::COUNT, builtIns->getSipKernelType);
|
||||
}
|
||||
|
||||
TEST_F(PlatformTest, givenDisabledPreemptionActiveSourceLevelDebuggerWhenInitializingPlatformThenCallGetSipKernel) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
|
||||
|
||||
auto builtIns = new MockBuiltins();
|
||||
pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns);
|
||||
pPlatform->peekExecutionEnvironment()->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger());
|
||||
|
||||
ASSERT_FALSE(builtIns->getSipKernelCalled);
|
||||
pPlatform->initialize();
|
||||
EXPECT_TRUE(builtIns->getSipKernelCalled);
|
||||
EXPECT_LE(SipKernelType::DbgCsr, builtIns->getSipKernelType);
|
||||
EXPECT_GE(SipKernelType::DbgCsrLocal, builtIns->getSipKernelType);
|
||||
}
|
||||
|
||||
TEST(PlatformTestSimple, givenCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsNotCalled) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(0);
|
||||
|
|
|
@ -36,43 +36,6 @@ class MockDeviceWithDebuggerActive : public MockDevice {
|
|||
}
|
||||
};
|
||||
|
||||
TEST(DeviceCreation, givenDeviceWithMidThreadPreemptionAndDebuggingActiveWhenDeviceIsCreatedThenCorrectSipKernelIsCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
{
|
||||
auto builtIns = new MockBuiltins();
|
||||
ASSERT_FALSE(builtIns->getSipKernelCalled);
|
||||
|
||||
DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::MidThread);
|
||||
auto exeEnv = new ExecutionEnvironment;
|
||||
exeEnv->sourceLevelDebugger.reset(new SourceLevelDebugger(new MockOsLibrary));
|
||||
exeEnv->builtins.reset(builtIns);
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(nullptr, exeEnv, 0u));
|
||||
|
||||
ASSERT_EQ(builtIns, device->getExecutionEnvironment()->getBuiltIns());
|
||||
EXPECT_TRUE(builtIns->getSipKernelCalled);
|
||||
EXPECT_LE(SipKernelType::DbgCsr, builtIns->getSipKernelType);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DeviceCreation, givenDeviceWithDisabledPreemptionAndDebuggingActiveWhenDeviceIsCreatedThenCorrectSipKernelIsCreated) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
{
|
||||
auto builtIns = new MockBuiltins();
|
||||
ASSERT_FALSE(builtIns->getSipKernelCalled);
|
||||
|
||||
DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::Disabled);
|
||||
|
||||
auto exeEnv = new ExecutionEnvironment;
|
||||
exeEnv->sourceLevelDebugger.reset(new SourceLevelDebugger(new MockOsLibrary));
|
||||
exeEnv->builtins.reset(builtIns);
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(nullptr, exeEnv, 0u));
|
||||
|
||||
ASSERT_EQ(builtIns, device->getExecutionEnvironment()->getBuiltIns());
|
||||
EXPECT_TRUE(builtIns->getSipKernelCalled);
|
||||
EXPECT_LE(SipKernelType::DbgCsr, builtIns->getSipKernelType);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) {
|
||||
auto exeEnv = new ExecutionEnvironment;
|
||||
auto gmock = new ::testing::NiceMock<GMockSourceLevelDebugger>(new MockOsLibrary);
|
||||
|
|
Loading…
Reference in New Issue