Skip to content

parallel draw_pictures - #564

Open
S1mpotyaga wants to merge 1 commit into
mainfrom
parallel-write-metrics
Open

parallel draw_pictures#564
S1mpotyaga wants to merge 1 commit into
mainfrom
parallel-write-metrics

Conversation

@S1mpotyaga

Copy link
Copy Markdown
Collaborator

close #559

@S1mpotyaga
S1mpotyaga requested a review from PaulRalnikov May 23, 2026 18:16
@PaulRalnikov PaulRalnikov added the needs-load-testing Add this tag if you want to run load testing action on your PR label Jun 16, 2026
Comment on lines +8 to +23
#pragma omp parallel
{
#pragma omp single
{
for (const auto& [metric_id, storage] : *this) {
std::filesystem::path plot_path =
output_dir / fmt::format("{}.svg", metric_id.name);
#pragma omp task firstprivate(metric_id, storage, plot_path)
{
storage->draw_plot(
plot_path, PlotMetadata{"Time, ns", metric_id.unit_name,
metric_id.name});
}
}
#pragma omp taskwait
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Даже посрпшивав нейроку, я только крайне относительно понял, как и что здесь работает:) Схема жесть перегруженная, и я бы советовал уменьшить количество приседаний для достижения в общем-то простой цели (распараллелить форик по unordered map). Да, OpenMP не умеет из коробки вот так просто в одну прагму параллелить такое, но зато умеет это делать с обычными фориками, где мы идем счетчиком, а не итератором:

Suggested change
#pragma omp parallel
{
#pragma omp single
{
for (const auto& [metric_id, storage] : *this) {
std::filesystem::path plot_path =
output_dir / fmt::format("{}.svg", metric_id.name);
#pragma omp task firstprivate(metric_id, storage, plot_path)
{
storage->draw_plot(
plot_path, PlotMetadata{"Time, ns", metric_id.unit_name,
metric_id.name});
}
}
#pragma omp taskwait
}
std::vector<std::reference_wrapper<const value_type>> items;
items.reserve(size());
for (const auto& kv : *this) {
items.push_back(kv);
}
#pragma omp parallel for schedule(dynamic)
for (std::size_t i = 0; i < items.size(); ++i) {
const auto& [metric_id, storage] = items[i].get();
std::filesystem::path plot_path =
output_dir / fmt::format("{}.svg", metric_id.name);
storage->draw_plot(
plot_path,
PlotMetadata{"Time, ns", metric_id.unit_name, metric_id.name});
}

@@ -5,12 +5,22 @@
namespace sim {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ты не доделал задачу. Классно, что распараллелились картинки, но еще остаются тектовые метрики. С ними немного сложно и неочевидно, но разобраться реально. Есть еще два основных файла, где нужны правки:

void collect_and_save_all_metrics(const utils::IdTable<T>& id_table,

for (const auto& [link_id, link] :

Comment on lines +3 to +4
#include <omp.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Выглядит лишним

Suggested change
#include <omp.h>

Comment on lines +3 to +4
#include <omp.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Сейм

Suggested change
#include <omp.h>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-load-testing Add this tag if you want to run load testing action on your PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: parallel write metrics

2 participants