Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "example_processes/mpi/include/ops_mpi.hpp" | ||
2 | |||
3 | #include <mpi.h> | ||
4 | |||
5 | #include <numeric> | ||
6 | #include <vector> | ||
7 | |||
8 | #include "core/util/include/util.hpp" | ||
9 | #include "example_processes/common/include/common.hpp" | ||
10 | |||
11 | namespace nesterov_a_test_task_processes { | ||
12 | |||
13 | 60 | NesterovATestTaskMPI::NesterovATestTaskMPI(const InType &in) { | |
14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
15 | 60 | GetInput() = in; | |
16 | 60 | GetOutput() = 0; | |
17 | 60 | } | |
18 | |||
19 |
2/4✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
|
60 | bool NesterovATestTaskMPI::ValidationImpl() { return (GetInput() > 0) && (GetOutput() == 0); } |
20 | |||
21 | 60 | bool NesterovATestTaskMPI::PreProcessingImpl() { | |
22 | 60 | GetOutput() = 2 * GetInput(); | |
23 | 60 | return GetOutput() > 0; | |
24 | } | ||
25 | |||
26 | 60 | bool NesterovATestTaskMPI::RunImpl() { | |
27 | 60 | auto input = GetInput(); | |
28 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
60 | if (input == 0) { |
29 | return false; | ||
30 | } | ||
31 | |||
32 |
2/2✓ Branch 0 taken 180 times.
✓ Branch 1 taken 60 times.
|
240 | for (InType i = 0; i < GetInput(); i++) { |
33 |
2/2✓ Branch 0 taken 540 times.
✓ Branch 1 taken 180 times.
|
720 | for (InType j = 0; j < GetInput(); j++) { |
34 |
2/2✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 540 times.
|
2160 | for (InType k = 0; k < GetInput(); k++) { |
35 | 1620 | std::vector<InType> tmp(i + j + k, 1); | |
36 | 1620 | GetOutput() += std::accumulate(tmp.begin(), tmp.end(), 0); | |
37 |
2/2✓ Branch 0 taken 1560 times.
✓ Branch 1 taken 60 times.
|
1620 | GetOutput() -= i + j + k; |
38 | } | ||
39 | } | ||
40 | } | ||
41 | |||
42 | 60 | const int num_threads = ppc::util::GetNumThreads(); | |
43 | 60 | GetOutput() *= num_threads; | |
44 | |||
45 | 60 | int rank = 0; | |
46 | 60 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
47 | |||
48 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
60 | if (rank == 0) { |
49 | 60 | GetOutput() /= num_threads; | |
50 | } else { | ||
51 | int counter = 0; | ||
52 | ✗ | for (int i = 0; i < num_threads; i++) { | |
53 | ✗ | counter++; | |
54 | } | ||
55 | |||
56 | ✗ | if (counter != 0) { | |
57 | ✗ | GetOutput() /= counter; | |
58 | } | ||
59 | } | ||
60 | |||
61 | 60 | MPI_Barrier(MPI_COMM_WORLD); | |
62 | 60 | return GetOutput() > 0; | |
63 | } | ||
64 | |||
65 | 60 | bool NesterovATestTaskMPI::PostProcessingImpl() { | |
66 | 60 | GetOutput() -= GetInput(); | |
67 | 60 | return GetOutput() > 0; | |
68 | } | ||
69 | |||
70 | } // namespace nesterov_a_test_task_processes | ||
71 |