Commit 74048aba authored by iker_martin's avatar iker_martin
Browse files

Bugfix for Data Redistribution with Merge Expand. Array sizes for parents...

Bugfix for Data Redistribution with Merge Expand. Array sizes for parents should always be the total amount of particular processes between both groups. Also a minor refactor in distribution.c
parent 08b89e91
......@@ -373,11 +373,22 @@ void async_point2point(char *send, char *recv, struct Counts s_counts, struct Co
*
*/
void prepare_redistribution(int qty, int myId, int numP, int numO, int is_children_group, int is_intercomm, char **recv, struct Counts *s_counts, struct Counts *r_counts) {
int init_struct = 1;
int array_size, init_struct = 1;
struct Dist_data dist_data;
array_size = numO;
if(!is_intercomm) {
array_size = numP > numO ? numP : numO;
}
if(is_children_group) {
mallocCounts(s_counts, numO);
if(is_intercomm) {
mallocCounts(s_counts, numO);
} else { // Merge method needs an array equal to the number of processes
mallocCounts(s_counts, array_size);
mallocCounts(r_counts, array_size);
init_struct = 0;
}
prepare_comm_alltoall(myId, numP, numO, qty, init_struct, r_counts);
// Obtener distribución para este hijo
get_block_dist(qty, myId, numP, &dist_data);
......@@ -391,22 +402,19 @@ void prepare_redistribution(int qty, int myId, int numP, int numO, int is_childr
mallocCounts(r_counts, numO);
prepare_comm_alltoall(myId, numP, numO, qty, init_struct, s_counts);
} else {
mallocCounts(s_counts, array_size);
mallocCounts(r_counts, array_size);
init_struct = 0;
prepare_comm_alltoall(myId, numP, numO, qty, init_struct, s_counts);
if(myId < numO) {
prepare_comm_alltoall(myId, numO, numP, qty, init_struct, r_counts);
// Obtener distribución para este hijo
get_block_dist(qty, myId, numO, &dist_data);
*recv = malloc(dist_data.tamBl * sizeof(char));
} else {
mallocCounts(r_counts, numP);
}
if(numP > numO) { // Shrink
mallocCounts(s_counts, numP);
init_struct = 0;
}
prepare_comm_alltoall(myId, numP, numO, qty, init_struct, s_counts);
//print_counts(dist_data, r_counts->counts, r_counts->displs, numP, 0, "Children P ");
//print_counts(dist_data, r_counts->counts, r_counts->displs, array_size, 0, "Children P ");
}
//print_counts(dist_data, s_counts->counts, s_counts->displs, numO, 0, "Parents ");
}
......
......@@ -39,11 +39,11 @@ void prepare_comm_alltoall(int myId, int numP, int numP_other, int n, int init_s
for(i=0; i<numP_other; i++) {
if(counts->counts[i] < 0) {
fprintf(stderr, "Counts value [i=%d] is negative for rank %d/%d", i, myId, numP);
fprintf(stderr, "Counts value [i=%d/%d] is negative for rank %d/%d ", i, numP_other, myId, numP);
MPI_Abort(MPI_COMM_WORLD, -3);
}
if(counts->displs[i] < 0) {
fprintf(stderr, "Displs value [i=%d] is negative for rank %d/%d", i, myId, numP);
fprintf(stderr, "Displs value [i=%d/%d] is negative for rank %d/%d ", i, numP_other, myId, numP);
MPI_Abort(MPI_COMM_WORLD, -3);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment