Skip to content

Commit

Permalink
with_updated_label -> append_to_label
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Oct 18, 2023
1 parent 380754b commit ef889a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
18 changes: 9 additions & 9 deletions containers/src/Kokkos_UnorderedMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,27 +337,27 @@ class UnorderedMap {
Impl::get_property<Impl::LabelTag>(prop_copy) + " - size"));

m_available_indexes =
bitset_type(Kokkos::Impl::with_updated_label(prop_copy, " - bitset"),
bitset_type(Kokkos::Impl::append_to_label(prop_copy, " - bitset"),
calculate_capacity(capacity_hint));

m_hash_lists = size_type_view(
Kokkos::Impl::with_updated_label(prop_copy_noinit, " - hash list"),
Kokkos::Impl::append_to_label(prop_copy_noinit, " - hash list"),
Impl::find_hash_size(capacity()));

m_next_index = size_type_view(
Kokkos::Impl::with_updated_label(prop_copy_noinit, " - next index"),
Kokkos::Impl::append_to_label(prop_copy_noinit, " - next index"),
capacity() + 1); // +1 so that the *_at functions can always return a
// valid reference

m_keys = key_type_view(
Kokkos::Impl::with_updated_label(prop_copy, " - keys"), capacity());
m_keys = key_type_view(Kokkos::Impl::append_to_label(prop_copy, " - keys"),
capacity());

m_values = value_type_view(
Kokkos::Impl::with_updated_label(prop_copy, " - values"),
is_set ? 0 : capacity());
m_values =
value_type_view(Kokkos::Impl::append_to_label(prop_copy, " - values"),
is_set ? 0 : capacity());

m_scalars =
scalars_view(Kokkos::Impl::with_updated_label(prop_copy, " - scalars"));
scalars_view(Kokkos::Impl::append_to_label(prop_copy, " - scalars"));

/**
* Deep copies should also be done using the space instance if given.
Expand Down
20 changes: 8 additions & 12 deletions containers/src/impl/Kokkos_UnorderedMap_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@
namespace Kokkos {
namespace Impl {

//! Either append to the label if the property already exists, or set it.
//! Append to the label contained in view_ctor_prop.
template <typename... P>
auto with_updated_label(const ViewCtorProp<P...>& view_ctor_prop,
const std::string& label) {
auto append_to_label(const ViewCtorProp<P...>& view_ctor_prop,
const std::string& label) {
using vcp_t = ViewCtorProp<P...>;
//! If the label property is already set, append. Otherwise, set label.
if constexpr (vcp_t::has_label) {
vcp_t new_ctor_props(view_ctor_prop);
static_cast<ViewCtorProp<void, std::string>&>(new_ctor_props)
.value.append(label);
return new_ctor_props;
} else {
return Impl::with_properties_if_unset(view_ctor_prop, label);
}
static_assert(vcp_t::has_label);
vcp_t new_ctor_props(view_ctor_prop);
static_cast<ViewCtorProp<void, std::string>&>(new_ctor_props)
.value.append(label);
return new_ctor_props;
}

uint32_t find_hash_size(uint32_t size);
Expand Down

0 comments on commit ef889a7

Please sign in to comment.