-
Notifications
You must be signed in to change notification settings - Fork 13
push_parallel_packed_range fixes and improvements #33
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5e79b09
Clean up C++ headers in packing.h
roystgnr f42d11d
Remove atavistic variables
roystgnr 48fbe7f
Fix possibly-uninitialized variable warning
roystgnr f88416f
Container-agnostic push_parallel_packed_range
roystgnr 4caf533
No timpi_experimental on nonblocking packed_range
roystgnr 21b67da
Unit tests for push_parallel_packed_range
roystgnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| #include <timpi/parallel_sync.h> | ||
| #include <timpi/timpi.h> | ||
|
|
||
| #include <iterator> | ||
| #include <map> | ||
| #include <set> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #define TIMPI_UNIT_ASSERT(expr) \ | ||
|
|
@@ -197,6 +201,92 @@ Communicator *TestCommWorld; | |
| TIMPI_UNIT_ASSERT(recv[0] == check); | ||
| } | ||
|
|
||
| void testPushPackedImpl(int M) | ||
|
Member
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. Hah, this should have been done a long time ago. Whoops. |
||
| { | ||
| const int size = TestCommWorld->size(), | ||
| rank = TestCommWorld->rank(); | ||
|
|
||
| std::map<processor_id_type, std::multiset<std::string>> | ||
| data, received_data; | ||
|
|
||
| auto stringy_number = [] (int number) | ||
| { | ||
| std::string digit_strings [10] = {"zero", "one", "two", | ||
| "three", "four", "five", "six", "seven", "eight", "nine"}; | ||
|
|
||
| std::string returnval = "done"; | ||
| while (number) | ||
| { | ||
| returnval = digit_strings[number%10]+" "+returnval; | ||
| number = number/10; | ||
| }; | ||
|
|
||
| return returnval; | ||
| }; | ||
|
|
||
| for (int d=0; d != M; ++d) | ||
| { | ||
| int diffsize = std::abs(d-rank); | ||
| int diffsqrt = std::sqrt(diffsize); | ||
| if (diffsqrt*diffsqrt == diffsize) | ||
| for (int i=-1; i != diffsqrt; ++i) | ||
| data[d].insert(stringy_number(d)); | ||
| } | ||
|
|
||
| auto collect_data = | ||
| [&received_data] | ||
| (processor_id_type pid, | ||
| const typename std::multiset<std::string> & data) | ||
| { | ||
| auto & received = received_data[pid]; | ||
| received.insert(data.begin(), data.end()); | ||
| }; | ||
|
|
||
| void * context = nullptr; | ||
| TIMPI::push_parallel_packed_range(*TestCommWorld, data, context, collect_data); | ||
|
|
||
| // Test the received results, for each processor id p we're in | ||
| // charge of. | ||
| std::vector<std::size_t> checked_sizes(size, 0); | ||
| for (int p=rank; p < M; p += size) | ||
| for (int srcp=0; srcp != size; ++srcp) | ||
| { | ||
| int diffsize = std::abs(srcp-p); | ||
| int diffsqrt = std::sqrt(diffsize); | ||
| if (diffsqrt*diffsqrt != diffsize) | ||
| { | ||
| if (received_data.count(srcp)) | ||
| { | ||
| const std::multiset<std::string> & datum = received_data[srcp]; | ||
| TIMPI_UNIT_ASSERT | ||
| (std::count(datum.begin(), datum.end(), | ||
| stringy_number(p)) == std::ptrdiff_t(0)); | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| TIMPI_UNIT_ASSERT(received_data.count(srcp) == std::size_t(1)); | ||
| const std::multiset<std::string> & datum = received_data[srcp]; | ||
| TIMPI_UNIT_ASSERT | ||
| (std::count(datum.begin(), datum.end(), stringy_number(p)) == | ||
| std::ptrdiff_t(diffsqrt+1)); | ||
| checked_sizes[srcp] += diffsqrt+1; | ||
| } | ||
|
|
||
| for (int srcp=0; srcp != size; ++srcp) | ||
| TIMPI_UNIT_ASSERT(checked_sizes[srcp] == received_data[srcp].size()); | ||
|
|
||
| } | ||
|
|
||
| void testPushPacked() | ||
| { | ||
| testPushPackedImpl(TestCommWorld->size()); | ||
| } | ||
|
|
||
| void testPushPackedOversized() | ||
| { | ||
| testPushPackedImpl((TestCommWorld->size() + 4) * 2); | ||
| } | ||
|
|
||
| int main(int argc, const char * const * argv) | ||
| { | ||
|
|
@@ -207,6 +297,8 @@ int main(int argc, const char * const * argv) | |
| testNullSendReceive(); | ||
| testContainerAllGather(); | ||
| testContainerSendReceive(); | ||
| testPushPacked(); | ||
| testPushPackedOversized(); | ||
|
|
||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is a really good switch.