diff --git a/src/vt/collective/scatter/scatter.impl.h b/src/vt/collective/scatter/scatter.impl.h index 7141c2f918..21c9ffd14d 100644 --- a/src/vt/collective/scatter/scatter.impl.h +++ b/src/vt/collective/scatter/scatter.impl.h @@ -59,9 +59,9 @@ void Scatter::scatter( std::size_t const& total_size, std::size_t const& max_proc_size, FuncSizeType size_fn, FuncDataType data_fn ) { - auto const& num_nodes = theContext()->getNumNodes(); - auto const& elm_size = max_proc_size; - auto const& combined_size = num_nodes * elm_size; + auto const num_nodes = theContext()->getNumNodes(); + auto const elm_size = max_proc_size; + auto const combined_size = static_cast(num_nodes * elm_size); auto scatter_msg = makeMessageSz(combined_size, combined_size, elm_size); vtAssert(total_size == combined_size, "Sizes must be consistent"); diff --git a/src/vt/group/region/group_range.cc b/src/vt/group/region/group_range.cc index 906c982597..8c83f27000 100644 --- a/src/vt/group/region/group_range.cc +++ b/src/vt/group/region/group_range.cc @@ -134,7 +134,7 @@ Range::Range(Range const& in_other, BoundType in_remove_extent) for (auto split = 0; split < num_splits; split++) { auto const& child_size = size / num_splits; auto hi_bound = split == num_splits - 1 ? - hi_ : std::min(static_cast(hi_), cur_lo + child_size*stride_); + hi_ : std::min(hi_, cur_lo + child_size*stride_); auto r1 = std::make_unique(cur_lo, BoundType{hi_bound}, stride_); apply(std::move(r1)); cur_lo += BoundType{child_size*stride_}; diff --git a/src/vt/utils/strong/strong_type.h b/src/vt/utils/strong/strong_type.h index 42ed57df72..f1a0d11626 100644 --- a/src/vt/utils/strong/strong_type.h +++ b/src/vt/utils/strong/strong_type.h @@ -205,6 +205,89 @@ struct Strong { return ThisType{v_ / in.v_}; } + /** + * \brief Addition assignment operator + * + * \param[in] in the other value + */ + template + ThisType& operator+=(const OtherType& in) { + v_ += static_cast(in); + return *this; + } + + /** + * \brief Division assignment operator + * + * \param[in] in the other value + */ + template + ThisType& operator/=(const OtherType& in) { + v_ /= static_cast(in); + return *this; + } + + /** + * \brief Multiplication assignment operator + * + * \param[in] in the other value + */ + template + ThisType& operator*=(const OtherType& in) { + v_ *= static_cast(in); + return *this; + } + + /** + * \brief Addition operator + * + * \param[in] in the other value + */ + template + ThisType operator+(const OtherType& in) const { + return ThisType{v_ + static_cast(in)}; + } + + /** + * \brief Subtraction operator + * + * \param[in] in the other value + */ + template + ThisType operator-(const OtherType& in) const { + return ThisType{v_ - static_cast(in)}; + } + + /** + * \brief Modulo operator + * + * \param[in] in the other value + */ + template + ThisType operator%(const OtherType& in) const { + return ThisType{v_ % static_cast(in)}; + } + + /** + * \brief Multiplication operator + * + * \param[in] in the other value + */ + template + ThisType operator*(const OtherType& in) const { + return ThisType{v_ * static_cast(in)}; + } + + /** + * \brief Division operator + * + * \param[in] in the other value + */ + template + ThisType operator/(const OtherType& in) const { + return ThisType{v_ / static_cast(in)}; + } + /** * \brief Pre-increment operator */ diff --git a/tests/unit/collection/test_destroy.cc b/tests/unit/collection/test_destroy.cc index e85aab5ccc..d6a77f2b54 100644 --- a/tests/unit/collection/test_destroy.cc +++ b/tests/unit/collection/test_destroy.cc @@ -107,7 +107,7 @@ static constexpr int32_t const num_elms_per_node = 8; TEST_F(TestDestroy, test_destroy_1) { auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + auto const& num_nodes = theContext()->getNumNodes().get(); vt::runInEpochCollective([&]{ if (this_node == vt::NodeT{0}) { diff --git a/tests/unit/collection/test_insert.extended.cc b/tests/unit/collection/test_insert.extended.cc index a2ba2fac25..78c52fc379 100644 --- a/tests/unit/collection/test_insert.extended.cc +++ b/tests/unit/collection/test_insert.extended.cc @@ -92,7 +92,7 @@ static constexpr int32_t const num_elms_per_node = 8; TEST_F(TestInsert, test_insert_dense_1) { auto const this_node = theContext()->getNode(); - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); auto proxy = vt::makeCollection("test_insert_dense_1") @@ -133,7 +133,7 @@ TEST_F(TestInsert, test_insert_dense_1) { TEST_F(TestInsert, test_insert_sparse_1) { auto const this_node = theContext()->getNode(); - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node * 16); auto proxy = vt::makeCollection("test_insert_sparse_1") @@ -158,7 +158,7 @@ TEST_F(TestInsert, test_insert_sparse_1) { TEST_F(TestInsert, test_insert_dense_node_1) { auto const this_node = theContext()->getNode(); - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); auto proxy = vt::makeCollection("test_insert_dense_node_1") @@ -185,7 +185,7 @@ TEST_F(TestInsert, test_insert_dense_node_1) { TEST_F(TestInsert, test_insert_sparse_node_1) { auto const this_node = theContext()->getNode(); - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node * 16); auto proxy = vt::makeCollection("test_insert_sparse_node_1") @@ -212,7 +212,7 @@ TEST_F(TestInsert, test_insert_sparse_node_1) { TEST_F(TestInsert, test_insert_send_dense_node_1) { auto const this_node = theContext()->getNode(); - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); auto proxy = vt::makeCollection("test_insert_send_dense_node_1") @@ -250,7 +250,7 @@ TEST_F(TestInsert, test_insert_send_dense_node_1) { TEST_F(TestInsert, test_insert_send_sparse_node_1) { auto const this_node = theContext()->getNode(); - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node * 16); auto proxy = vt::makeCollection("test_insert_send_sparse_node_1") diff --git a/tests/unit/collection/test_lb.extended.cc b/tests/unit/collection/test_lb.extended.cc index 8fbb665c6e..21b18f8091 100644 --- a/tests/unit/collection/test_lb.extended.cc +++ b/tests/unit/collection/test_lb.extended.cc @@ -229,7 +229,7 @@ struct MyCol2 : vt::Collection {}; using TestLoadBalancerNoWork = TestParallelHarness; TEST_F(TestLoadBalancerNoWork, test_load_balancer_no_work) { - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * 8); theCollection()->constructCollective( range, [](vt::Index1D) { return std::make_unique(); }, @@ -705,8 +705,8 @@ getJsonStringForPhase( TEST_P(TestDumpUserdefinedData, test_dump_userdefined_json) { bool should_dump = GetParam(); - auto this_node = vt::theContext()->getNode(); - auto num_nodes = vt::theContext()->getNumNodes(); + auto this_node = vt::theContext()->getNode().get(); + auto num_nodes = vt::theContext()->getNumNodes().get(); vt::vrt::collection::CollectionProxy proxy; auto const range = vt::Index1D(num_nodes * 1); diff --git a/tests/unit/collection/test_list_insert.cc b/tests/unit/collection/test_list_insert.cc index 263d169d5d..f0398d28c7 100644 --- a/tests/unit/collection/test_list_insert.cc +++ b/tests/unit/collection/test_list_insert.cc @@ -124,7 +124,7 @@ TEST_F(TestListInsert, test_bounded_list_insert_1) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); std::vector list_insert; @@ -151,7 +151,7 @@ TEST_F(TestListInsert, test_bounded_list_insert_no_default_constructor) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); std::vector list_insert; @@ -192,7 +192,7 @@ TEST_F(TestListInsert, test_unbounded_list_insert_2) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); std::vector list_insert; @@ -219,7 +219,7 @@ TEST_F(TestListInsert, test_unbounded_list_insert_no_default_constructor) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); std::vector list_insert; @@ -247,7 +247,7 @@ TEST_F(TestListInsert, test_bounded_list_insert_here_3) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const this_node = theContext()->getNode(); auto const range = Index1D(num_nodes * num_elms_per_node); @@ -281,7 +281,7 @@ TEST_F(TestListInsert, test_bounded_list_insert_here_no_default_constructor) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const this_node = theContext()->getNode(); auto const range = Index1D(num_nodes * num_elms_per_node); @@ -314,7 +314,7 @@ TEST_F(TestListInsert, test_unbounded_list_insert_here_4) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const this_node = theContext()->getNode(); auto const range = Index1D(num_nodes * num_elms_per_node); @@ -348,7 +348,7 @@ TEST_F(TestListInsert, test_unbounded_list_insert_here_no_default_constructor) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const this_node = theContext()->getNode(); auto const range = Index1D(num_nodes * num_elms_per_node); @@ -426,7 +426,7 @@ TEST_F(TestListInsert, test_bounded_bulk_insert_no_default_constructor) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const range = Index1D(num_nodes * num_elms_per_node); auto proxy = vt::makeCollection("test_bounded_bulk_insert_no_default_constructor") @@ -450,7 +450,7 @@ TEST_F(TestListInsert, test_bounded_mix_list_insert_no_default_constructor) { num_inserted = 0; num_work = 0; - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const this_node = theContext()->getNode(); auto const range = Index1D(num_nodes * num_elms_per_node); diff --git a/tests/unit/collection/test_mapping.cc b/tests/unit/collection/test_mapping.cc index 07d6bdad5c..b223608bf8 100644 --- a/tests/unit/collection/test_mapping.cc +++ b/tests/unit/collection/test_mapping.cc @@ -100,20 +100,20 @@ std::vector kFactors(T n, int8_t k) { T const orig_n = n; std::vector factors; while (n % 2 == 0) { - factors.push_back(2); + factors.push_back(T{2}); n /= 2; } - for (T i = 3; i*i <= n; i += 2) { + for (T i = T{3}; i*i <= n; i += 2) { while (n % i == 0) { - factors.push_back(i); + factors.push_back(T{i}); n /= i; } } if (n > 2) { - factors.push_back(n); + factors.push_back(T{n}); } while (factors.size() < static_cast(k)) { - factors.push_back(1); + factors.push_back(T{1}); } std::vector output = factors; @@ -133,7 +133,7 @@ std::vector kFactors(T n, int8_t k) { output = compressed; } - T total = 1; + T total = T{1}; std::string buf = ""; for (auto&& elm : output) { buf += fmt::format("{}, ", elm); diff --git a/tests/unit/collection/test_query_context.cc b/tests/unit/collection/test_query_context.cc index ef12bcb060..d9b03251b6 100644 --- a/tests/unit/collection/test_query_context.cc +++ b/tests/unit/collection/test_query_context.cc @@ -76,7 +76,7 @@ TEST_F(TestQueryContext, test_query_context_broadcast_1) { auto const& this_node = theContext()->getNode(); auto const& num_nodes = theContext()->getNumNodes(); if (this_node == vt::NodeT{0}) { - auto const& range = Index1D(num_nodes * num_elms_per_node); + auto const& range = Index1D(num_nodes.get() * num_elms_per_node); auto proxy = theCollection()->construct( range, "test_query_context_broadcast_1" ); @@ -88,7 +88,7 @@ TEST_F(TestQueryContext, test_query_context_broadcast_1) { TEST_F(TestQueryContext, test_query_context_send_1) { auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + auto const& num_nodes = theContext()->getNumNodes().get(); if (this_node == vt::NodeT{0}) { auto const& range = Index1D(num_nodes * num_elms_per_node); auto proxy = theCollection()->construct( diff --git a/tests/unit/collection/test_storage.cc b/tests/unit/collection/test_storage.cc index b707501b5c..d6de5716b4 100644 --- a/tests/unit/collection/test_storage.cc +++ b/tests/unit/collection/test_storage.cc @@ -109,7 +109,7 @@ struct TestCollectionStorage : TestParallelHarness { }; TEST_F(TestCollectionStorage, test_collection_storage_1) { - auto const num_nodes = theContext()->getNumNodes(); + auto const num_nodes = theContext()->getNumNodes().get(); auto const num_elms = Index1D{num_nodes*16}; using MsgType = typename TestCol::TestMsg;