diff --git a/cs677/pa4/maximum-parsimony.cc b/cs677/pa4/maximum-parsimony.cc index 70b4934..a26458f 100644 --- a/cs677/pa4/maximum-parsimony.cc +++ b/cs677/pa4/maximum-parsimony.cc @@ -108,9 +108,16 @@ int main(int argc, char * argv[]) /* after all processes have evaluated their trees, figure out * which process discovered the lowest cost tree */ int processes_lowest_costs[world_size]; - MPI_Gather(&lowest_cost, 1, MPI_INT, - &processes_lowest_costs[0], world_size, MPI_INT, - 0, MPI_COMM_WORLD); + int recvcnts[world_size]; + int displs[world_size]; + for (int i = 0; i < world_size; i++) + { + recvcnts[i] = 1; + displs[i] = i; + } + MPI_Gatherv(&lowest_cost, 1, MPI_INT, + &processes_lowest_costs[0], &recvcnts[0], &displs[0], + MPI_INT, 0, MPI_COMM_WORLD); int min_process = 0; if (my_rank == 0) {