-
Notifications
You must be signed in to change notification settings - Fork 58
kmp5VT [Feature] Round Robin pmap #235
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
33 commits
Select commit
Hold shift + click to select a range
b7ba269
Add round_robin_pmap
kmp5VT c2df90a
Used size_ variable when I should actually use procs_
kmp5VT 398eb4f
If the array doesn't exist on the proc, don't do any loops
kmp5VT 76a85a6
Add round robin pmap unittest
kmp5VT 1cccd1d
Fix round robin to correctly compute local_size
kmp5VT 5655ea7
Fix computation of local_size_ for round_robin_pmap
kmp5VT b026737
Bump BTAS tag
kmp5VT 2f1fee2
Bump btas tag
kmp5VT 55e3be2
Bump BTAS tag
kmp5VT c01f72d
Fix paste artifact and run git-hooks
kmp5VT 390a6ca
run git-hooks: clang-format
kmp5VT e8cb11f
Move round_robin_pmap to correct alphabetical order
kmp5VT bd8ba8a
git-hooks: clang-format
kmp5VT ceb866d
Add round_robin_pmap
kmp5VT 07faf80
Used size_ variable when I should actually use procs_
kmp5VT 618f11c
If the array doesn't exist on the proc, don't do any loops
kmp5VT 547663e
Add round robin pmap unittest
kmp5VT 5885966
Fix round robin to correctly compute local_size
kmp5VT 7b91010
Fix computation of local_size_ for round_robin_pmap
kmp5VT 19f209e
Bump BTAS tag
kmp5VT e1f4353
Bump btas tag
kmp5VT 8b6a1ec
Bump BTAS tag
kmp5VT 540aafd
bump BTAS tag
kmp5VT c9f173a
Bump BTAS tag
kmp5VT 9baf290
Bump BTAS tag
kmp5VT 0f610f0
Update versions.cmake
kmp5VT e883684
Update BTAS tag, as it breaks TA and update install.md
kmp5VT cc293e0
Fix paste artifact and run git-hooks
kmp5VT f58e7b7
run git-hooks: clang-format
kmp5VT 9664309
Move round_robin_pmap to correct alphabetical order
kmp5VT d1e5a34
git-hooks: clang-format
kmp5VT c159b4c
Update versions.cmake
kmp5VT dbb4025
Merge branch 'master' into updated_round_robin
kmp5VT 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
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 |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // | ||
| // Created by Karl Pierce on 7/26/20. | ||
| // | ||
|
|
||
| #ifndef TILEDARRAY_PMAP_ROUND_ROBIN_PMAP_H__INCLUDED | ||
| #define TILEDARRAY_PMAP_ROUND_ROBIN_PMAP_H__INCLUDED | ||
|
|
||
| #include <TiledArray/pmap/pmap.h> | ||
|
|
||
| namespace TiledArray { | ||
| namespace detail { | ||
|
|
||
| /// A blocked process map | ||
|
|
||
| /// Map N elements among P processes into blocks that are approximately N/P | ||
| /// elements in size. A minimum block size may also be specified. | ||
| class RoundRobinPmap : public Pmap { | ||
| protected: | ||
| // Import Pmap protected variables | ||
| using Pmap::procs_; ///< The number of processes | ||
| using Pmap::rank_; ///< The rank of this process | ||
| using Pmap::size_; ///< The number of tiles mapped among all processes | ||
|
|
||
| private: | ||
| const size_type remainder_; ///< tile remainder (= size_ % procs_) | ||
|
|
||
| public: | ||
| typedef Pmap::size_type size_type; ///< Key type | ||
|
|
||
| /// Construct Round Robin map | ||
|
|
||
| /// \param world The world where the tiles will be mapped | ||
| /// \param size The number of tiles to be mapped | ||
| RoundRobinPmap(World& world, size_type size) | ||
| : Pmap(world, size), remainder_(size_ % procs_) { | ||
| auto num_tiles_per_proc = size / procs_; | ||
| if (remainder_ == 0 || rank_ >= remainder_) | ||
| this->local_size_ = num_tiles_per_proc; | ||
| else | ||
| this->local_size_ = num_tiles_per_proc + 1; | ||
| } | ||
|
|
||
| virtual ~RoundRobinPmap() {} | ||
|
|
||
| /// Maps \c tile to the processor that owns it | ||
|
|
||
| /// \param tile The tile to be queried | ||
| /// \return Processor that logically owns \c tile | ||
| virtual size_type owner(const size_type tile) const { | ||
| TA_ASSERT(tile < size_); | ||
| return (tile % procs_); | ||
| } | ||
|
|
||
| /// Check that the tile is owned by this process | ||
|
|
||
| /// \param tile The tile to be checked | ||
| /// \return \c true if \c tile is owned by this process, otherwise \c false . | ||
| virtual bool is_local(const size_type tile) const { | ||
| return (tile % procs_ == rank_); | ||
| } | ||
|
|
||
| }; // class RoundRobinPmap | ||
|
|
||
| } // namespace detail | ||
| } // namespace TiledArray | ||
|
|
||
| #endif // TILEDARRAY_PMAP_ROUND_ROBIN_PMAP_H__INCLUDED | ||
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 |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /* | ||
| * This file is a part of TiledArray. | ||
| * Copyright (C) 2013 Virginia Tech | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| #include "TiledArray/pmap/round_robin_pmap.h" | ||
| #include "global_fixture.h" | ||
| #include "tiledarray.h" | ||
| #include "unit_test_config.h" | ||
|
|
||
| using namespace TiledArray; | ||
|
|
||
| struct RoundRobinPmapFixture { | ||
| RoundRobinPmapFixture() {} | ||
| }; | ||
|
|
||
| // ============================================================================= | ||
| // RoundRobinPmap Test Suite | ||
|
|
||
| BOOST_FIXTURE_TEST_SUITE(round_robin_pmap_suite, RoundRobinPmapFixture) | ||
|
|
||
| BOOST_AUTO_TEST_CASE(constructor) { | ||
| for (std::size_t tiles = 1ul; tiles < 100ul; ++tiles) { | ||
| BOOST_REQUIRE_NO_THROW( | ||
| TiledArray::detail::RoundRobinPmap pmap(*GlobalFixture::world, tiles)); | ||
| TiledArray::detail::RoundRobinPmap pmap(*GlobalFixture::world, tiles); | ||
| BOOST_CHECK_EQUAL(pmap.rank(), GlobalFixture::world->rank()); | ||
| BOOST_CHECK_EQUAL(pmap.procs(), GlobalFixture::world->size()); | ||
| BOOST_CHECK_EQUAL(pmap.size(), tiles); | ||
| } | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(owner) { | ||
| const std::size_t rank = GlobalFixture::world->rank(); | ||
| const std::size_t size = GlobalFixture::world->size(); | ||
|
|
||
| ProcessID *p_owner = new ProcessID[size]; | ||
|
|
||
| // Check various pmap sizes | ||
| for (std::size_t tiles = 1ul; tiles < 100ul; ++tiles) { | ||
| TiledArray::detail::RoundRobinPmap pmap(*GlobalFixture::world, tiles); | ||
|
|
||
| for (std::size_t tile = 0; tile < tiles; ++tile) { | ||
| std::fill_n(p_owner, size, 0); | ||
| p_owner[rank] = pmap.owner(tile); | ||
| // check that the value is in range | ||
| BOOST_CHECK_LT(p_owner[rank], size); | ||
| GlobalFixture::world->gop.sum(p_owner, size); | ||
|
|
||
| // Make sure everyone agrees on who owns what. | ||
| for (std::size_t p = 0ul; p < size; ++p) | ||
| BOOST_CHECK_EQUAL(p_owner[p], p_owner[rank]); | ||
| } | ||
| } | ||
|
|
||
| delete[] p_owner; | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(local_size) { | ||
| for (std::size_t tiles = 1ul; tiles < 100ul; ++tiles) { | ||
| TiledArray::detail::RoundRobinPmap pmap(*GlobalFixture::world, tiles); | ||
|
|
||
| std::size_t total_size = pmap.local_size(); | ||
| GlobalFixture::world->gop.sum(total_size); | ||
|
|
||
| // Check that the total number of elements in all local groups is equal to | ||
| // the number of tiles in the map. | ||
| BOOST_CHECK_EQUAL(total_size, tiles); | ||
| BOOST_CHECK(pmap.empty() == (pmap.local_size() == 0ul)); | ||
| } | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(local_group) { | ||
| ProcessID tile_owners[100]; | ||
|
|
||
| for (std::size_t tiles = 1ul; tiles < 100ul; ++tiles) { | ||
| TiledArray::detail::RoundRobinPmap pmap(*GlobalFixture::world, tiles); | ||
|
|
||
| // Check that all local elements map to this rank | ||
| for (detail::RoundRobinPmap::const_iterator it = pmap.begin(); | ||
| it != pmap.end(); ++it) { | ||
| BOOST_CHECK_EQUAL(pmap.owner(*it), GlobalFixture::world->rank()); | ||
| } | ||
|
|
||
| std::fill_n(tile_owners, tiles, 0); | ||
| for (detail::RoundRobinPmap::const_iterator it = pmap.begin(); | ||
| it != pmap.end(); ++it) { | ||
| tile_owners[*it] += GlobalFixture::world->rank(); | ||
| } | ||
|
|
||
| GlobalFixture::world->gop.sum(tile_owners, tiles); | ||
| for (std::size_t tile = 0; tile < tiles; ++tile) { | ||
| BOOST_CHECK_EQUAL(tile_owners[tile], pmap.owner(tile)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_SUITE_END() |
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.
Uh oh!
There was an error while loading. Please reload this page.