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] Add debug caps for dumping snippets parameters #28378

Merged
merged 11 commits into from
Feb 4, 2025

Conversation

aobolensk
Copy link
Contributor

Details:

  • Add infrastructure to dump snippets parameters using OV_SNIPPETS_DUMP_PARAMS environment variable
  • Enable caps for brgemm snippet

Tickets:

  • 137302

@aobolensk aobolensk requested a review from v-Golubev January 10, 2025 15:06
@aobolensk aobolensk requested a review from a team as a code owner January 10, 2025 15:06
@github-actions github-actions bot added the category: CPU OpenVINO CPU plugin label Jan 10, 2025
@aobolensk aobolensk requested a review from a team as a code owner January 10, 2025 15:50
@aobolensk aobolensk requested review from tsavina and removed request for a team January 10, 2025 15:50
@github-actions github-actions bot added the category: docs OpenVINO documentation label Jan 10, 2025
@aobolensk aobolensk requested a review from a team as a code owner January 14, 2025 13:51
@aobolensk aobolensk force-pushed the brgemm-debug-caps branch 2 times, most recently from 4229be8 to 1fe9e26 Compare January 14, 2025 18:13
@aobolensk aobolensk requested a review from v-Golubev January 15, 2025 08:25
Copy link
Contributor

@v-Golubev v-Golubev left a comment

Choose a reason for hiding this comment

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

It can be also useful to dump Subgraph's name as well. Let's discuss possible options offline

@aobolensk
Copy link
Contributor Author

It can be also useful to dump Subgraph's name as well. Let's discuss possible options offline

Done

Copy link
Contributor

@v-Golubev v-Golubev left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@aobolensk aobolensk force-pushed the brgemm-debug-caps branch 3 times, most recently from a75589b to cb4be59 Compare January 17, 2025 11:04
@aobolensk aobolensk removed request for a team, akuporos and AlexKoff88 January 28, 2025 16:39
: PerfCountEndBase({pc_begin}),
accumulation(0ul),
iteration(0u),
dumpers(dumpers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid redundant copy, since you are passing by value

Suggested change
dumpers(dumpers) {
dumpers(std::move(dumpers)) {

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

class Dumper {
public:
Dumper() = default;
Dumper(const Dumper&) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting 🤔
Why do we delete default copy constructors here and in the derived classes?
We don't manage any resources using pointers, so the default-generated would work as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Debug leftovers, removed

Comment on lines 29 to 48
auto accumulation = node->get_accumulation();
auto iteration = node->get_iteration();
OPENVINO_ASSERT(accumulation.size() == iteration.size(), "accumulation size should be the same as iteration size in perf_count_end node.");
auto iterator_iter = iteration.begin();
auto iterator_acc = accumulation.begin();
int t_num = 0;
uint64_t avg_max = 0;
std::cout << "Perf count data in perfCountEnd node with name " << node->get_friendly_name() << " is:" << std::endl;
for (; iterator_iter != iteration.end(); ++iterator_iter, ++iterator_acc) {
const auto iter = *iterator_iter;
const auto acc = *iterator_acc;
uint64_t avg = iter == 0 ? 0 : acc / iter;
if (avg > avg_max)
avg_max = avg;
std::cout << "accumulated time:" << acc << "ns, iteration:" << iter << " avg time:" << avg << "ns" << " on thread:" << t_num << std::endl;
t_num++;
}

// max time of all threads: combine for reduce max
auto BinaryFunc = [](const uint64_t& a, const uint64_t& b) {
return a >= b ? a : b;
};

// max accumulation
uint64_t acc_max = accumulation.combine(BinaryFunc);
std::cout << "max accumulated time:" << acc_max << "ns" << std::endl;
// max avg
std::cout << "max avg time:" << avg_max << "ns" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you decided to retain the old behavior, where the output is printed on every iteration instead of printing it once in the destructor. Is there any particular reason why?
As we discussed on the meeting, this approach have higher runtime overheads that might be important when we have nested perf counters. Moreover now we have two dumpers with mismatching behavior, which might be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason, actually. Moved to destructor, aligned behavior

@aobolensk aobolensk force-pushed the brgemm-debug-caps branch 2 times, most recently from 355a01c to e2cfa14 Compare January 30, 2025 13:04
CSVDumper::CSVDumper(const std::string& csv_path) : csv_path(csv_path) {}

CSVDumper::~CSVDumper() {
dump_brgemm_params_to_csv();
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the dump_brgemm_params_to_csv method is redundant, please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, removed

class ConsoleDumper : public Dumper {
public:
ConsoleDumper() = default;
ConsoleDumper(const ConsoleDumper&) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and in CSVDumper: why do you keep deleting copy constructors? 🙃
There must be a reason for it, could you share?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I stopped removing constructors now

*/
class CSVDumper : public Dumper {
public:
CSVDumper(const std::string &csv_path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please pass by value and use std::move to avoid extra copy, like in this comment

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 4, 2025
Merged via the queue into openvinotoolkit:master with commit c27f796 Feb 4, 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 category: docs OpenVINO documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants