GCC Code Coverage Report


Directory: ./
File: tasks/zagryadskov_m_complex_spmm_ccs/seq/src/ops_seq.cpp
Date: 2026-05-11 08:26:31
Exec Total Coverage
Lines: 60 60 100.0%
Functions: 9 9 100.0%
Branches: 34 40 85.0%

Line Branch Exec Source
1 #include "zagryadskov_m_complex_spmm_ccs/seq/include/ops_seq.hpp"
2
3 #include <cmath>
4 #include <complex>
5 #include <tuple>
6 #include <vector>
7
8 #include "zagryadskov_m_complex_spmm_ccs/common/include/common.hpp"
9
10 namespace zagryadskov_m_complex_spmm_ccs {
11
12
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 ZagryadskovMComplexSpMMCCSSEQ::ZagryadskovMComplexSpMMCCSSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetOutput() = CCS();
16 24 }
17
18 24 void ZagryadskovMComplexSpMMCCSSEQ::SpMMSymbolic(const CCS &a, const CCS &b, std::vector<int> &col_ptr, int jstart,
19 int jend) {
20 24 std::vector<int> marker(a.m, -1);
21
22
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 24 times.
80 for (int j = jstart; j < jend; ++j) {
23 int count = 0;
24
25
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 56 times.
136 for (int k = b.col_ptr[j]; k < b.col_ptr[j + 1]; ++k) {
26 80 int b_row = b.row_ind[k];
27
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 80 times.
168 for (int zp = a.col_ptr[b_row]; zp < a.col_ptr[b_row + 1]; ++zp) {
28
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
88 int a_row = a.row_ind[zp];
29
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
88 if (marker[a_row] != j) {
30 72 marker[a_row] = j;
31 72 ++count;
32 }
33 }
34 }
35 56 col_ptr[j + 1] += count;
36 }
37 24 }
38
39
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 24 times.
56 void ZagryadskovMComplexSpMMCCSSEQ::SpMMKernel(const CCS &a, const CCS &b, CCS &c, const std::complex<double> &zero,
40 std::vector<int> &rows, std::vector<std::complex<double>> &acc,
41 std::vector<int> &marker, int j) {
42 rows.clear();
43 56 int write_ptr = c.col_ptr[j];
44
45
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 56 times.
136 for (int k = b.col_ptr[j]; k < b.col_ptr[j + 1]; ++k) {
46 80 std::complex<double> tmpval = b.values[k];
47 80 int b_row = b.row_ind[k];
48
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 80 times.
168 for (int zp = a.col_ptr[b_row]; zp < a.col_ptr[b_row + 1]; ++zp) {
49
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
88 int a_row = a.row_ind[zp];
50
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
88 acc[a_row] += tmpval * a.values[zp];
51
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
88 if (marker[a_row] != j) {
52
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 32 times.
72 marker[a_row] = j;
53 rows.push_back(a_row);
54 }
55 }
56 }
57
58
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 56 times.
128 for (int r_idx : rows) {
59 72 c.row_ind[write_ptr] = r_idx;
60 72 c.values[write_ptr] = acc[r_idx];
61 72 ++write_ptr;
62 72 acc[r_idx] = zero;
63 }
64 56 }
65
66 24 void ZagryadskovMComplexSpMMCCSSEQ::SpMMNumeric(const CCS &a, const CCS &b, CCS &c, const std::complex<double> &zero,
67 int jstart, int jend) {
68 24 std::vector<int> marker(a.m, -1);
69
1/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 std::vector<std::complex<double>> acc(a.m, zero);
70 24 std::vector<int> rows;
71
72
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 24 times.
80 for (int j = jstart; j < jend; ++j) {
73
1/2
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
56 SpMMKernel(a, b, c, zero, rows, acc, marker, j);
74 }
75 24 }
76
77 24 void ZagryadskovMComplexSpMMCCSSEQ::SpMM(const CCS &a, const CCS &b, CCS &c) {
78 24 c.m = a.m;
79 24 c.n = b.n;
80
81 24 std::complex<double> zero(0.0, 0.0);
82 24 c.col_ptr.assign(c.n + 1, 0);
83
84 24 SpMMSymbolic(a, b, c.col_ptr, 0, c.n);
85
86
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 24 times.
80 for (int j = 0; j < c.n; ++j) {
87 56 c.col_ptr[j + 1] += c.col_ptr[j];
88 }
89 24 int nnz = c.col_ptr[b.n];
90 24 c.row_ind.resize(nnz);
91 24 c.values.resize(nnz);
92 24 SpMMNumeric(a, b, c, zero, 0, c.n);
93 24 }
94
95 24 bool ZagryadskovMComplexSpMMCCSSEQ::ValidationImpl() {
96 const CCS &a = std::get<0>(GetInput());
97 const CCS &b = std::get<1>(GetInput());
98 24 return a.n == b.m;
99 }
100
101 24 bool ZagryadskovMComplexSpMMCCSSEQ::PreProcessingImpl() {
102 24 return true;
103 }
104
105 24 bool ZagryadskovMComplexSpMMCCSSEQ::RunImpl() {
106 const CCS &a = std::get<0>(GetInput());
107 const CCS &b = std::get<1>(GetInput());
108 CCS &c = GetOutput();
109
110 24 SpMM(a, b, c);
111
112 24 return true;
113 }
114
115 24 bool ZagryadskovMComplexSpMMCCSSEQ::PostProcessingImpl() {
116 24 return true;
117 }
118
119 } // namespace zagryadskov_m_complex_spmm_ccs
120