| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "pikhotskiy_r_scatter/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <mpi.h> | ||
| 4 | |||
| 5 | #include <cstddef> | ||
| 6 | #include <cstring> | ||
| 7 | |||
| 8 | #include "pikhotskiy_r_scatter/common/include/common.hpp" | ||
| 9 | |||
| 10 | namespace pikhotskiy_r_scatter { | ||
| 11 | |||
| 12 | 32 | PikhotskiyRScatterSEQ::PikhotskiyRScatterSEQ(const InType &in) { | |
| 13 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 14 | GetInput() = in; | ||
| 15 | GetOutput() = nullptr; | ||
| 16 | 32 | } | |
| 17 | |||
| 18 | ✗ | size_t PikhotskiyRScatterSEQ::GetTypeSize(MPI_Datatype datatype) { | |
| 19 | ✗ | if (datatype == MPI_INT) { | |
| 20 | return sizeof(int); | ||
| 21 | } | ||
| 22 |
2/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
16 | if (datatype == MPI_FLOAT) { |
| 23 | return sizeof(float); | ||
| 24 | } | ||
| 25 |
1/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | if (datatype == MPI_DOUBLE) { |
| 26 | ✗ | return sizeof(double); | |
| 27 | } | ||
| 28 | return 0; | ||
| 29 | } | ||
| 30 | |||
| 31 | 32 | bool PikhotskiyRScatterSEQ::ValidationImpl() { | |
| 32 | const auto &input_data = GetInput(); | ||
| 33 | 32 | int send_element_count = std::get<1>(input_data); | |
| 34 | 32 | MPI_Datatype send_datatype = std::get<2>(input_data); | |
| 35 | 32 | void *receive_data_ptr = std::get<3>(input_data); | |
| 36 | 32 | int receive_element_count = std::get<4>(input_data); | |
| 37 | 32 | MPI_Datatype receive_datatype = std::get<5>(input_data); | |
| 38 | int root_process = std::get<6>(input_data); | ||
| 39 | MPI_Comm comm = std::get<7>(input_data); | ||
| 40 | |||
| 41 | (void)receive_datatype; | ||
| 42 | (void)root_process; | ||
| 43 | (void)comm; | ||
| 44 | |||
| 45 |
1/2✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
|
32 | if (send_element_count < 0 || receive_element_count < 0) { |
| 46 | return false; | ||
| 47 | } | ||
| 48 | |||
| 49 |
1/2✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
|
32 | if (send_element_count != receive_element_count) { |
| 50 | return false; | ||
| 51 | } | ||
| 52 | |||
| 53 |
1/2✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
|
32 | if (send_datatype != receive_datatype) { |
| 54 | return false; | ||
| 55 | } | ||
| 56 | |||
| 57 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
|
32 | if (receive_element_count > 0 && receive_data_ptr == nullptr) { |
| 58 | ✗ | return false; | |
| 59 | } | ||
| 60 | |||
| 61 | return true; | ||
| 62 | } | ||
| 63 | |||
| 64 | 32 | bool PikhotskiyRScatterSEQ::PreProcessingImpl() { | |
| 65 | 32 | return true; | |
| 66 | } | ||
| 67 | |||
| 68 | 32 | bool PikhotskiyRScatterSEQ::RunImpl() { | |
| 69 | const auto &input_data = GetInput(); | ||
| 70 | 32 | const void *send_data_ptr = std::get<0>(input_data); | |
| 71 | int send_element_count = std::get<1>(input_data); | ||
| 72 | 32 | MPI_Datatype send_datatype = std::get<2>(input_data); | |
| 73 | 32 | void *receive_data_ptr = std::get<3>(input_data); | |
| 74 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
|
32 | int receive_element_count = std::get<4>(input_data); |
| 75 | MPI_Datatype receive_datatype = std::get<5>(input_data); | ||
| 76 | int root_process = std::get<6>(input_data); | ||
| 77 | MPI_Comm comm = std::get<7>(input_data); | ||
| 78 | |||
| 79 | (void)send_element_count; | ||
| 80 | (void)receive_datatype; | ||
| 81 | (void)root_process; | ||
| 82 | (void)comm; | ||
| 83 | |||
| 84 | size_t element_size = GetTypeSize(send_datatype); | ||
| 85 | |||
| 86 | 32 | size_t total_copy_size = static_cast<size_t>(receive_element_count) * element_size; | |
| 87 | |||
| 88 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
|
32 | if (total_copy_size > 0) { |
| 89 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (send_data_ptr != nullptr) { |
| 90 | std::memcpy(receive_data_ptr, send_data_ptr, total_copy_size); | ||
| 91 | } else { | ||
| 92 | std::memset(receive_data_ptr, 0, total_copy_size); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | 32 | GetOutput() = receive_data_ptr; | |
| 97 | |||
| 98 | 32 | return true; | |
| 99 | } | ||
| 100 | |||
| 101 | 32 | bool PikhotskiyRScatterSEQ::PostProcessingImpl() { | |
| 102 | 32 | return true; | |
| 103 | } | ||
| 104 | |||
| 105 | } // namespace pikhotskiy_r_scatter | ||
| 106 |