GCC Code Coverage Report


Directory: ./
File: tasks/zhurin_i_gaus_kernel/omp/src/ops_omp.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 5 5 100.0%
Branches: 10 16 62.5%

Line Branch Exec Source
1 #include "zhurin_i_gaus_kernel/omp/include/ops_omp.hpp"
2
3 #include <algorithm>
4 #include <utility>
5 #include <vector>
6
7 #include "zhurin_i_gaus_kernel/common/include/common.hpp"
8
9 namespace zhurin_i_gaus_kernel {
10
11 24 bool ZhurinIGausKernelOMP::ValidationImpl() {
12 const auto &in = GetInput();
13 24 int w = std::get<0>(in);
14 24 int h = std::get<1>(in);
15 24 int parts = std::get<2>(in);
16 const auto &img = std::get<3>(in);
17
18
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if (w <= 0 || h <= 0 || parts <= 0 || parts > w) {
19 return false;
20 }
21 if (std::cmp_not_equal(img.size(), h)) {
22 return false;
23 }
24
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 24 times.
88 for (int i = 0; i < h; ++i) {
25
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if (std::cmp_not_equal(img[i].size(), w)) {
26 return false;
27 }
28 }
29 return true;
30 }
31
32 24 bool ZhurinIGausKernelOMP::PreProcessingImpl() {
33 const auto &in = GetInput();
34 24 width_ = std::get<0>(in);
35 24 height_ = std::get<1>(in);
36 24 num_parts_ = std::get<2>(in);
37
38
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 padded_.assign(height_ + 2, std::vector<int>(width_ + 2, 0));
39 const auto &img = std::get<3>(in);
40
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 24 times.
88 for (int i = 0; i < height_; ++i) {
41 64 std::copy(img[i].begin(), img[i].end(), padded_[i + 1].begin() + 1);
42 }
43
44
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 result_.assign(height_, std::vector<int>(width_, 0));
45 24 return true;
46 }
47
48
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 ZhurinIGausKernelOMP::ZhurinIGausKernelOMP(const InType &in) {
49 SetTypeOfTask(GetStaticTypeOfTask());
50 GetInput() = in;
51 24 GetOutput() = OutType{};
52 24 }
53
54 24 bool ZhurinIGausKernelOMP::RunImpl() {
55 24 int w = width_;
56 24 int h = height_;
57 24 int np = num_parts_;
58 24 int base_width = w / np;
59 24 int remainder = w % np;
60
61 24 auto &local_padded = padded_;
62 24 auto &local_result = result_;
63
64 24 #pragma omp parallel for schedule(static) default(none) \
65 shared(w, h, base_width, remainder, np, local_padded, local_result)
66 for (int part = 0; part < np; ++part) {
67 int part_width = base_width + (part < remainder ? 1 : 0);
68 int x_start = (part * base_width) + std::min(part, remainder);
69 int x_end = x_start + part_width;
70
71 for (int i = 1; i <= h; ++i) {
72 for (int j = x_start + 1; j <= x_end; ++j) {
73 int sum = (local_padded[i - 1][j - 1] * kKernel[0][0]) + (local_padded[i - 1][j] * kKernel[0][1]) +
74 (local_padded[i - 1][j + 1] * kKernel[0][2]) + (local_padded[i][j - 1] * kKernel[1][0]) +
75 (local_padded[i][j] * kKernel[1][1]) + (local_padded[i][j + 1] * kKernel[1][2]) +
76 (local_padded[i + 1][j - 1] * kKernel[2][0]) + (local_padded[i + 1][j] * kKernel[2][1]) +
77 (local_padded[i + 1][j + 1] * kKernel[2][2]);
78 local_result[i - 1][j - 1] = sum >> kShift;
79 }
80 }
81 }
82 24 return true;
83 }
84
85 24 bool ZhurinIGausKernelOMP::PostProcessingImpl() {
86 24 GetOutput() = result_;
87 24 return true;
88 }
89
90 } // namespace zhurin_i_gaus_kernel
91