Skip to content

Commit

Permalink
unorderedmap: adding missing constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
romintomasetti committed Jan 29, 2024
1 parent 2015055 commit c60ad81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions containers/src/Kokkos_UnorderedMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ class UnorderedMap {
/// Kokkos::UnorderedMapInsertOpTypes for more ops.
template <typename InsertOpType = default_op_type>
KOKKOS_INLINE_FUNCTION insert_result
insert(key_type const &k, impl_value_type const &v = impl_value_type(),
insert(key_type const &k,
[[maybe_unused]] impl_value_type const &v = impl_value_type(),
[[maybe_unused]] InsertOpType arg_insert_op = InsertOpType()) const {
if constexpr (is_set) {
static_assert(std::is_same_v<InsertOpType, default_op_type>,
Expand Down Expand Up @@ -652,7 +653,7 @@ class UnorderedMap {
m_keys[new_index] = k;
#endif

if (!is_set) {
if constexpr (!is_set) {
KOKKOS_NONTEMPORAL_PREFETCH_STORE(&m_values[new_index]);
#ifdef KOKKOS_ENABLE_SYCL
Kokkos::atomic_store(&m_values[new_index], v);
Expand Down Expand Up @@ -844,7 +845,7 @@ class UnorderedMap {
sizeof(size_type) * src.m_next_index.extent(0));
raw_deep_copy(tmp.m_keys.data(), src.m_keys.data(),
sizeof(key_type) * src.m_keys.extent(0));
if (!is_set) {
if constexpr (!is_set) {
raw_deep_copy(tmp.m_values.data(), src.m_values.data(),
sizeof(impl_value_type) * src.m_values.extent(0));
}
Expand Down
4 changes: 2 additions & 2 deletions containers/src/impl/Kokkos_UnorderedMap_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct UnorderedMapErase {
next = m_map.m_next_index[curr];
m_map.m_next_index[curr] = invalid_index;
m_map.m_keys[curr] = key_type();
if (m_map.is_set) m_map.m_values[curr] = value_type();
if constexpr (map_type::is_set) m_map.m_values[curr] = value_type();
curr = next;
m_map.m_hash_lists(i) = next;
}
Expand All @@ -117,7 +117,7 @@ struct UnorderedMapErase {
m_map.m_next_index[prev] = next;
m_map.m_next_index[curr] = invalid_index;
m_map.m_keys[curr] = key_type();
if (map_type::is_set) m_map.m_values[curr] = value_type();
if constexpr (map_type::is_set) m_map.m_values[curr] = value_type();
}
curr = next;
}
Expand Down

0 comments on commit c60ad81

Please sign in to comment.