From 3e9ea923b6ae543ac57205914edf83a75a274eea Mon Sep 17 00:00:00 2001 From: norangebit Date: Tue, 13 Apr 2021 15:27:05 +0200 Subject: [PATCH] Uses asynchronous send --- src/parallel.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); } }