Add static getter to retrieve platform level SIP kernel allocation

Change-Id: I2220c3b027ccb6ab52169077ef522c29476b3e68
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-01-20 19:10:01 +01:00
committed by sys_ocldev
parent 877b82a8e7
commit 7b4b4eaeb1
9 changed files with 62 additions and 17 deletions

View File

@ -0,0 +1,12 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_BUILT_INS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/sip_kernel_type.h
)
set_property(GLOBAL PROPERTY NEO_CORE_BUILT_INS ${NEO_CORE_BUILT_INS})

View File

@ -0,0 +1,21 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <cstdint>
namespace NEO {
enum class SipKernelType : std::uint32_t {
Csr = 0,
DbgCsr,
DbgCsrLocal,
COUNT
};
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -81,8 +81,8 @@ void PreemptionHelper::programStateSip(LinearStream &preambleCmdStream, Device &
if (isMidThreadPreemption || sourceLevelDebuggerActive) {
auto sip = reinterpret_cast<STATE_SIP *>(preambleCmdStream.getSpace(sizeof(STATE_SIP)));
*sip = GfxFamily::cmdInitStateSip;
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, sourceLevelDebuggerActive);
sip->setSystemInstructionPointer(device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation()->getGpuAddressToPatch());
auto sipAllocation = SipKernel::getSipKernelAllocation(device);
sip->setSystemInstructionPointer(sipAllocation->getGpuAddressToPatch());
}
}

View File

@ -1,15 +1,15 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/built_ins/sip_kernel_type.h"
#include "core/helpers/debug_helpers.h"
#include "core/helpers/non_copyable_or_moveable.h"
#include "core/helpers/vec.h"
#include "runtime/built_ins/sip.h"
#include "CL/cl.h"
#include "built_in_ops.h"
@ -35,6 +35,7 @@ struct KernelInfo;
struct MultiDispatchInfo;
class Program;
class SchedulerKernel;
class SipKernel;
static constexpr ConstStringRef mediaKernelsBuildOptionsList[] = {
"-D cl_intel_device_side_advanced_vme_enable",

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -12,7 +12,9 @@
#include "core/helpers/ptr_math.h"
#include "core/helpers/string.h"
#include "core/memory_manager/graphics_allocation.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/program/kernel_info.h"
#include "runtime/program/program.h"
@ -90,4 +92,10 @@ SipKernelType SipKernel::getSipKernelType(GFXCORE_FAMILY family, bool debuggingA
auto &hwHelper = HwHelper::get(family);
return hwHelper.getSipKernelType(debuggingActive);
}
GraphicsAllocation *SipKernel::getSipKernelAllocation(Device &device) {
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, device.isSourceLevelDebuggerActive());
return device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation();
}
} // namespace NEO

View File

@ -1,14 +1,14 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/built_ins/sip_kernel_type.h"
#include "core/helpers/hw_info.h"
#include <cinttypes>
#include <memory>
namespace NEO {
@ -17,13 +17,6 @@ class Device;
class Program;
class GraphicsAllocation;
enum class SipKernelType : std::uint32_t {
Csr = 0,
DbgCsr,
DbgCsrLocal,
COUNT
};
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel);
const char *getSipLlSrc(const Device &device);
@ -49,6 +42,7 @@ class SipKernel {
MOCKABLE_VIRTUAL GraphicsAllocation *getSipAllocation() const;
static SipKernelType getSipKernelType(GFXCORE_FAMILY family, bool debuggingActive);
static GraphicsAllocation *getSipKernelAllocation(Device &device);
protected:
SipKernelType type = SipKernelType::COUNT;

View File

@ -389,8 +389,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
makeResident(*preemptionAllocation);
if (dispatchFlags.preemptionMode == PreemptionMode::MidThread || device.isSourceLevelDebuggerActive()) {
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, device.isSourceLevelDebuggerActive());
makeResident(*device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation());
makeResident(*SipKernel::getSipKernelAllocation(device));
if (debugSurface) {
makeResident(*debugSurface);
}

View File

@ -7,6 +7,7 @@
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${NEO_SOURCE_DIR}/runtime/core_files.cmake)
append_sources_from_properties(NEO_CORE_SOURCES
NEO_CORE_BUILT_INS
NEO_CORE_COMMAND_CONTAINER
NEO_CORE_COMMAND_STREAM
NEO_CORE_COMMANDS

View File

@ -2077,6 +2077,15 @@ TEST_F(BuiltInTests, givenSipKernelWhenItIsCreatedThenItHasGraphicsAllocationFor
EXPECT_NE(nullptr, sipAllocation);
}
TEST_F(BuiltInTests, givenSameDeviceIsUsedWhenUsingStaticGetterThenExpectRetrieveSameAllocation) {
const SipKernel &sipKern = pDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
auto sipAllocation = sipKern.getSipAllocation();
EXPECT_NE(nullptr, sipAllocation);
auto staticSipAllocation = SipKernel::getSipKernelAllocation(*pDevice);
EXPECT_NE(nullptr, staticSipAllocation);
EXPECT_EQ(sipAllocation, staticSipAllocation);
}
TEST_F(BuiltInTests, givenDebugFlagForceUseSourceWhenArgIsBinaryThenReturnBuiltinCodeBinary) {
DebugManager.flags.RebuildPrecompiledKernels.set(true);
auto builtinsLib = std::unique_ptr<BuiltinsLib>(new BuiltinsLib());