Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snippets][CPU] Enable verbose perf count insertion pass conditionally #28846

Merged

Conversation

aobolensk
Copy link
Contributor

@aobolensk aobolensk commented Feb 6, 2025

Details:

Disable verbose performance count logging only when OV_SNIPPETS_DUMP_BRGEMM_PARAMS environment variable is set

Tickets:

  • N/A

@aobolensk aobolensk requested a review from a-sidorova February 6, 2025 06:54
@aobolensk aobolensk requested review from a team as code owners February 6, 2025 06:54
@github-actions github-actions bot added the category: CPU OpenVINO CPU plugin label Feb 6, 2025
@aobolensk aobolensk force-pushed the perf-count-verbose-insertion branch from 1d5fba7 to 302fa8e Compare February 6, 2025 09:51
@aobolensk aobolensk changed the title [Snippets][CPU] Enable verbose perf count insertion pass when PerfCountMode is set [Snippets][CPU] Enable verbose perf count insertion pass conditionally Feb 6, 2025
@@ -187,6 +190,9 @@ class Subgraph : public ov::op::util::SubGraphOp {
// True if Subgraph contains ops that are not applicable to auto broadcast rule.
// (e.g. GroupNormalization, reshape)
bool m_has_broadcast_sensitive_ops = false;
#ifdef SNIPPETS_DEBUG_CAPS
DebugCapsConfig m_debug_config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we store DebugCapsConfig by value in two places (op::Subgraph & LIR), there always be a problem of consistency of these two states. For example, what if I call Subgraph::get_debug_config() after LIR is created? Can we rely on this value? What if it was already changed in the LIR config?

The easiest way to address this issue is to store DebugCapsConfig by pointer in both of the configs. This way we will always automatically maintain consistency. Do you think we can do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -40,7 +40,7 @@ class Config {
// False if LIR can be built from ov::Model only. Prevents adding I/O expressions
bool m_manual_build_support = false;
#ifdef SNIPPETS_DEBUG_CAPS
DebugCapsConfig debug_config;
std::shared_ptr<DebugCapsConfig> debug_config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you didn't initialize this pointer - because it should be copied from Subgraph::config.
However, we often dereference the result of "linear_ir->get_config().debug_config" without any additional checks here or here for example. So if a LIR was constructed directly (e.g. in unit tests), we can easily get a segfault.

So we probably need to add an openvino assert to LinearIR::get_config to make sure that debug_config was initialized properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another, a bit dirtier solution is to default-initialize it here as well. I wouldn't recommend it though, because of the consistency problem we discussed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added assert to LinearIR::get_config

@@ -40,7 +40,7 @@ class Config {
// False if LIR can be built from ov::Model only. Prevents adding I/O expressions
bool m_manual_build_support = false;
#ifdef SNIPPETS_DEBUG_CAPS
DebugCapsConfig debug_config;
std::shared_ptr<DebugCapsConfig> debug_config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another, a bit dirtier solution is to default-initialize it here as well. I wouldn't recommend it though, because of the consistency problem we discussed.

@aobolensk aobolensk requested review from a team as code owners February 10, 2025 07:52
@github-actions github-actions bot added the category: GPU OpenVINO GPU plugin label Feb 10, 2025
@aobolensk aobolensk force-pushed the perf-count-verbose-insertion branch from 8a31d8d to 7316acb Compare February 10, 2025 07:56
@github-actions github-actions bot removed the category: GPU OpenVINO GPU plugin label Feb 10, 2025
@aobolensk aobolensk removed request for a team February 10, 2025 09:47
@@ -101,6 +101,9 @@ class Subgraph : public ov::op::util::SubGraphOp {

size_t get_virtual_port_count() const { return m_virtual_port_count; }
bool is_quantized() const { return config.m_is_quantized; }
#ifdef SNIPPETS_DEBUG_CAPS
DebugCapsConfig& get_debug_config() { return *config.m_debug_config; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor:
Can we add assert to check that ptr is not null? I see that the m_debug_config is defined in public section as non-const and can be nullified/changed in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@IvanNovoselov IvanNovoselov added this pull request to the merge queue Feb 10, 2025
Merged via the queue into openvinotoolkit:master with commit 38791c6 Feb 10, 2025
186 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CPU OpenVINO CPU plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants