GCC Code Coverage Report


Directory: ./
File: tasks/volkov_a_sparse_mat_mul_ccs/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 34 34 100.0%
Functions: 5 5 100.0%
Branches: 17 20 85.0%

Line Branch Exec Source
1 #include "volkov_a_sparse_mat_mul_ccs/seq/include/ops_seq.hpp"
2
3 #include <cmath>
4 #include <tuple>
5 #include <vector>
6
7 #include "volkov_a_sparse_mat_mul_ccs/common/include/common.hpp"
8
9 namespace volkov_a_sparse_mat_mul_ccs {
10
11
1/2
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
40 VolkovASparseMatMulCcsSeq::VolkovASparseMatMulCcsSeq(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13 GetInput() = in;
14 40 }
15
16 40 bool VolkovASparseMatMulCcsSeq::ValidationImpl() {
17 const auto &matrix_a = std::get<0>(GetInput());
18 const auto &matrix_b = std::get<1>(GetInput());
19 40 return (matrix_a.cols_count == matrix_b.rows_count);
20 }
21
22 40 bool VolkovASparseMatMulCcsSeq::PreProcessingImpl() {
23 40 return true;
24 }
25
26 40 bool VolkovASparseMatMulCcsSeq::RunImpl() {
27 const auto &matrix_a = std::get<0>(GetInput());
28 const auto &matrix_b = std::get<1>(GetInput());
29 auto &matrix_c = GetOutput();
30
31 40 matrix_c.rows_count = matrix_a.rows_count;
32 40 matrix_c.cols_count = matrix_b.cols_count;
33
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
40 matrix_c.col_ptrs.assign(matrix_c.cols_count + 1, 0);
34 matrix_c.row_indices.clear();
35 matrix_c.values.clear();
36
37 40 std::vector<double> col_accumulator(matrix_a.rows_count, 0.0);
38
39
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 40 times.
112 for (int j = 0; j < matrix_b.cols_count; ++j) {
40 72 matrix_c.col_ptrs[j] = static_cast<int>(matrix_c.values.size());
41
42 72 int b_start = matrix_b.col_ptrs[j];
43 72 int b_end = matrix_b.col_ptrs[j + 1];
44
45
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 72 times.
168 for (int k = b_start; k < b_end; ++k) {
46 96 int b_row = matrix_b.row_indices[k];
47 96 double b_val = matrix_b.values[k];
48
49 96 int a_start = matrix_a.col_ptrs[b_row];
50 96 int a_end = matrix_a.col_ptrs[b_row + 1];
51
52
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 96 times.
208 for (int idx = a_start; idx < a_end; ++idx) {
53 112 int a_row = matrix_a.row_indices[idx];
54 112 double a_val = matrix_a.values[idx];
55
56 112 col_accumulator[a_row] += a_val * b_val;
57 }
58 }
59
60
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 72 times.
232 for (int i = 0; i < matrix_a.rows_count; ++i) {
61
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 64 times.
160 if (std::abs(col_accumulator[i]) > 1e-10) {
62
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 88 times.
96 matrix_c.row_indices.push_back(i);
63
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 88 times.
96 matrix_c.values.push_back(col_accumulator[i]);
64 }
65 160 col_accumulator[i] = 0.0;
66 }
67 }
68
69 40 matrix_c.non_zeros = static_cast<int>(matrix_c.values.size());
70
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 matrix_c.col_ptrs[matrix_b.cols_count] = matrix_c.non_zeros;
71
72 40 return true;
73 }
74
75 40 bool VolkovASparseMatMulCcsSeq::PostProcessingImpl() {
76 40 return true;
77 }
78
79 } // namespace volkov_a_sparse_mat_mul_ccs
80