Skip to content
Snippets Groups Projects
Commit bf26d145 authored by alexgara's avatar alexgara
Browse files

error in second loop

parent 2e2666e2
Branches
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@
#define END_SIG -2
/* Macro for checking mpi funcs and print if there is a error */
#define MPI_CHEK_FUCKTION( call) {int ierr = 1; int resultlen; if (ierr != MPI_SUCCESS){ char error_msg[MPI_MAX_ERROR_STRING]; MPI_Error_string(ierr, error_msg, &resultlen); fprintf(stderr, "MPI fallo en linea (%d):\n%s\n", __LINE__, error_msg); MPI_Abort(MPI_COMM_WORLD, -1);}}
#define MPI_CHEK_FUCKTION( call ) {int ierr = call; int resultlen; if (ierr != MPI_SUCCESS){ char error_msg[MPI_MAX_ERROR_STRING]; MPI_Error_string(ierr, error_msg, &resultlen); fprintf(stderr, "MPI fallo en linea (%d):\n%s\n\n", __LINE__, error_msg); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); fflush(stdout);}}
/*
* Function: Increment the number of pattern matches on the sequence positions
......@@ -401,6 +401,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr,"Error al crear envio_array en proc:%d\n", rank );
MPI_Abort( MPI_COMM_WORLD, EXIT_FAILURE );
}
unsigned long *recibo_array = (unsigned long*) malloc(sizeof(unsigned long)*3);
if ( recibo_array == NULL ) {
fprintf(stderr,"Error al crear recibo_array en proc:%d\n", rank );
......@@ -422,7 +423,6 @@ int main(int argc, char *argv[]) {
envio_array[2]=pat;
//Envio el parton para que continue el siguente que le toca
MPI_CHEK_FUCKTION(MPI_Isend(envio_array, 3, MPI_UNSIGNED_LONG, rank+1, TAG_NO_COMPLETE, MPI_COMM_WORLD, &request));
send_to_continue_flag = 1;
break;
......@@ -450,9 +450,13 @@ int main(int argc, char *argv[]) {
envio_array[1] = (unsigned long) END_SIG;
envio_array[2] = (unsigned long) END_SIG;
MPI_CHEK_FUCKTION(MPI_Isend(envio_array, 3, MPI_UNSIGNED_LONG, rank+1, TAG_END, MPI_COMM_WORLD, &request));
}
MPI_CHEK_FUCKTION(MPI_Barrier(MPI_COMM_WORLD));
printf("==================\n rank=%d LLEGA pat=%lu, sig=%d\n", rank, pat, rank+1);
fflush(stdout);
MPI_CHEK_FUCKTION(MPI_Barrier(MPI_COMM_WORLD));
//NOW PROCESS CHECK FOR THE REAMAING PATTERN THAT ITS PREVIOUS DOSENT HAVE FOUND
int start_r, pat_r, length_r;
while(1 && (rank != 0)){
......@@ -461,8 +465,10 @@ int main(int argc, char *argv[]) {
//First check if the previous process has finished & have nothing more to do
MPI_CHEK_FUCKTION(MPI_Recv(recibo_array, 3, MPI_UNSIGNED_LONG, rank-1, MPI_ANY_TAG, MPI_COMM_WORLD, &status));
printf("\n RECIBE(%d) rank=%d desde rank-1=%d pat=%lu con TAG=%d\n", (status.MPI_TAG==TAG_END) ,rank, status.MPI_SOURCE, recibo_array[2], status.MPI_TAG);
//THEN its end sigal the first so no more thing to do
if(status.MPI_TAG == END_SIG) break;
if(status.MPI_TAG == TAG_END) break;
//else continue because the rank-1 send work to do
start_r = recibo_array[0];
......@@ -480,6 +486,7 @@ int main(int argc, char *argv[]) {
//Send to the next rank
MPI_CHEK_FUCKTION(MPI_Isend(envio_array, 3, MPI_UNSIGNED_LONG, rank+1, TAG_NO_COMPLETE, MPI_COMM_WORLD, &request));
//printf("\n ENVIA(%d) rank=%d a rank+1=%d pat=%lu\n", (1), rank, rank+1, envio_array[2]);
send_to_continue_flag = 1;
break;
}
......@@ -498,6 +505,9 @@ int main(int argc, char *argv[]) {
}
}
printf("\nTERMINO rank=%d LLEGA pat=%lu, sig=%d\n", rank, pat, rank+1);
fflush(stdout);
//If its outside then send signal to the next that there is no more patterns
if(rank != 0){
envio_array[0] = END_SIG;
......@@ -505,6 +515,7 @@ int main(int argc, char *argv[]) {
envio_array[2] = END_SIG;
MPI_CHEK_FUCKTION(MPI_Isend(envio_array, 3, MPI_UNSIGNED_LONG, rank+1, TAG_END, MPI_COMM_WORLD, &request));
}
MPI_CHEK_FUCKTION(MPI_Barrier(MPI_COMM_WORLD));
unsigned long *recive_pat_found;
......@@ -533,11 +544,13 @@ int main(int argc, char *argv[]) {
//The other ranks send to the master
MPI_CHEK_FUCKTION(MPI_Reduce(pat_found, NULL, pat_number, MPI_UNSIGNED_LONG, MPI_MIN, 0, MPI_COMM_WORLD));
if(rank == 1 || rank == 2)
if(rank == 1 || rank == 2){
MPI_CHEK_FUCKTION(MPI_Recv(recive_pat_found, pat_number, MPI_UNSIGNED_LONG, 0, TAG_SEND_PAT_FOUND, MPI_COMM_WORLD, &status));
}
}
/* 7. Check sums */
unsigned long checksum_matches = 0;
unsigned long checksum_found = 0;
......@@ -560,8 +573,9 @@ int main(int argc, char *argv[]) {
}
//Recv the calculated checksum from rank 1
if( rank == 0)
if( rank == 0) {
MPI_CHEK_FUCKTION(MPI_Recv(&checksum_found, 1, MPI_UNSIGNED_LONG, 1, TAG_SEND_CHECKSUM, MPI_COMM_WORLD, &status));
}
// rank 2 TODO calculate checksum_matches
/** Esta parte de momento la consideramos opcional
......
$ ./align_seq 500000 0.15 0.4 0.15 1120 20 10 2110 50000 500 7000 4000 M 346536
./align_seq 500000 0.15 0.4 0.15 1120 20 10 2110 50000 500 7000 4000 M 346536
Time: 10.761040
Result: 1900, 5291, 30391, 17177
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment