Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project(nons)

# main part of project

find_package(OpenMP REQUIRED)

option(BUILD_PROJECT "Build project" ON)
option(PROFILING "Add profiling flag" OFF)

Expand Down Expand Up @@ -32,7 +34,7 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/external/matplotplusplus/)
if (BUILD_PROJECT)
set(TARGET_NAME "${PROJECT_NAME}")
add_executable(${TARGET_NAME} ${src} source/main.cpp)
target_link_libraries(${TARGET_NAME} yaml-cpp matplot)
target_link_libraries(${TARGET_NAME} yaml-cpp matplot OpenMP::OpenMP_CXX)
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Werror -Wextra)

if (DEFINED LOG_LEVEL)
Expand All @@ -55,7 +57,7 @@ if(BUILD_TESTS)
target_compile_definitions(${TEST_NAME} PRIVATE PROJECT_ROOT_DIR="${CMAKE_SOURCE_DIR}")

target_compile_options(${TEST_NAME} PRIVATE -Wall -Werror -Wextra)
target_link_libraries(${TEST_NAME} gtest gmock gtest_main yaml-cpp matplot)
target_link_libraries(${TEST_NAME} gtest gmock gtest_main yaml-cpp matplot OpenMP::OpenMP_CXX)

if (DEFINED LOG_LEVEL)
target_compile_definitions(${TEST_NAME} PRIVATE LOG_LEVEL=${LOG_LEVEL})
Expand Down
22 changes: 16 additions & 6 deletions source/metrics/metrics_table/metrics_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
namespace sim {

void MetricsTable::draw_pictures(std::filesystem::path output_dir) const {
for (const auto& [metric_id, storage] : *this) {
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});
#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
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "connections_summary.hpp"

#include <omp.h>

#include "utils/filesystem.hpp"

namespace sim {
Expand Down
2 changes: 2 additions & 0 deletions source/network/network.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "network.hpp"

#include <omp.h>

#include "connection/connections_summary/connections_summary.hpp"
#include "metrics/metrics_table/combine_metrics_tables.hpp"

Expand Down
Loading