Skip to content

Commit 6f69bd3

Browse files
Initialize SIP kernel in Device::create()
Related-To: NEO-4878 Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 38577be commit 6f69bd3

File tree

27 files changed

+97
-53
lines changed

27 files changed

+97
-53
lines changed

level_zero/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2019-2020 Intel Corporation
2+
# Copyright (C) 2019-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -228,7 +228,7 @@ if(BUILD_WITH_L0)
228228
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_tbx_sockets.cpp
229229
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/get_devices.cpp
230230
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/source_level_debugger_dll.cpp
231-
${COMPUTE_RUNTIME_DIR}/opencl/source/helpers/built_ins_helper.cpp
231+
${COMPUTE_RUNTIME_DIR}/shared/source/helpers/built_ins_helper.cpp
232232
${COMPUTE_RUNTIME_DIR}/shared/source/aub/aub_stream_interface.cpp
233233
)
234234

level_zero/cmake/l0_tests.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020 Intel Corporation
2+
# Copyright (C) 2020-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -66,14 +66,15 @@ add_library(compute_runtime_mockable_extra
6666
EXCLUDE_FROM_ALL
6767
${CMAKE_CURRENT_LIST_DIR}/l0_tests.cmake
6868
${NEO_SHARED_TEST_DIRECTORY}/unit_test/utilities/cpuintrinsics.cpp
69+
${NEO_SHARED_TEST_DIRECTORY}/unit_test/helpers/built_ins_helper.cpp
6970
${NEO_SHARED_TEST_DIRECTORY}/unit_test/helpers/test_files.cpp
7071
${NEO_SHARED_TEST_DIRECTORY}/unit_test/mocks/mock_compiler_interface_spirv.cpp
7172
${NEO_SHARED_TEST_DIRECTORY}/unit_test/mocks/mock_compiler_interface_spirv.h
7273
${NEO_SHARED_TEST_DIRECTORY}/unit_test/mocks/mock_command_stream_receiver.cpp
7374
${NEO_SHARED_TEST_DIRECTORY}/unit_test/mocks/mock_device.cpp
75+
${NEO_SHARED_TEST_DIRECTORY}/unit_test/mocks/mock_sip.cpp
7476
${NEO_SOURCE_DIR}/opencl/test/unit_test/aub_stream_mocks/aub_stream_interface_mock.cpp
7577
${NEO_SOURCE_DIR}/opencl/test/unit_test/abort.cpp
76-
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/built_ins_helper.cpp
7778
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/debug_helpers.cpp
7879
${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/os_interface.cpp
7980
${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/source_level_debugger_ult.cpp
@@ -88,7 +89,6 @@ add_library(compute_runtime_mockable_extra
8889
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_gmm_resource_info.cpp
8990
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_memory_manager.cpp
9091
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_program.cpp
91-
${NEO_SOURCE_DIR}/opencl/test/unit_test/mocks/mock_sip.cpp
9292
${NEO_SOURCE_DIR}/opencl/test/unit_test/utilities/debug_settings_reader_creator.cpp
9393
${NEO_SOURCE_DIR}/shared/source/debug_settings/debug_settings_manager.cpp
9494
)

level_zero/core/source/device/device_imp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "shared/source/execution_environment/execution_environment.h"
1515
#include "shared/source/execution_environment/root_device_environment.h"
1616
#include "shared/source/gmm_helper/gmm_helper.h"
17+
#include "shared/source/helpers/built_ins_helper.h"
1718
#include "shared/source/helpers/constants.h"
1819
#include "shared/source/helpers/engine_node_helper.h"
1920
#include "shared/source/helpers/hw_helper.h"
@@ -589,6 +590,11 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
589590
if (device->getHwInfo().capabilityTable.supportsImages) {
590591
device->getBuiltinFunctionsLib()->initImageFunctions();
591592
}
593+
auto hwInfo = neoDevice->getHardwareInfo();
594+
if (neoDevice->getPreemptionMode() == NEO::PreemptionMode::MidThread || neoDevice->isDebuggerActive()) {
595+
auto sipType = NEO::SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, neoDevice->isDebuggerActive());
596+
NEO::initSipKernel(sipType, *neoDevice);
597+
}
592598
}
593599

594600
auto supportDualStorageSharedMemory = neoDevice->getMemoryManager()->isLocalMemorySupported(device->neoDevice->getRootDeviceIndex());

