diff --git a/src/parallel.c b/src/parallel.c index cd7548e..5d0430c 100644 --- a/src/parallel.c +++ b/src/parallel.c @@ -130,15 +130,17 @@ void find_end(int residue, char *pattern, char *text, int **matches, int *match_ void search_for_splitted_pattern(int *residue, int *match_number, int **matches) { // send the residue to the next process if (rank + 1 != size) { - MPI_Send(residue, 1, MPI_INT, rank + 1, DEFAULT_TAG, MPI_COMM_WORLD); + MPI_Request request; + MPI_Isend(residue, 1, MPI_INT, rank + 1, DEFAULT_TAG, MPI_COMM_WORLD, &request); } // receiving the residue from the previous process + int other_residue = 0; if (rank != 0) { - MPI_Recv(residue, 1, MPI_INT, rank - 1, DEFAULT_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - if (*residue != 0) + MPI_Recv(&other_residue, 1, MPI_INT, rank - 1, DEFAULT_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + if (other_residue != 0) // search for a split match - find_end(*residue, pattern, private_text, matches, match_number); + find_end(other_residue, pattern, private_text, matches, match_number); } }