From 3f82f00898a6afe87c151373fac76b080c909162 Mon Sep 17 00:00:00 2001 From: Nicole Lemaster Slattengren Date: Wed, 25 Nov 2020 09:12:00 -0800 Subject: [PATCH] #868: add struct that will replace scalar obj id --- src/vt/vrt/collection/balance/lb_common.h | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/vt/vrt/collection/balance/lb_common.h b/src/vt/vrt/collection/balance/lb_common.h index 8455b7a8f0..421c78d1e9 100644 --- a/src/vt/vrt/collection/balance/lb_common.h +++ b/src/vt/vrt/collection/balance/lb_common.h @@ -56,6 +56,26 @@ namespace balance { using ElementIDType = uint64_t; +struct ElementIDStruct { + using isByteCopyable = std::true_type; + + ElementIDType id = 0; + NodeType home_node = uninitialized_destination; + NodeType curr_node = uninitialized_destination; + + bool operator==(const ElementIDStruct& rhs) const { + return id == rhs.id and home_node == rhs.home_node; + } + + bool operator<(const ElementIDStruct& rhs) const { + return id < rhs.id; + } +}; + +std::ostream& operator<<( + std::ostream& os, const ::vt::vrt::collection::balance::ElementIDStruct& id +); + static constexpr ElementIDType const no_element_id = 0; using LoadMapType = std::unordered_map; @@ -107,4 +127,18 @@ extern std::unordered_map lb_stat_name_; }}}} /* end namespace vt::vrt::collection::lb */ +namespace std { + +using ElementIDStructType = vt::vrt::collection::balance::ElementIDStruct; +using ElementIDMemberType = vt::vrt::collection::balance::ElementIDType; + +template <> +struct hash { + size_t operator()(ElementIDStructType const& in) const { + return std::hash()(in.id); + } +}; + +} /* end namespace std */ + #endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_LB_COMMON_H*/