level_zero/core/test/black_box_tests/zello_world_jitc_ocloc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -25,7 +25,7 @@ std::vector<uint8_t> compileToSpirV(const std::string &src, const std::string &o
2525
std::vector<uint8_t> ret;
2626

2727
const char *mainFileName = "main.cl";
28-
const char *argv[] = {"ocloc", "-q", "-device", "skl", "-file", mainFileName};
28+
const char *argv[] = {"ocloc", "-q", "-device", "skl", "-file", mainFileName, "-options", options.c_str()};
2929
const unsigned char *sources[] = {reinterpret_cast<const unsigned char *>(src.c_str())};
3030
size_t sourcesLengths[] = {src.size() + 1};
3131
const char *sourcesNames[] = {mainFileName};

level_zero/core/test/unit_tests/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -13,13 +13,13 @@
1313
#include "shared/test/unit_test/helpers/memory_leak_listener.h"
1414
#include "shared/test/unit_test/helpers/test_files.h"
1515
#include "shared/test/unit_test/helpers/ult_hw_config.inl"
16+
#include "shared/test/unit_test/mocks/mock_sip.h"
1617

1718
#include "opencl/source/program/kernel_info.h"
1819
#include "opencl/source/utilities/logger.h"
1920
#include "opencl/test/unit_test/custom_event_listener.h"
2021
#include "opencl/test/unit_test/global_environment.h"
2122
#include "opencl/test/unit_test/mocks/mock_gmm_client_context.h"
22-
#include "opencl/test/unit_test/mocks/mock_sip.h"
2323

2424
#include "level_zero/core/source/cmdlist/cmdlist.h"
2525

level_zero/core/test/unit_tests/sources/device/test_device.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424

2525
using ::testing::Return;
2626

27+
namespace NEO {
28+
namespace MockSipData {
29+
extern SipKernelType calledType;
30+
extern bool called;
31+
} // namespace MockSipData
32+
} // namespace NEO
33+
2734
namespace L0 {
2835
namespace ult {
2936

@@ -46,6 +53,46 @@ TEST(L0DeviceTest, GivenDualStorageSharedMemorySupportedWhenCreatingDeviceThenPa
4653
EXPECT_EQ(ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS, static_cast<CommandQueueImp *>(deviceImp->pageFaultCommandList->cmdQImmediate)->getSynchronousMode());
4754
}
4855

56+
TEST(L0DeviceTest, givenMidThreadPreemptionWhenCreatingDeviceThenSipKernelIsInitialized) {
57+
VariableBackup<bool> mockSipCalled(&NEO::MockSipData::called, false);
58+
VariableBackup<NEO::SipKernelType> mockSipCalledType(&NEO::MockSipData::calledType, NEO::SipKernelType::COUNT);
59+
60+
std::unique_ptr<DriverHandleImp> driverHandle(new DriverHandleImp);
61+
auto hwInfo = *NEO::defaultHwInfo;
62+
hwInfo.capabilityTable.defaultPreemptionMode = NEO::PreemptionMode::MidThread;
63+
64+
auto neoDevice = std::unique_ptr<NEO::Device>(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
65+
66+
EXPECT_EQ(NEO::SipKernelType::COUNT, NEO::MockSipData::calledType);
67+
EXPECT_FALSE(NEO::MockSipData::called);
68+
69+
auto device = std::unique_ptr<L0::Device>(Device::create(driverHandle.get(), neoDevice.release(), 1, false));
70+
ASSERT_NE(nullptr, device);
71+
72+
EXPECT_EQ(NEO::SipKernelType::Csr, NEO::MockSipData::calledType);
73+
EXPECT_TRUE(NEO::MockSipData::called);
74+
}
75+
76+
TEST(L0DeviceTest, givenDisabledPreemptionWhenCreatingDeviceThenSipKernelIsNotInitialized) {
77+
VariableBackup<bool> mockSipCalled(&NEO::MockSipData::called, false);
78+
VariableBackup<NEO::SipKernelType> mockSipCalledType(&NEO::MockSipData::calledType, NEO::SipKernelType::COUNT);
79+
80+
std::unique_ptr<DriverHandleImp> driverHandle(new DriverHandleImp);
81+
auto hwInfo = *NEO::defaultHwInfo;
82+
hwInfo.capabilityTable.defaultPreemptionMode = NEO::PreemptionMode::Disabled;
83+
84+
auto neoDevice = std::unique_ptr<NEO::Device>(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0));
85+
86+
EXPECT_EQ(NEO::SipKernelType::COUNT, NEO::MockSipData::calledType);
87+
EXPECT_FALSE(NEO::MockSipData::called);
88+
89+
auto device = std::unique_ptr<L0::Device>(Device::create(driverHandle.get(), neoDevice.release(), 1, false));
90+
ASSERT_NE(nullptr, device);
91+
92+
EXPECT_EQ(NEO::SipKernelType::COUNT, NEO::MockSipData::calledType);
93+
EXPECT_FALSE(NEO::MockSipData::called);
94+
}
95+
4996
struct DeviceTest : public ::testing::Test {
5097
void SetUp() override {
5198
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);

opencl/source/built_ins/builtins_dispatch_builder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -11,13 +11,13 @@
1111
#include "shared/source/built_ins/sip.h"
1212
#include "shared/source/compiler_interface/compiler_interface.h"
1313
#include "shared/source/helpers/basic_math.h"
14+
#include "shared/source/helpers/built_ins_helper.h"
1415
#include "shared/source/helpers/debug_helpers.h"
1516

1617
#include "opencl/source/built_ins/aux_translation_builtin.h"
1718
#include "opencl/source/built_ins/built_ins.inl"
1819
#include "opencl/source/built_ins/vme_dispatch_builder.h"
1920
#include "opencl/source/cl_device/cl_device.h"
20-
#include "opencl/source/helpers/built_ins_helper.h"
2121
#include "opencl/source/helpers/convert_color.h"
2222
#include "opencl/source/helpers/dispatch_info_builder.h"
2323
#include "opencl/source/kernel/kernel.h"

opencl/source/dll/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018-2020 Intel Corporation
2+
# Copyright (C) 2018-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -22,15 +22,15 @@ set(RUNTIME_SRCS_DLL_BASE
2222
${NEO_SHARED_DIRECTORY}/gmm_helper/resource_info.cpp
2323
${NEO_SHARED_DIRECTORY}/gmm_helper/page_table_mngr.cpp
2424
${NEO_SHARED_DIRECTORY}/helpers/abort.cpp
25-
${NEO_SHARED_DIRECTORY}/helpers/debug_helpers.cpp
2625
${NEO_SHARED_DIRECTORY}/helpers/allow_deferred_deleter.cpp
26+
${NEO_SHARED_DIRECTORY}/helpers/built_ins_helper.cpp
27+
${NEO_SHARED_DIRECTORY}/helpers/debug_helpers.cpp
2728
${NEO_SHARED_DIRECTORY}/utilities/cpuintrinsics.cpp
2829
${NEO_SHARED_DIRECTORY}/utilities/debug_settings_reader_creator.cpp
2930
${NEO_SHARED_DIRECTORY}/utilities/io_functions.cpp
3031
${NEO_SOURCE_DIR}/opencl/source/api/api.cpp
3132
${NEO_SOURCE_DIR}/opencl/source/compiler_interface/default_cache_config.cpp
3233
${NEO_SOURCE_DIR}/opencl/source/helpers/api_specific_config_ocl.cpp
33-
${NEO_SOURCE_DIR}/opencl/source/helpers/built_ins_helper.cpp
3434

3535
${GTPIN_INIT_FILE}
3636
${HW_SRC_LINK}

opencl/source/helpers/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2018-2020 Intel Corporation
2+
# Copyright (C) 2018-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -8,7 +8,6 @@ set(RUNTIME_SRCS_HELPERS_BASE
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/base_object.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/base_object.h
11-
${CMAKE_CURRENT_SOURCE_DIR}/built_ins_helper.h
1211
${CMAKE_CURRENT_SOURCE_DIR}/cl_blit_properties.h
1312
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/cl_device_helpers.cpp
1413
${CMAKE_CURRENT_SOURCE_DIR}/cl_device_helpers.h

opencl/source/platform/platform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2020 Intel Corporation
2+
* Copyright (C) 2018-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -14,6 +14,7 @@
1414
#include "shared/source/execution_environment/execution_environment.h"
1515
#include "shared/source/execution_environment/root_device_environment.h"
1616
#include "shared/source/gmm_helper/gmm_helper.h"
17+
#include "shared/source/helpers/built_ins_helper.h"
1718
#include "shared/source/helpers/debug_helpers.h"
1819
#include "shared/source/helpers/get_info.h"
1920
#include "shared/source/helpers/hw_helper.h"
@@ -25,7 +26,6 @@
2526
#include "opencl/source/api/api.h"
2627
#include "opencl/source/cl_device/cl_device.h"
2728
#include "opencl/source/gtpin/gtpin_notify.h"
28-
#include "opencl/source/helpers/built_ins_helper.h"
2929
#include "opencl/source/helpers/get_info_status_mapper.h"
3030
#include "opencl/source/platform/extensions.h"
3131
#include "opencl/source/sharings/sharing_factory.h"

0 commit comments

Comments
 (0)