GCC Code Coverage Report


Directory: ./
File: tasks/orehov_n_topology_star/mpi/src/ops_mpi.cpp
Date: 2026-01-09 01:27:18
Exec Total Coverage
Lines: 48 51 94.1%
Functions: 5 5 100.0%
Branches: 35 60 58.3%

Line Branch Exec Source
1 #include "orehov_n_topology_star/mpi/include/ops_mpi.hpp"
2
3 #include <mpi.h>
4
5 #include <tuple>
6 #include <vector>
7
8 #include "orehov_n_topology_star/common/include/common.hpp"
9
10 namespace orehov_n_topology_star {
11
12
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 OrehovNTopologyStarMPI::OrehovNTopologyStarMPI(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 10 GetOutput() = std::vector<int>();
16 10 }
17
18 10 bool OrehovNTopologyStarMPI::ValidationImpl() {
19 10 int count_process = 0;
20 10 int rank = 0;
21 10 int status = 1;
22 bool error = true;
23 10 MPI_Comm_size(MPI_COMM_WORLD, &count_process);
24 10 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
25
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 if (rank == 0) {
26 5 int source = std::get<0>(GetInput());
27 5 int dest = std::get<1>(GetInput());
28 5 int size_array = std::get<2>(GetInput());
29
30
5/10
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
5 error = (source >= 0 && source < count_process) && (dest >= 0 && dest < count_process) && (size_array >= 0);
31
32
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (count_process == 1) {
33 error = true;
34 }
35 }
36 10 status = static_cast<int>(error);
37 10 MPI_Bcast(&status, 1, MPI_INT, 0, MPI_COMM_WORLD);
38 10 return (status == 1);
39 }
40
41 10 bool OrehovNTopologyStarMPI::PreProcessingImpl() {
42 10 return true;
43 }
44
45 10 bool OrehovNTopologyStarMPI::RunImpl() {
46 10 int size = 0;
47 10 int rank = 0;
48 int dest = 0;
49 int source = 0;
50 int size_array = 0;
51
52 10 MPI_Comm_size(MPI_COMM_WORLD, &size);
53 10 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
54
55 10 source = std::get<0>(GetInput());
56 10 dest = std::get<1>(GetInput());
57 10 size_array = std::get<2>(GetInput());
58
59 10 std::vector<int> data(size_array);
60
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (size == 1) {
61 data = std::get<3>(GetInput());
62 GetOutput() = data;
63 return true;
64 }
65
66
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if (source == dest) {
67
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 data = std::get<3>(GetInput());
68
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 MPI_Bcast(data.data(), size_array, MPI_INT, dest, MPI_COMM_WORLD);
69
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 GetOutput() = data;
70 return true;
71 }
72
73
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if (rank == source) {
74
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 data = std::get<3>(GetInput());
75
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if (source != 0) {
76
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 MPI_Send(data.data(), size_array, MPI_INT, 0, 0, MPI_COMM_WORLD);
77 } else {
78
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 MPI_Send(data.data(), size_array, MPI_INT, dest, 0, MPI_COMM_WORLD);
79 }
80 }
81
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
6 if (rank == 0 && source != 0) {
82
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 MPI_Recv(data.data(), size_array, MPI_INT, source, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
83
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (dest != 0) {
84 MPI_Send(data.data(), size_array, MPI_INT, dest, 0, MPI_COMM_WORLD);
85 }
86 }
87
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
6 if (rank == dest && dest != 0) {
88
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 MPI_Recv(data.data(), size_array, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
89 }
90
91
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 MPI_Bcast(data.data(), size_array, MPI_INT, dest, MPI_COMM_WORLD);
92
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 GetOutput() = data;
93 return true;
94 }
95
96 10 bool OrehovNTopologyStarMPI::PostProcessingImpl() {
97 10 return true;
98 }
99
100 } // namespace orehov_n_topology_star
101