-
Notifications
You must be signed in to change notification settings - Fork 20
Fix in stable_distribute and stable_distribute_inplace #25
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,15 +111,18 @@ void stable_distribute(_InIterator begin, _InIterator end, _OutIterator out, con | |
| size_t prefix = mxx::exscan(local_size, comm); | ||
|
|
||
| // 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.size(), comm.rank()); | ||
| int first_p = part.rank_of(prefix); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the line that leads to an error if |
||
| size_t left_to_send = local_size; | ||
| for (; left_to_send > 0 && first_p < comm.size(); ++first_p) { | ||
| size_t nsend = std::min<size_t>(part.iprefix_size(first_p) - prefix, left_to_send); | ||
| send_counts[first_p] = nsend; | ||
| left_to_send -= nsend; | ||
| prefix += nsend; | ||
| 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) { | ||
| size_t nsend = std::min<size_t>(part.iprefix_size(first_p) - prefix, left_to_send); | ||
| send_counts[first_p] = nsend; | ||
| left_to_send -= nsend; | ||
| prefix += nsend; | ||
| } | ||
| } | ||
| std::vector<size_t> recv_counts = mxx::all2all(send_counts, comm); | ||
| // TODO: accept iterators in mxx::all2all? | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,6 +143,16 @@ TEST(MxxDistribution, DistributeVector) { | |
|
|
||
| test_distribute<std::vector<int>>(size, gen, c); | ||
| test_stable_distribute<std::vector<int>>(size, gen, c); | ||
|
|
||
| // create a distribution of total size smaller than | ||
| // the total number of processes and zero elements on the last process | ||
| size = (c.rank() % 2 == 0) ? 1 : 0; | ||
| if (c.is_last()) { | ||
| size = 0; | ||
| } | ||
| // XXX: test_distribute fails with an assertion error in mxx::sort | ||
| // test_distribute<std::vector<int>>(size, gen, c); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to fail with an assertion error in sample_distribute. Is that expected? |
||
| test_stable_distribute<std::vector<int>>(size, gen, c); | ||
| } | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefixmay be the same astotal_sizeif the processes with rank lower than the current process have all the input elements.