gem5-dev@gem5.org

The gem5 Developer List

View all threads

[S] Change in gem5/gem5[develop]: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default

GB
Gabriel B. (Gerrit)
Fri, Jul 7, 2023 10:17 AM

Gabriel B. has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email )

(

12 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
)Change subject: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by
default
......................................................................

base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default

Change-Id: Iad01d7fa6ff6293a2d931ba796666ad3550c6e44
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67664
Reviewed-by: Daniel Carvalho odanrc@yahoo.com.br
Tested-by: kokoro noreply+kokoro@google.com
Maintainer: Daniel Carvalho odanrc@yahoo.com.br

M src/base/stl_helpers/hash_helpers.hh
1 file changed, 31 insertions(+), 0 deletions(-)

Approvals:
Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass

diff --git a/src/base/stl_helpers/hash_helpers.hh
b/src/base/stl_helpers/hash_helpers.hh
index f638ea9..1432d52 100644
--- a/src/base/stl_helpers/hash_helpers.hh
+++ b/src/base/stl_helpers/hash_helpers.hh
@@ -40,6 +40,11 @@

#include "base/type_traits.hh"

+#include <functional>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
namespace gem5::stl_helpers
{

@@ -165,6 +170,32 @@
using hash_impl::hash_value;
using hash_impl::is_hash_enabled;

+/*

    • Provide unordered_map and unordered_set with stl_helpers::hash
      functions.
    • These aliases enable clean use of stl_helpers::hash as default Hash
      template
    • parameter. The reason for not using an alias is that template type
      aliases
    • with default template arguments do not behave well with template
      parameter
    • deductions in certain situations. One must remember that
      std::unordered_X
    • is not a polymorphic type and as such, gem5::stl_helpers::unordered_X
      shall
    • never be owned as a std::unordered_X.
  • */
    +template<
  • typename Key,
  • typename T,
  • typename Hash = hash<Key>,
  • typename KeyEqual = std::equal_to<Key>,
  • typename Allocator = std::allocator< std::pair<const Key, T> >>
    +struct unordered_map: std::unordered_map<Key, T, Hash, KeyEqual, Allocator>
    +{};

+template<

  • typename Key,

  • typename Hash = hash<Key>,

  • typename KeyEqual = std::equal_to<Key>,

  • typename Allocator = std::allocator<Key>>
    +struct unordered_set: std::unordered_set<Key, Hash, KeyEqual, Allocator>
    +{};

  • } // namespace gem5::stl_helpers

    #endif // BASE_STL_HELPERS_HASH_HELPERS_HH

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iad01d7fa6ff6293a2d931ba796666ad3550c6e44
Gerrit-Change-Number: 67664
Gerrit-PatchSet: 14
Gerrit-Owner: Gabriel B. gabriel.busnot@arteris.com
Gerrit-Reviewer: Bobby Bruce bbruce@ucdavis.edu
Gerrit-Reviewer: Daniel Carvalho odanrc@yahoo.com.br
Gerrit-Reviewer: Gabriel B. gabriel.busnot@arteris.com
Gerrit-Reviewer: kokoro noreply+kokoro@google.com
Gerrit-CC: kokoro noreply+kokoro@google.com

Gabriel B. has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email ) ( 12 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default ...................................................................... base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default Change-Id: Iad01d7fa6ff6293a2d931ba796666ad3550c6e44 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67664 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Daniel Carvalho <odanrc@yahoo.com.br> --- M src/base/stl_helpers/hash_helpers.hh 1 file changed, 31 insertions(+), 0 deletions(-) Approvals: Daniel Carvalho: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/src/base/stl_helpers/hash_helpers.hh b/src/base/stl_helpers/hash_helpers.hh index f638ea9..1432d52 100644 --- a/src/base/stl_helpers/hash_helpers.hh +++ b/src/base/stl_helpers/hash_helpers.hh @@ -40,6 +40,11 @@ #include "base/type_traits.hh" +#include <functional> +#include <tuple> +#include <type_traits> +#include <utility> + namespace gem5::stl_helpers { @@ -165,6 +170,32 @@ using hash_impl::hash_value; using hash_impl::is_hash_enabled; +/* + * Provide unordered_map and unordered_set with stl_helpers::hash functions. + * These aliases enable clean use of stl_helpers::hash as default Hash template + * parameter. The reason for not using an alias is that template type aliases + * with default template arguments do not behave well with template parameter + * deductions in certain situations. One must remember that std::unordered_X + * is not a polymorphic type and as such, gem5::stl_helpers::unordered_X shall + * never be owned as a std::unordered_X. + */ +template< + typename Key, + typename T, + typename Hash = hash<Key>, + typename KeyEqual = std::equal_to<Key>, + typename Allocator = std::allocator< std::pair<const Key, T> >> +struct unordered_map: std::unordered_map<Key, T, Hash, KeyEqual, Allocator> +{}; + +template< + typename Key, + typename Hash = hash<Key>, + typename KeyEqual = std::equal_to<Key>, + typename Allocator = std::allocator<Key>> +struct unordered_set: std::unordered_set<Key, Hash, KeyEqual, Allocator> +{}; + } // namespace gem5::stl_helpers #endif // BASE_STL_HELPERS_HASH_HELPERS_HH -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: public/gem5 Gerrit-Branch: develop Gerrit-Change-Id: Iad01d7fa6ff6293a2d931ba796666ad3550c6e44 Gerrit-Change-Number: 67664 Gerrit-PatchSet: 14 Gerrit-Owner: Gabriel B. <gabriel.busnot@arteris.com> Gerrit-Reviewer: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-Reviewer: Daniel Carvalho <odanrc@yahoo.com.br> Gerrit-Reviewer: Gabriel B. <gabriel.busnot@arteris.com> Gerrit-Reviewer: kokoro <noreply+kokoro@google.com> Gerrit-CC: kokoro <noreply+kokoro@google.com>