GCC Code Coverage Report


Directory: ./
File: tasks/korolev_k_matrix_mult/all/src/ops_all.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 15 29 51.7%
Functions: 5 6 83.3%
Branches: 8 36 22.2%

Line Branch Exec Source
1 #include "korolev_k_matrix_mult/all/include/ops_all.hpp"
2
3 #include <mpi.h>
4
5 #include <cstddef>
6 #include <functional>
7 #include <vector>
8
9 #include "korolev_k_matrix_mult/common/include/common.hpp"
10 #include "korolev_k_matrix_mult/common/include/strassen_impl.hpp"
11 #include "util/include/util.hpp"
12
13 namespace korolev_k_matrix_mult {
14
15
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 KorolevKMatrixMultALL::KorolevKMatrixMultALL(const InType &in) {
16 SetTypeOfTask(GetStaticTypeOfTask());
17 GetInput() = in;
18 GetOutput().clear();
19 6 }
20
21 6 bool KorolevKMatrixMultALL::ValidationImpl() {
22 const auto &in = GetInput();
23
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
6 return in.n > 0 && in.A.size() == in.n * in.n && in.B.size() == in.n * in.n && GetOutput().empty();
24 }
25
26 6 bool KorolevKMatrixMultALL::PreProcessingImpl() {
27 6 GetOutput().resize(GetInput().n * GetInput().n);
28 6 return true;
29 }
30
31 6 bool KorolevKMatrixMultALL::RunImpl() {
32 const auto &in = GetInput();
33
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 size_t n = in.n;
34 size_t np2 = strassen_impl::NextPowerOf2(n);
35
36 auto parallel_run = [](std::vector<std::function<void()>> &tasks) {
37 #pragma omp parallel default(none) num_threads(ppc::util::GetNumThreads()) shared(tasks)
38 #pragma omp single
39 {
40 for (size_t i = 0; i < tasks.size(); ++i) {
41 #pragma omp task default(none) firstprivate(i) shared(tasks)
42 tasks[i]();
43 }
44 #pragma omp taskwait
45 }
46 };
47
48
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (np2 == n) {
49
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 strassen_impl::StrassenMultiply(in.A, in.B, GetOutput(), n, parallel_run);
50 } else {
51 std::vector<double> a_pad(np2 * np2, 0);
52 std::vector<double> b_pad(np2 * np2, 0);
53 std::vector<double> c_pad(np2 * np2, 0);
54 for (size_t i = 0; i < n; ++i) {
55 for (size_t j = 0; j < n; ++j) {
56 a_pad[(i * np2) + j] = in.A[(i * n) + j];
57 b_pad[(i * np2) + j] = in.B[(i * n) + j];
58 }
59 }
60 strassen_impl::StrassenMultiply(a_pad, b_pad, c_pad, np2, parallel_run);
61 for (size_t i = 0; i < n; ++i) {
62 for (size_t j = 0; j < n; ++j) {
63 GetOutput()[(i * n) + j] = c_pad[(i * np2) + j];
64 }
65 }
66 }
67 6 MPI_Barrier(MPI_COMM_WORLD);
68 6 return true;
69 }
70
71 6 bool KorolevKMatrixMultALL::PostProcessingImpl() {
72 6 return !GetOutput().empty();
73 }
74
75 } // namespace korolev_k_matrix_mult
76