GCC Code Coverage Report


Directory: ./
File: tasks/korolev_k_matrix_mult/tbb/src/ops_tbb.cpp
Date: 2026-05-11 08:26:31
Exec Total Coverage
Lines: 14 27 51.9%
Functions: 5 6 83.3%
Branches: 8 36 22.2%

Line Branch Exec Source
1 #include "korolev_k_matrix_mult/tbb/include/ops_tbb.hpp"
2
3 #include <oneapi/tbb/parallel_invoke.h>
4
5 #include <cstddef>
6 #include <functional>
7 #include <vector>
8
9 #include "korolev_k_matrix_mult/common/include/common.hpp"
10 #include "korolev_k_matrix_mult/common/include/strassen_impl.hpp"
11
12 namespace korolev_k_matrix_mult {
13
14
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 KorolevKMatrixMultTBB::KorolevKMatrixMultTBB(const InType &in) {
15 SetTypeOfTask(GetStaticTypeOfTask());
16 GetInput() = in;
17 GetOutput().clear();
18 12 }
19
20 12 bool KorolevKMatrixMultTBB::ValidationImpl() {
21 const auto &in = GetInput();
22
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
12 return in.n > 0 && in.A.size() == in.n * in.n && in.B.size() == in.n * in.n && GetOutput().empty();
23 }
24
25 12 bool KorolevKMatrixMultTBB::PreProcessingImpl() {
26 12 GetOutput().resize(GetInput().n * GetInput().n);
27 12 return true;
28 }
29
30 12 bool KorolevKMatrixMultTBB::RunImpl() {
31 const auto &in = GetInput();
32
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 size_t n = in.n;
33 size_t np2 = strassen_impl::NextPowerOf2(n);
34
35 auto parallel_run = [](std::vector<std::function<void()>> &tasks) {
36 tbb::parallel_invoke(tasks[0], tasks[1], tasks[2], tasks[3], tasks[4], tasks[5], tasks[6]);
37 };
38
39
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (np2 == n) {
40
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
24 strassen_impl::StrassenMultiply(in.A, in.B, GetOutput(), n, parallel_run);
41 } else {
42 std::vector<double> a_pad(np2 * np2, 0);
43 std::vector<double> b_pad(np2 * np2, 0);
44 std::vector<double> c_pad(np2 * np2, 0);
45 for (size_t i = 0; i < n; ++i) {
46 for (size_t j = 0; j < n; ++j) {
47 a_pad[(i * np2) + j] = in.A[(i * n) + j];
48 b_pad[(i * np2) + j] = in.B[(i * n) + j];
49 }
50 }
51 strassen_impl::StrassenMultiply(a_pad, b_pad, c_pad, np2, parallel_run);
52 for (size_t i = 0; i < n; ++i) {
53 for (size_t j = 0; j < n; ++j) {
54 GetOutput()[(i * n) + j] = c_pad[(i * np2) + j];
55 }
56 }
57 }
58 12 return true;
59 }
60
61 12 bool KorolevKMatrixMultTBB::PostProcessingImpl() {
62 12 return !GetOutput().empty();
63 }
64
65 } // namespace korolev_k_matrix_mult
66