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 | |
23 | namespace dnnl { |
24 | namespace impl { |
25 | namespace gpu { |
26 | namespace jit { |
27 | |
28 | // Trace for debugging purposes. |
29 | #ifdef GEN_CONV_PROFILE |
30 | ir_utils::debug_profiler_t &get_trace_profiler(); |
31 | inline void trace_start() { |
32 | get_trace_profiler().start(); |
33 | } |
34 | inline void trace_reset() { |
35 | get_trace_profiler().reset(); |
36 | } |
37 | inline void trace_stamp(const char *pass_name) { |
38 | get_trace_profiler().stamp(pass_name); |
39 | } |
40 | inline void trace_stop(const char *pass_name) { |
41 | get_trace_profiler().stop(pass_name); |
42 | } |
43 | inline void trace_perf() { |
44 | ir_perf() << get_trace_profiler() << std::endl; |
45 | } |
46 | #else |
47 | inline void trace_start() {}; |
48 | inline void trace_reset() {}; |
49 | inline void trace_stamp(const char *) {}; |
50 | inline void trace_stop(const char *) {}; |
51 | inline void trace_perf() {}; |
52 | #endif |
53 | |
54 | #if defined(GEN_CONV_PROFILE) || defined(GEN_CONV_DEBUG) |
55 | void trace_pass( |
56 | const char *pass_name, const stmt_t &stmt, ir_context_t &ir_ctx); |
57 | #else |
58 | inline 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 | |