GCC Code Coverage Report


Directory: ./
File: tasks/chaschin_vladimir_linear_image_filtration_seq/omp/src/ops_omp.cpp
Date: 2026-05-11 08:26:31
Exec Total Coverage
Lines: 30 30 100.0%
Functions: 7 7 100.0%
Branches: 10 12 83.3%

Line Branch Exec Source
1 #include "chaschin_vladimir_linear_image_filtration_seq/omp/include/ops_omp.hpp"
2
3 #include <omp.h>
4
5 #include <utility>
6 #include <vector>
7
8 #include "chaschin_vladimir_linear_image_filtration_seq/common/include/common.hpp"
9 namespace chaschin_v_linear_image_filtration_omp {
10
11
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 ChaschinVLinearFiltrationOMP::ChaschinVLinearFiltrationOMP(const chaschin_v_linear_image_filtration_seq::InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13 auto in_copy = in;
14 GetInput() = std::move(in_copy);
15 this->GetOutput().clear();
16 20 }
17
18 20 bool ChaschinVLinearFiltrationOMP::ValidationImpl() {
19 const auto &in = GetInput();
20 const auto &image = std::get<0>(in);
21 20 return !image.empty();
22 }
23
24 20 bool ChaschinVLinearFiltrationOMP::PreProcessingImpl() {
25 20 return true;
26 }
27
28 21824 inline float HorizontalFilterAtOMP(const std::vector<float> &img, int n, int x, int y) {
29 21824 const int idx = (y * n) + x;
30
31
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 21328 times.
21824 if (x == 0) {
32 496 return ((2.F * img[idx]) + img[idx + 1]) / 3.F;
33 }
34
35
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 20832 times.
21328 if (x == n - 1) {
36 496 return (img[idx - 1] + (2.F * img[idx])) / 3.F;
37 }
38
39 20832 return (img[idx - 1] + (2.F * img[idx]) + img[idx + 1]) / 4.F;
40 }
41
42 21824 inline float VerticalFilterAtOMP(const std::vector<float> &temp, int n, int m, int x, int y) {
43 21824 const int idx = (y * n) + x;
44
45
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 21328 times.
21824 if (y == 0) {
46 496 return ((2.F * temp[idx]) + temp[idx + n]) / 3.F;
47 }
48
49
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 20832 times.
21328 if (y == m - 1) {
50 496 return (temp[idx - n] + (2.F * temp[idx])) / 3.F;
51 }
52
53 20832 return (temp[idx - n] + (2.F * temp[idx]) + temp[idx + n]) / 4.F;
54 }
55
56 20 bool ChaschinVLinearFiltrationOMP::RunImpl() {
57 const auto &in = GetInput();
58 const auto &image = std::get<0>(in);
59 20 int n = std::get<1>(in);
60 20 int m = std::get<2>(in);
61
62 auto &out = GetOutput();
63 20 out.resize(static_cast<std::vector<float>::size_type>(n) * static_cast<std::vector<float>::size_type>(m));
64
65 std::vector<float> temp(static_cast<std::vector<float>::size_type>(n) *
66 20 static_cast<std::vector<float>::size_type>(m));
67
68 // ---------- горизонтальная фильтрация ----------
69 20 #pragma omp parallel for default(none) shared(n, m, image, temp)
70 for (int yi = 0; yi < m; ++yi) {
71 for (int xf = 0; xf < n; ++xf) {
72 temp[(yi * n) + xf] = HorizontalFilterAtOMP(image, n, xf, yi);
73 }
74 }
75
76 // ---------- вертикальная фильтрация ----------
77
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 #pragma omp parallel for default(none) shared(n, m, temp, out)
78 for (int yi = 0; yi < m; ++yi) {
79 for (int xy = 0; xy < n; ++xy) {
80 out[(yi * n) + xy] = VerticalFilterAtOMP(temp, n, m, xy, yi);
81 }
82 }
83
84 20 return true;
85 }
86
87 20 bool ChaschinVLinearFiltrationOMP::PostProcessingImpl() {
88 20 return true;
89 }
90
91 } // namespace chaschin_v_linear_image_filtration_omp
92