Move sending of remain
This commit is contained in:
parent
f19c43bb67
commit
5cdbeea5db
14
main.c
14
main.c
@ -44,13 +44,6 @@ int main() {
|
||||
|
||||
distribute_text();
|
||||
|
||||
// sending the remain to the last trial
|
||||
// this is necessary for the calculation of the offset
|
||||
if (rank == MASTER)
|
||||
MPI_Send(&remain, 1, MPI_INT, size - 1, DEFAULT_TAG, MPI_COMM_WORLD);
|
||||
else if (rank == size - 1)
|
||||
MPI_Recv(&remain, 1, MPI_INT, MASTER, DEFAULT_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
||||
|
||||
printf("%d -> input: %s\n", rank, private_text);
|
||||
printf("%d -> text len: %d\n", rank, private_text_len);
|
||||
|
||||
@ -87,6 +80,13 @@ int main() {
|
||||
find_end(residue, pattern, private_text, &matches, &match_number);
|
||||
}
|
||||
|
||||
// sending the remain to the last process
|
||||
// this is necessary for the calculation of shift amount
|
||||
if (rank == MASTER)
|
||||
MPI_Send(&remain, 1, MPI_INT, size - 1, DEFAULT_TAG, MPI_COMM_WORLD);
|
||||
else if (rank == size - 1)
|
||||
MPI_Recv(&remain, 1, MPI_INT, MASTER, DEFAULT_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
||||
|
||||
// transformation of match indices from relative to absolute position.
|
||||
int shift = rank * (private_text_len - remain); // the rest is zero for all but the last process
|
||||
apply_shift(shift, matches, match_number);
|
||||
|
Loading…
Reference in New Issue
Block a user