GCC Code Coverage Report


Directory: ./
File: tasks/boltenkov_s_gaussian_kernel/omp/src/ops_omp.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 28 28 100.0%
Functions: 5 5 100.0%
Branches: 22 46 47.8%

Line Branch Exec Source
1 #include "boltenkov_s_gaussian_kernel/omp/include/ops_omp.hpp"
2
3 #include <omp.h>
4
5 #include <algorithm>
6 #include <cstddef>
7 #include <vector>
8
9 #include "boltenkov_s_gaussian_kernel/common/include/common.hpp"
10 #include "util/include/util.hpp"
11
12 namespace boltenkov_s_gaussian_kernel {
13
14
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 BoltenkovSGaussianKernelOMP::BoltenkovSGaussianKernelOMP(const InType &in)
15
5/12
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32 : kernel_{{{1, 2, 1}, {2, 4, 2}, {1, 2, 1}}} {
16 SetTypeOfTask(GetStaticTypeOfTask());
17 GetInput() = in;
18 8 GetOutput() = std::vector<std::vector<int>>();
19
3/10
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
16 }
20
21 8 bool BoltenkovSGaussianKernelOMP::ValidationImpl() {
22 8 std::size_t n = std::get<0>(GetInput());
23
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 std::size_t m = std::get<1>(GetInput());
24
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (std::get<2>(GetInput()).size() != n) {
25 return false;
26 }
27
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 8 times.
228 for (std::size_t i = 0; i < n; i++) {
28
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 if (std::get<2>(GetInput())[i].size() != m) {
29 return false;
30 }
31 }
32 return true;
33 }
34
35 8 bool BoltenkovSGaussianKernelOMP::PreProcessingImpl() {
36 8 GetOutput().resize(std::get<0>(GetInput()));
37
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 8 times.
228 for (std::size_t i = 0; i < std::get<0>(GetInput()); i++) {
38 220 GetOutput()[i].resize(std::get<1>(GetInput()));
39 }
40 8 return true;
41 }
42
43 8 bool BoltenkovSGaussianKernelOMP::RunImpl() {
44 8 std::size_t n = std::get<0>(GetInput());
45 8 std::size_t m = std::get<1>(GetInput());
46
47 8 std::vector<std::vector<int>> data = std::get<2>(GetInput());
48
3/6
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
16 std::vector<std::vector<int>> tmp_data(n + 2, std::vector<int>(m + 2, 0));
49 std::vector<std::vector<int>> &res = GetOutput();
50
51
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 #pragma omp parallel for num_threads(ppc::util::GetNumThreads()) default(none) shared(tmp_data, data) firstprivate(n)
52 for (std::size_t i = 1; i <= n; i++) {
53 std::copy(data[i - 1].begin(), data[i - 1].end(), tmp_data[i].begin() + 1);
54 }
55
56
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 auto kernel = kernel_;
57 8 int shift = shift_;
58
59
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 #pragma omp parallel for num_threads(ppc::util::GetNumThreads()) default(none) shared(tmp_data, res) \
60 firstprivate(n, m, kernel, shift)
61 for (std::size_t i = 1; i <= n; i++) {
62 for (std::size_t j = 1; j <= m; j++) {
63 res[i - 1][j - 1] = (tmp_data[i - 1][j - 1] * kernel[0][0]) + (tmp_data[i - 1][j] * kernel[0][1]) +
64 (tmp_data[i - 1][j + 1] * kernel[0][2]) + (tmp_data[i][j - 1] * kernel[1][0]) +
65 (tmp_data[i][j] * kernel[1][1]) + (tmp_data[i][j + 1] * kernel[1][2]) +
66 (tmp_data[i + 1][j - 1] * kernel[2][0]) + (tmp_data[i + 1][j] * kernel[2][1]) +
67 (tmp_data[i + 1][j + 1] * kernel[2][2]);
68 res[i - 1][j - 1] >>= shift;
69 }
70 }
71
72 8 return true;
73 8 }
74
75 8 bool BoltenkovSGaussianKernelOMP::PostProcessingImpl() {
76 8 return true;
77 }
78
79 } // namespace boltenkov_s_gaussian_kernel
80