GCC Code Coverage Report


Directory: ./
File: tasks/egashin_k_radix_simple_merge/stl/src/ops_stl.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 41 41 100.0%
Functions: 7 7 100.0%
Branches: 30 44 68.2%

Line Branch Exec Source
1 #include "egashin_k_radix_simple_merge/stl/include/ops_stl.hpp"
2
3 #include <cstddef>
4 #include <thread>
5 #include <utility>
6 #include <vector>
7
8 #include "egashin_k_radix_simple_merge/common/include/common.hpp"
9 #include "egashin_k_radix_simple_merge/common/include/radix_utils.hpp"
10 #include "util/include/util.hpp"
11
12 namespace egashin_k_radix_simple_merge {
13
14
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 EgashinKRadixSimpleMergeSTL::EgashinKRadixSimpleMergeSTL(const InType &in) {
15 SetTypeOfTask(GetStaticTypeOfTask());
16
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 GetInput() = in;
17 GetOutput() = {};
18 64 }
19
20 64 bool EgashinKRadixSimpleMergeSTL::ValidationImpl() {
21 64 return true;
22 }
23
24 64 bool EgashinKRadixSimpleMergeSTL::PreProcessingImpl() {
25 64 result_ = GetInput();
26 64 return true;
27 }
28
29
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 bool EgashinKRadixSimpleMergeSTL::RunImpl() {
30
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 if (result_.size() < 2) {
31 return true;
32 }
33
34 48 const int workers = radix_utils::WorkerCount(result_.size(), ppc::util::GetNumThreads());
35 48 const auto ranges = radix_utils::MakeRanges(result_.size(), workers);
36
37 48 std::vector<std::thread> threads;
38
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 threads.reserve(static_cast<size_t>(workers));
39
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 48 times.
168 for (int i = 0; i < workers; ++i) {
40
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
120 threads.emplace_back([&, index = static_cast<size_t>(i)] {
41 120 radix_utils::SortRange(result_, ranges[index].first, ranges[index].second);
42 120 });
43 }
44
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 48 times.
168 for (auto &thread : threads) {
45
1/2
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
120 thread.join();
46 }
47
48
1/2
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
48 auto parts = radix_utils::MakeParts(result_, ranges);
49
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 48 times.
108 while (parts.size() > 1) {
50 60 const size_t pair_count = parts.size() / 2;
51
2/4
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
60 std::vector<std::vector<double>> next((parts.size() + 1) / 2);
52
53 const int merge_workers = radix_utils::WorkerCount(pair_count, workers);
54
1/2
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
60 const auto merge_ranges = radix_utils::MakeRanges(pair_count, merge_workers);
55
56 60 threads.clear();
57
1/2
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
60 threads.reserve(static_cast<size_t>(merge_workers));
58
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 60 times.
132 for (int i = 0; i < merge_workers; ++i) {
59
1/4
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
72 threads.emplace_back([&, index = static_cast<size_t>(i)] {
60
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
144 for (size_t j = merge_ranges[index].first; j < merge_ranges[index].second; ++j) {
61 144 next[j] = radix_utils::Merge(parts[2 * j], parts[(2 * j) + 1]);
62 }
63 72 });
64 }
65
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 60 times.
132 for (auto &thread : threads) {
66
1/2
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
72 thread.join();
67 }
68
69
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 if (parts.size() % 2 != 0) {
70 next.back() = std::move(parts.back());
71 }
72 60 parts = std::move(next);
73 60 }
74
75 result_ = std::move(parts.front());
76 return true;
77 48 }
78
79 64 bool EgashinKRadixSimpleMergeSTL::PostProcessingImpl() {
80 64 GetOutput() = result_;
81 64 return true;
82 }
83
84 } // namespace egashin_k_radix_simple_merge
85