GCC Code Coverage Report


Directory: ./
File: tasks/example/threads/omp/src/ops_omp.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/omp/include/ops_omp.hpp"
2
3 #include <atomic>
4 #include <numeric>
5 #include <vector>
6
7 #include "example/common/include/common.hpp"
8 #include "util/include/util.hpp"
9
10 namespace example_threads {
11
12 12 NesterovATestTaskOMP::NesterovATestTaskOMP(const InType &in) : BaseTask(in) {}
13
14 12 bool NesterovATestTaskOMP::ValidationImpl() {
15
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);
16 }
17
18 12 bool NesterovATestTaskOMP::PreProcessingImpl() {
19 12 GetMutableOutput() = 2 * GetInput();
20 12 return GetMutableOutput() > 0;
21 }
22
23 12 bool NesterovATestTaskOMP::RunImpl() {
24
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 for (InType i = 0; i < GetInput(); i++) {
25
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for (InType j = 0; j < GetInput(); j++) {
26
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 108 times.
432 for (InType k = 0; k < GetInput(); k++) {
27 324 std::vector<InType> tmp(i + j + k, 1);
28 324 GetMutableOutput() += std::accumulate(tmp.begin(), tmp.end(), 0);
29
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 12 times.
324 GetMutableOutput() -= i + j + k;
30 }
31 }
32 }
33
34 12 const int num_threads = ppc::util::GetNumThreads();
35 12 GetMutableOutput() *= num_threads;
36
37 12 std::atomic<int> counter(0);
38 12 #pragma omp parallel default(none) shared(counter) num_threads(ppc::util::GetNumThreads())
39 counter++;
40
41 12 GetMutableOutput() /= counter;
42 12 return GetMutableOutput() > 0;
43 }
44
45 12 bool NesterovATestTaskOMP::PostProcessingImpl() {
46 12 GetMutableOutput() -= GetInput();
47 12 return GetMutableOutput() > 0;
48 }
49
50 } // namespace example_threads
51