GCC Code Coverage Report


Directory: ./
File: tasks/example_processes/mpi/src/ops_mpi.cpp
Date: 2025-08-13 00:58:25
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 5 5 100.0%
Branches: 16 20 80.0%

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