fix my incorrect MPI code

This commit is contained in:
Gavin Ridley 2023-04-24 13:19:29 -04:00
parent abfe5ebf99
commit 8344431ea0

View file

@ -20,21 +20,19 @@ extern "C" bool openmc_master()
vector<int64_t> calculate_parallel_index_vector(int64_t size)
{
vector<int64_t> 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<int64_t> 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;