Skip to content

Commit 7b4b4ea

Browse files
Add static getter to retrieve platform level SIP kernel allocation
Change-Id: I2220c3b027ccb6ab52169077ef522c29476b3e68 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 877b82a commit 7b4b4ea

File tree

9 files changed

+62
-17
lines changed

9 files changed

+62
-17
lines changed

core/built_ins/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (C) 2020 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
set(NEO_CORE_BUILT_INS
8+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9+
${CMAKE_CURRENT_SOURCE_DIR}/sip_kernel_type.h
10+
)
11+
12+
set_property(GLOBAL PROPERTY NEO_CORE_BUILT_INS ${NEO_CORE_BUILT_INS})

core/built_ins/sip_kernel_type.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include <cstdint>
11+
12+
namespace NEO {
13+
14+
enum class SipKernelType : std::uint32_t {
15+
Csr = 0,
16+
DbgCsr,
17+
DbgCsrLocal,
18+
COUNT
19+
};
20+
21+
} // namespace NEO

core/command_stream/preemption.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2019 Intel Corporation
2+
* Copyright (C) 2017-2020 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -81,8 +81,8 @@ void PreemptionHelper::programStateSip(LinearStream &preambleCmdStream, Device &
8181
if (isMidThreadPreemption || sourceLevelDebuggerActive) {
8282
auto sip = reinterpret_cast<STATE_SIP *>(preambleCmdStream.getSpace(sizeof(STATE_SIP)));
8383
*sip = GfxFamily::cmdInitStateSip;
84-
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, sourceLevelDebuggerActive);
85-
sip->setSystemInstructionPointer(device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation()->getGpuAddressToPatch());
84+
auto sipAllocation = SipKernel::getSipKernelAllocation(device);
85+
sip->setSystemInstructionPointer(sipAllocation->getGpuAddressToPatch());
8686
}
8787
}
8888

runtime/built_ins/built_ins.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/*
2-
* Copyright (C) 2017-2019 Intel Corporation
2+
* Copyright (C) 2017-2020 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
9+
#include "core/built_ins/sip_kernel_type.h"
910
#include "core/helpers/debug_helpers.h"
1011
#include "core/helpers/non_copyable_or_moveable.h"
1112
#include "core/helpers/vec.h"
12-
#include "runtime/built_ins/sip.h"
1313

1414
#include "CL/cl.h"
1515
#include "built_in_ops.h"
@@ -35,6 +35,7 @@ struct KernelInfo;
3535
struct MultiDispatchInfo;
3636
class Program;
3737
class SchedulerKernel;
38+
class SipKernel;
3839

3940
static constexpr ConstStringRef mediaKernelsBuildOptionsList[] = {
4041
"-D cl_intel_device_side_advanced_vme_enable",

runtime/built_ins/sip.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2019 Intel Corporation
2+
* Copyright (C) 2017-2020 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -12,7 +12,9 @@
1212
#include "core/helpers/ptr_math.h"
1313
#include "core/helpers/string.h"
1414
#include "core/memory_manager/graphics_allocation.h"
15+
#include "runtime/built_ins/built_ins.h"
1516
#include "runtime/device/device.h"
17+
#include "runtime/execution_environment/execution_environment.h"
1618
#include "runtime/program/kernel_info.h"
1719
#include "runtime/program/program.h"
1820

@@ -90,4 +92,10 @@ SipKernelType SipKernel::getSipKernelType(GFXCORE_FAMILY family, bool debuggingA
9092
auto &hwHelper = HwHelper::get(family);
9193
return hwHelper.getSipKernelType(debuggingActive);
9294
}
95+
96+
GraphicsAllocation *SipKernel::getSipKernelAllocation(Device &device) {
97+
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, device.isSourceLevelDebuggerActive());
98+
return device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation();
99+
}
100+
93101
} // namespace NEO

runtime/built_ins/sip.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* Copyright (C) 2017-2019 Intel Corporation
2+
* Copyright (C) 2017-2020 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
9+
#include "core/built_ins/sip_kernel_type.h"
910
#include "core/helpers/hw_info.h"
1011

11-
#include <cinttypes>
1212
#include <memory>
1313

1414
namespace NEO {
@@ -17,13 +17,6 @@ class Device;
1717
class Program;
1818
class GraphicsAllocation;
1919

20-
enum class SipKernelType : std::uint32_t {
21-
Csr = 0,
22-
DbgCsr,
23-
DbgCsrLocal,
24-
COUNT
25-
};
26-
2720
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel);
2821

2922
const char *getSipLlSrc(const Device &device);
@@ -49,6 +42,7 @@ class SipKernel {
4942

5043
MOCKABLE_VIRTUAL GraphicsAllocation *getSipAllocation() const;
5144
static SipKernelType getSipKernelType(GFXCORE_FAMILY family, bool debuggingActive);
45+
static GraphicsAllocation *getSipKernelAllocation(Device &device);
5246

5347
protected:
5448
SipKernelType type = SipKernelType::COUNT;

runtime/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
389389
makeResident(*preemptionAllocation);
390390

391391
if (dispatchFlags.preemptionMode == PreemptionMode::MidThread || device.isSourceLevelDebuggerActive()) {
392-
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, device.isSourceLevelDebuggerActive());
393-
makeResident(*device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation());
392+
makeResident(*SipKernel::getSipKernelAllocation(device));
394393
if (debugSurface) {
395394
makeResident(*debugSurface);
396395
}

runtime/core_files.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${NEO_SOURCE_DIR}/runtime/core_files.cmake)
88

99
append_sources_from_properties(NEO_CORE_SOURCES
10+
NEO_CORE_BUILT_INS
1011
NEO_CORE_COMMAND_CONTAINER
1112
NEO_CORE_COMMAND_STREAM
1213
NEO_CORE_COMMANDS

unit_tests/built_ins/built_in_tests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,15 @@ TEST_F(BuiltInTests, givenSipKernelWhenItIsCreatedThenItHasGraphicsAllocationFor
20772077
EXPECT_NE(nullptr, sipAllocation);
20782078
}
20792079

2080+
TEST_F(BuiltInTests, givenSameDeviceIsUsedWhenUsingStaticGetterThenExpectRetrieveSameAllocation) {
2081+
const SipKernel &sipKern = pDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
2082+
auto sipAllocation = sipKern.getSipAllocation();
2083+
EXPECT_NE(nullptr, sipAllocation);
2084+
auto staticSipAllocation = SipKernel::getSipKernelAllocation(*pDevice);
2085+
EXPECT_NE(nullptr, staticSipAllocation);
2086+
EXPECT_EQ(sipAllocation, staticSipAllocation);
2087+
}
2088+
20802089
TEST_F(BuiltInTests, givenDebugFlagForceUseSourceWhenArgIsBinaryThenReturnBuiltinCodeBinary) {
20812090
DebugManager.flags.RebuildPrecompiledKernels.set(true);
20822091
auto builtinsLib = std::unique_ptr<BuiltinsLib>(new BuiltinsLib());

0 commit comments

Comments
 (0)