From 8344431ea06fa9612694d4dcaef00e6e93f8be77 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Mon, 24 Apr 2023 13:19:29 -0400 Subject: [PATCH] fix my incorrect MPI code --- src/message_passing.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/message_passing.cpp b/src/message_passing.cpp index 1630e52c0..374c1aa72 100644 --- a/src/message_passing.cpp +++ b/src/message_passing.cpp @@ -20,21 +20,19 @@ extern "C" bool openmc_master() vector calculate_parallel_index_vector(int64_t size) { vector result; - result.reserve(n_procs + 1); + result.resize(n_procs + 1); + result[0] = 0; #ifdef OPENMC_MPI - result.resize(n_procs); - result[0] = 0; - vector bank_size(n_procs + 1); // Populate the result with cumulative sum of the number of // surface source banks per process - MPI_Scan(&size, bank_size.data(), 1, MPI_INT64_T, MPI_SUM, intracomm); - MPI_Allgather(bank_size.data() + 1, 1, MPI_INT64_T, result.data(), 1, - MPI_INT64_T, intracomm); + int64_t scan_total; + MPI_Scan(&size, &scan_total, 1, MPI_INT64_T, MPI_SUM, intracomm); + MPI_Allgather( + &scan_total, 1, MPI_INT64_T, result.data() + 1, 1, MPI_INT64_T, intracomm); #else - result.push_back(0); - result.push_back(size); + result[1] = size; #endif return result;