Skip to content

Commit cac7865

Browse files
committed
xe: jit: enable nGEN debug information
1 parent 2cc1df0 commit cac7865

13 files changed

+72
-31
lines changed

src/gpu/intel/jit/binary_format.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2019-2024 Intel Corporation
2+
* Copyright 2019-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,7 +52,8 @@ class binary_format_kernel_t : public jit_generator<hw> {
5252
NGEN_FORWARD_OPENCL(hw);
5353

5454
public:
55-
binary_format_kernel_t() {
55+
binary_format_kernel_t()
56+
: jit_generator<hw>({GENERATOR_NAME, GENERATOR_LINE}) {
5657

5758
auto low_half = [](uint64_t q) -> uint32_t { return q & 0xFFFFFFFF; };
5859
auto high_half = [](uint64_t q) -> uint32_t { return q >> 32; };

src/gpu/intel/jit/codegen/kernel.hpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2022-2024 Intel Corporation
2+
* Copyright 2022-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -187,9 +187,11 @@ class ir_kernel_t : public jit_generator<hw> {
187187
friend class ir_to_ngen_t<hw>;
188188
friend class send_impl_t;
189189

190-
ir_kernel_t(
191-
const kernel_desc_base_t &desc, const kernel_info_t &kernel_info)
192-
: kernel_name_(desc.kernel_name())
190+
ir_kernel_t(const kernel_desc_base_t &desc,
191+
const kernel_info_t &kernel_info,
192+
const debug_config_t &debug_config)
193+
: jit_generator<hw>(debug_config)
194+
, kernel_name_(desc.kernel_name())
193195
, exec_cfg_(desc.exec_cfg())
194196
, kernel_info_(kernel_info)
195197
, local_range_(desc.local_range())
@@ -203,8 +205,10 @@ class ir_kernel_t : public jit_generator<hw> {
203205

204206
ir_kernel_t(const std::string &kernel_name, const exec_config_t &exec_cfg,
205207
const kernel_info_t &kernel_info,
206-
const compute::range_t &local_range, bool require_dpas)
207-
: kernel_name_(kernel_name)
208+
const compute::range_t &local_range, bool require_dpas,
209+
const debug_config_t &debug_config)
210+
: jit_generator<hw>(debug_config)
211+
, kernel_name_(kernel_name)
208212
, exec_cfg_(exec_cfg)
209213
, kernel_info_(kernel_info)
210214
, local_range_(local_range)

src/gpu/intel/jit/conv/conv_kernel.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2021-2024 Intel Corporation
2+
* Copyright 2021-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,7 +56,8 @@ conv_kernel_t<hw>::conv_kernel_t(const conv_config_t &cfg,
5656
const kernel_info_t &kernel_info, const compute::range_t &local_range,
5757
const layout_t &zp_dst)
5858
: ir_kernel_t<hw>("gen_conv", cfg.exec_cfg(), kernel_info, local_range,
59-
utils::one_of(cfg.fma_kind(), fma_kind_t::dpas, fma_kind_t::dpasw))
59+
utils::one_of(cfg.fma_kind(), fma_kind_t::dpas, fma_kind_t::dpasw),
60+
{GENERATOR_NAME, GENERATOR_LINE})
6061
, prb_(cfg.prb())
6162
, cfg_(cfg) {
6263

src/gpu/intel/jit/conv/zero_out.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2022-2024 Intel Corporation
2+
* Copyright 2022-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,8 @@ class zero_out_kernel_t : public ir_kernel_t<hw> {
3636
zero_out_kernel_t(const exec_config_t &exec_cfg,
3737
const kernel_info_t &kernel_info, bool require_dpas)
3838
: ir_kernel_t<hw>("zero_out", exec_cfg, kernel_info,
39-
kernel_info.nd_range().local_range(), require_dpas) {
39+
kernel_info.nd_range().local_range(), require_dpas,
40+
{GENERATOR_NAME, GENERATOR_LINE}) {
4041

4142
setup_interface();
4243
generate_prologue();

src/gpu/intel/jit/emulated_generator.hpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2024 Intel Corporation
2+
* Copyright 2024-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,9 +40,11 @@ class emulated_generator_t : public jit_generator<hw> {
4040
NGEN_FORWARD_OPENCL(hw);
4141

4242
public:
43-
emulated_generator_t(
44-
const compute::device_info_t &device_info, const std::string &name)
45-
: ra_(hw, name), emu_strategy(hw, device_info.stepping_id()) {}
43+
emulated_generator_t(const compute::device_info_t &device_info,
44+
const std::string &name, const debug_config_t &debug_config)
45+
: jit_generator<hw>(debug_config)
46+
, ra_(hw, name)
47+
, emu_strategy(hw, device_info.stepping_id()) {}
4648

4749
protected:
4850
reg_allocator_t ra_;

src/gpu/intel/jit/gemm/include/generator.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2019-2024 Intel Corporation
2+
* Copyright 2019-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ class BLASKernelGenerator : public GENERATOR_BASE(hw) {
6565
public:
6666
using super = GENERATOR_SUPER(hw);
6767

68-
BLASKernelGenerator() {}
68+
BLASKernelGenerator(): GENERATOR_BASE(hw)({GENERATOR_NAME, GENERATOR_LINE}) {}
6969

7070
FORWARD(hw)
7171

src/gpu/intel/jit/gen9_simple_sum_kernel_f32.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2019-2024 Intel Corporation
2+
* Copyright 2019-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,8 @@ namespace jit {
2929

3030
class gen9_simple_sum_kernel_f32_t : public jit_generator<gpu_gen9> {
3131
public:
32-
gen9_simple_sum_kernel_f32_t() : jit_generator<gpu_gen9>() {
32+
gen9_simple_sum_kernel_f32_t()
33+
: jit_generator<gpu_gen9>({GENERATOR_NAME, GENERATOR_LINE}) {
3334
using namespace ngen;
3435
constexpr auto GlobalPtr = ExternalArgumentType::GlobalPtr;
3536
constexpr auto Scalar = ExternalArgumentType::Scalar;

src/gpu/intel/jit/jit_generator.hpp

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2019-2024 Intel Corporation
2+
* Copyright 2019-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -111,6 +111,19 @@ struct jit_reduction_injector_f32;
111111
template <gpu_gen_t hw>
112112
struct jit_post_op_injector;
113113

114+
#if (!defined(NDEBUG) || defined(DNNL_DEV_MODE))
115+
#define GENERATOR_NAME __FILE__
116+
#define GENERATOR_LINE __LINE__
117+
#else
118+
#define GENERATOR_NAME "oneDNN"
119+
#define GENERATOR_LINE 0
120+
#endif
121+
122+
struct debug_config_t {
123+
const char *name;
124+
uint32_t line;
125+
};
126+
114127
template <gpu_gen_t hw>
115128
class jit_generator : public ngen::OpenCLCodeGenerator<hw>,
116129
public jit_generator_base {
@@ -130,9 +143,15 @@ class jit_generator : public ngen::OpenCLCodeGenerator<hw>,
130143
};
131144
std::unique_ptr<void, svm_deleter> dbg_memory_;
132145
#endif
133-
146+
#ifdef DNNL_DEV_MODE
147+
static constexpr bool enable_debug_lines = true;
148+
#else
149+
static constexpr bool enable_debug_lines = false;
150+
#endif
134151
public:
135-
jit_generator() = default;
152+
jit_generator(const debug_config_t &debug_config)
153+
: ngen::OpenCLCodeGenerator<hw>(0,
154+
{debug_config.name, debug_config.line, enable_debug_lines}) {};
136155

137156
const char *kernel_name() const override {
138157
return ngen::OpenCLCodeGenerator<hw>::getExternalName().c_str();

src/gpu/intel/jit/jit_reduction_generator.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2024 Intel Corporation
2+
* Copyright 2024-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,8 @@ class jit_reduction_generator_t : public emulated_generator_t<hw> {
4343
public:
4444
jit_reduction_generator_t(const compute::device_info_t &device_info,
4545
alg_kind_t alg, dim_t stride, dim_t iters, int nregs)
46-
: emulated_generator_t<hw>(device_info, "ngen_jit_reduction") {
46+
: emulated_generator_t<hw>(device_info, "ngen_jit_reduction",
47+
{GENERATOR_NAME, GENERATOR_LINE}) {
4748
constexpr auto GlobalPtr = ngen::ExternalArgumentType::GlobalPtr;
4849

4950
// Number of dst elements computed per thread

src/gpu/intel/jit/ngen/ngen_config.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,13 @@ using half = dnnl::impl::float16_t;
3131
#define NGEN_BFLOAT16_TYPE
3232
#define NGEN_HALF_TYPE
3333

34+
#if (!defined(NDEBUG) || defined(DNNL_DEV_MODE)) && (__cplusplus >= 202002L || _MSVC_LANG >= 202002L)
35+
#if __has_include(<version>)
36+
#include <version>
37+
#if __cpp_lib_source_location >= 201907L
38+
#define NGEN_ENABLE_SOURCE_LOCATION true
39+
#endif
40+
#endif
41+
#endif
42+
3443
#endif /* header guard */

src/gpu/intel/jit/pooling/pooling_kernel.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2023-2024 Intel Corporation
2+
* Copyright 2023-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,7 +41,8 @@ class pooling_kernel_t : public ir_kernel_t<hw> {
4141
pooling_kernel_t(pooling_config_t &cfg, const std::string &kernel_name,
4242
const kernel_info_t &kernel_info, const primitive_desc_t &pd)
4343
: ir_kernel_t<hw>(kernel_name, cfg.exec_cfg(), kernel_info,
44-
kernel_info.nd_range().local_range(), /*require_dpas=*/false) {
44+
kernel_info.nd_range().local_range(), /*require_dpas=*/false,
45+
{GENERATOR_NAME, GENERATOR_LINE}) {
4546
pooling_ir_builder_t builder(cfg, kernel_info, pd);
4647
stmt_t body = builder.stmt();
4748
setup_interface(body);

src/gpu/intel/jit/reorder/reorder_kernel.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2022-2024 Intel Corporation
2+
* Copyright 2022-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,8 @@ class reorder_kernel_t : public ir_kernel_t<hw> {
4343
const std::string &kernel_name, const kernel_info_t &kernel_info,
4444
bool require_dpas, const primitive_desc_t *pd = nullptr)
4545
: ir_kernel_t<hw>(kernel_name, cfg.exec_cfg(), kernel_info,
46-
kernel_info.nd_range().local_range(), require_dpas) {
46+
kernel_info.nd_range().local_range(), require_dpas,
47+
{GENERATOR_NAME, GENERATOR_LINE}) {
4748
const primitive_attr_t *attr = (pd) ? pd->attr() : nullptr;
4849
const memory_desc_t *dst_md = (pd) ? pd->dst_md() : nullptr;
4950
reorder_ir_builder_t builder(cfg, kernel_info, attr, dst_md);

src/gpu/intel/jit/v2/conv/kernel.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2023-2024 Intel Corporation
2+
* Copyright 2023-2025 Intel Corporation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ class kernel_t : public ir_kernel_t<hw> {
4545
template <ngen::HW hw>
4646
kernel_t<hw>::kernel_t(
4747
const kernel_desc_base_t &_desc, const kernel_info_t &kernel_info)
48-
: ir_kernel_t<hw>(_desc, kernel_info) {
48+
: ir_kernel_t<hw>(_desc, kernel_info, {GENERATOR_NAME, GENERATOR_LINE}) {
4949

5050
auto &desc = static_cast<const kernel_desc_t &>(_desc);
5151

0 commit comments

Comments
 (0)