GCC Code Coverage Report


Directory: ./
File: tasks/safronov_m_multiplication_matrix_blockscheme_cannon/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 73 73 100.0%
Functions: 10 10 100.0%
Branches: 60 82 73.2%

Line Branch Exec Source
1 #include "safronov_m_multiplication_matrix_blockscheme_cannon/seq/include/ops_seq.hpp"
2
3 #include <utility>
4 #include <vector>
5
6 #include "safronov_m_multiplication_matrix_blockscheme_cannon/common/include/common.hpp"
7
8 namespace safronov_m_multiplication_matrix_blocksscheme_cannon {
9
10
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 SafronovMMultiplicationMatrixBlockSchemeCannon::SafronovMMultiplicationMatrixBlockSchemeCannon(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12 GetInput() = in;
13 64 }
14
15 64 bool SafronovMMultiplicationMatrixBlockSchemeCannon::ValidationImpl() {
16 const auto &in = GetInput();
17 64 int size_block = std::get<0>(in);
18 const auto &matrix_a = std::get<1>(in);
19 const auto &matrix_b = std::get<2>(in);
20
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 64 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 64 times.
64 return (size_block > 0) && (!matrix_a.empty() && !matrix_b.empty()) && (matrix_a.size() == matrix_a[0].size()) &&
21
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
128 (matrix_b.size() == matrix_b[0].size()) && (matrix_a.size() == matrix_b.size()) &&
22
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 (matrix_a.size() % size_block == 0);
23 }
24
25
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 bool SafronovMMultiplicationMatrixBlockSchemeCannon::PreProcessingImpl() {
26 GetOutput().clear();
27 64 return true;
28 }
29
30 608 void SafronovMMultiplicationMatrixBlockSchemeCannon::MultiplyingBlocks(std::vector<std::vector<double>> &block_a,
31 std::vector<std::vector<double>> &block_b,
32 std::vector<std::vector<double>> &block_c,
33 int size_block) {
34
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 608 times.
2176 for (int i = 0; i < size_block; i++) {
35
2/2
✓ Branch 0 taken 4448 times.
✓ Branch 1 taken 1568 times.
6016 for (int j = 0; j < size_block; j++) {
36
2/2
✓ Branch 0 taken 13472 times.
✓ Branch 1 taken 4448 times.
17920 for (int k = 0; k < size_block; k++) {
37 13472 block_c[i][j] += block_a[i][k] * block_b[k][j];
38 }
39 }
40 }
41 608 }
42
43 64 void SafronovMMultiplicationMatrixBlockSchemeCannon::ShiftingBlocksMatrixALeft(
44 std::vector<std::vector<std::vector<std::vector<double>>>> &matrix_blocks_a, int columns) {
45
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 64 times.
208 for (int i = 0; i < columns; i++) {
46 144 std::vector<std::vector<double>> tmp = std::move(matrix_blocks_a[i][0]);
47
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 144 times.
336 for (int j = 1; j < columns; j++) {
48 192 matrix_blocks_a[i][j - 1] = std::move(matrix_blocks_a[i][j]);
49 }
50 144 matrix_blocks_a[i][columns - 1] = std::move(tmp);
51 144 }
52 64 }
53
54 64 void SafronovMMultiplicationMatrixBlockSchemeCannon::ShiftingBlocksMatrixBUp(
55 std::vector<std::vector<std::vector<std::vector<double>>>> &matrix_blocks_b, int columns) {
56
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 64 times.
208 for (int i = 0; i < columns; i++) {
57 144 std::vector<std::vector<double>> tmp = std::move(matrix_blocks_b[0][i]);
58
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 144 times.
336 for (int j = 1; j < columns; j++) {
59 192 matrix_blocks_b[j - 1][i] = std::move(matrix_blocks_b[j][i]);
60 }
61 144 matrix_blocks_b[columns - 1][i] = std::move(tmp);
62 144 }
63 64 }
64
65 64 void SafronovMMultiplicationMatrixBlockSchemeCannon::AlgorithmCannon(
66 std::vector<std::vector<std::vector<std::vector<double>>>> &matrix_blocks_a,
67 std::vector<std::vector<std::vector<std::vector<double>>>> &matrix_blocks_b,
68 std::vector<std::vector<std::vector<std::vector<double>>>> &matrix_blocks_c, int size_block, int columns_blocks) {
69
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 64 times.
192 for (int i = 0; i < columns_blocks; i++) {
70
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 128 times.
400 for (int j = 0; j < columns_blocks; j++) {
71
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 272 times.
880 for (int k = 0; k < columns_blocks; k++) {
72 608 SafronovMMultiplicationMatrixBlockSchemeCannon::MultiplyingBlocks(matrix_blocks_a[j][k], matrix_blocks_b[j][k],
73 608 matrix_blocks_c[j][k], size_block);
74 }
75 }
76
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
128 if (i < columns_blocks - 1) {
77 64 SafronovMMultiplicationMatrixBlockSchemeCannon::ShiftingBlocksMatrixALeft(matrix_blocks_a, columns_blocks);
78 64 SafronovMMultiplicationMatrixBlockSchemeCannon::ShiftingBlocksMatrixBUp(matrix_blocks_b, columns_blocks);
79 }
80 }
81 64 }
82
83 64 void SafronovMMultiplicationMatrixBlockSchemeCannon::FillingResultingMatrix(
84 std::vector<std::vector<std::vector<std::vector<double>>>> &matrix_blocks_c,
85 std::vector<std::vector<double>> &matrix_c, int size_block, int columns_blocks) {
86
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 64 times.
192 for (int i = 0; i < columns_blocks; i++) {
87
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 128 times.
400 for (int j = 0; j < columns_blocks; j++) {
88
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 272 times.
960 for (int k = 0; k < size_block; k++) {
89
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 688 times.
2624 for (int col = 0; col < size_block; col++) {
90 1936 matrix_c[(i * size_block) + k][(j * size_block) + col] = matrix_blocks_c[i][j][k][col];
91 }
92 }
93 }
94 }
95 64 }
96
97 64 bool SafronovMMultiplicationMatrixBlockSchemeCannon::RunImpl() {
98 const auto &in = GetInput();
99 64 int size_block = std::get<0>(in);
100 const auto &matrix_a = std::get<1>(in);
101 const auto &matrix_b = std::get<2>(in);
102 64 int n = static_cast<int>(matrix_a.size());
103 64 int columns_blocks = n / size_block;
104 std::vector<std::vector<std::vector<std::vector<double>>>> matrix_blocks_a(
105 columns_blocks,
106 64 std::vector<std::vector<std::vector<double>>>(
107
3/6
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 64 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
128 columns_blocks, std::vector<std::vector<double>>(size_block, std::vector<double>(size_block))));
108 std::vector<std::vector<std::vector<std::vector<double>>>> matrix_blocks_b(
109 columns_blocks,
110 64 std::vector<std::vector<std::vector<double>>>(
111
4/8
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 64 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
128 columns_blocks, std::vector<std::vector<double>>(size_block, std::vector<double>(size_block))));
112 std::vector<std::vector<std::vector<std::vector<double>>>> matrix_blocks_c(
113 columns_blocks,
114 64 std::vector<std::vector<std::vector<double>>>(
115
4/8
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 64 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
128 columns_blocks, std::vector<std::vector<double>>(size_block, std::vector<double>(size_block, 0.0))));
116
117
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 64 times.
192 for (int i = 0; i < columns_blocks; i++) {
118
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 128 times.
400 for (int j = 0; j < columns_blocks; j++) {
119 272 int shift = (i + j) % columns_blocks;
120
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 272 times.
960 for (int k = 0; k < size_block; k++) {
121
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 688 times.
2624 for (int col = 0; col < size_block; col++) {
122 1936 matrix_blocks_a[i][j][k][col] = matrix_a[(i * size_block) + k][(shift * size_block) + col];
123 1936 matrix_blocks_b[i][j][k][col] = matrix_b[(shift * size_block) + k][(j * size_block) + col];
124 }
125 }
126 }
127 }
128 64 SafronovMMultiplicationMatrixBlockSchemeCannon::AlgorithmCannon(matrix_blocks_a, matrix_blocks_b, matrix_blocks_c,
129 size_block, columns_blocks);
130
131
2/4
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
64 std::vector<std::vector<double>> matrix_c(n, std::vector<double>(n));
132 64 SafronovMMultiplicationMatrixBlockSchemeCannon::FillingResultingMatrix(matrix_blocks_c, matrix_c, size_block,
133 columns_blocks);
134 64 GetOutput() = std::move(matrix_c);
135 64 return true;
136 64 }
137
138 64 bool SafronovMMultiplicationMatrixBlockSchemeCannon::PostProcessingImpl() {
139 64 return true;
140 }
141
142 } // namespace safronov_m_multiplication_matrix_blocksscheme_cannon
143