Kernel source debugging support 1/n

- new patch token
- program debug compilation flag
- sip kernel new methods for querying bti and debug
surface size

Change-Id: Icaddd15f269c4b76efdf926f2e346aa61cbaae02
This commit is contained in:
Hoppe, Mateusz
2018-03-09 14:40:31 +01:00
committed by sys_ocldev
parent 0ef0d6fc52
commit cc6fa3d1e1
22 changed files with 356 additions and 5 deletions

View File

@@ -265,7 +265,9 @@ std::string OfflineCompiler::getStringWithinDelimiters(const std::string &src) {
start += strlen("R\"===(");
size_t size = stop - start;
std::string dst(src, start, size);
std::string dst(src, start, size + 1);
dst[size] = '\0'; // put null char at the end
return dst;
}

View File

@@ -30,6 +30,8 @@
namespace OCLRT {
const size_t SipKernel::maxDbgSurfaceSize = 0x49c000; // proper value should be taken from compiler when it's ready
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel) {
switch (kernel) {
default:
@@ -78,6 +80,10 @@ const char *getSipLlSrc(const Device &device) {
SipKernel::SipKernel(SipKernelType type, Program *sipProgram)
: type(type) {
program.reset(sipProgram);
if (type == SipKernelType::DbgCsr || type == SipKernelType::DbgCsrLocal) {
debugSurfaceBti = 0;
debugSurfaceSize = SipKernel::maxDbgSurfaceSize;
}
}
GraphicsAllocation *SipKernel::getSipAllocation() const {

View File

@@ -58,10 +58,22 @@ class SipKernel {
return type;
}
int32_t getDebugSurfaceBti() const {
return debugSurfaceBti;
}
size_t getDebugSurfaceSize() const {
return debugSurfaceSize;
}
static const size_t maxDbgSurfaceSize;
GraphicsAllocation *getSipAllocation() const;
protected:
SipKernelType type = SipKernelType::COUNT;
std::unique_ptr<Program> program;
int32_t debugSurfaceBti = -1;
size_t debugSurfaceSize = 0;
};
}

View File

@@ -24,6 +24,8 @@ set(RUNTIME_SRCS_COMPILER_INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/binary_cache.h
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options.cpp
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options.h
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.inl
${CMAKE_CURRENT_SOURCE_DIR}/create_main.cpp
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/compiler_interface/compiler_options.h"
namespace OCLRT {
const char *CompilerOptions::debugKernelEnable = " -cl-kernel-debug-enable";
} // namespace OCLRT

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <string>
namespace OCLRT {
struct CompilerOptions {
static const char *debugKernelEnable;
};
} // namespace OCLRT

View File

@@ -23,6 +23,7 @@
#include "config.h"
#include "elf/writer.h"
#include "runtime/compiler_interface/compiler_interface.h"
#include "runtime/compiler_interface/compiler_options.h"
#include "runtime/platform/platform.h"
#include "runtime/helpers/validators.h"
#include "program.h"
@@ -151,6 +152,11 @@ cl_int Program::compile(
// set parameters for compilation
internalOptions.append(platform()->peekCompilerExtensions());
if (isKernelDebugEnabled()) {
internalOptions.append(CompilerOptions::debugKernelEnable);
}
inputArgs.pInput = pCompileData;
inputArgs.InputSize = (uint32_t)compileDataSize;
inputArgs.pOptions = options.c_str();

View File

@@ -413,6 +413,11 @@ void KernelInfo::storePatchToken(const SPatchKernelAttributesInfo *pKernelAttrib
}
}
void KernelInfo::storePatchToken(const SPatchAllocateSystemThreadSurface *pSystemThreadSurface) {
usesSsh |= true;
patchInfo.pAllocateSystemThreadSurface = pSystemThreadSurface;
}
const char *KernelInfo::queryPrintfString(uint32_t index) const {
auto printfInfo = patchInfo.stringDataMap.find(index);
return printfInfo == patchInfo.stringDataMap.end() ? nullptr : printfInfo->second.pStringData;

View File

@@ -153,6 +153,7 @@ struct KernelInfo {
void storePatchToken(const SPatchAllocateStatelessDefaultDeviceQueueSurface *pStatelessDefaultDeviceQueueSurfaceArg);
void storePatchToken(const SPatchString *pStringArg);
void storePatchToken(const SPatchKernelAttributesInfo *pKernelAttributesInfo);
void storePatchToken(const SPatchAllocateSystemThreadSurface *pSystemThreadSurface);
GraphicsAllocation *getGraphicsAllocation() const { return this->kernelAllocation; }
cl_int resolveKernelInfo();
void resizeKernelArgInfoAndRegisterParameter(uint32_t argCount) {

View File

@@ -56,6 +56,7 @@ using iOpenCL::SPatchAllocateStatelessDefaultDeviceQueueSurface;
using iOpenCL::SPatchString;
using iOpenCL::SPatchGtpinFreeGRFInfo;
using iOpenCL::SPatchStateSIP;
using iOpenCL::SPatchAllocateSystemThreadSurface;
typedef struct TagPrintfStringInfo {
size_t SizeInBytes;
@@ -86,6 +87,7 @@ struct PatchInfo {
const SPatchAllocateStatelessPrintfSurface *pAllocateStatelessPrintfSurface = nullptr;
const SPatchAllocateStatelessEventPoolSurface *pAllocateStatelessEventPoolSurface = nullptr;
const SPatchAllocateStatelessDefaultDeviceQueueSurface *pAllocateStatelessDefaultDeviceQueueSurface = nullptr;
const SPatchAllocateSystemThreadSurface *pAllocateSystemThreadSurface = nullptr;
::std::map<uint32_t, PrintfStringInfo> stringDataMap;
::std::vector<const SPatchKernelArgumentInfo *> kernelArgumentInfo;

View File

@@ -755,6 +755,17 @@ cl_int Program::parsePatchList(KernelInfo &kernelInfo) {
"\n .SystemKernelOffset", pPatchToken->SystemKernelOffset);
} break;
case PATCH_TOKEN_ALLOCATE_SIP_SURFACE: {
auto *pPatchToken = reinterpret_cast<const SPatchAllocateSystemThreadSurface *>(pPatch);
kernelInfo.storePatchToken(pPatchToken);
DBG_LOG(LogPatchTokens,
"\n.PATCH_TOKEN_ALLOCATE_SIP_SURFACE", pPatch->Token,
"\n .Size", pPatch->Size,
"\n .BTI", pPatchToken->BTI,
"\n .Offset", pPatchToken->Offset,
"\n .PerThreadSystemThreadSurfaceSize", pPatchToken->PerThreadSystemThreadSurfaceSize);
} break;
default:
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, " Program::parsePatchList. Unknown Patch Token: %d\n", pPatch->Token);
if (false == isSafeToSkipUnhandledToken(pPatch->Token)) {

View File

@@ -235,6 +235,10 @@ class Program : public BaseObject<_cl_program> {
return programOptionVersion;
}
void enableKernelDebug() {
kernelDebugEnabled = true;
}
static bool isValidLlvmBinary(const void *pBinary, size_t binarySize);
static bool isValidSpirvBinary(const void *pBinary, size_t binarySize);
@@ -276,6 +280,10 @@ class Program : public BaseObject<_cl_program> {
void updateNonUniformFlag();
void updateNonUniformFlag(const Program **inputProgram, size_t numInputPrograms);
bool isKernelDebugEnabled() {
return kernelDebugEnabled;
}
static const std::string clOptNameClVer;
static const std::string clOptNameUniformWgs;
// clang-format off
@@ -326,7 +334,7 @@ class Program : public BaseObject<_cl_program> {
cl_uint numDevices;
bool isBuiltIn;
bool kernelDebugEnabled = false;
friend class OfflineCompiler;
// clang-format on
};

View File

@@ -384,6 +384,45 @@ function(neo_gen_kernel_with_options target gen filepath)
set_target_properties(${target} PROPERTIES FOLDER "kernels/${gen}")
endfunction()
function(neo_gen_kernel_from_ll target gen filepath output_name compile_options)
get_filename_component(filename ${filepath} NAME)
get_filename_component(basename ${filepath} NAME_WE)
set(outputdir "${TargetDir}/${gen}/test_files/${NEO_ARCH}")
set(workdir "${CMAKE_CURRENT_SOURCE_DIR}/test_files/")
set(results)
set(outputpath_base "${outputdir}/${output_name}_${gen}")
set(output_files
${outputpath_base}.bin
${outputpath_base}.gen
)
string(CONCAT compile_options \" ${compile_options} \" )
set(cmd "LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc> -q -file ${filename} -output ${output_name} -device ${gen} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input")
if(MSVC)
add_custom_command(
OUTPUT ${output_files}
COMMAND cloc -q -file ${filename} -output ${output_name} -device ${gen} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input
WORKING_DIRECTORY ${workdir}
DEPENDS ${filepath} cloc
)
else()
add_custom_command(
OUTPUT ${output_files}
COMMAND LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cloc> $<TARGET_FILE:cloc> -q -file ${filename} -output ${output_name} -device ${gen} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input
WORKING_DIRECTORY ${workdir}
DEPENDS ${filepath} cloc
)
endif()
list(APPEND results ${output_files})
add_custom_target(${target} DEPENDS ${results} copy_compiler_files)
set_target_properties(${target} PROPERTIES FOLDER "kernels/${gen}")
endfunction()
set(TEST_KERNEL test_files/CopyBuffer_simd8.cl)
set(TEST_KERNEL_options
@@ -401,6 +440,14 @@ set(TEST_KERNEL_2_0
test_files/simple_block_kernel.cl
)
set(TEST_KERNEL_SIP_DEBUG_options
"-cl-include-sip-kernel-debug -cl-include-sip-csr -cl-set-bti:0"
)
set(TEST_KERNEL_SIP_DEBUG_LOCAL_options
"-cl-include-sip-kernel-local-debug -cl-include-sip-csr -cl-set-bti:0"
)
set(TEST_KERNELS
test_files/15895692906525787409.cl
test_files/copybuffer.cl
@@ -464,8 +511,32 @@ foreach(GEN_NUM RANGE 0 ${MAX_GEN} 1)
if(MSVC OR CMAKE_SIZEOF_VOID_P EQUAL 8)
neo_gen_kernels(test_kernels_${PLATFORM_IT_LOWER} ${PLATFORM_IT_LOWER} ${TEST_KERNELS})
neo_gen_kernel_with_options(test_kernel_${PLATFORM_IT_LOWER} ${PLATFORM_IT_LOWER} ${TEST_KERNEL} ${TEST_KERNEL_options})
add_dependencies(unit_tests test_kernels_${PLATFORM_IT_LOWER})
add_dependencies(unit_tests test_kernel_${PLATFORM_IT_LOWER})
set(sip_kernel_file_name)
set(sip_kernel_output_file)
set(sip_debug_kernel_output_file)
set(sip_debug_local_kernel_output_file)
if(${NEO_BITS} EQUAL "32")
list(APPEND sip_kernel_file_name "test_files/sip_dummy_kernel_32.ll")
list(APPEND sip_debug_kernel_output_file "sip_dummy_kernel_debug_32")
list(APPEND sip_debug_local_kernel_output_file "sip_dummy_kernel_debug_local_32")
else()
list(APPEND sip_kernel_file_name "test_files/sip_dummy_kernel_64.ll")
list(APPEND sip_debug_kernel_output_file "sip_dummy_kernel_debug_64")
list(APPEND sip_debug_local_kernel_output_file "sip_dummy_kernel_debug_local_64")
endif()
if("gen${GEN_NUM}" STREQUAL "gen9" )
neo_gen_kernel_from_ll(test_kernel_sip_debug_local_${PLATFORM_IT_LOWER} ${PLATFORM_IT_LOWER} ${sip_kernel_file_name} ${sip_debug_local_kernel_output_file} ${TEST_KERNEL_SIP_DEBUG_LOCAL_options})
add_dependencies(unit_tests test_kernel_sip_debug_local_${PLATFORM_IT_LOWER})
endif()
neo_gen_kernel_from_ll(test_kernel_sip_debug_${PLATFORM_IT_LOWER} ${PLATFORM_IT_LOWER} ${sip_kernel_file_name} ${sip_debug_kernel_output_file} ${TEST_KERNEL_SIP_DEBUG_options})
add_dependencies(unit_tests test_kernel_sip_debug_${PLATFORM_IT_LOWER})
if(${PLATFORM_SUPPORTS_2_0})
neo_gen_kernel_with_options(test_kernel_2_0_${PLATFORM_IT_LOWER} ${PLATFORM_IT_LOWER} ${TEST_KERNEL_2_0} ${TEST_KERNEL_2_0_options})
add_dependencies(unit_tests test_kernel_2_0_${PLATFORM_IT_LOWER})

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -23,13 +23,30 @@
#include "gtest/gtest.h"
#include "test.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/built_ins/sip.h"
#include "unit_tests/global_environment.h"
#include "unit_tests/helpers/test_files.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_device_factory.h"
#include "unit_tests/mocks/mock_program.h"
using namespace OCLRT;
namespace SipKernelTests {
std::string getDebugSipKernelNameWithBitnessAndProductSuffix(std::string &base, const char *product) {
std::string fullName = base + std::string("_");
if (sizeof(uintptr_t) == 8) {
fullName.append("64_");
} else {
fullName.append("32_");
}
fullName.append(product);
return fullName;
}
TEST(Sip, WhenSipKernelIsInvalidThenEmptyCompilerInternalOptionsAreReturned) {
const char *opt = getSipKernelCompilerInternalOptions(SipKernelType::COUNT);
ASSERT_NE(nullptr, opt);
@@ -93,6 +110,10 @@ TEST(Sip, getType) {
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
}
TEST(Sip, givenSipKernelClassWhenAskedForMaxDebugSurfaceSizeThenCorrectValueIsReturned) {
EXPECT_EQ(0x49c000u, SipKernel::maxDbgSurfaceSize);
}
TEST(DebugSip, WhenRequestingDbgCsrSipKernelThenProperCompilerInternalOptionsAreReturned) {
const char *opt = getSipKernelCompilerInternalOptions(SipKernelType::DbgCsr);
ASSERT_NE(nullptr, opt);
@@ -104,3 +125,27 @@ TEST(DebugSip, WhenRequestingDbgCsrWithLocalMemorySipKernelThenProperCompilerInt
ASSERT_NE(nullptr, opt);
EXPECT_STREQ("-cl-include-sip-kernel-local-debug -cl-include-sip-csr -cl-set-bti:0", opt);
}
TEST(DebugSip, givenDebugCsrSipKernelWhenAskedForDebugSurfaceBtiAndSizeThenBtiIsZeroAndSizeGreaterThanZero) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice);
MockCompilerDebugVars igcDebugVars;
auto product = mockDevice->getProductAbbrev();
std::string name = "sip_dummy_kernel_debug";
std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, product);
std::string builtInGenFile = builtInFileRoot;
builtInGenFile.append(".gen");
igcDebugVars.fileName = builtInGenFile;
gEnvironment->igcPushDebugVars(igcDebugVars);
auto &builtins = BuiltIns::getInstance();
auto &sipKernel = builtins.getSipKernel(SipKernelType::DbgCsr, *mockDevice);
EXPECT_EQ((int32_t)0, sipKernel.getDebugSurfaceBti());
EXPECT_EQ(SipKernel::maxDbgSurfaceSize, sipKernel.getDebugSurfaceSize());
gEnvironment->igcPopDebugVars();
}
} // namespace SipKernelTests

View File

@@ -28,6 +28,7 @@ set(IGDRCL_SRCS_tests_gen9
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sampler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sip_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_device_queue_hw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_platform_caps.cpp

View File

@@ -0,0 +1,61 @@
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "gtest/gtest.h"
#include "test.h"
#include "runtime/built_ins/built_ins.h"
#include "runtime/built_ins/sip.h"
#include "unit_tests/global_environment.h"
#include "unit_tests/helpers/test_files.h"
#include "unit_tests/mocks/mock_device.h"
using namespace OCLRT;
namespace SipKernelTests {
extern std::string getDebugSipKernelNameWithBitnessAndProductSuffix(std::string &base, const char *product);
typedef ::testing::Test gen9SipTests;
GEN9TEST_F(gen9SipTests, givenDebugCsrSipKernelWithLocalMemoryWhenAskedForDebugSurfaceBtiAndSizeThenBtiIsZeroAndSizeGreaterThanZero) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice);
MockCompilerDebugVars igcDebugVars;
auto product = mockDevice->getProductAbbrev();
std::string name = "sip_dummy_kernel_debug";
std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, product);
std::string builtInGenFile = builtInFileRoot;
builtInGenFile.append(".gen");
igcDebugVars.fileName = builtInGenFile;
gEnvironment->igcPushDebugVars(igcDebugVars);
auto &builtins = BuiltIns::getInstance();
auto &sipKernel = builtins.getSipKernel(SipKernelType::DbgCsrLocal, *mockDevice);
EXPECT_EQ((int32_t)0, sipKernel.getDebugSurfaceBti());
EXPECT_EQ(SipKernel::maxDbgSurfaceSize, sipKernel.getDebugSurfaceSize());
gEnvironment->igcPopDebugVars();
}
} // namespace SipKernelTests

View File

@@ -35,6 +35,8 @@ class GraphicsAllocation;
////////////////////////////////////////////////////////////////////////////////
class MockProgram : public Program {
public:
using Program::isKernelDebugEnabled;
MockProgram() : Program() {}
MockProgram(Context *context, bool isBuiltinKernel) : Program(context, isBuiltinKernel) {}
~MockProgram() {

View File

@@ -395,6 +395,10 @@ TEST(OfflineCompilerTest, getStringWithinDelimiters) {
auto dst = mockOfflineCompiler->getStringWithinDelimiters(src);
size_t size = dst.size();
char nullChar = '\0';
EXPECT_EQ(nullChar, dst[size - 1]);
// expect that pattern was not found
EXPECT_EQ(std::string::npos, dst.find("R\"===("));
EXPECT_EQ(std::string::npos, dst.find(")===\""));

View File

@@ -1233,3 +1233,22 @@ TEST_F(KernelDataTest, PATCH_TOKEN_STATE_SIP) {
EXPECT_EQ_VAL(token.SystemKernelOffset, pKernelInfo->systemKernelOffset);
}
TEST_F(KernelDataTest, PATCH_TOKEN_ALLOCATE_SIP_SURFACE) {
SPatchAllocateSystemThreadSurface token;
token.Token = PATCH_TOKEN_ALLOCATE_SIP_SURFACE;
token.Size = static_cast<uint32_t>(sizeof(SPatchAllocateSystemThreadSurface));
token.Offset = 32;
token.BTI = 0;
token.PerThreadSystemThreadSurfaceSize = 0x10000;
pPatchList = &token;
patchListSize = token.Size;
buildAndDecode();
EXPECT_EQ(0u, pKernelInfo->patchInfo.pAllocateSystemThreadSurface->BTI);
EXPECT_EQ(token.Offset, pKernelInfo->patchInfo.pAllocateSystemThreadSurface->Offset);
EXPECT_EQ(token.Token, pKernelInfo->patchInfo.pAllocateSystemThreadSurface->Token);
EXPECT_EQ(token.PerThreadSystemThreadSurfaceSize, pKernelInfo->patchInfo.pAllocateSystemThreadSurface->PerThreadSystemThreadSurfaceSize);
}

View File

@@ -21,6 +21,7 @@
*/
#include "runtime/kernel/kernel.h"
#include "runtime/command_stream/command_stream_receiver_hw.h"
#include "runtime/compiler_interface/compiler_options.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "runtime/indirect_heap/indirect_heap.h"
#include "runtime/helpers/aligned_memory.h"
@@ -33,6 +34,7 @@
#include "runtime/program/create.inl"
#include "program_tests.h"
#include "unit_tests/fixtures/program_fixture.inl"
#include "unit_tests/global_environment.h"
#include "unit_tests/helpers/kernel_binary_helper.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/program/program_from_binary.h"
@@ -2929,3 +2931,33 @@ TEST(SimpleProgramTests, givenDefaultProgramWhenSetDeviceIsCalledThenDeviceIsSet
pProgram.SetDevice(nullptr);
EXPECT_EQ(nullptr, pProgram.getDevicePtr());
}
TEST_F(ProgramTests, givenDeafultProgramObjectWhenKernelDebugEnabledIsQueriedThenFalseIsReturned) {
MockProgram program(pContext, false);
EXPECT_FALSE(program.isKernelDebugEnabled());
}
TEST_F(ProgramTests, givenProgramObjectWhenEnableKernelDebugIsCalledThenProgramHasKernelDebugEnabled) {
MockProgram program(pContext, false);
program.enableKernelDebug();
EXPECT_TRUE(program.isKernelDebugEnabled());
}
TEST_P(ProgramFromSourceTest, givenEnabledKernelDebugWhenProgramIsCompiledThenInternalOptionsIncludeDebugFlag) {
pProgram->enableKernelDebug();
cl_device_id device = pPlatform->getDevice(0);
std::string receivedInternalOptions;
auto debugVars = OCLRT::getFclDebugVars();
debugVars.receivedInternalOptionsOutput = &receivedInternalOptions;
gEnvironment->fclPushDebugVars(debugVars);
cl_int retVal = pProgram->compile(1, &device, nullptr,
0, nullptr, nullptr,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_THAT(receivedInternalOptions, ::testing::HasSubstr(CompilerOptions::debugKernelEnable));
gEnvironment->fclPopDebugVars();
}

View File

@@ -36,4 +36,5 @@ define void @f() {
!5 = !{!"kernel_arg_type_qual"}
!6 = !{!"kernel_arg_base_type"}
!7 = !{!"kernel_arg_name"}
)==="

View File

@@ -23,8 +23,8 @@
R"===(
target datalayout = "e-p:64:64:64"
target triple = "spir64"
define void @f() {
ret void
define void @f() {
ret void
}
!opencl.compiler.options = !{!0}
!opencl.kernels = !{!1}
@@ -36,4 +36,5 @@ define void @f() {
!5 = !{!"kernel_arg_type_qual"}
!6 = !{!"kernel_arg_base_type"}
!7 = !{!"kernel_arg_name"}
)==="