GCC Code Coverage Report


Directory: ./
File: tasks/example/processes/t3/mpi/src/ops_mpi.cpp
Date: 2026-08-18 01:54:56
Exec Total Coverage
Lines: 30 30 100.0%
Functions: 5 5 100.0%
Branches: 16 20 80.0%

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