| 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::SpMM(const CCS &a, const CCS &b, CCS &c) { | |
| 19 | 24 | c.m = a.m; | |
| 20 | 24 | c.n = b.n; | |
| 21 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
|
24 | c.col_ptr.assign(b.n + 1, 0); |
| 22 | c.row_ind.clear(); | ||
| 23 | c.values.clear(); | ||
| 24 | std::complex<double> zero(0.0, 0.0); | ||
| 25 | 24 | std::vector<int> rows; | |
| 26 |
1/4✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
24 | std::vector<int> marker(a.m, -1); |
| 27 |
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); |
| 28 | const double eps = 1e-14; | ||
| 29 | |||
| 30 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 24 times.
|
80 | for (int j = 0; j < b.n; ++j) { |
| 31 | rows.clear(); | ||
| 32 | |||
| 33 |
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) { |
| 34 | 80 | std::complex<double> tmpval = b.values[k]; | |
| 35 | 80 | int btmpind = b.row_ind[k]; | |
| 36 | |||
| 37 |
2/2✓ Branch 0 taken 88 times.
✓ Branch 1 taken 80 times.
|
168 | for (int zp = a.col_ptr[btmpind]; zp < a.col_ptr[btmpind + 1]; ++zp) { |
| 38 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
|
88 | int atmpind = a.row_ind[zp]; |
| 39 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
|
88 | acc[atmpind] += tmpval * a.values[zp]; |
| 40 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 16 times.
|
88 | if (marker[atmpind] != j) { |
| 41 | rows.push_back(atmpind); | ||
| 42 | 72 | marker[atmpind] = j; | |
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 56 times.
|
128 | for (int tmpind : rows) { |
| 48 |
1/2✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 | if (std::abs(acc[tmpind]) > eps) { |
| 49 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 64 times.
|
72 | c.values.push_back(acc[tmpind]); |
| 50 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 64 times.
|
72 | c.row_ind.push_back(tmpind); |
| 51 | 72 | ++c.col_ptr[j + 1]; | |
| 52 | } | ||
| 53 | 72 | acc[tmpind] = zero; | |
| 54 | } | ||
| 55 | |||
| 56 | 56 | c.col_ptr[j + 1] += c.col_ptr[j]; | |
| 57 | } | ||
| 58 | 24 | } | |
| 59 | |||
| 60 | 24 | bool ZagryadskovMComplexSpMMCCSSEQ::ValidationImpl() { | |
| 61 | const CCS &a = std::get<0>(GetInput()); | ||
| 62 | const CCS &b = std::get<1>(GetInput()); | ||
| 63 | 24 | return a.n == b.m; | |
| 64 | } | ||
| 65 | |||
| 66 | 24 | bool ZagryadskovMComplexSpMMCCSSEQ::PreProcessingImpl() { | |
| 67 | 24 | return true; | |
| 68 | } | ||
| 69 | |||
| 70 | 24 | bool ZagryadskovMComplexSpMMCCSSEQ::RunImpl() { | |
| 71 | const CCS &a = std::get<0>(GetInput()); | ||
| 72 | const CCS &b = std::get<1>(GetInput()); | ||
| 73 | CCS &c = GetOutput(); | ||
| 74 | |||
| 75 | 24 | SpMM(a, b, c); | |
| 76 | |||
| 77 | 24 | return true; | |
| 78 | } | ||
| 79 | |||
| 80 | 24 | bool ZagryadskovMComplexSpMMCCSSEQ::PostProcessingImpl() { | |
| 81 | 24 | return true; | |
| 82 | } | ||
| 83 | |||
| 84 | } // namespace zagryadskov_m_complex_spmm_ccs | ||
| 85 |