GCC Code Coverage Report


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

Line Branch Exec Source
1 #include "makoveeva_matmul_double_omp/omp/include/ops_omp.hpp"
2
3 #include <omp.h>
4
5 #include <cmath>
6 #include <cstddef>
7 #include <vector>
8
9 #include "makoveeva_matmul_double_omp/common/include/common.hpp"
10
11 namespace makoveeva_matmul_double_omp {
12
13 // Убираем : n_(0) - инициализация будет в классе
14
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 MatmulDoubleOMPTask::MatmulDoubleOMPTask(const InType &in) {
15 SetTypeOfTask(GetStaticTypeOfTask());
16 GetInput() = in;
17 48 GetOutput() = std::vector<double>();
18 48 }
19
20 48 bool MatmulDoubleOMPTask::ValidationImpl() {
21 const auto &input = GetInput();
22 48 const size_t n = std::get<0>(input);
23 const auto &a = std::get<1>(input);
24 const auto &b = std::get<2>(input);
25
26
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
48 return n > 0 && a.size() == n * n && b.size() == n * n;
27 }
28
29 48 bool MatmulDoubleOMPTask::PreProcessingImpl() {
30 const auto &input = GetInput();
31 48 n_ = std::get<0>(input);
32 48 A_ = std::get<1>(input);
33 48 B_ = std::get<2>(input);
34 48 C_.assign(n_ * n_, 0.0);
35
36 48 return true;
37 }
38
39 48 bool MatmulDoubleOMPTask::RunImpl() {
40
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if (n_ <= 0) {
41 return false;
42 }
43
44 const size_t n = n_;
45 48 const auto &a = A_;
46 48 const auto &b = B_;
47 48 auto &c = C_;
48
49 48 #pragma omp parallel for collapse(2) default(none) shared(a, b, c, n)
50 for (size_t i = 0; i < n; ++i) {
51 for (size_t j = 0; j < n; ++j) {
52 double sum = 0.0;
53 for (size_t k = 0; k < n; ++k) {
54 sum += a[(i * n) + k] * b[(k * n) + j];
55 }
56 c[(i * n) + j] = sum;
57 }
58 }
59
60 48 GetOutput() = C_;
61 48 return true;
62 }
63
64 48 bool MatmulDoubleOMPTask::PostProcessingImpl() {
65 48 return true;
66 }
67
68 } // namespace makoveeva_matmul_double_omp
69