Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in stable_distribute function. #27

Merged
merged 1 commit into from
Jun 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/mxx/distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ void stable_distribute(_InIterator begin, _InIterator end, _OutIterator out, con
// calculate where to send elements
// if there are any elements to send
std::vector<size_t> send_counts(comm.size(), 0);
blk_dist part(total_size, comm);
if (local_size > 0) {
blk_dist part(total_size, comm.size(), comm.rank());
int first_p = part.rank_of(prefix);
size_t left_to_send = local_size;
for (; left_to_send > 0 && first_p < comm.size(); ++first_p) {
Expand All @@ -126,7 +126,11 @@ void stable_distribute(_InIterator begin, _InIterator end, _OutIterator out, con
}
std::vector<size_t> recv_counts = mxx::all2all(send_counts, comm);
// TODO: accept iterators in mxx::all2all?
mxx::all2allv(&(*begin), send_counts, &(*out), recv_counts, comm);
using SendType = typename std::iterator_traits<_InIterator>::value_type;
using RecvType = typename std::iterator_traits<_OutIterator>::value_type;
const SendType* send_buf = (local_size > 0) ? &(*begin) : nullptr;
RecvType* recv_buf = (part.local_size() > 0) ? &(*out) : nullptr;
mxx::all2allv(send_buf, send_counts, recv_buf, recv_counts, comm);
}
}

Expand Down