Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/framework/containers/particles_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,24 @@ namespace ntt {
}

#if !defined(MPI_ENABLED)
const npart_t nout_offset = 0;
const npart_t nout_total = nout;
const std::size_t nout_offset = 0;
const std::size_t nout_total = nout;
(void)domains_total;
(void)domains_offset;
#else
npart_t nout_offset = 0;
npart_t nout_total = nout;
auto nout_total_vec = std::vector<npart_t>(domains_total);
// global totals/offsets are sums over all ranks and can exceed the
// per-rank `npart_t` (uint32_t) range at large problem sizes, so
// accumulate them in a 64-bit type
std::size_t nout_offset = 0;
std::size_t nout_total = 0;
auto nout_total_vec = std::vector<npart_t>(domains_total);
MPI_Allgather(&nout,
1,
mpi::get_type<npart_t>(),
nout_total_vec.data(),
1,
mpi::get_type<npart_t>(),
MPI_COMM_WORLD);
nout_total = 0;
for (auto r = 0u; r < domains_total; ++r) {
if (r < domains_offset) {
nout_offset += nout_total_vec[r];
Expand Down Expand Up @@ -442,10 +444,13 @@ namespace ntt {
set_npart(npart_read);

#if !defined(MPI_ENABLED)
const npart_t npart_offset = 0u;
const std::size_t npart_offset = 0u;
(void)domains_total;
#else
npart_t npart_offset = 0u;
// global offset is a sum over all ranks and can exceed the per-rank
// `npart_t` (uint32_t) range at large problem sizes, so accumulate
// it in a 64-bit type
std::size_t npart_offset = 0u;
{
const auto npart_send = npart();
std::vector<npart_t> glob_nparts(domains_total);
Expand Down Expand Up @@ -618,8 +623,11 @@ namespace ntt {
fmt::format("Writing particle checkpoint for species #%d", index()),
HERE);

npart_t npart_offset = 0u;
npart_t npart_total = npart();
// global totals/offsets are sums over all ranks and can exceed the
// per-rank `npart_t` (uint32_t) range at large problem sizes, so
// accumulate them in a 64-bit type
std::size_t npart_offset = 0u;
std::size_t npart_total = npart();

#if defined(MPI_ENABLED)
{
Expand Down
Loading