GCC Code Coverage Report


Directory: ./
File: tasks/zhurin_i_gaus_kernel/tbb/src/ops_tbb.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 45 45 100.0%
Functions: 6 6 100.0%
Branches: 18 24 75.0%

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