From 69d1c2ac4f813d43b6c381eb5ab05e64f0b5cdaf Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:15:05 +0100 Subject: [PATCH 01/24] Improved messages for option settings. --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8f4877..dfb73ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,19 +42,17 @@ target_sources(${PROJECT_NAME} # Options check and set definitions # =================================== if (DHB_WITH_SYSTEM_ALLOCATOR) - MESSAGE(STATUS "Using DHB System Allocator.") + MESSAGE(STATUS "DHB uses system allocator.") target_compile_definitions(dhb PUBLIC -DDHB_SYSTEM_ALLOCATOR) endif() if (DHB_WITH_64BIT_IDS) - MESSAGE(STATUS "Using 64 bit IDs.") + MESSAGE(STATUS "DHB uses 64 bit vertex IDs.") target_compile_definitions(dhb PUBLIC -DDHB_64BIT_IDS) else() - MESSAGE(STATUS "Using 32 bit IDs.") + MESSAGE(STATUS "DHB uses 32 bit vertex IDs.") endif() -set_property(TARGET dhb PROPERTY POSITION_INDEPENDENT_CODE ON) - find_package(OpenMP) # Thanks to NetworKit for the following OpenMP code looking or OpenMP in the # most common folders: From 07af34586fce46ea970657660ee943eb7cb02716 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:36:58 +0100 Subject: [PATCH 02/24] Pedantic warnings are errors option. --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfb73ec..abc2180 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # DHB_WITH_SYSTEM_ALLOCATOR=OFF option(DHB_WITH_SYSTEM_ALLOCATOR "Use DHB System Allocator" OFF) option(DHB_WITH_64BIT_IDS "Use 64 bit IDs." OFF) +option(DHB_WARNINGS_AS_ERRORS "Sets warning level high, treats warnings as errors ." OFF) add_library(dhb STATIC) @@ -53,6 +54,11 @@ else() MESSAGE(STATUS "DHB uses 32 bit vertex IDs.") endif() +if (DHB_WARNINGS_AS_ERRORS) + MESSAGE(STATUS "DHB is extra pedantic, throws errors on warnings.") + target_compile_options(dhb PRIVATE -Werror -Wall -Wextra -Wpedantic -Wmaybe-uninitialized) +endif() + find_package(OpenMP) # Thanks to NetworKit for the following OpenMP code looking or OpenMP in the # most common folders: @@ -93,9 +99,6 @@ if(NOT OpenMP_FOUND) endif() target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_CXX) -# Be extra pedantic about warnings! -target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror) - target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src From 1959415ea1c07af71217e8c680423accf3aa6d62 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:38:10 +0100 Subject: [PATCH 03/24] Setting target properties in one place incl. c++ std and target independent code. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abc2180..7fdf9f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,8 +129,10 @@ set_target_properties(${PROJECT_NAME}::${PROJECT_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" ) -set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${public_headers}") -set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d") +set_target_properties(dhb PROPERTIES CXX_STANDARD 17) +set_target_properties(dhb PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(dhb PROPERTIES DEBUG_POSTFIX "d") +set_target_properties(dhb PROPERTIES PUBLIC_HEADER "${public_headers}") # =================================== # Make a Configuration Package From 5fe4e880c2c7f0b43dd378a8e31e37783e5e58e1 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:05:25 +0100 Subject: [PATCH 04/24] Scope explicitly. --- include/dhb/block.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index 8dc3b60..e4ddd31 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -437,8 +437,9 @@ template class BlockState { } // If we did hit a tombstone, insert at the tombstone. - if (ts != illegalIndex()) + if (ts != illegalIndex()) { j = ts; + } // Insert into the adjacency list. auto i = m_degree++; From d3c956031c6e8d1eb219e8404fbb30ab6b02848e Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:05:57 +0100 Subject: [PATCH 05/24] TODO: init value when GCC compiles showing warning as error. --- include/dhb/block.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dhb/block.h b/include/dhb/block.h index e4ddd31..c8e4d3f 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -416,6 +416,7 @@ template class BlockState { if (uses_htab(m_bsize)) { index_type* htab = m_htab; auto h = hash_node(v); + // TODO when warning is printed: index_type j = 0u; index_type j; index_type ts = illegalIndex(); for (index_type i = 0; true; ++i) { From 3348183d4f3daadbdcfdf71fe0a526bbcedbd3e8 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:07:59 +0100 Subject: [PATCH 06/24] Use signed literals for assignments. --- include/dhb/block.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index c8e4d3f..69cacf3 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -523,7 +523,7 @@ template class BlockState { } else { // Find the index. index_type iv; - for (iv = 0; iv < m_degree; ++iv) + for (iv = 0u; iv < m_degree; ++iv) if (m_entries[iv].vertex == v) break; @@ -532,7 +532,7 @@ template class BlockState { return false; // Swap with the last entry. - if (iv + 1 != m_degree) + if (iv + 1u != m_degree) m_entries[iv] = m_entries[m_degree - 1]; // Remove the last entry. From 277ff4b6342a4dfc7cf233f839603231082df697 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:08:21 +0100 Subject: [PATCH 07/24] Initialize j: fixing warning of maybe uninitialized variable. --- include/dhb/block.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index 69cacf3..a8c5c8b 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -416,8 +416,7 @@ template class BlockState { if (uses_htab(m_bsize)) { index_type* htab = m_htab; auto h = hash_node(v); - // TODO when warning is printed: index_type j = 0u; - index_type j; + index_type j = 0u; index_type ts = illegalIndex(); for (index_type i = 0; true; ++i) { if (i == m_bsize) { From 95775c591a71d8a6e2647f66fec385c6932a53bc Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:09:39 +0100 Subject: [PATCH 08/24] Revise comment on when to use a hash table. --- include/dhb/block.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index a8c5c8b..45857f6 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -21,10 +21,10 @@ inline index_type tombstoneIndex() { return static_cast(-2); }; // TODO: This could take the entry size into account. inline bool uses_htab(size_t bsize) { const size_t cache_line = 64; - // Each entry is typically 16 bytes or so. - // Preliminary experiments how that using the hash index is only useful if the block becomes - // larger than several cache lines (approx. 16 or so). - // Hence, the following is a reasonably good heuristic: + // Each entry is typically 16 bytes or so. Preliminary experiments show that + // using the hash index is only useful if the block becomes larger than + // several cache lines (approx. 16 or so). Hence, the following is a + // reasonably good heuristic: return 16 * bsize > 16 * cache_line; } From 39cda5402cfa8b585b079005e329eaf6c4ef4bb7 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:28:33 +0100 Subject: [PATCH 09/24] Passed bsize is const. --- include/dhb/block.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index 45857f6..e6dcac8 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -19,7 +19,7 @@ inline index_type illegalIndex() { return static_cast(-1); }; inline index_type tombstoneIndex() { return static_cast(-2); }; // TODO: This could take the entry size into account. -inline bool uses_htab(size_t bsize) { +inline bool uses_htab(size_t const bsize) { const size_t cache_line = 64; // Each entry is typically 16 bytes or so. Preliminary experiments show that // using the hash index is only useful if the block becomes larger than From 87725d3140bee503030c0bab4102ad79209ab5ef Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:28:45 +0100 Subject: [PATCH 10/24] cache line size ist consexpr --- include/dhb/block.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index e6dcac8..d741630 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -20,7 +20,7 @@ inline index_type tombstoneIndex() { return static_cast(-2); }; // TODO: This could take the entry size into account. inline bool uses_htab(size_t const bsize) { - const size_t cache_line = 64; + size_t constexpr cache_line = 64; // Each entry is typically 16 bytes or so. Preliminary experiments show that // using the hash index is only useful if the block becomes larger than // several cache lines (approx. 16 or so). Hence, the following is a From d01f87d8cea2bc0c4714f380280a336f70f146d5 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:29:26 +0100 Subject: [PATCH 11/24] Compare against signed literal: Keeps value type from being interpreted as unsigned int. --- include/dhb/block.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index d741630..8b9ad47 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -25,7 +25,7 @@ inline bool uses_htab(size_t const bsize) { // using the hash index is only useful if the block becomes larger than // several cache lines (approx. 16 or so). Hence, the following is a // reasonably good heuristic: - return 16 * bsize > 16 * cache_line; + return 16u * bsize > 16u * cache_line; } // Taken from https://stackoverflow.com/a/12996028. From d53f6a48953325aefcbc81495ab5058d05b1f6c5 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:30:24 +0100 Subject: [PATCH 12/24] Include exception for std::terminate(). --- include/dhb/block.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dhb/block.h b/include/dhb/block.h index 8b9ad47..417de2e 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include From 324c9cf296d438fd60cc138722aec90c3098af2f Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 12:51:29 +0100 Subject: [PATCH 13/24] Being extra pedanctic also for dhb test target. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fdf9f1..3abcfce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,11 @@ if (DHB_BUILD_TESTS) test/submatrix.cpp ) + if (DHB_WARNINGS_AS_ERRORS) + MESSAGE(STATUS "DHB test is extra pedantic, throws errors on warnings.") + target_compile_options(dhb_test PRIVATE -Werror -Wall -Wextra -Wpedantic -Wmaybe-uninitialized) + endif() + target_link_libraries(dhb_test PRIVATE dhb Catch2::Catch2WithMain OpenMP::OpenMP_CXX) install( From 1a7a2417466b82177c3b7e69f6ae884e19b97759 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 13:37:15 +0100 Subject: [PATCH 14/24] Fix vec tests using uint32_t as indices (rename file to _test.cpp). --- CMakeLists.txt | 2 +- test/{vec.cpp => vec_test.cpp} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename test/{vec.cpp => vec_test.cpp} (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3abcfce..d3d8986 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,7 @@ if (DHB_BUILD_TESTS) test/graph_io.h test/graph_io.cpp test/matrix_test.cpp - test/vec.cpp + test/vec_test.cpp test/block.cpp test/submatrix.cpp ) diff --git a/test/vec.cpp b/test/vec_test.cpp similarity index 92% rename from test/vec.cpp rename to test/vec_test.cpp index 91c7285..d4c6b23 100644 --- a/test/vec.cpp +++ b/test/vec_test.cpp @@ -2,7 +2,7 @@ #include TEST_CASE("Vec") { - dhb::Vec v; + dhb::Vec v; REQUIRE(std::get<1>(v.insert(2, 1))); REQUIRE(std::get<1>(v.insert(3, 1))); @@ -11,11 +11,11 @@ TEST_CASE("Vec") { REQUIRE(std::get<1>(v.insert(11, 1))); SECTION("iterate") { - std::array indices{2, 3, 5, 7, 11}; + std::array indices{2, 3, 5, 7, 11}; bool entries_are_equal = std::equal(v.begin(), v.end(), indices.begin(), indices.end(), - [](auto ent, int idx) -> bool { return ent.vertex() == idx; }); + [](auto ent, uint32_t idx) -> bool { return ent.vertex() == idx; }); CHECK(entries_are_equal); bool all_edge_data_is_1 = From d2f72c6aefa696e8c42a50f32a5e45945379d727 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 13:37:31 +0100 Subject: [PATCH 15/24] Remove unused variable. --- include/dhb/dynamic_hashed_blocks.h | 1 - include/dhb/vec.h | 1 - 2 files changed, 2 deletions(-) diff --git a/include/dhb/dynamic_hashed_blocks.h b/include/dhb/dynamic_hashed_blocks.h index 1d38290..3bfcaaf 100644 --- a/include/dhb/dynamic_hashed_blocks.h +++ b/include/dhb/dynamic_hashed_blocks.h @@ -55,7 +55,6 @@ template struct Matrix { BlockState new_block{new_bhandle, state}; auto result = new_block.insert(v, ed); - auto old_block = std::move(m_graph->m_vertices[m_source]); auto old_bhandle = m_graph->m_handles[m_source]; m_graph->m_vertices[m_source] = std::move(new_block); m_graph->m_handles[m_source] = new_bhandle; diff --git a/include/dhb/vec.h b/include/dhb/vec.h index 6b9c090..1f3be69 100644 --- a/include/dhb/vec.h +++ b/include/dhb/vec.h @@ -59,7 +59,6 @@ template struct Vec { BlockState new_block{new_bhandle, state}; auto result = new_block.insert(u, ed); - auto old_block = std::move(m_state); auto old_bhandle = m_handle; m_state = std::move(new_block); m_handle = new_bhandle; From 2284e1e6c902796c5b00c51113a4e9c4fbc0f203 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:08:46 +0100 Subject: [PATCH 16/24] Fix submatrix test not initializing edge data correctly, renaming test file to _test.cpp. --- CMakeLists.txt | 2 +- test/{submatrix.cpp => submatrix_test.cpp} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename test/{submatrix.cpp => submatrix_test.cpp} (95%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3d8986..3d79316 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,7 @@ if (DHB_BUILD_TESTS) test/matrix_test.cpp test/vec_test.cpp test/block.cpp - test/submatrix.cpp + test/submatrix_test.cpp ) if (DHB_WARNINGS_AS_ERRORS) diff --git a/test/submatrix.cpp b/test/submatrix_test.cpp similarity index 95% rename from test/submatrix.cpp rename to test/submatrix_test.cpp index 76a3ddc..84bd479 100644 --- a/test/submatrix.cpp +++ b/test/submatrix_test.cpp @@ -15,9 +15,9 @@ class TestMatrix { // [ 13 | 4 | 0 ] // clang-format off dhb::Edges edges_a = { - {0, Tar{0, ED{1.0}}}, {0, Tar{1, ED{3.0}}}, {0, Tar{2, ED{0.0}}}, - {1, Tar{0, ED{4.0}}}, {1, Tar{1, ED{5.0}}}, {1, Tar{2, ED{8.0}}}, - {2, Tar{0, ED{13.0}}}, {2, Tar{1, ED{4.0}}}, {2, Tar{2, ED{0.0}}}, + {0, Tar{0, ED{1.0, 0}}}, {0, Tar{1, ED{3.0, 0}}}, {0, Tar{2, ED{0.0, 0}}}, + {1, Tar{0, ED{4.0, 0}}}, {1, Tar{1, ED{5.0, 0}}}, {1, Tar{2, ED{8.0, 0}}}, + {2, Tar{0, ED{13.0, 0}}}, {2, Tar{1, ED{4.0, 0}}}, {2, Tar{2, ED{0.0, 0}}}, }; // clang-format on From cc7da5df8079f504bfb7c632506c0b7764d52ae2 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:09:15 +0100 Subject: [PATCH 17/24] Fix signed / unsigned comparison warning: indices are unsigned integers. --- test/vec_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vec_test.cpp b/test/vec_test.cpp index d4c6b23..0fc32f9 100644 --- a/test/vec_test.cpp +++ b/test/vec_test.cpp @@ -63,11 +63,11 @@ TEST_CASE("Vec") { SECTION("erase") { v.erase(v.find(11)); v.erase(v.find(5)); - std::array indices{2, 3, 7}; + std::array indices{2, 3, 7}; bool erase_took_place = std::equal(v.begin(), v.end(), indices.begin(), indices.end(), - [](auto ent, int idx) -> bool { return ent.vertex() == idx; }); + [](auto ent, uint32_t idx) -> bool { return ent.vertex() == idx; }); CHECK(erase_took_place); } From 1a8c7970e859e8230d8e95f8462b76d3544d60db Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:12:10 +0100 Subject: [PATCH 18/24] Remove unused variables from matrix tests. --- test/matrix_test.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/matrix_test.cpp b/test/matrix_test.cpp index 21b887d..4085467 100644 --- a/test/matrix_test.cpp +++ b/test/matrix_test.cpp @@ -272,7 +272,6 @@ TEST_CASE("Matrix") { Edges new_edges{e89_14, e89_8, e89_13_update}; auto cmp = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key = [](Edge e) { return e.source; }; auto fun = [&](Edge e) { std::tuple::iterator, bool> insertion_result = m.neighbors(e.source).insert(e.target.vertex, e.target.data); @@ -306,7 +305,6 @@ TEST_CASE("Matrix") { Matrix m(graph::vertex_count(edges)); auto cmp = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key = [](Edge e) { return e.source; }; auto fun = [&](Edge e) { m.neighbors(e.source).insert(e.target.vertex, e.target.data); }; auto get_edge_f = [](Edge const& e) { return e.source; }; BatchParallelizer par; @@ -318,7 +316,6 @@ TEST_CASE("Matrix") { Edges new_edges{e89_14, e89_8}; auto cmp2 = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key2 = [](Edge e) { return e.source; }; par(new_edges.begin(), new_edges.end(), std::move(get_edge_f), std::move(cmp2), [&](Edge e) { m.neighbors(e.source).insert(e.target.vertex, e.target.data); }); @@ -351,7 +348,6 @@ TEST_CASE("Matrix") { Edges new_edges{e89_14, e89_8}; auto cmp2 = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key2 = [](Edge e) { return e.source; }; par(new_edges.begin(), new_edges.end(), std::move(get_edge_f), std::move(cmp2), [&](Edge e) { m.neighbors(e.source).insert(e.target.vertex, e.target.data); }); @@ -372,9 +368,7 @@ TEST_CASE("Matrix") { Matrix m(graph::vertex_count(edges)); - auto cmp = [](Edge const& a, Edge const& b) { return a.source < b.source; }; auto key = [](Edge e) { return e.source; }; - auto fun = [&](Edge e) { m.neighbors(e.source).insert(e.target.vertex, e.target.data); }; auto get_edge_f = [](Edge const& e) { return e.source; }; BatchParallelizer par; @@ -401,7 +395,6 @@ TEST_CASE("Matrix") { Edges new_edges{e89_14, e89_8}; auto cmp2 = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key2 = [](Edge e) { return e.source; }; par(new_edges.begin(), new_edges.end(), std::move(get_edge_f), std::move(cmp2), [&](Edge e) { m.neighbors(e.source).insert(e.target.vertex, e.target.data); }); @@ -423,7 +416,6 @@ TEST_CASE("Matrix") { Matrix m(graph::vertex_count(edges)); auto cmp = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key = [](Edge e) { return e.source; }; auto get_edge_f = [](Edge const& e) { return e.source; }; BatchParallelizer par; @@ -437,9 +429,6 @@ TEST_CASE("Matrix") { Edges new_edges{e89_14, e89_8, e89_13_update}; - auto cmp2 = [](Edge const& a, Edge const& b) { return a.source < b.source; }; - auto key2 = [](Edge e) { return e.source; }; - par(new_edges.begin(), new_edges.end(), std::move(get_edge_f), std::move(cmp), [&](Edge e) { std::tuple::iterator, bool> insertion_result = m.neighbors(e.source).insert(e.target.vertex, e.target.data); From a458aba02c2bd852e27691c5794f0548dbe37c83 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:18:39 +0100 Subject: [PATCH 19/24] Fix unsigned / signed comparisons in batcher. --- include/dhb/batcher.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/dhb/batcher.h b/include/dhb/batcher.h index 99e4250..1fbd5be 100644 --- a/include/dhb/batcher.h +++ b/include/dhb/batcher.h @@ -69,7 +69,7 @@ template class BatchParallelizer { public: template void operator()(Iterator begin, Iterator end, GetSourceF&& get_source_f, Cmp cmp, F func) { - int const t_count = omp_get_max_threads(); + uint32_t const t_count = omp_get_max_threads(); size_t const n = end - begin; if (t_count == 1 || n < t_count) { for (auto it = begin; it != end; ++it) @@ -90,7 +90,7 @@ template class BatchParallelizer { template void apply(Iterator begin, Iterator end, K key, F func) { - size_t const t_count = omp_get_max_threads(); + uint32_t const t_count = omp_get_max_threads(); size_t const n = end - begin; if (t_count == 1 || n < t_count) { for (auto it = begin; it != end; ++it) @@ -104,7 +104,7 @@ template class BatchParallelizer { #pragma omp parallel num_threads(t_count) { size_t const t = omp_get_thread_num(); - assert(omp_get_num_threads() == t_count); + assert(uint32_t(omp_get_num_threads()) == t_count); auto counts_of_thread = [&](int ct) -> uint64_t* { return &m_batch_counts[ct * (t_count + 1)]; @@ -165,7 +165,7 @@ template class BatchParallelizer { } template void distribute(Iterator begin, Iterator end, K key) { - int const t_count = omp_get_num_threads(); + uint32_t const t_count = omp_get_num_threads(); size_t const n = end - begin; if (t_count == 1 || n < t_count) { return; @@ -177,7 +177,7 @@ template class BatchParallelizer { m_batch_slots.resize(n); } - auto t = omp_get_thread_num(); + uint32_t t = omp_get_thread_num(); auto counts_of_thread = [&](int ct) -> uint64_t* { return &m_batch_counts[ct * (t_count + 1)]; @@ -192,7 +192,7 @@ template class BatchParallelizer { // First, perform a local counting sort to sort updates according to associated threads. auto t_counts = counts_of_thread(t); - for (int at = 0; at < t_count; ++at) + for (uint32_t at = 0; at < t_count; ++at) t_counts[at] = 0; for (size_t i = i_begin; i < i_end; ++i) { @@ -202,7 +202,7 @@ template class BatchParallelizer { } uint64_t psum = 0; - for (int at = 0; at < t_count; ++at) { + for (uint32_t at = 0; at < t_count; ++at) { psum += t_counts[at]; t_counts[at] = i_begin + psum; } @@ -223,7 +223,7 @@ template class BatchParallelizer { } template void map(Iterator begin, Iterator end, F func) { - int const t_count = omp_get_num_threads(); + uint32_t const t_count = omp_get_num_threads(); size_t const n = end - begin; if (t_count == 1 || n < t_count) { #pragma omp master @@ -243,7 +243,7 @@ template class BatchParallelizer { }; uint64_t local_count = 0; - for (int ot = 0; ot < t_count; ++ot) { + for (uint32_t ot = 0; ot < t_count; ++ot) { auto ot_counts = counts_of_thread(ot); auto j_begin = ot_counts[t]; auto j_end = ot_counts[t + 1]; From 5514ebf4e127f6a8ecccc65ca5794602e5d3b647 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:19:14 +0100 Subject: [PATCH 20/24] Remove unused variables. --- include/dhb/batcher.h | 2 -- include/dhb/dynamic_hashed_blocks.h | 1 - 2 files changed, 3 deletions(-) diff --git a/include/dhb/batcher.h b/include/dhb/batcher.h index 1fbd5be..20c0058 100644 --- a/include/dhb/batcher.h +++ b/include/dhb/batcher.h @@ -156,7 +156,6 @@ template class BatchParallelizer { auto j_end = ot_counts[t + 1]; for (size_t j = j_begin; j < j_end; ++j) { auto i = m_batch_slots[j]; - auto edge = *(begin + i); func(*(begin + i)); } local_count += j_end - j_begin; @@ -249,7 +248,6 @@ template class BatchParallelizer { auto j_end = ot_counts[t + 1]; for (size_t j = j_begin; j < j_end; ++j) { auto i = m_batch_slots[j]; - auto edge = *(begin + i); func(*(begin + i)); } local_count += j_end - j_begin; diff --git a/include/dhb/dynamic_hashed_blocks.h b/include/dhb/dynamic_hashed_blocks.h index 3bfcaaf..18a4f48 100644 --- a/include/dhb/dynamic_hashed_blocks.h +++ b/include/dhb/dynamic_hashed_blocks.h @@ -173,7 +173,6 @@ template struct Matrix { auto new_bhandle = m_manager->allocate_block(degree); BlockState new_block{new_bhandle, associated_block}; - auto old_block = std::move(m_vertices[u]); auto old_bhandle = m_handles[u]; m_vertices[u] = std::move(new_block); m_handles[u] = new_bhandle; From 75027ea221e207947cd3990a438506ce03af7c5a Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:42:01 +0100 Subject: [PATCH 21/24] Wrap include of mman.h with pre-processor if clause checking for system allocator option. --- include/dhb/block.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index 15d3e3a..2c79609 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -7,9 +7,12 @@ #include #include #include -#include #include +#ifndef DHB_SYSTEM_ALLOCATOR +#include +#endif + namespace dhb { class BlockHandle; From dcb2202c9905d87a2f719be123c76a4af25d09c8 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:42:16 +0100 Subject: [PATCH 22/24] Remove redundant comments. --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d79316..857ae03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,6 @@ include(GNUInstallDirs) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# Configure the option whether you want to use the systems own allocater -# DHB_WITH_SYSTEM_ALLOCATOR=ON -# or our own written allocator strategy -# DHB_WITH_SYSTEM_ALLOCATOR=OFF option(DHB_WITH_SYSTEM_ALLOCATOR "Use DHB System Allocator" OFF) option(DHB_WITH_64BIT_IDS "Use 64 bit IDs." OFF) option(DHB_WARNINGS_AS_ERRORS "Sets warning level high, treats warnings as errors ." OFF) From fb9c56a11a6e9ee91c9954f6a45e29744adc195c Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:02:13 +0100 Subject: [PATCH 23/24] Remove redundant semicolon? --- include/dhb/block.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dhb/block.h b/include/dhb/block.h index 2c79609..b01b7d2 100644 --- a/include/dhb/block.h +++ b/include/dhb/block.h @@ -19,8 +19,8 @@ class BlockHandle; class BlockArray; using index_type = size_t; -inline index_type illegalIndex() { return static_cast(-1); }; -inline index_type tombstoneIndex() { return static_cast(-2); }; +inline index_type illegalIndex() { return static_cast(-1); } +inline index_type tombstoneIndex() { return static_cast(-2); } // TODO: This could take the entry size into account. inline bool uses_htab(size_t const bsize) { From ef2edc96f3e0372662ece64211ff1689851ddd27 Mon Sep 17 00:00:00 2001 From: Jones <2944106+c-bebop@users.noreply.github.com> Date: Fri, 28 Mar 2025 13:37:53 +0100 Subject: [PATCH 24/24] Include numeric for std::accumulate(). --- include/dhb/dynamic_hashed_blocks.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dhb/dynamic_hashed_blocks.h b/include/dhb/dynamic_hashed_blocks.h index 18a4f48..a9ebda6 100644 --- a/include/dhb/dynamic_hashed_blocks.h +++ b/include/dhb/dynamic_hashed_blocks.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include