1/*******************************************************************************
2* Copyright 2022 Intel Corporation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*******************************************************************************/
16
17#ifndef GPU_JIT_UTILS_TRACE_HPP
18#define GPU_JIT_UTILS_TRACE_HPP
19
20#include "gpu/jit/ir/ir.hpp"
21#include "gpu/jit/utils/utils.hpp"
22
23namespace dnnl {
24namespace impl {
25namespace gpu {
26namespace jit {
27
28// Trace for debugging purposes.
29#ifdef GEN_CONV_PROFILE
30ir_utils::debug_profiler_t &get_trace_profiler();
31inline void trace_start() {
32 get_trace_profiler().start();
33}
34inline void trace_reset() {
35 get_trace_profiler().reset();
36}
37inline void trace_stamp(const char *pass_name) {
38 get_trace_profiler().stamp(pass_name);
39}
40inline void trace_stop(const char *pass_name) {
41 get_trace_profiler().stop(pass_name);
42}
43inline void trace_perf() {
44 ir_perf() << get_trace_profiler() << std::endl;
45}
46#else
47inline void trace_start() {};
48inline void trace_reset() {};
49inline void trace_stamp(const char *) {};
50inline void trace_stop(const char *) {};
51inline void trace_perf() {};
52#endif
53
54#if defined(GEN_CONV_PROFILE) || defined(GEN_CONV_DEBUG)
55void trace_pass(
56 const char *pass_name, const stmt_t &stmt, ir_context_t &ir_ctx);
57#else
58inline void trace_pass(
59 const char *pass_name, const stmt_t &stmt, ir_context_t &ir_ctx) {};
60#endif
61
62} // namespace jit
63} // namespace gpu
64} // namespace impl
65} // namespace dnnl
66
67#endif
68