GCC Code Coverage Report


Directory: ./
File: tasks/example/threads/tbb/src/ops_tbb.cpp
Date: 2026-08-18 01:54:56
Exec Total Coverage
Lines: 22 22 100.0%
Functions: 5 5 100.0%
Branches: 10 12 83.3%

Line Branch Exec Source
1 #include "example/threads/tbb/include/ops_tbb.hpp"
2
3 #include <tbb/tbb.h>
4
5 #include <atomic>
6 #include <numeric>
7 #include <util/include/util.hpp>
8 #include <vector>
9
10 #include "example/common/include/common.hpp"
11 #include "oneapi/tbb/parallel_for.h"
12
13 namespace example_threads {
14
15 12 NesterovATestTaskTBB::NesterovATestTaskTBB(const InType &in) : BaseTask(in) {}
16
17 12 bool NesterovATestTaskTBB::ValidationImpl() {
18
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 return (GetInput() > 0) && (GetMutableOutput() == 0);
19 }
20
21 12 bool NesterovATestTaskTBB::PreProcessingImpl() {
22 12 GetMutableOutput() = 2 * GetInput();
23 12 return GetMutableOutput() > 0;
24 }
25
26 12 bool NesterovATestTaskTBB::RunImpl() {
27
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 for (InType i = 0; i < GetInput(); i++) {
28
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for (InType j = 0; j < GetInput(); j++) {
29
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 108 times.
432 for (InType k = 0; k < GetInput(); k++) {
30 324 std::vector<InType> tmp(i + j + k, 1);
31 324 GetMutableOutput() += std::accumulate(tmp.begin(), tmp.end(), 0);
32
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 12 times.
324 GetMutableOutput() -= i + j + k;
33 }
34 }
35 }
36
37 12 const int num_threads = ppc::util::GetNumThreads();
38 12 GetMutableOutput() *= num_threads;
39
40 12 std::atomic<int> counter(0);
41 42 tbb::parallel_for(0, ppc::util::GetNumThreads(), [&](int /*i*/) -> void { counter++; });
42
43 12 GetMutableOutput() /= counter;
44 12 return GetMutableOutput() > 0;
45 }
46
47 12 bool NesterovATestTaskTBB::PostProcessingImpl() {
48 12 GetMutableOutput() -= GetInput();
49 12 return GetMutableOutput() > 0;
50 }
51
52 } // namespace example_threads
53