| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "borunov_v_ring/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <mpi.h> | ||
| 4 | |||
| 5 | #include <chrono> | ||
| 6 | #include <cmath> | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "borunov_v_ring/common/include/common.hpp" | ||
| 10 | #include "util/include/util.hpp" | ||
| 11 | |||
| 12 | namespace borunov_v_ring { | ||
| 13 | 40 | BorunovVRingSEQ::BorunovVRingSEQ(const InType &in) { | |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 | 40 | GetInput() = in; | |
| 16 | 40 | } | |
| 17 | |||
| 18 | 40 | bool BorunovVRingSEQ::ValidationImpl() { | |
| 19 |
2/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
|
40 | return (GetInput().source_rank >= 0 && GetInput().target_rank >= 0); |
| 20 | } | ||
| 21 | |||
| 22 | 40 | bool BorunovVRingSEQ::PreProcessingImpl() { | |
| 23 | 40 | return true; | |
| 24 | } | ||
| 25 | |||
| 26 | 40 | bool BorunovVRingSEQ::RunImpl() { | |
| 27 | 40 | int source = GetInput().source_rank; | |
| 28 | 40 | int target = GetInput().target_rank; | |
| 29 | |||
| 30 | 40 | int size = ppc::util::GetNumProc(); | |
| 31 | |||
| 32 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
|
40 | if (ppc::util::IsUnderMpirun()) { |
| 33 | ✗ | int mpi_size = 1; | |
| 34 | ✗ | MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); | |
| 35 | ✗ | if (mpi_size > 0) { | |
| 36 | size = mpi_size; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | 40 | if (size <= 0) { | |
| 41 | size = 1; | ||
| 42 | } | ||
| 43 | |||
| 44 | 40 | source = source % size; | |
| 45 | 40 | target = target % size; | |
| 46 | |||
| 47 | 40 | std::vector<int> path; | |
| 48 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | int current = source; |
| 49 | path.push_back(current); | ||
| 50 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
|
40 | while (current != target) { |
| 51 | ✗ | current = (current + 1) % size; | |
| 52 | path.push_back(current); | ||
| 53 | } | ||
| 54 | |||
| 55 | 40 | auto start_time = std::chrono::steady_clock::now(); | |
| 56 | auto target_duration = std::chrono::milliseconds(800); | ||
| 57 | |||
| 58 | 40 | volatile double sum = 0.0; | |
| 59 | const int iterations = 10000; | ||
| 60 | |||
| 61 |
2/2✓ Branch 1 taken 97216 times.
✓ Branch 2 taken 40 times.
|
97256 | while (std::chrono::steady_clock::now() - start_time < target_duration) { |
| 62 |
2/2✓ Branch 0 taken 972160000 times.
✓ Branch 1 taken 97216 times.
|
972257216 | for (int i = 0; i < iterations; ++i) { |
| 63 | 972160000 | sum += std::sin(static_cast<double>(i)); | |
| 64 | } | ||
| 65 | } | ||
| 66 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | (void)sum; |
| 67 | |||
| 68 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | GetOutput() = path; |
| 69 | 40 | return true; | |
| 70 | } | ||
| 71 | |||
| 72 | 40 | bool BorunovVRingSEQ::PostProcessingImpl() { | |
| 73 | 40 | return true; | |
| 74 | } | ||
| 75 | |||
| 76 | } // namespace borunov_v_ring | ||
| 77 |