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