Uses asynchronous send

This commit is contained in:
Raffaele Mignone 2021-04-13 15:27:05 +02:00
parent d6f54cf62b
commit 3e9ea923b6
Signed by: norangebit
GPG Key ID: F5255658CB220573

View File

@ -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) { void search_for_splitted_pattern(int *residue, int *match_number, int **matches) {
// send the residue to the next process // send the residue to the next process
if (rank + 1 != size) { 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 // receiving the residue from the previous process
int other_residue = 0;
if (rank != 0) { if (rank != 0) {
MPI_Recv(residue, 1, MPI_INT, rank - 1, DEFAULT_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE); MPI_Recv(&other_residue, 1, MPI_INT, rank - 1, DEFAULT_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
if (*residue != 0) if (other_residue != 0)
// search for a split match // search for a split match
find_end(*residue, pattern, private_text, matches, match_number); find_end(other_residue, pattern, private_text, matches, match_number);
} }
} }