GCC Code Coverage Report


Directory: ./
File: tasks/ashihmin_d_mult_matr_crs/omp/src/ops_omp.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 5 5 100.0%
Branches: 7 12 58.3%

Line Branch Exec Source
1 #include "ashihmin_d_mult_matr_crs/omp/include/ops_omp.hpp"
2
3 #include <omp.h>
4
5 #include <cmath>
6 #include <map>
7 #include <vector>
8
9 #include "ashihmin_d_mult_matr_crs/common/include/common.hpp"
10
11 namespace ashihmin_d_mult_matr_crs {
12
13
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 AshihminDMultMatrCrsOMP::AshihminDMultMatrCrsOMP(const InType &in) {
14 SetTypeOfTask(GetStaticTypeOfTask());
15 GetInput() = in;
16 24 }
17
18 24 bool AshihminDMultMatrCrsOMP::ValidationImpl() {
19 24 return GetInput().first.cols == GetInput().second.rows;
20 }
21
22 24 bool AshihminDMultMatrCrsOMP::PreProcessingImpl() {
23 auto &matrix_c = GetOutput();
24 24 matrix_c.rows = GetInput().first.rows;
25 24 matrix_c.cols = GetInput().second.cols;
26
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 matrix_c.row_ptr.assign(matrix_c.rows + 1, 0);
27 matrix_c.values.clear();
28 matrix_c.col_index.clear();
29 24 return true;
30 }
31
32 24 bool AshihminDMultMatrCrsOMP::RunImpl() {
33 24 const auto &matrix_a = GetInput().first;
34 24 const auto &matrix_b = GetInput().second;
35 auto &matrix_c = GetOutput();
36 24 int rows_a = matrix_a.rows;
37
38 24 std::vector<std::vector<int>> local_cols(rows_a);
39
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 std::vector<std::vector<double>> local_vals(rows_a);
40
41 24 #pragma omp parallel for default(none) shared(matrix_a, matrix_b, local_cols, local_vals, rows_a)
42 for (int i = 0; i < rows_a; ++i) {
43 std::map<int, double> row_accumulator;
44 for (int j = matrix_a.row_ptr[i]; j < matrix_a.row_ptr[i + 1]; ++j) {
45 int col_a = matrix_a.col_index[j];
46 double val_a = matrix_a.values[j];
47 for (int k = matrix_b.row_ptr[col_a]; k < matrix_b.row_ptr[col_a + 1]; ++k) {
48 row_accumulator[matrix_b.col_index[k]] += val_a * matrix_b.values[k];
49 }
50 }
51 for (const auto &[col, val] : row_accumulator) {
52 if (std::abs(val) > 1e-15) {
53 local_cols[i].push_back(col);
54 local_vals[i].push_back(val);
55 }
56 }
57 }
58
59
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for (int i = 0; i < rows_a; ++i) {
60
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 matrix_c.col_index.insert(matrix_c.col_index.end(), local_cols[i].begin(), local_cols[i].end());
61
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 matrix_c.values.insert(matrix_c.values.end(), local_vals[i].begin(), local_vals[i].end());
62 48 matrix_c.row_ptr[i + 1] = static_cast<int>(matrix_c.values.size());
63 }
64 24 return true;
65 24 }
66
67 24 bool AshihminDMultMatrCrsOMP::PostProcessingImpl() {
68 24 return true;
69 }
70
71 } // namespace ashihmin_d_mult_matr_crs
72