From b7ba2695d5492115a02375d688c9b10b43f48bd6 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Mon, 27 Jul 2020 12:54:09 -0400 Subject: [PATCH 01/32] Add round_robin_pmap --- src/CMakeLists.txt | 1 + src/TiledArray/pmap/round_robin_pmap.h | 65 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/TiledArray/pmap/round_robin_pmap.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d5d6a3ae0..e7a65e7792 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,7 @@ TiledArray/math/vector_op.h TiledArray/math/scalapack.h TiledArray/math/linalg/rank-local.h TiledArray/pmap/blocked_pmap.h +TiledArray/pmap/round_robin_pmap.h TiledArray/pmap/cyclic_pmap.h TiledArray/pmap/hash_pmap.h TiledArray/pmap/pmap.h diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h new file mode 100644 index 0000000000..20e3e03678 --- /dev/null +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -0,0 +1,65 @@ +// +// 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 + +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 Blocked 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_){ + bool plus_one = ( rank_ - remainder_ >= 0); + this->local_size_ = (plus_one ? size / procs_ + 1 : size_/procs_); + } + + 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 % size_); + } + + /// 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 % size_ == rank_); + } + + }; // class BlockedPmap + + } // namespace detail +} // namespace TiledArray + +#endif // TILEDARRAY_PMAP_ROUND_ROBIN_PMAP_H__INCLUDED From c2df90a7665cb46a0f861a29a89d3299ae89a216 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Mon, 27 Jul 2020 13:15:33 -0400 Subject: [PATCH 02/32] Used size_ variable when I should actually use procs_ --- src/TiledArray/pmap/round_robin_pmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index 20e3e03678..ba95f51822 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -46,7 +46,7 @@ namespace TiledArray { /// \return Processor that logically owns \c tile virtual size_type owner(const size_type tile) const { TA_ASSERT(tile < size_); - return (tile % size_); + return (tile % procs_); } /// Check that the tile is owned by this process @@ -54,7 +54,7 @@ namespace TiledArray { /// \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 % size_ == rank_); + return (tile % procs_ == rank_); } }; // class BlockedPmap From 398eb4f3b9c2828cbdfc8bf6c14c9955a8bddb66 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Wed, 29 Jul 2020 15:46:39 -0400 Subject: [PATCH 03/32] If the array doesn't exist on the proc, don't do any loops --- src/TiledArray/conversions/vector_of_arrays.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/TiledArray/conversions/vector_of_arrays.h b/src/TiledArray/conversions/vector_of_arrays.h index 6768a1786f..ac41c660b7 100644 --- a/src/TiledArray/conversions/vector_of_arrays.h +++ b/src/TiledArray/conversions/vector_of_arrays.h @@ -109,29 +109,30 @@ TA::SparseShape fuse_vector_of_shapes_tiles( bool have_rank = (rank == fused_vidx % size); // how many arrays actually constribute to this fused tile ... last fused // tile may have fewer than block_size - const auto vblk_size = - (narrays - vidx) >= block_size ? block_size : narrays - vidx; - for (size_t tile_ord = 0; tile_ord != ntiles_per_array; - ++tile_ord, ++fused_tile_ord) { - if (have_rank) { + if (have_rank) { + const auto vblk_size = + (narrays - vidx) >= block_size ? block_size : narrays - vidx; + for (size_t tile_ord = 0; tile_ord != ntiles_per_array; + ++tile_ord, ++fused_tile_ord) { auto array_ptr = arrays.begin() + element_offset_in_owner * vblk_size; float unscaled_fused_tile_norm2 = 0; const auto tile_volume = tile_volumes[tile_ord]; for (size_t v = 0, vv = vidx; v != vblk_size; ++v, ++vv) { const auto unscaled_tile_norm = - (*(array_ptr)).shape().data()[tile_ord] * tile_volume; + (*(array_ptr)).shape().data()[tile_ord] * tile_volume; unscaled_fused_tile_norm2 += unscaled_tile_norm * unscaled_tile_norm; ++array_ptr; } const auto fused_tile_volume = tile_volume * vblk_size; const auto fused_tile_norm = - std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; + std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; *(fused_tile_norms.data() + fused_tile_ord) = fused_tile_norm; } + element_offset_in_owner += 1; + } else{ + fused_tile_ord += ntiles_per_array; } - element_offset_in_owner = - have_rank ? element_offset_in_owner + 1 : element_offset_in_owner; } auto fused_shapes = TA::SparseShape(global_world, fused_tile_norms, From 76a85a65cc716873afa4a2d90b7cdb971dce2636 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Wed, 29 Jul 2020 16:04:00 -0400 Subject: [PATCH 04/32] Add round robin pmap unittest --- tests/CMakeLists.txt | 1 + tests/round_robin_pmap.cpp | 112 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tests/round_robin_pmap.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bd9ef161db..d75c0f8e5f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -56,6 +56,7 @@ set(ta_test_src_files ta_test.cpp tiled_range1.cpp tiled_range.cpp blocked_pmap.cpp + round_robin_pmap.cpp hash_pmap.cpp cyclic_pmap.cpp replicated_pmap.cpp diff --git a/tests/round_robin_pmap.cpp b/tests/round_robin_pmap.cpp new file mode 100644 index 0000000000..99b18db2a6 --- /dev/null +++ b/tests/round_robin_pmap.cpp @@ -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 . + * + */ + +#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() From 1cccd1db4f2432f958819ebd92df7b3d26374b78 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Thu, 30 Jul 2020 11:24:07 -0400 Subject: [PATCH 05/32] Fix round robin to correctly compute local_size --- src/TiledArray/pmap/round_robin_pmap.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index ba95f51822..afd9be3d40 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -33,9 +33,14 @@ namespace TiledArray { /// \param size The number of tiles to be mapped RoundRobinPmap(World& world, size_type size) : Pmap(world, size), - remainder_(size_ % procs_){ - bool plus_one = ( rank_ - remainder_ >= 0); - this->local_size_ = (plus_one ? size / procs_ + 1 : size_/procs_); + remainder_(size_ % procs_) { + auto num_tiles_per_proc = size / procs_; + if (remainder_ == 0) + this->local_size_ = num_tiles_per_proc; + else if (rank_ - remainder_ > 0) + this->local_size_ = (size < procs_ ? 0 : num_tiles_per_proc - 1); + else + this->local_size_ = num_tiles_per_proc + 1; } virtual ~RoundRobinPmap() {} From 5655ea7b6422ff7e523b2d34711546c810832856 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Fri, 31 Jul 2020 12:58:16 -0400 Subject: [PATCH 06/32] Fix computation of local_size_ for round_robin_pmap --- src/TiledArray/pmap/round_robin_pmap.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index afd9be3d40..e06ba560af 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -35,12 +35,10 @@ namespace TiledArray { : Pmap(world, size), remainder_(size_ % procs_) { auto num_tiles_per_proc = size / procs_; - if (remainder_ == 0) + if (remainder_ == 0 || rank_ >= remainder_) this->local_size_ = num_tiles_per_proc; - else if (rank_ - remainder_ > 0) - this->local_size_ = (size < procs_ ? 0 : num_tiles_per_proc - 1); else - this->local_size_ = num_tiles_per_proc + 1; + this->local_size_ = num_tiles_per_proc + 1; } virtual ~RoundRobinPmap() {} From b02673719d2d042ad9aade5ccdb2b3c9cc8916ab Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Mon, 21 Sep 2020 15:52:15 -0400 Subject: [PATCH 07/32] Bump BTAS tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index c91689708c..ad015417bf 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -22,8 +22,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 1c6099ed2d709896430a892b05bcb94b306f76c9) -set(TA_TRACKED_BTAS_PREVIOUS_TAG ef198e3fa53911eac308c8100c8651b5952c4f26) +set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 3e286d05ee3a19ac320c12c380d947c3e31d77ff) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From 2f1fee2c1fcf33725ad90f1c314140600613cb49 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Wed, 21 Oct 2020 13:37:20 -0400 Subject: [PATCH 08/32] Bump btas tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index ad015417bf..3018d352c5 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -22,8 +22,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 3e286d05ee3a19ac320c12c380d947c3e31d77ff) +set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732 ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG a9b0dce72b3d9b9e5c2cd93831f8e797a8bfe16d) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From 55e3be2cfb32c18a7f78a47947a8774e5a746e16 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Thu, 22 Oct 2020 15:02:01 -0400 Subject: [PATCH 09/32] Bump BTAS tag --- external/versions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/versions.cmake b/external/versions.cmake index 3018d352c5..1d62fc5da5 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -23,7 +23,7 @@ set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG a9b0dce72b3d9b9e5c2cd93831f8e797a8bfe16d) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 2335c7b01c3d5b99027764eda997469cca218992) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From c01f72d32e5f153e755761a1a8146d01aec886fb Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 10:09:57 -0500 Subject: [PATCH 10/32] Fix paste artifact and run git-hooks --- src/TiledArray/pmap/round_robin_pmap.h | 99 +++++++++++++------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index e06ba560af..1406a48487 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -8,61 +8,60 @@ #include namespace TiledArray { - namespace detail { +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 Blocked 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 BlockedPmap - - } // namespace detail +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 From 390a6ca2f78b994cc321ba4d033d6904f10a2389 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 11:29:30 -0500 Subject: [PATCH 11/32] run git-hooks: clang-format --- tests/round_robin_pmap.cpp | 114 ++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/round_robin_pmap.cpp b/tests/round_robin_pmap.cpp index 99b18db2a6..4851c5b5b1 100644 --- a/tests/round_robin_pmap.cpp +++ b/tests/round_robin_pmap.cpp @@ -34,79 +34,79 @@ struct RoundRobinPmapFixture { 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); - } + 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(); + const std::size_t rank = GlobalFixture::world->rank(); + const std::size_t size = GlobalFixture::world->size(); - ProcessID* p_owner = new ProcessID[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); + // 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); + 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]); - } - } + // 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; + 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); + 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); + 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)); - } + // 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)); - } - } + 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() From e8cb11f71338443908767af1d7c7d02bcbdd4adf Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 11:30:38 -0500 Subject: [PATCH 12/32] Move round_robin_pmap to correct alphabetical order --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e7a65e7792..8ba82b06d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,11 +125,11 @@ TiledArray/math/vector_op.h TiledArray/math/scalapack.h TiledArray/math/linalg/rank-local.h TiledArray/pmap/blocked_pmap.h -TiledArray/pmap/round_robin_pmap.h TiledArray/pmap/cyclic_pmap.h TiledArray/pmap/hash_pmap.h TiledArray/pmap/pmap.h TiledArray/pmap/replicated_pmap.h +TiledArray/pmap/round_robin_pmap.h TiledArray/policies/dense_policy.h TiledArray/policies/sparse_policy.h TiledArray/special/diagonal_array.h From bd8ba8a2d2108230518c6ff7b69eaea8772afca1 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 11:31:16 -0500 Subject: [PATCH 13/32] git-hooks: clang-format --- src/TiledArray/conversions/vector_of_arrays.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TiledArray/conversions/vector_of_arrays.h b/src/TiledArray/conversions/vector_of_arrays.h index ac41c660b7..1f67c1ca14 100644 --- a/src/TiledArray/conversions/vector_of_arrays.h +++ b/src/TiledArray/conversions/vector_of_arrays.h @@ -111,7 +111,7 @@ TA::SparseShape fuse_vector_of_shapes_tiles( // tile may have fewer than block_size if (have_rank) { const auto vblk_size = - (narrays - vidx) >= block_size ? block_size : narrays - vidx; + (narrays - vidx) >= block_size ? block_size : narrays - vidx; for (size_t tile_ord = 0; tile_ord != ntiles_per_array; ++tile_ord, ++fused_tile_ord) { auto array_ptr = arrays.begin() + element_offset_in_owner * vblk_size; @@ -119,18 +119,18 @@ TA::SparseShape fuse_vector_of_shapes_tiles( const auto tile_volume = tile_volumes[tile_ord]; for (size_t v = 0, vv = vidx; v != vblk_size; ++v, ++vv) { const auto unscaled_tile_norm = - (*(array_ptr)).shape().data()[tile_ord] * tile_volume; + (*(array_ptr)).shape().data()[tile_ord] * tile_volume; unscaled_fused_tile_norm2 += unscaled_tile_norm * unscaled_tile_norm; ++array_ptr; } const auto fused_tile_volume = tile_volume * vblk_size; const auto fused_tile_norm = - std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; + std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; *(fused_tile_norms.data() + fused_tile_ord) = fused_tile_norm; } element_offset_in_owner += 1; - } else{ + } else { fused_tile_ord += ntiles_per_array; } } From ceb866d4d2eff30f45743aee64f5faf7cae196ae Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Mon, 27 Jul 2020 12:54:09 -0400 Subject: [PATCH 14/32] Add round_robin_pmap --- src/CMakeLists.txt | 1 + src/TiledArray/pmap/round_robin_pmap.h | 96 +++++++++++++------------- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ba82b06d7..57c947415d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,7 @@ TiledArray/math/vector_op.h TiledArray/math/scalapack.h TiledArray/math/linalg/rank-local.h TiledArray/pmap/blocked_pmap.h +TiledArray/pmap/round_robin_pmap.h TiledArray/pmap/cyclic_pmap.h TiledArray/pmap/hash_pmap.h TiledArray/pmap/pmap.h diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index 1406a48487..20e3e03678 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -8,60 +8,58 @@ #include namespace TiledArray { -namespace detail { + 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 + 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 Blocked 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_){ + bool plus_one = ( rank_ - remainder_ >= 0); + this->local_size_ = (plus_one ? size / procs_ + 1 : size_/procs_); + } + + 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 % size_); + } + + /// 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 % size_ == rank_); + } + + }; // class BlockedPmap + + } // namespace detail } // namespace TiledArray #endif // TILEDARRAY_PMAP_ROUND_ROBIN_PMAP_H__INCLUDED From 07faf80abb79831f1f3085d5581f6048b2352fc5 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Mon, 27 Jul 2020 13:15:33 -0400 Subject: [PATCH 15/32] Used size_ variable when I should actually use procs_ --- src/TiledArray/pmap/round_robin_pmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index 20e3e03678..ba95f51822 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -46,7 +46,7 @@ namespace TiledArray { /// \return Processor that logically owns \c tile virtual size_type owner(const size_type tile) const { TA_ASSERT(tile < size_); - return (tile % size_); + return (tile % procs_); } /// Check that the tile is owned by this process @@ -54,7 +54,7 @@ namespace TiledArray { /// \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 % size_ == rank_); + return (tile % procs_ == rank_); } }; // class BlockedPmap From 618f11c1a5558f2654990de5d8690e3cf27d296e Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Wed, 29 Jul 2020 15:46:39 -0400 Subject: [PATCH 16/32] If the array doesn't exist on the proc, don't do any loops --- src/TiledArray/conversions/vector_of_arrays.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TiledArray/conversions/vector_of_arrays.h b/src/TiledArray/conversions/vector_of_arrays.h index 1f67c1ca14..ac41c660b7 100644 --- a/src/TiledArray/conversions/vector_of_arrays.h +++ b/src/TiledArray/conversions/vector_of_arrays.h @@ -111,7 +111,7 @@ TA::SparseShape fuse_vector_of_shapes_tiles( // tile may have fewer than block_size if (have_rank) { const auto vblk_size = - (narrays - vidx) >= block_size ? block_size : narrays - vidx; + (narrays - vidx) >= block_size ? block_size : narrays - vidx; for (size_t tile_ord = 0; tile_ord != ntiles_per_array; ++tile_ord, ++fused_tile_ord) { auto array_ptr = arrays.begin() + element_offset_in_owner * vblk_size; @@ -119,18 +119,18 @@ TA::SparseShape fuse_vector_of_shapes_tiles( const auto tile_volume = tile_volumes[tile_ord]; for (size_t v = 0, vv = vidx; v != vblk_size; ++v, ++vv) { const auto unscaled_tile_norm = - (*(array_ptr)).shape().data()[tile_ord] * tile_volume; + (*(array_ptr)).shape().data()[tile_ord] * tile_volume; unscaled_fused_tile_norm2 += unscaled_tile_norm * unscaled_tile_norm; ++array_ptr; } const auto fused_tile_volume = tile_volume * vblk_size; const auto fused_tile_norm = - std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; + std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; *(fused_tile_norms.data() + fused_tile_ord) = fused_tile_norm; } element_offset_in_owner += 1; - } else { + } else{ fused_tile_ord += ntiles_per_array; } } From 547663edbb35f6a5ea81420261cabf73bfd96fc6 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Wed, 29 Jul 2020 16:04:00 -0400 Subject: [PATCH 17/32] Add round robin pmap unittest --- tests/round_robin_pmap.cpp | 114 ++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/round_robin_pmap.cpp b/tests/round_robin_pmap.cpp index 4851c5b5b1..99b18db2a6 100644 --- a/tests/round_robin_pmap.cpp +++ b/tests/round_robin_pmap.cpp @@ -34,79 +34,79 @@ struct RoundRobinPmapFixture { 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); - } + 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(); + const std::size_t rank = GlobalFixture::world->rank(); + const std::size_t size = GlobalFixture::world->size(); - ProcessID *p_owner = new ProcessID[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); + // 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); + 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]); - } - } + // 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; + 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); + 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); + 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)); - } + // 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)); - } - } + 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() From 58859667f804cf21caed48e7b89e9a30702de8f9 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Thu, 30 Jul 2020 11:24:07 -0400 Subject: [PATCH 18/32] Fix round robin to correctly compute local_size --- src/TiledArray/pmap/round_robin_pmap.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index ba95f51822..afd9be3d40 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -33,9 +33,14 @@ namespace TiledArray { /// \param size The number of tiles to be mapped RoundRobinPmap(World& world, size_type size) : Pmap(world, size), - remainder_(size_ % procs_){ - bool plus_one = ( rank_ - remainder_ >= 0); - this->local_size_ = (plus_one ? size / procs_ + 1 : size_/procs_); + remainder_(size_ % procs_) { + auto num_tiles_per_proc = size / procs_; + if (remainder_ == 0) + this->local_size_ = num_tiles_per_proc; + else if (rank_ - remainder_ > 0) + this->local_size_ = (size < procs_ ? 0 : num_tiles_per_proc - 1); + else + this->local_size_ = num_tiles_per_proc + 1; } virtual ~RoundRobinPmap() {} From 7b91010cd8389142082552267e2e0b08786fd049 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Fri, 31 Jul 2020 12:58:16 -0400 Subject: [PATCH 19/32] Fix computation of local_size_ for round_robin_pmap --- src/TiledArray/pmap/round_robin_pmap.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index afd9be3d40..e06ba560af 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -35,12 +35,10 @@ namespace TiledArray { : Pmap(world, size), remainder_(size_ % procs_) { auto num_tiles_per_proc = size / procs_; - if (remainder_ == 0) + if (remainder_ == 0 || rank_ >= remainder_) this->local_size_ = num_tiles_per_proc; - else if (rank_ - remainder_ > 0) - this->local_size_ = (size < procs_ ? 0 : num_tiles_per_proc - 1); else - this->local_size_ = num_tiles_per_proc + 1; + this->local_size_ = num_tiles_per_proc + 1; } virtual ~RoundRobinPmap() {} From 19f209e2b3d09b26131977d725f53557e36efdda Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Mon, 21 Sep 2020 15:52:15 -0400 Subject: [PATCH 20/32] Bump BTAS tag --- external/versions.cmake | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index 1d62fc5da5..4eaac45302 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -1,9 +1,8 @@ # for each dependency track both current and previous id (the variable for the latter must contain PREVIOUS) # to be able to auto-update them -# Boost explicitly downgraded to 1.59 from 1.68 -set(TA_TRACKED_BOOST_VERSION 1.59) -set(TA_TRACKED_BOOST_PREVIOUS_VERSION 1.68) +set(TA_TRACKED_BOOST_VERSION 1.33) +set(TA_TRACKED_BOOST_PREVIOUS_VERSION 1.33) set(TA_INSTALL_BOOST_VERSION 1.70.0) set(TA_INSTALL_BOOST_PREVIOUS_VERSION 1.70.0) set(TA_INSTALL_BOOST_URL_HASH 882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9) @@ -14,16 +13,16 @@ set(TA_TRACKED_EIGEN_VERSION 3.3) set(TA_TRACKED_EIGEN_PREVIOUS_VERSION 3.3) set(TA_INSTALL_EIGEN_VERSION 3.3.7) set(TA_INSTALL_EIGEN_PREVIOUS_VERSION 3.3.7) -set(TA_INSTALL_EIGEN_URL_HASH b9e98a200d2455f06db9c661c5610496) -set(TA_INSTALL_EIGEN_PREVIOUS_URL_HASH b9e98a200d2455f06db9c661c5610496) +set(TA_INSTALL_EIGEN_URL_HASH 05b1f7511c93980c385ebe11bd3c93fa) +set(TA_INSTALL_EIGEN_PREVIOUS_URL_HASH 05b1f7511c93980c385ebe11bd3c93fa) set(TA_TRACKED_MADNESS_TAG b22ee85059e6ccc9a6e803ba0550652ece8d9df1) set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 2335c7b01c3d5b99027764eda997469cca218992) +set(TA_TRACKED_BTAS_TAG cf39ce37ab976675b854c4b37a4a842066c96767) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 3e286d05ee3a19ac320c12c380d947c3e31d77ff) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From e1f43537181bf69804bf3869e40040335b8676f7 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Wed, 21 Oct 2020 13:37:20 -0400 Subject: [PATCH 21/32] Bump btas tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index 4eaac45302..c304d55ae9 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG cf39ce37ab976675b854c4b37a4a842066c96767) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 3e286d05ee3a19ac320c12c380d947c3e31d77ff) +set(TA_TRACKED_BTAS_TAG 2335c7b01c3d5b99027764eda997469cca218992 ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG a9b0dce72b3d9b9e5c2cd93831f8e797a8bfe16d) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From 8b6a1ecba3bcca4d0426f51ab439d06b622183dd Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Thu, 22 Oct 2020 15:02:01 -0400 Subject: [PATCH 22/32] Bump BTAS tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index c304d55ae9..567c3f7734 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 2335c7b01c3d5b99027764eda997469cca218992 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG a9b0dce72b3d9b9e5c2cd93831f8e797a8bfe16d) +set(TA_TRACKED_BTAS_TAG d5a6d6461a4da5b4dcf86da2cc886ab07a2c4d7d ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 2335c7b01c3d5b99027764eda997469cca218992) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From 540aafd94953c69fb59a3090ccab5f466a082cbf Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Tue, 27 Oct 2020 11:10:11 -0400 Subject: [PATCH 23/32] bump BTAS tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index 567c3f7734..d74ea196b8 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG d5a6d6461a4da5b4dcf86da2cc886ab07a2c4d7d ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 2335c7b01c3d5b99027764eda997469cca218992) +set(TA_TRACKED_BTAS_TAG 2ba1697ecb876de4093382d1f564223fd198e269 ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG d5a6d6461a4da5b4dcf86da2cc886ab07a2c4d7d) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From c9f173a0ae8f63ee822cd332c3b30fd220cbb886 Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Tue, 17 Nov 2020 11:03:48 -0500 Subject: [PATCH 24/32] Bump BTAS tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index d74ea196b8..cca853ffac 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 2ba1697ecb876de4093382d1f564223fd198e269 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG d5a6d6461a4da5b4dcf86da2cc886ab07a2c4d7d) +set(TA_TRACKED_BTAS_TAG 69e8bd8826ae0e78cc78a603ddd563c42048790b ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 2ba1697ecb876de4093382d1f564223fd198e269) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From 9baf29018f1a81ffcd1e7c24c7ed1c5f734aeeeb Mon Sep 17 00:00:00 2001 From: kmp5VT Date: Sun, 29 Nov 2020 12:27:49 -0500 Subject: [PATCH 25/32] Bump BTAS tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index cca853ffac..14583d1788 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 69e8bd8826ae0e78cc78a603ddd563c42048790b ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 2ba1697ecb876de4093382d1f564223fd198e269) +set(TA_TRACKED_BTAS_TAG e46a729dbec4bfd8c8d41c84289d0c9ba8326285 ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 69e8bd8826ae0e78cc78a603ddd563c42048790b) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From 0f610f0c88f86db01025699876b1c818e9f9a8de Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Sat, 26 Dec 2020 19:04:30 -0500 Subject: [PATCH 26/32] Update versions.cmake --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index 14583d1788..0d2d8bd836 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG e46a729dbec4bfd8c8d41c84289d0c9ba8326285 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG 69e8bd8826ae0e78cc78a603ddd563c42048790b) +set(TA_TRACKED_BTAS_TAG a6476624db407c1558e8f1fa0750498a31743e06 ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG e46a729dbec4bfd8c8d41c84289d0c9ba8326285) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From e883684fb0605ec1ca367e60832daa88823365be Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 10:07:28 -0500 Subject: [PATCH 27/32] Update BTAS tag, as it breaks TA and update install.md --- INSTALL.md | 4 ++-- external/versions.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index b4d923e5ce..b759452822 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -40,9 +40,9 @@ Both methods are supported. However, for most users we _strongly_ recommend to b - Boost.Container: header-only - Boost.Test: header-only or (optionally) as a compiled library, *only used for unit testing* - Boost.Range: header-only, *only used for unit testing* -- [BTAS](https://github.com/ValeevGroup/BTAS), tag 1c6099ed2d709896430a892b05bcb94b306f76c9 . If usable BTAS installation is not found, TiledArray will download and compile + - [BTAS](https://github.com/ValeevGroup/BTAS), tag 4f160466504d0405cefcc844b5db20b6bf70c732 . If usable BTAS installation is not found, TiledArray will download and compile BTAS from source. *This is the recommended way to compile BTAS for all users*. -- [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag b22ee85059e6ccc9a6e803ba0550652ece8d9df1 . + - [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag b22ee85059e6ccc9a6e803ba0550652ece8d9df1 . Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray. If usable MADNESS installation is not found, TiledArray will download and compile MADNESS from source. *This is the recommended way to compile MADNESS for all users*. diff --git a/external/versions.cmake b/external/versions.cmake index 0d2d8bd836..01d74069f0 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG a6476624db407c1558e8f1fa0750498a31743e06 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG e46a729dbec4bfd8c8d41c84289d0c9ba8326285) +set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732 ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG a6476624db407c1558e8f1fa0750498a31743e06) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3) From cc293e0ba23e1666a382fa771a9f5697c1744053 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 10:09:57 -0500 Subject: [PATCH 28/32] Fix paste artifact and run git-hooks --- src/TiledArray/pmap/round_robin_pmap.h | 99 +++++++++++++------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/src/TiledArray/pmap/round_robin_pmap.h b/src/TiledArray/pmap/round_robin_pmap.h index e06ba560af..1406a48487 100644 --- a/src/TiledArray/pmap/round_robin_pmap.h +++ b/src/TiledArray/pmap/round_robin_pmap.h @@ -8,61 +8,60 @@ #include namespace TiledArray { - namespace detail { +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 Blocked 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 BlockedPmap - - } // namespace detail +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 From f58e7b75d5ef69d7d5df824dd15bbfe46d28f2e5 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 11:29:30 -0500 Subject: [PATCH 29/32] run git-hooks: clang-format --- tests/round_robin_pmap.cpp | 114 ++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/round_robin_pmap.cpp b/tests/round_robin_pmap.cpp index 99b18db2a6..4851c5b5b1 100644 --- a/tests/round_robin_pmap.cpp +++ b/tests/round_robin_pmap.cpp @@ -34,79 +34,79 @@ struct RoundRobinPmapFixture { 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); - } + 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(); + const std::size_t rank = GlobalFixture::world->rank(); + const std::size_t size = GlobalFixture::world->size(); - ProcessID* p_owner = new ProcessID[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); + // 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); + 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]); - } - } + // 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; + 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); + 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); + 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)); - } + // 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)); - } - } + 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() From 9664309c85e61a7ca4513c70c31f2d0360ee72c9 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 11:30:38 -0500 Subject: [PATCH 30/32] Move round_robin_pmap to correct alphabetical order --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 57c947415d..8ba82b06d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,7 +125,6 @@ TiledArray/math/vector_op.h TiledArray/math/scalapack.h TiledArray/math/linalg/rank-local.h TiledArray/pmap/blocked_pmap.h -TiledArray/pmap/round_robin_pmap.h TiledArray/pmap/cyclic_pmap.h TiledArray/pmap/hash_pmap.h TiledArray/pmap/pmap.h From d1e5a34238df0a8b34d269f3328b611171fafad0 Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Mon, 28 Dec 2020 11:31:16 -0500 Subject: [PATCH 31/32] git-hooks: clang-format --- src/TiledArray/conversions/vector_of_arrays.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TiledArray/conversions/vector_of_arrays.h b/src/TiledArray/conversions/vector_of_arrays.h index ac41c660b7..1f67c1ca14 100644 --- a/src/TiledArray/conversions/vector_of_arrays.h +++ b/src/TiledArray/conversions/vector_of_arrays.h @@ -111,7 +111,7 @@ TA::SparseShape fuse_vector_of_shapes_tiles( // tile may have fewer than block_size if (have_rank) { const auto vblk_size = - (narrays - vidx) >= block_size ? block_size : narrays - vidx; + (narrays - vidx) >= block_size ? block_size : narrays - vidx; for (size_t tile_ord = 0; tile_ord != ntiles_per_array; ++tile_ord, ++fused_tile_ord) { auto array_ptr = arrays.begin() + element_offset_in_owner * vblk_size; @@ -119,18 +119,18 @@ TA::SparseShape fuse_vector_of_shapes_tiles( const auto tile_volume = tile_volumes[tile_ord]; for (size_t v = 0, vv = vidx; v != vblk_size; ++v, ++vv) { const auto unscaled_tile_norm = - (*(array_ptr)).shape().data()[tile_ord] * tile_volume; + (*(array_ptr)).shape().data()[tile_ord] * tile_volume; unscaled_fused_tile_norm2 += unscaled_tile_norm * unscaled_tile_norm; ++array_ptr; } const auto fused_tile_volume = tile_volume * vblk_size; const auto fused_tile_norm = - std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; + std::sqrt(unscaled_fused_tile_norm2) / fused_tile_volume; *(fused_tile_norms.data() + fused_tile_ord) = fused_tile_norm; } element_offset_in_owner += 1; - } else{ + } else { fused_tile_ord += ntiles_per_array; } } From c159b4c5c2201290a02424f41c24db70ce1b461d Mon Sep 17 00:00:00 2001 From: Karl Pierce Date: Fri, 8 Jan 2021 16:04:34 -0500 Subject: [PATCH 32/32] Update versions.cmake Bump BTAS tag --- external/versions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/versions.cmake b/external/versions.cmake index 01d74069f0..d43eb12f5e 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -21,8 +21,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 925552feaf326cca8e83de7bd042074ad3cfd3f1) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 4f160466504d0405cefcc844b5db20b6bf70c732 ) -set(TA_TRACKED_BTAS_PREVIOUS_TAG a6476624db407c1558e8f1fa0750498a31743e06) +set(TA_TRACKED_BTAS_TAG 74553a6c7d7f0657951646a96c45c3170c71e40f) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 08f22d26b9f42a5a52e39088f157c87ac26822c8) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3)