GCC Code Coverage Report


Directory: ./
File: tasks/vdovin_a_topology_ruler/mpi/src/ops_mpi.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 34 38 89.5%
Functions: 5 5 100.0%
Branches: 14 18 77.8%

Line Branch Exec Source
1 #include "vdovin_a_topology_ruler/mpi/include/ops_mpi.hpp"
2
3 #include <mpi.h>
4
5 #include <vector>
6
7 #include "vdovin_a_topology_ruler/common/include/common.hpp"
8
9 namespace vdovin_a_topology_ruler {
10
11
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 VdovinATopologyRulerMPI::VdovinATopologyRulerMPI(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 GetInput() = in;
14 6 }
15
16 6 bool VdovinATopologyRulerMPI::ValidationImpl() {
17 6 int rank = 0;
18 6 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
19
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (rank == 0) {
20 3 return !GetInput().empty();
21 }
22 return true;
23 }
24
25 6 bool VdovinATopologyRulerMPI::PreProcessingImpl() {
26 6 int rank = 0;
27 6 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
28
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (rank == 0) {
29 3 data_ = GetInput();
30 }
31 6 return true;
32 }
33
34 6 bool VdovinATopologyRulerMPI::RunImpl() {
35 6 int rank = 0;
36 6 int size = 0;
37 6 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
38 6 MPI_Comm_size(MPI_COMM_WORLD, &size);
39
40 6 int data_size = 0;
41
42
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (rank == 0) {
43 3 data_size = static_cast<int>(data_.size());
44 }
45
46 6 MPI_Bcast(&data_size, 1, MPI_INT, 0, MPI_COMM_WORLD);
47
48
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (rank != 0) {
49 3 data_.resize(data_size);
50 }
51
52
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (size == 1) {
53 GetOutput() = data_;
54 return true;
55 }
56
57
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (rank == 0) {
58 3 MPI_Send(data_.data(), data_size, MPI_INT, 1, 0, MPI_COMM_WORLD);
59 } else {
60 3 int left_neighbor = rank - 1;
61 3 MPI_Recv(data_.data(), data_size, MPI_INT, left_neighbor, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
62
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (rank < size - 1) {
63 int right_neighbor = rank + 1;
64 MPI_Send(data_.data(), data_size, MPI_INT, right_neighbor, 0, MPI_COMM_WORLD);
65 }
66 }
67
68 6 GetOutput() = data_;
69 return true;
70 }
71
72 6 bool VdovinATopologyRulerMPI::PostProcessingImpl() {
73 6 return true;
74 }
75
76 } // namespace vdovin_a_topology_ruler
77