Skip to content

Commit 0a82f7c

Browse files
jeremyg-lunargarno-lunarg
authored andcommitted
build: Replace robin-hood-hashing with unordered_dense
robin-hood-hashing is no longer developed. unordered_dense is its replacement, by the same author.
1 parent 675cc64 commit 0a82f7c

File tree

8 files changed

+35
-82
lines changed

8 files changed

+35
-82
lines changed

.github/workflows/vvl.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ jobs:
6060

6161
linux:
6262
runs-on: ubuntu-22.04
63-
name: "linux (${{matrix.sanitize}} sanitizer, ${{matrix.config}}, robinhood ${{matrix.robin_hood}} )"
63+
name: "linux (${{matrix.sanitize}} sanitizer, ${{matrix.config}}, unordered_dense ${{matrix.unordered_dense}} )"
6464
strategy:
6565
fail-fast: false
6666
matrix:
6767
sanitize: [ address, thread ]
6868
config: [debug, release]
69-
robin_hood: [ "ON" ]
69+
unordered_dense: [ "ON" ]
7070
include:
71-
# Test with Robin Hood disabled
71+
# Test with unordered_dense disabled
7272
# Chromium build, and some package managers don't use it.
7373
- config: release
74-
robin_hood: "OFF"
74+
unordered_dense: "OFF"
7575
sanitize: address
7676
steps:
7777
- uses: actions/checkout@v4
7878
- uses: lukka/get-cmake@latest
7979
- uses: hendrikmuhs/[email protected]
8080
with:
81-
key: ${{ matrix.config }}-${{ matrix.sanitize }}-${{matrix.robin_hood}}
81+
key: ${{ matrix.config }}-${{ matrix.sanitize }}-${{matrix.unordered_dense}}
8282
- run: sudo apt-get -qq update && sudo apt-get install -y libwayland-dev xorg-dev
83-
- run: python scripts/tests.py --build --config ${{ matrix.config }} --cmake='-DUSE_ROBIN_HOOD_HASHING=${{matrix.robin_hood}}'
83+
- run: python scripts/tests.py --build --config ${{ matrix.config }} --cmake='-DUSE_UNORDERED_DENSE=${{matrix.unordered_dense}}'
8484
env:
8585
CFLAGS: -fsanitize=${{ matrix.sanitize }}
8686
CXXFLAGS: -fsanitize=${{ matrix.sanitize }}
@@ -145,7 +145,7 @@ jobs:
145145
build-ci/external/glslang/build/install
146146
build-ci/external/googltest/build/install
147147
build-ci/external/mimalloc/build/install
148-
build-ci/external/robin-hood-hashing/build/install
148+
build-ci/external/unordered_dense/build/install
149149
build-ci/external/SPIRV-Headers/build/install
150150
build-ci/external/SPIRV-Tools/build/install
151151
build-ci/external/Vulkan-Headers/build/install

