GCC Code Coverage Report


Directory: ./
File: tasks/zhurin_i_gaus_kernel/stl/src/ops_stl.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 49 49 100.0%
Functions: 6 6 100.0%
Branches: 23 32 71.9%

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