Skip to content

Commit

Permalink
#868: add struct that will replace scalar obj id
Browse files Browse the repository at this point in the history
  • Loading branch information
nlslatt committed Nov 25, 2020
1 parent 159abcf commit 3f82f00
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/vt/vrt/collection/balance/lb_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElementIDType,TimeType>;
Expand Down Expand Up @@ -107,4 +127,18 @@ extern std::unordered_map<Statistic,std::string> 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<ElementIDStructType> {
size_t operator()(ElementIDStructType const& in) const {
return std::hash<ElementIDMemberType>()(in.id);
}
};

} /* end namespace std */

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_LB_COMMON_H*/

0 comments on commit 3f82f00

Please sign in to comment.