layers/CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ target_link_libraries(VkLayer_utils PUBLIC
8080
target_include_directories(VkLayer_utils SYSTEM PRIVATE external)
8181
target_include_directories(VkLayer_utils PUBLIC . ${API_TYPE})
8282

83-
find_package(robin_hood CONFIG)
84-
option(USE_ROBIN_HOOD_HASHING "robin_hood provides faster versions of std::unordered_map and std::unordered_set" ${robin_hood_FOUND})
85-
if (USE_ROBIN_HOOD_HASHING)
86-
target_link_libraries(VkLayer_utils PUBLIC robin_hood::robin_hood)
87-
target_compile_definitions(VkLayer_utils PUBLIC USE_ROBIN_HOOD_HASHING)
83+
find_package(unordered_dense CONFIG)
84+
option(USE_UNORDERED_DENSE "unordered_denser provides faster versions of std::unordered_map and std::unordered_set" ${unordered_dense_FOUND})
85+
if (USE_UNORDERED_DENSE)
86+
target_link_libraries(VkLayer_utils PUBLIC unordered_dense::unordered_dense)
87+
target_compile_definitions(VkLayer_utils PUBLIC USE_UNORDERED_DENSE)
8888
endif()
8989

9090
# Using mimalloc on non-Windows OSes currently results in unit test instability with some

layers/containers/custom_containers.h

+9-50
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,27 @@
3232
#include <optional>
3333
#include <utility>
3434

35-
#ifdef USE_ROBIN_HOOD_HASHING
36-
#include "robin_hood.h"
35+
#ifdef USE_UNORDERED_DENSE
36+
#include "ankerl/unordered_dense.h"
3737
#else
3838
#include <unordered_set>
3939
#endif
4040

4141
// namespace aliases to allow map and set implementations to easily be swapped out
4242
namespace vvl {
4343

44-
#ifdef USE_ROBIN_HOOD_HASHING
44+
#ifdef USE_UNORDERED_DENSE
4545
template <typename T>
46-
using hash = robin_hood::hash<T>;
46+
using hash = ankerl::unordered_dense::hash<T>;
4747

48-
template <typename Key, typename Hash = robin_hood::hash<Key>, typename KeyEqual = std::equal_to<Key>>
49-
using unordered_set = robin_hood::unordered_set<Key, Hash, KeyEqual>;
48+
template <typename Key, typename Hash = ankerl::unordered_dense::hash<Key>, typename KeyEqual = std::equal_to<Key>>
49+
using unordered_set = ankerl::unordered_dense::set<Key, Hash, KeyEqual>;
5050

51-
template <typename Key, typename T, typename Hash = robin_hood::hash<Key>, typename KeyEqual = std::equal_to<Key>>
52-
using unordered_map = robin_hood::unordered_map<Key, T, Hash, KeyEqual>;
51+
template <typename Key, typename T, typename Hash = ankerl::unordered_dense::hash<Key>, typename KeyEqual = std::equal_to<Key>>
52+
using unordered_map = ankerl::unordered_dense::segmented_map<Key, T, Hash, KeyEqual>;
5353

5454
template <typename Key, typename T>
55-
using map_entry = robin_hood::pair<Key, T>;
56-
57-
// robin_hood-compatible insert_iterator (std:: uses the wrong insert method)
58-
// NOTE: std::iterator was deprecated in C++17, and newer versions of libstdc++ appear to mark this as such.
59-
template <typename T>
60-
struct insert_iterator {
61-
using iterator_category = std::output_iterator_tag;
62-
using value_type = typename T::value_type;
63-
using iterator = typename T::iterator;
64-
using difference_type = void;
65-
using pointer = void;
66-
using reference = T &;
67-
68-
insert_iterator(reference t, iterator i) : container(&t), iter(i) {}
69-
70-
insert_iterator &operator=(const value_type &value) {
71-
auto result = container->insert(value);
72-
iter = result.first;
73-
++iter;
74-
return *this;
75-
}
76-
77-
insert_iterator &operator=(value_type &&value) {
78-
auto result = container->insert(std::move(value));
79-
iter = result.first;
80-
++iter;
81-
return *this;
82-
}
83-
84-
insert_iterator &operator*() { return *this; }
85-
86-
insert_iterator &operator++() { return *this; }
87-
88-
insert_iterator &operator++(int) { return *this; }
89-
90-
private:
91-
T *container;
92-
iterator iter;
93-
};
55+
using map_entry = std::pair<Key, T>;
9456
#else
9557
template <typename T>
9658
using hash = std::hash<T>;
@@ -103,9 +65,6 @@ using unordered_map = std::unordered_map<Key, T, Hash, KeyEqual>;
10365

10466
template <typename Key, typename T>
10567
using map_entry = std::pair<Key, T>;
106-
107-
template <typename T>
108-
using insert_iterator = std::insert_iterator<T>;
10968
#endif
11069

11170
} // namespace vvl

layers/core_checks/cc_image_layout.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ void CoreChecks::TransitionFinalSubpassLayouts(vvl::CommandBuffer &cb_state) {
162162

163163
static GlobalImageLayoutRangeMap *GetLayoutRangeMap(GlobalImageLayoutMap &map, const vvl::Image &image_state) {
164164
// This approach allows for a single hash lookup or/create new
165-
auto &layout_map = map[&image_state];
166-
if (!layout_map) {
167-
layout_map.emplace(image_state.subresource_encoder.SubresourceCount());
168-
}
169-
return &(*layout_map);
165+
auto result = map.emplace(&image_state, image_state.subresource_encoder.SubresourceCount());
166+
return &(result.first->second.value());
170167
}
171168

172169
// Helper to update the Global or Overlay layout map

layers/state_tracker/image_state.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ std::vector<VkPresentModeKHR> Surface::GetPresentModes(VkPhysicalDevice phys_dev
667667
assert(phys_dev);
668668
std::vector<VkPresentModeKHR> result;
669669
if (auto search = present_modes_data_.find(phys_dev); search != present_modes_data_.end()) {
670-
for (auto mode = search->second.begin(); mode != search->second.end(); mode++) {
670+
for (auto mode = search->second.begin(); mode != search->second.end(); ++mode) {
671671
result.push_back(mode->first);
672672
}
673673
return result;

scripts/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ if (UPDATE_DEPS)
122122
include("${UPDATE_DEPS_DIR}/helper.cmake")
123123
endif()
124124
endif()
125-
if (ROBIN_HOOD_HASHING_INSTALL_DIR)
126-
list(APPEND CMAKE_PREFIX_PATH ${ROBIN_HOOD_HASHING_INSTALL_DIR})
127-
set(CMAKE_REQUIRE_FIND_PACKAGE_robin_hood TRUE PARENT_SCOPE)
125+
if (UNORDERED_DENSE_INSTALL_DIR)
126+
list(APPEND CMAKE_PREFIX_PATH ${UNORDERED_DENSE_INSTALL_DIR})
127+
set(CMAKE_REQUIRE_FIND_PACKAGE_unordered_dense TRUE PARENT_SCOPE)
128128
endif()
129129
if (GLSLANG_INSTALL_DIR)
130130
list(APPEND CMAKE_PREFIX_PATH ${GLSLANG_INSTALL_DIR})

scripts/gn/secondary/build_overrides/vulkan_validation_layers.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ vulkan_utility_libraries_dir = "//external/Vulkan-Utility-Libraries"
1818
vvl_spirv_tools_dir = "//external/SPIRV-Tools"
1919
vvl_spirv_headers_dir = "//external/SPIRV-Headers"
2020
vvl_glslang_dir = "//external/glslang/"
21-
robin_hood_headers_dir = "//external/robin-hood-hashing/src/include"
21+
unordered_dense_headers_dir = "//external/unordered_dense/include"
2222

2323
# Subdirectories for generated files
2424
vulkan_data_subdir = ""

scripts/known_good.json

+7-10
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@
4646
"commit": "b0a5c4ac12b742086ffb16e2ba0ad4903450ae1d"
4747
},
4848
{
49-
"name": "robin-hood-hashing",
50-
"url": "https://github.com/martinus/robin-hood-hashing.git",
51-
"sub_dir": "robin-hood-hashing",
52-
"build_dir": "robin-hood-hashing/build",
53-
"install_dir": "robin-hood-hashing/build/install",
54-
"cmake_options": [
55-
"-DRH_STANDALONE_PROJECT=OFF"
56-
],
57-
"commit": "3.11.5"
49+
"name": "unordered_dense",
50+
"url": "https://github.com/martinus/unordered_dense.git",
51+
"sub_dir": "unordered_dense",
52+
"build_dir": "unordered_dense/build",
53+
"install_dir": "unordered_dense/build/install",
54+
"commit": "v4.4.0"
5855
},
5956
{
6057
"name": "mimalloc",
@@ -149,7 +146,7 @@
149146
"Vulkan-Utility-Libraries": "VULKAN_UTILITY_LIBRARIES_INSTALL_DIR",
150147
"SPIRV-Headers": "SPIRV_HEADERS_INSTALL_DIR",
151148
"SPIRV-Tools": "SPIRV_TOOLS_INSTALL_DIR",
152-
"robin-hood-hashing": "ROBIN_HOOD_HASHING_INSTALL_DIR",
149+
"unordered_dense": "UNORDERED_DENSE_INSTALL_DIR",
153150
"googletest": "GOOGLETEST_INSTALL_DIR",
154151
"mimalloc": "MIMALLOC_INSTALL_DIR"
155152
}

0 commit comments

Comments
 (0)