Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "example_threads/seq/include/ops_seq.hpp" | ||
2 | |||
3 | #include <numeric> | ||
4 | #include <vector> | ||
5 | |||
6 | #include "example_threads/common/include/common.hpp" | ||
7 | #include "util/include/util.hpp" | ||
8 | |||
9 | namespace nesterov_a_test_task_threads { | ||
10 | |||
11 | 48 | NesterovATestTaskSEQ::NesterovATestTaskSEQ(const InType& in) { | |
12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
13 | 48 | GetInput() = in; | |
14 | GetOutput() = 0; | ||
15 | 48 | } | |
16 | |||
17 | 48 | bool NesterovATestTaskSEQ::ValidationImpl() { | |
18 |
2/4✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
|
48 | return (GetInput() > 0) && (GetOutput() == 0); |
19 | } | ||
20 | |||
21 | 48 | bool NesterovATestTaskSEQ::PreProcessingImpl() { | |
22 | 48 | GetOutput() = 2 * GetInput(); | |
23 | 48 | return GetOutput() > 0; | |
24 | } | ||
25 | |||
26 | 48 | bool NesterovATestTaskSEQ::RunImpl() { | |
27 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if (GetInput() == 0) { |
28 | return false; | ||
29 | } | ||
30 | |||
31 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 48 times.
|
192 | for (InType i = 0; i < GetInput(); i++) { |
32 |
2/2✓ Branch 0 taken 432 times.
✓ Branch 1 taken 144 times.
|
576 | for (InType j = 0; j < GetInput(); j++) { |
33 |
2/2✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 432 times.
|
1728 | for (InType k = 0; k < GetInput(); k++) { |
34 | 1296 | std::vector<InType> tmp(i + j + k, 1); | |
35 | 1296 | GetOutput() += std::accumulate(tmp.begin(), tmp.end(), 0); | |
36 |
2/2✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 48 times.
|
1296 | GetOutput() -= i + j + k; |
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | 48 | const int num_threads = ppc::util::GetNumThreads(); | |
42 | 48 | GetOutput() *= num_threads; | |
43 | |||
44 | int counter = 0; | ||
45 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 48 times.
|
168 | for (int i = 0; i < num_threads; i++) { |
46 | 120 | counter++; | |
47 | } | ||
48 | |||
49 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if (counter != 0) { |
50 | 48 | GetOutput() /= counter; | |
51 | } | ||
52 | 48 | return GetOutput() > 0; | |
53 | } | ||
54 | |||
55 | 48 | bool NesterovATestTaskSEQ::PostProcessingImpl() { | |
56 | 48 | GetOutput() -= GetInput(); | |
57 | 48 | return GetOutput() > 0; | |
58 | } | ||
59 | |||
60 | } // namespace nesterov_a_test_task_threads | ||
61 |