Skip to content

Commit

Permalink
decrease buffer length and only form if child processes are present
Browse files Browse the repository at this point in the history
  • Loading branch information
EricaCMitchell committed Sep 12, 2024
1 parent 96ac90e commit 30ce5ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/madness/world/worldgop.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,12 @@ namespace madness {
world_.mpi.binary_tree_info(0, parent, child0, child1);
const std::size_t nelem_per_maxmsg = max_reducebcast_msg_size() / sizeof(T);

auto buf0 = std::unique_ptr<T[]>(new T[nelem_per_maxmsg]);
auto buf1 = std::unique_ptr<T[]>(new T[nelem_per_maxmsg]);
std::unique_ptr<T[]> buf0 = (child0 != -1)
? std::unique_ptr<T[]>(new T[std::min(nelem_per_maxmsg,nelem)])
: nullptr;
std::unique_ptr<T[]> buf1 = (child1 != -1)
? std::unique_ptr<T[]>(new T[std::min(nelem_per_maxmsg,nelem)])
: nullptr;

auto reduce_impl = [&,this](T* buf, int nelem) {
MADNESS_ASSERT(nelem <= nelem_per_maxmsg);
Expand Down

0 comments on commit 30ce5ea

Please sign in to comment.