Skip to content

Commit 6ccfa2e

Browse files
authored
Update ops_mpi.cpp
1 parent 7848c0b commit 6ccfa2e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

tasks/bruskova_v_char_frequency/mpi/src/ops_mpi.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ bool BruskovaVCharFrequencyMPI::PreProcessingImpl() {
1717
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
1818
if (rank == 0) {
1919
auto *input_ptr = reinterpret_cast<char *>(taskData->inputs[0]);
20-
this->GetInput().first = std::string(input_ptr, taskData->inputs_count[0]);
21-
this->GetInput().second = *reinterpret_cast<char *>(taskData->inputs[1]);
22-
target_char_ = this->GetInput().second;
20+
input_str_ = std::string(input_ptr, taskData->inputs_count[0]);
21+
target_char_ = *reinterpret_cast<char *>(taskData->inputs[1]);
2322
}
2423
return true;
2524
}
@@ -32,7 +31,7 @@ bool BruskovaVCharFrequencyMPI::RunImpl() {
3231

3332
int total_len = 0;
3433
if (rank == 0) {
35-
total_len = static_cast<int>(this->GetInput().first.length());
34+
total_len = static_cast<int>(input_str_.length());
3635
}
3736

3837
MPI_Bcast(&total_len, 1, MPI_INT, 0, MPI_COMM_WORLD);
@@ -48,9 +47,9 @@ bool BruskovaVCharFrequencyMPI::RunImpl() {
4847
for (int i = 1; i < size; ++i) {
4948
int i_local_len = base_len + (i < remainder ? 1 : 0);
5049
int i_start_pos = (i * base_len) + (i < remainder ? i : remainder);
51-
MPI_Send(this->GetInput().first.data() + i_start_pos, i_local_len, MPI_CHAR, i, 0, MPI_COMM_WORLD);
50+
MPI_Send(input_str_.data() + i_start_pos, i_local_len, MPI_CHAR, i, 0, MPI_COMM_WORLD);
5251
}
53-
std::copy(this->GetInput().first.begin(), this->GetInput().first.begin() + local_len, local_str.begin());
52+
std::copy(input_str_.begin(), input_str_.begin() + local_len, local_str.begin());
5453
} else if (local_len > 0) {
5554
MPI_Recv(local_str.data(), local_len, MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
5655
}

0 commit comments

Comments
 (0)