Skip to content

Commit 38791c6

Browse files
authored
[Snippets][CPU] Enable verbose perf count insertion pass conditionally (openvinotoolkit#28846)
### Details: Disable verbose performance count logging only when `OV_SNIPPETS_DUMP_BRGEMM_PARAMS` environment variable is set ### Tickets: - N/A
1 parent 58ee4f2 commit 38791c6

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

src/common/snippets/include/snippets/lowered/linear_ir.hpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Config {
4040
// False if LIR can be built from ov::Model only. Prevents adding I/O expressions
4141
bool m_manual_build_support = false;
4242
#ifdef SNIPPETS_DEBUG_CAPS
43-
DebugCapsConfig debug_config;
43+
std::shared_ptr<DebugCapsConfig> debug_config = std::make_shared<DebugCapsConfig>();
4444
#endif
4545
};
4646

@@ -69,7 +69,12 @@ class LinearIR {
6969
const std::vector<ExpressionPtr>& get_parameters() const { return m_parameter_expressions; }
7070
const std::vector<ExpressionPtr>& get_results() const { return m_result_expressions; }
7171
const std::vector<BufferExpressionPtr>& get_buffers() const { return m_buffer_expressions; }
72-
const Config& get_config() const { return m_config; }
72+
const Config& get_config() const {
73+
#ifdef SNIPPETS_DEBUG_CAPS
74+
OPENVINO_ASSERT(m_config.debug_config, "Debug config is not initialized");
75+
#endif // SNIPPETS_DEBUG_CAPS
76+
return m_config;
77+
}
7378
size_t get_static_buffer_scratchpad_size() const { return m_static_buffer_scratchpad_size; }
7479

7580
void set_loop_depth(size_t loop_depth) { m_config.m_loop_depth = loop_depth; }

src/common/snippets/include/snippets/op/subgraph.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class Subgraph : public ov::op::util::SubGraphOp {
101101

102102
size_t get_virtual_port_count() const { return m_virtual_port_count; }
103103
bool is_quantized() const { return config.m_is_quantized; }
104+
#ifdef SNIPPETS_DEBUG_CAPS
105+
DebugCapsConfig& get_debug_config() {
106+
OPENVINO_ASSERT(config.m_debug_config, "Debug config is not initialized");
107+
return *config.m_debug_config;
108+
}
109+
#endif // SNIPPETS_DEBUG_CAPS
104110
bool has_domain_sensitive_ops() const { return config.m_has_domain_sensitive_ops; }
105111

106112
// plugin sets generator for a snippet to some specific generator.
@@ -187,6 +193,9 @@ class Subgraph : public ov::op::util::SubGraphOp {
187193
// True if Subgraph contains ops that are not applicable to auto broadcast rule.
188194
// (e.g. GroupNormalization, reshape)
189195
bool m_has_broadcast_sensitive_ops = false;
196+
#ifdef SNIPPETS_DEBUG_CAPS
197+
std::shared_ptr<DebugCapsConfig> m_debug_config = std::make_shared<DebugCapsConfig>();
198+
#endif
190199
} config;
191200

192201
std::shared_ptr<ShapeInferSnippetsNode> m_shape_infer = nullptr;

src/common/snippets/include/snippets/utils/linear_ir_pass_dumper.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace snippets {
1717
class LIRPassDump {
1818
public:
1919
explicit LIRPassDump(const lowered::LinearIR& linear_ir, std::string pass_name)
20-
: linear_ir(linear_ir), pass_name(std::move(pass_name)), debug_config(linear_ir.get_config().debug_config) {
20+
: linear_ir(linear_ir), pass_name(std::move(pass_name)), debug_config(*linear_ir.get_config().debug_config) {
2121
dump("_in");
2222
}
2323
~LIRPassDump() {
@@ -53,7 +53,7 @@ class LIRPassDump {
5353
} // namespace ov
5454

5555
#define SNIPPETS_DEBUG_LIR_PASS_DUMP(_linear_ir, _pass) \
56-
auto dumpLIR = _linear_ir.get_config().debug_config.dumpLIR; \
56+
auto dumpLIR = _linear_ir.get_config().debug_config->dumpLIR; \
5757
auto pass_name = std::string(_pass->get_type_name()); \
5858
auto dump_name = dumpLIR.passes; \
5959
auto dumperPtr = ((std::find(dump_name.begin(), dump_name.end(), ov::util::to_lower(pass_name)) != dump_name.end()) || \

src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ bool InsertPerfCountVerbose::run(snippets::lowered::LinearIR& linear_ir,
2626

2727
static size_t seq_number = 0;
2828
bool modified = false;
29-
auto csv_path = linear_ir.get_config().debug_config.dumpParams.csv_path;
29+
auto csv_path = linear_ir.get_config().debug_config->dumpParams.csv_path;
3030

3131
std::vector<std::shared_ptr<snippets::utils::Dumper>> dumpers;
3232
dumpers.push_back(std::make_shared<snippets::utils::ConsoleDumper>());
3333
// Add CSV dumper if path is provided
34-
if (!linear_ir.get_config().debug_config.dumpParams.csv_path.empty()) {
34+
if (!linear_ir.get_config().debug_config->dumpParams.csv_path.empty()) {
3535
dumpers.push_back(std::make_shared<snippets::utils::CSVDumper>(csv_path));
3636
}
3737

src/common/snippets/src/op/subgraph.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ Subgraph::convert_body_to_linear_ir(size_t min_parallel_work_amount, size_t min_
363363
lowering_config.m_enable_domain_optimization = !config.m_has_domain_sensitive_ops;
364364
lowering_config.m_min_parallel_work_amount = min_parallel_work_amount;
365365
lowering_config.m_min_kernel_work_amount = min_kernel_work_amount;
366+
#ifdef SNIPPETS_DEBUG_CAPS
367+
lowering_config.debug_config = config.m_debug_config;
368+
OPENVINO_ASSERT(lowering_config.debug_config, "Debug config is not initialized");
369+
#endif // SNIPPETS_DEBUG_CAPS
366370

367371
m_linear_ir = std::make_shared<lowered::LinearIR>(body_ptr(), shape_infer_factory, lowering_config);
368372
m_shape_infer = m_linear_ir->get_shape_infer_instance();
@@ -481,7 +485,7 @@ void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, siz
481485
validation_pipeline.run(*m_linear_ir);
482486

483487
#ifdef SNIPPETS_DEBUG_CAPS
484-
if (m_linear_ir->get_config().debug_config.perf_count_mode != DebugCapsConfig::PerfCountMode::Disabled) {
488+
if (m_linear_ir->get_config().debug_config->perf_count_mode != DebugCapsConfig::PerfCountMode::Disabled) {
485489
lowered::pass::InsertPerfCount perf_count_pass({});
486490
perf_count_pass.run(*m_linear_ir, m_linear_ir->cbegin(), m_linear_ir->cend());
487491
}

src/plugins/intel_cpu/src/nodes/subgraph.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,13 @@ Subgraph::ControlFlowPasses Subgraph::getControlFlowPasses() const {
543543
ov::intel_cpu::pass::BrgemmCPUBlocking);
544544

545545
#ifdef SNIPPETS_DEBUG_CAPS
546-
SNIPPETS_REGISTER_PASS_RELATIVE(Place::After,
547-
ov::intel_cpu::pass::BrgemmCPUBlocking,
548-
ov::snippets::lowered::pass::InsertPerfCountVerbose,
549-
getName());
546+
const auto& debug_config = subgraph_attrs->snippet->get_debug_config();
547+
if (debug_config.perf_count_mode != snippets::DebugCapsConfig::PerfCountMode::Disabled) {
548+
SNIPPETS_REGISTER_PASS_RELATIVE(Place::After,
549+
ov::intel_cpu::pass::BrgemmCPUBlocking,
550+
ov::snippets::lowered::pass::InsertPerfCountVerbose,
551+
getName());
552+
}
550553
#endif // SNIPPETS_DEBUG_CAPS
551554

552555
SNIPPETS_REGISTER_PASS_RELATIVE(Place::After,

0 commit comments

Comments
 (0)