From fb11346a3574ffcec8d587b8f7d872787637c8c6 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:04:58 +0200 Subject: [PATCH 01/13] First cases. --- CMakeLists.txt | 4 ++-- arbor/include/arbor/util/lexcmp_def.hpp | 1 + arborenv/gpu_uuid.cpp | 17 +++++------------ modcc/symge.hpp | 11 +++++------ 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05dab8a457..eed6e424de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,8 +194,8 @@ include("CheckCompilerXLC") include("CompilerOptions") add_compile_options("$<$:${CXXOPT_WALL}>") -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CUDA_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CUDA_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/arbor/include/arbor/util/lexcmp_def.hpp b/arbor/include/arbor/util/lexcmp_def.hpp index 57f0062ad7..8b58d33e69 100644 --- a/arbor/include/arbor/util/lexcmp_def.hpp +++ b/arbor/include/arbor/util/lexcmp_def.hpp @@ -18,6 +18,7 @@ */ #include +#include #define ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(proxy,op,type,a_fields,b_fields) \ inline bool operator op(const type& a,const type& b) { return proxy a_fields op proxy b_fields; } diff --git a/arborenv/gpu_uuid.cpp b/arborenv/gpu_uuid.cpp index fe09cfbe57..d13f0ee4da 100644 --- a/arborenv/gpu_uuid.cpp +++ b/arborenv/gpu_uuid.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "gpu_uuid.hpp" @@ -41,21 +42,13 @@ using arb::util::on_scope_exit; namespace arbenv { -// Test GPU uids for equality -bool operator==(const uuid& lhs, const uuid& rhs) { - for (auto i=0u; i(const uuid& lhs, const uuid& rhs) { for (auto i=0u; ilhs.bytes[i]) return false; + if (lhs.bytes[i]lhs.bytes[i]) return std::strong_ordering::greater; } - return false; + return return std::strong_ordering::equivalent; } std::ostream& operator<<(std::ostream& o, const uuid& id) { diff --git a/modcc/symge.hpp b/modcc/symge.hpp index 3a3cbc1ecd..4ed8a92370 100644 --- a/modcc/symge.hpp +++ b/modcc/symge.hpp @@ -46,6 +46,8 @@ struct symbol_term { symbol left, right; symbol_term() = default; + symbol_term(const symbol left): left(std::move(left)) {} + symbol_term(symbol left, symbol right): left(std::move(left)), right(std::move(right)) {} bool is_zero() const { return !left || !right; } operator bool() const { return !is_zero(); } }; @@ -54,14 +56,11 @@ struct symbol_term_diff { symbol_term left, right; symbol_term_diff() = default; - symbol_term_diff(const symbol_term& left): left(left), right{} {} - symbol_term_diff(const symbol_term& left, const symbol_term& right): - left(left), right(right) {} + symbol_term_diff(const symbol_term left): left(std::move(left)) {} + symbol_term_diff(symbol_term left, symbol_term right): left(std::move(left)), right(std::move(right)) {} }; -inline symbol_term operator*(symbol a, symbol b) { - return symbol_term{a, b}; -} +inline symbol_term operator*(symbol a, symbol b) { return symbol_term{a, b}; } inline symbol_term_diff operator-(symbol_term l, symbol_term r) { return symbol_term_diff{l, r}; From 062cb283431f3ddf371f993a4e5fc662f5d15c9b Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:31:15 +0200 Subject: [PATCH 02/13] Macro and counter --- arbor/include/arbor/util/lexcmp_def.hpp | 6 +++++- arbor/util/counter.hpp | 9 ++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arbor/include/arbor/util/lexcmp_def.hpp b/arbor/include/arbor/util/lexcmp_def.hpp index 8b58d33e69..5c8657a46b 100644 --- a/arbor/include/arbor/util/lexcmp_def.hpp +++ b/arbor/include/arbor/util/lexcmp_def.hpp @@ -23,7 +23,11 @@ #define ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(proxy,op,type,a_fields,b_fields) \ inline bool operator op(const type& a,const type& b) { return proxy a_fields op proxy b_fields; } +#define ARB_DEFINE_SPACESHIP_IMPL_(proxy,type,a_fields,b_fields) \ +inline auto operator<=>(const type& a,const type& b) { return proxy a_fields <=> proxy b_fields; } + #define ARB_DEFINE_LEXICOGRAPHIC_ORDERING(type,a_fields,b_fields) \ +ARB_DEFINE_SPACESHIP_IMPL_(std::tie,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,<,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,>,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,<=,type,a_fields,b_fields) \ @@ -32,10 +36,10 @@ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,!=,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,==,type,a_fields,b_fields) #define ARB_DEFINE_LEXICOGRAPHIC_ORDERING_BY_VALUE(type,a_fields,b_fields) \ +ARB_DEFINE_SPACESHIP_IMPL_(std::make_tuple,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,<,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,>,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,<=,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,>=,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,!=,type,a_fields,b_fields) \ ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,==,type,a_fields,b_fields) - diff --git a/arbor/util/counter.hpp b/arbor/util/counter.hpp index fc59c4a411..4dd2b6fbeb 100644 --- a/arbor/util/counter.hpp +++ b/arbor/util/counter.hpp @@ -2,6 +2,7 @@ /* Present an integral value as an iterator, for integral-range 'containers' */ +#include #include #include #include @@ -77,17 +78,11 @@ struct counter { value_type operator[](difference_type n) const { return v_+n; } - bool operator==(counter x) const { return v_==x.v_; } - bool operator!=(counter x) const { return v_!=x.v_; } - bool operator<=(counter x) const { return v_<=x.v_; } - bool operator>=(counter x) const { return v_>=x.v_; } - bool operator<(counter x) const { return v_(counter x) const { return v_>x.v_; } + auto operator<=>(const counter& y) const = default; counter& operator=(const counter&) = default; counter& operator=(counter&&) = default; -private: V v_; }; From ebe5f75a3fb9f5187b1d36ed11e8b4078ce1ee01 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:58:29 +0200 Subject: [PATCH 03/13] Absorb lexicographic compare into <=> --- arbor/include/arbor/common_types.hpp | 22 ++--- arbor/include/arbor/fvm_types.hpp | 6 +- arbor/include/arbor/morph/primitives.hpp | 27 ++---- arbor/include/arbor/network.hpp | 18 +--- arbor/include/arbor/spike.hpp | 4 +- arbor/include/arbor/spike_event.hpp | 5 +- arbor/include/arbor/util/any_ptr.hpp | 8 +- arbor/include/arbor/util/lexcmp_def.hpp | 45 ---------- arbor/morph/segment_tree.cpp | 1 + arborio/swcio.cpp | 5 +- cmake/CompilerOptions.cmake | 8 -- python/label_dict.hpp | 1 + test/unit/CMakeLists.txt | 1 - test/unit/test_lexcmp.cpp | 110 ----------------------- 14 files changed, 35 insertions(+), 226 deletions(-) delete mode 100644 arbor/include/arbor/util/lexcmp_def.hpp delete mode 100644 test/unit/test_lexcmp.cpp diff --git a/arbor/include/arbor/common_types.hpp b/arbor/include/arbor/common_types.hpp index 32737f883b..8e0206d98b 100644 --- a/arbor/include/arbor/common_types.hpp +++ b/arbor/include/arbor/common_types.hpp @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -58,6 +57,7 @@ using cell_local_size_type = std::make_unsigned_t; struct cell_member_type { cell_gid_type gid; cell_lid_type index; + auto operator<=>(const cell_member_type&) const = default; }; // Pair of indexes that describe range of local indices. @@ -66,8 +66,8 @@ struct lid_range { cell_lid_type begin = 0; cell_lid_type end = 0; lid_range() = default; - lid_range(cell_lid_type b, cell_lid_type e): - begin(b), end(e) {} + lid_range(cell_lid_type b, cell_lid_type e): begin(b), end(e) {} + auto operator<=>(const lid_range&) const = default; }; // Global range of indices with given step size. @@ -77,10 +77,8 @@ struct gid_range { cell_gid_type end = 0; cell_gid_type step = 1; gid_range() = default; - gid_range(cell_gid_type b, cell_gid_type e): - begin(b), end(e), step(1) {} - gid_range(cell_gid_type b, cell_gid_type e, cell_gid_type s): - begin(b), end(e), step(s) {} + gid_range(cell_gid_type b, cell_gid_type e): begin(b), end(e), step(1) {} + gid_range(cell_gid_type b, cell_gid_type e, cell_gid_type s): begin(b), end(e), step(s) {} }; // Policy for selecting a cell_lid_type from a range of possible values. @@ -132,18 +130,16 @@ struct cell_address_type { cell_address_type& operator=(const cell_address_type&) = default; cell_address_type& operator=(cell_address_type&&) = default; -}; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(cell_address_type, (a.gid, a.tag), (b.gid, b.tag)) + auto operator<=>(const cell_address_type&) const = default; +}; struct cell_remote_label_type { cell_gid_type rid; // remote id cell_lid_type index = 0; // index on remote id -}; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(cell_remote_label_type,(a.rid,a.index),(b.rid,b.index)) -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(cell_member_type,(a.gid,a.index),(b.gid,b.index)) -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(lid_range,(a.begin, a.end),(b.begin,b.end)) + auto operator<=>(const cell_remote_label_type&) const = default; +}; // For storing time values [ms] diff --git a/arbor/include/arbor/fvm_types.hpp b/arbor/include/arbor/fvm_types.hpp index d6d86111e4..9131abcba9 100644 --- a/arbor/include/arbor/fvm_types.hpp +++ b/arbor/include/arbor/fvm_types.hpp @@ -10,7 +10,11 @@ struct fvm_gap_junction { arb_size_type local_cv; // CV index of the local gap junction site. arb_size_type peer_cv; // CV index of the peer gap junction site. arb_value_type weight; // unit-less local weight of the connection. + + constexpr bool operator==(const fvm_gap_junction&) const = default; + constexpr auto operator<=>(const fvm_gap_junction& o) { + return std::tie(local_cv, peer_cv, local_idx, weight) <=> std::tie(o.local_cv, o.peer_cv, o.local_idx, o.weight); + } }; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(fvm_gap_junction, (a.local_cv, a.peer_cv, a.local_idx, a.weight), (b.local_cv, b.peer_cv, b.local_idx, b.weight)) } // namespace arb diff --git a/arbor/include/arbor/morph/primitives.hpp b/arbor/include/arbor/morph/primitives.hpp index 9d75060df2..d1071c89a4 100644 --- a/arbor/include/arbor/morph/primitives.hpp +++ b/arbor/include/arbor/morph/primitives.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -8,12 +7,8 @@ #include #include -#include -// // Types used to identify concrete locations. -// - namespace arb { using msize_t = std::uint32_t; @@ -24,10 +19,9 @@ struct ARB_SYMBOL_VISIBLE mpoint { double x, y, z; // [µm] double radius; // [μm] friend std::ostream& operator<<(std::ostream&, const mpoint&); + auto operator<=>(const mpoint&) const = default; }; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(mpoint, (a.x,a.y,a.z,a.radius), (b.x,b.y,b.z,b.radius)); - ARB_ARBOR_API mpoint lerp(const mpoint& a, const mpoint& b, double u); ARB_ARBOR_API bool is_collocated(const mpoint& a, const mpoint& b); ARB_ARBOR_API double distance(const mpoint& a, const mpoint& b); @@ -46,25 +40,22 @@ struct ARB_SYMBOL_VISIBLE msegment { mpoint prox; mpoint dist; int tag; - + auto operator<=>(const msegment&) const = default; friend std::ostream& operator<<(std::ostream&, const msegment&); }; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(msegment, (a.id,a.prox,a.dist,a.tag), (b.id,b.prox,b.dist,b.tag)); - // Describe a specific location on a morpholology. struct ARB_SYMBOL_VISIBLE mlocation { // The id of the branch. msize_t branch = 0; // The relative position on the branch ∈ [0,1]. double pos = 0.0; - + auto operator<=>(const mlocation&) const = default; friend std::ostream& operator<<(std::ostream&, const mlocation&); }; // branch ≠ npos and 0 ≤ pos ≤ 1 ARB_ARBOR_API bool test_invariants(const mlocation&); -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(mlocation, (a.branch,a.pos), (b.branch,b.pos)); using mlocation_list = std::vector; ARB_ARBOR_API std::ostream& operator<<(std::ostream& o, const mlocation_list& l); @@ -94,20 +85,16 @@ struct ARB_SYMBOL_VISIBLE mcable { double prox_pos; // ∈ [0,1] double dist_pos; // ∈ [0,1] - friend mlocation prox_loc(const mcable& c) { - return {c.branch, c.prox_pos}; - } - friend mlocation dist_loc(const mcable& c) { - return {c.branch, c.dist_pos}; - } + auto operator<=>(const mcable&) const = default; + + friend mlocation prox_loc(const mcable& c) { return {c.branch, c.prox_pos}; } + friend mlocation dist_loc(const mcable& c) { return {c.branch, c.dist_pos}; } // branch ≠ npos, and 0 ≤ prox_pos ≤ dist_pos ≤ 1 friend bool test_invariants(const mcable&); friend std::ostream& operator<<(std::ostream&, const mcable&); }; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(mcable, (a.branch,a.prox_pos,a.dist_pos), (b.branch,b.prox_pos,b.dist_pos)); - using mcable_list = std::vector; ARB_ARBOR_API std::ostream& operator<<(std::ostream& o, const mcable_list& c); // Tests whether each cable in the list satisfies the invariants for a cable, diff --git a/arbor/include/arbor/network.hpp b/arbor/include/arbor/network.hpp index 262f318bdf..ac7c18a527 100644 --- a/arbor/include/arbor/network.hpp +++ b/arbor/include/arbor/network.hpp @@ -12,10 +12,7 @@ #include #include #include -#include #include -#include -#include #include #include #include @@ -41,14 +38,10 @@ struct ARB_SYMBOL_VISIBLE network_site_info { hash_type label; mlocation location; mpoint global_location; - + auto operator<=>(const network_site_info&) const = default; ARB_ARBOR_API friend std::ostream& operator<<(std::ostream& os, const network_site_info& s); }; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(network_site_info, - (a.gid, a.kind, a.label, a.location, a.global_location), - (b.gid, a.kind, b.label, b.location, b.global_location)) - struct ARB_SYMBOL_VISIBLE network_connection_info { network_site_info source, target; double weight, delay; @@ -62,14 +55,9 @@ struct ARB_SYMBOL_VISIBLE network_connection_info { weight(weight), delay(delay) {} - ARB_ARBOR_API friend std::ostream& operator<<(std::ostream& os, - const network_connection_info& s); + auto operator<=>(const network_connection_info&) const = default; + ARB_ARBOR_API friend std::ostream& operator<<(std::ostream& os, const network_connection_info& s); }; - -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(network_connection_info, - (a.source, a.target, a.weight, a.delay), - (b.source, b.target, b.weight, b.delay)) - struct network_selection_impl; struct network_value_impl; diff --git a/arbor/include/arbor/spike.hpp b/arbor/include/arbor/spike.hpp index 04843bcb67..effacc5e77 100644 --- a/arbor/include/arbor/spike.hpp +++ b/arbor/include/arbor/spike.hpp @@ -21,7 +21,7 @@ struct basic_spike { basic_spike(id_type s, time_type t): source(std::move(s)), time(t) {} - + auto operator<=>(const basic_spike&) const = default; ARB_SERDES_ENABLE(basic_spike, source, time); }; @@ -30,8 +30,6 @@ using spike = basic_spike; using spike_predicate = std::function; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(spike, (a.source, a.time), (b.source, b.time)); - // Custom stream operator for printing arb::spike<> values. template std::ostream& operator<<(std::ostream& o, basic_spike const& s) { diff --git a/arbor/include/arbor/spike_event.hpp b/arbor/include/arbor/spike_event.hpp index 7e1fc637e8..6dea97002d 100644 --- a/arbor/include/arbor/spike_event.hpp +++ b/arbor/include/arbor/spike_event.hpp @@ -22,11 +22,12 @@ struct spike_event { spike_event() = default; constexpr spike_event(cell_lid_type tgt, time_type t, arb_weight_type w) noexcept: target(tgt), weight(w), time(t) {} + bool operator==(const spike_event&) const = default; + constexpr auto operator<=>(const spike_event& o) const { return std::tie(time, target, weight) <=> std::tie(o.time, o.target, o.weight); } + ARB_SERDES_ENABLE(spike_event, target, time, weight); }; -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(spike_event,(a.time,a.target,a.weight),(b.time,b.target,b.weight)) - using pse_vector = std::vector; ARB_ARBOR_API std::ostream& operator<<(std::ostream&, const spike_event&); diff --git a/arbor/include/arbor/util/any_ptr.hpp b/arbor/include/arbor/util/any_ptr.hpp index 80f5273c6d..819f5f6c0d 100644 --- a/arbor/include/arbor/util/any_ptr.hpp +++ b/arbor/include/arbor/util/any_ptr.hpp @@ -62,7 +62,7 @@ struct ARB_SYMBOL_VISIBLE any_ptr { } template ::value>> - T as() const noexcept { + constexpr T as() const noexcept { if (std::is_same::value) { return (T)ptr_; } @@ -88,14 +88,14 @@ struct ARB_SYMBOL_VISIBLE any_ptr { return *this; } + constexpr auto operator<=>(const any_ptr& o) { return this->as() <=> o.as(); } + constexpr auto operator==(const any_ptr& o) { return this->as() == o.as(); } + private: void* ptr_ = nullptr; const std::type_info* type_ptr_ = &typeid(void); }; -// Order, compare by pointer value: -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_BY_VALUE(any_ptr, (a.as()), (b.as())) - // Overload `util::any_cast` for these pointers. template T any_cast(any_ptr p) noexcept { return p.as(); } diff --git a/arbor/include/arbor/util/lexcmp_def.hpp b/arbor/include/arbor/util/lexcmp_def.hpp deleted file mode 100644 index 5c8657a46b..0000000000 --- a/arbor/include/arbor/util/lexcmp_def.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -/* - * Macro definitions for defining comparison operators for - * record-like types. - * - * Use: - * - * To define comparison operations for a record type xyzzy - * with fields foo, bar and baz: - * - * ARB_DEFINE_LEXICOGRAPHIC_ORDERING(xyzzy,(a.foo,a.bar,a.baz),(b.foo,b.bar,b.baz)) - * - * The explicit use of 'a' and 'b' in the second and third parameters - * is needed only to save a heroic amount of preprocessor macro - * deep magic. - * - */ - -#include -#include - -#define ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(proxy,op,type,a_fields,b_fields) \ -inline bool operator op(const type& a,const type& b) { return proxy a_fields op proxy b_fields; } - -#define ARB_DEFINE_SPACESHIP_IMPL_(proxy,type,a_fields,b_fields) \ -inline auto operator<=>(const type& a,const type& b) { return proxy a_fields <=> proxy b_fields; } - -#define ARB_DEFINE_LEXICOGRAPHIC_ORDERING(type,a_fields,b_fields) \ -ARB_DEFINE_SPACESHIP_IMPL_(std::tie,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,<,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,>,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,<=,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,>=,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,!=,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,==,type,a_fields,b_fields) - -#define ARB_DEFINE_LEXICOGRAPHIC_ORDERING_BY_VALUE(type,a_fields,b_fields) \ -ARB_DEFINE_SPACESHIP_IMPL_(std::make_tuple,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,<,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,>,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,<=,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,>=,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,!=,type,a_fields,b_fields) \ -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::make_tuple,==,type,a_fields,b_fields) diff --git a/arbor/morph/segment_tree.cpp b/arbor/morph/segment_tree.cpp index 551e213ed1..7181809434 100644 --- a/arbor/morph/segment_tree.cpp +++ b/arbor/morph/segment_tree.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/arborio/swcio.cpp b/arborio/swcio.cpp index 5cdfab8c22..93f70209a7 100644 --- a/arborio/swcio.cpp +++ b/arborio/swcio.cpp @@ -1,9 +1,7 @@ -#include +#include #include #include -#include #include -#include #include #include #include @@ -13,7 +11,6 @@ #include #include - #include "arbor/morph/primitives.hpp" #include diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index 912c6104b5..503e046102 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -46,14 +46,6 @@ set(CXXOPT_WALL $,-Wno-range-loop-analysis,> - # Clang: - # - # * Disable 'unused-function' warning: this will flag the unused - # functions generated by `ARB_DEFINE_LEXICOGRAPHIC_ORDERING` - - $,-Wno-unused-function,> - $,-Wno-unused-function,> - # * Clang erroneously warns that T is an 'unused type alias' # in code like this: # struct X { diff --git a/python/label_dict.hpp b/python/label_dict.hpp index 1e60451234..c8012ed6b7 100644 --- a/python/label_dict.hpp +++ b/python/label_dict.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 96f7e6d328..98f0f5f947 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -86,7 +86,6 @@ set(unit_sources test_iexpr.cpp test_index.cpp test_kinetic_linear.cpp - test_lexcmp.cpp test_label_resolution.cpp test_lif_cell_group.cpp test_local_context.cpp diff --git a/test/unit/test_lexcmp.cpp b/test/unit/test_lexcmp.cpp deleted file mode 100644 index af40b23880..0000000000 --- a/test/unit/test_lexcmp.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include - -#include - -struct lexcmp_test_one { - int foo; -}; - -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(lexcmp_test_one, (a.foo), (b.foo)) - -TEST(lexcmp_def,one) { - lexcmp_test_one p{3}, q{4}, r{4}; - - EXPECT_LE(p,q); - EXPECT_LT(p,q); - EXPECT_NE(p,q); - EXPECT_GE(q,p); - EXPECT_GT(q,p); - - EXPECT_LE(q,r); - EXPECT_GE(q,r); - EXPECT_EQ(q,r); -} - -struct lexcmp_test_three { - int x; - std::string y; - double z; -}; - -// test fields in reverse order: z, y, x -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(lexcmp_test_three, (a.z,a.y,a.x), (b.z,b.y,b.x)) - -TEST(lexcmp_def,three) { - lexcmp_test_three p{1,"foo",2}; - lexcmp_test_three q{1,"foo",3}; - lexcmp_test_three r{1,"bar",2}; - lexcmp_test_three s{5,"foo",2}; - - EXPECT_LE(p,q); - EXPECT_LT(p,q); - EXPECT_NE(p,q); - EXPECT_GE(q,p); - EXPECT_GT(q,p); - - EXPECT_LE(r,p); - EXPECT_LT(r,p); - EXPECT_NE(p,r); - EXPECT_GE(p,r); - EXPECT_GT(p,r); - - EXPECT_LE(p,s); - EXPECT_LT(p,s); - EXPECT_NE(p,s); - EXPECT_GE(s,p); - EXPECT_GT(s,p); -} - -// test fields accessed by reference-returning member function - -class lexcmp_test_refmemfn { -public: - explicit lexcmp_test_refmemfn(int foo): foo_(foo) {} - - const int& foo() const { return foo_; } - int& foo() { return foo_; } - -private: - int foo_; -}; - -ARB_DEFINE_LEXICOGRAPHIC_ORDERING(lexcmp_test_refmemfn, (a.foo()), (b.foo())) - -TEST(lexcmp_def,refmemfn) { - lexcmp_test_refmemfn p{3}; - const lexcmp_test_refmemfn q{4}; - - EXPECT_LE(p,q); - EXPECT_LT(p,q); - EXPECT_NE(p,q); - EXPECT_GE(q,p); - EXPECT_GT(q,p); -} - -// test comparison via proxy tuple object - -class lexcmp_test_valmemfn { -public: - explicit lexcmp_test_valmemfn(int foo, int bar): foo_(foo), bar_(bar) {} - int foo() const { return foo_; } - int bar() const { return bar_; } - -private: - int foo_; - int bar_; -}; - -ARB_DEFINE_LEXICOGRAPHIC_ORDERING_BY_VALUE(lexcmp_test_valmemfn, (a.foo(),a.bar()), (b.foo(),b.bar())) - -TEST(lexcmp_def,proxy) { - lexcmp_test_valmemfn p{3,2}, q{3,4}; - - EXPECT_LE(p,q); - EXPECT_LT(p,q); - EXPECT_NE(p,q); - EXPECT_GE(q,p); - EXPECT_GT(q,p); -} - - From e65af748fc04f940a1dddbf94a7dc14d565fd01d Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:10:17 +0200 Subject: [PATCH 04/13] Remove some custom definitions. --- arbor/backends/gpu/fine.hpp | 2 ++ arbor/connection.hpp | 15 +++++++-------- arbor/include/arbor/morph/morphology.hpp | 1 - arbor/include/arbor/network.hpp | 1 - arbor/include/arbor/spike_event.hpp | 1 - arbor/include/arbor/util/any_ptr.hpp | 6 ++---- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/arbor/backends/gpu/fine.hpp b/arbor/backends/gpu/fine.hpp index de090d8e53..1de5524262 100644 --- a/arbor/backends/gpu/fine.hpp +++ b/arbor/backends/gpu/fine.hpp @@ -38,6 +38,8 @@ struct branch { unsigned parent_idx; // unsigned start_idx; // the index of the first node in the input parent index unsigned length; // the number of nodes in the branch + + bool operator==(const branch&) const = default; }; // order branches by: diff --git a/arbor/connection.hpp b/arbor/connection.hpp index 276ed217aa..d39c9e4184 100644 --- a/arbor/connection.hpp +++ b/arbor/connection.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include #include #include @@ -14,6 +12,13 @@ struct connection { float weight = 0.0f; float delay = 0.0f; cell_size_type index_on_domain = cell_gid_type(-1); + + bool operator==(const connection&) const = default; + + // connections are sorted by source id + // these operators make for easy interopability with STL algorithms + auto operator<=>(const connection& rhs) const { return source <=> rhs.source; } + auto operator<=>(const cell_member_type& rhs) const { return source <=> rhs; } }; inline @@ -21,12 +26,6 @@ spike_event make_event(const connection& c, const spike& s) { return {c.target, s.time + c.delay, c.weight}; } -// connections are sorted by source id -// these operators make for easy interopability with STL algorithms -static inline bool operator<(const connection& lhs, const connection& rhs) { return lhs.source < rhs.source; } -static inline bool operator<(const connection& lhs, cell_member_type rhs) { return lhs.source < rhs; } -static inline bool operator<(cell_member_type lhs, const connection& rhs) { return lhs < rhs.source; } - } // namespace arb static inline std::ostream& operator<<(std::ostream& o, arb::connection const& con) { diff --git a/arbor/include/arbor/morph/morphology.hpp b/arbor/include/arbor/morph/morphology.hpp index 68ce34a0ef..062eddd196 100644 --- a/arbor/include/arbor/morph/morphology.hpp +++ b/arbor/include/arbor/morph/morphology.hpp @@ -7,7 +7,6 @@ #include #include #include -#include namespace arb { diff --git a/arbor/include/arbor/network.hpp b/arbor/include/arbor/network.hpp index ac7c18a527..a3be0e2c91 100644 --- a/arbor/include/arbor/network.hpp +++ b/arbor/include/arbor/network.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/arbor/include/arbor/spike_event.hpp b/arbor/include/arbor/spike_event.hpp index 6dea97002d..aedac08c72 100644 --- a/arbor/include/arbor/spike_event.hpp +++ b/arbor/include/arbor/spike_event.hpp @@ -8,7 +8,6 @@ #include #include #include -#include namespace arb { diff --git a/arbor/include/arbor/util/any_ptr.hpp b/arbor/include/arbor/util/any_ptr.hpp index 819f5f6c0d..c162478711 100644 --- a/arbor/include/arbor/util/any_ptr.hpp +++ b/arbor/include/arbor/util/any_ptr.hpp @@ -31,8 +31,6 @@ #include #include -#include - namespace arb { namespace util { @@ -88,8 +86,8 @@ struct ARB_SYMBOL_VISIBLE any_ptr { return *this; } - constexpr auto operator<=>(const any_ptr& o) { return this->as() <=> o.as(); } - constexpr auto operator==(const any_ptr& o) { return this->as() == o.as(); } + constexpr auto operator<=>(const any_ptr& o) const { return this->as() <=> o.as(); } + constexpr auto operator==(const any_ptr& o) const { return this->as() == o.as(); } private: void* ptr_ = nullptr; From 7aa7d3bb512c5320e93deafc003f521b9e07b32e Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:40:13 +0200 Subject: [PATCH 05/13] Final clean-up. --- arbor/backends/gpu/matrix_fine.hpp | 2 -- arbor/util/iterutil.hpp | 26 +++----------------------- arbor/util/sentinel.hpp | 23 ----------------------- 3 files changed, 3 insertions(+), 48 deletions(-) diff --git a/arbor/backends/gpu/matrix_fine.hpp b/arbor/backends/gpu/matrix_fine.hpp index d89d939892..8614ac9c67 100644 --- a/arbor/backends/gpu/matrix_fine.hpp +++ b/arbor/backends/gpu/matrix_fine.hpp @@ -3,8 +3,6 @@ #include "fine.hpp" -#include - namespace arb { namespace gpu { ARB_ARBOR_API void assemble_matrix_fine( diff --git a/arbor/util/iterutil.hpp b/arbor/util/iterutil.hpp index c8ede990b5..ca1560b6d5 100644 --- a/arbor/util/iterutil.hpp +++ b/arbor/util/iterutil.hpp @@ -282,13 +282,9 @@ class generating_view_iterator_adaptor { return c; } - bool operator==(const Derived& x) const noexcept { - return index_==x.index_; - } - - bool operator!=(const Derived& x) const noexcept { - return !(derived()==x); - } + bool operator==(const Derived& x) const { return index_==x.index_; } + bool operator!=(const Derived& x) const { return !(derived()==x); } + auto operator<=>(const Derived& x) const { return derived().index_ <=> x.index_; } // bidirectional iterator requirements @@ -334,22 +330,6 @@ class generating_view_iterator_adaptor { difference_type operator-(const Derived& x) const noexcept { return (difference_type)index_ - (difference_type)x.index_; } - - bool operator<(const Derived& x) const noexcept { - return index_ < x.index_; - } - - bool operator<=(const Derived& x) const noexcept { - return derived()=(const Derived& x) const noexcept { - return !(derived()(const Derived& x) const noexcept { - return !(derived()<=x); - } }; } // namespace util diff --git a/arbor/util/sentinel.hpp b/arbor/util/sentinel.hpp index f93185e445..278432e374 100644 --- a/arbor/util/sentinel.hpp +++ b/arbor/util/sentinel.hpp @@ -3,8 +3,6 @@ #include #include -#include "util/meta.hpp" - /* * Use a proxy iterator to present a range as having the same begin and * end types, for use with e.g. pre-C++17 ranged-for loops or STL @@ -95,10 +93,6 @@ class sentinel_iterator { } } - bool operator!=(const sentinel_iterator& x) const { - return !(*this==x); - } - // bidirectional iterator requirements sentinel_iterator& operator--() { @@ -146,24 +140,7 @@ class sentinel_iterator { return *(iter()+n); } - bool operator<=(const sentinel_iterator& x) const { - return x.is_sentinel() || (!is_sentinel() && iter()<=x.iter()); - } - - bool operator<(const sentinel_iterator& x) const { - return !is_sentinel() && (x.is_sentinel() || iter()<=x.iter()); - } - - bool operator>=(const sentinel_iterator& x) const { - return !(x<*this); - } - - bool operator>(const sentinel_iterator& x) const { - return !(x<=*this); - } - // access to underlying iterator/sentinel - bool is_sentinel() const { return e_.index()!=0; } bool is_iterator() const { return e_.index()==0; } From 72e9fbe239277696482082c0d6f31b5e7835eaf8 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:10:14 +0200 Subject: [PATCH 06/13] Result -> invoke_result. --- arbor/include/arbor/util/uninitialized.hpp | 4 ++-- arbor/util/rangeutil.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arbor/include/arbor/util/uninitialized.hpp b/arbor/include/arbor/util/uninitialized.hpp index 7752f2c26a..23320c1b17 100644 --- a/arbor/include/arbor/util/uninitialized.hpp +++ b/arbor/include/arbor/util/uninitialized.hpp @@ -74,11 +74,11 @@ class uninitialized { // Apply the one-parameter functor F to the value by reference. template - std::result_of_t apply(F&& f) { return f(ref()); } + std::invoke_result_t apply(F&& f) { return f(ref()); } // Apply the one-parameter functor F to the value by const reference. template - std::result_of_t apply(F&& f) const { return f(cref()); } + std::invoke_result_t apply(F&& f) const { return f(cref()); } }; /* diff --git a/arbor/util/rangeutil.hpp b/arbor/util/rangeutil.hpp index 312bd55877..59a6be0e61 100644 --- a/arbor/util/rangeutil.hpp +++ b/arbor/util/rangeutil.hpp @@ -349,7 +349,7 @@ bool equal(const Seq1& seq1, const Seq2& seq2, Eq p = Eq{}) { template < typename Seq, typename Proj, - typename Compare = std::less::value_type)>> + typename Compare = std::less::value_type)>> > bool is_sorted_by(const Seq& seq, const Proj& proj, Compare cmp = Compare{}) { using std::begin; From 097938d947976a1e7177f7c52a9b5abf4180059f Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:31:18 +0200 Subject: [PATCH 07/13] Proper invoke_result_t. --- arbor/include/arbor/util/uninitialized.hpp | 4 ++-- arbor/util/rangeutil.hpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arbor/include/arbor/util/uninitialized.hpp b/arbor/include/arbor/util/uninitialized.hpp index 23320c1b17..f7d92eea55 100644 --- a/arbor/include/arbor/util/uninitialized.hpp +++ b/arbor/include/arbor/util/uninitialized.hpp @@ -74,11 +74,11 @@ class uninitialized { // Apply the one-parameter functor F to the value by reference. template - std::invoke_result_t apply(F&& f) { return f(ref()); } + std::invoke_result_t apply(F&& f) { return f(ref()); } // Apply the one-parameter functor F to the value by const reference. template - std::invoke_result_t apply(F&& f) const { return f(cref()); } + std::invoke_result_t apply(F&& f) const { return f(cref()); } }; /* diff --git a/arbor/util/rangeutil.hpp b/arbor/util/rangeutil.hpp index 59a6be0e61..2d08638abd 100644 --- a/arbor/util/rangeutil.hpp +++ b/arbor/util/rangeutil.hpp @@ -346,11 +346,9 @@ bool equal(const Seq1& seq1, const Seq2& seq2, Eq p = Eq{}) { // (TODO: this will perform unnecessary copies if `proj` returns a reference; // specialize on this if it becomes an issue.) -template < - typename Seq, - typename Proj, - typename Compare = std::less::value_type)>> -> +template ::value_type>>> bool is_sorted_by(const Seq& seq, const Proj& proj, Compare cmp = Compare{}) { using std::begin; using std::end; From 17602dfb9510021858ee9ec79eb027849e616821 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 10 Sep 2024 21:55:46 +0200 Subject: [PATCH 08/13] Make it const. --- arbor/include/arbor/fvm_types.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbor/include/arbor/fvm_types.hpp b/arbor/include/arbor/fvm_types.hpp index 9131abcba9..a91708b25f 100644 --- a/arbor/include/arbor/fvm_types.hpp +++ b/arbor/include/arbor/fvm_types.hpp @@ -12,7 +12,7 @@ struct fvm_gap_junction { arb_value_type weight; // unit-less local weight of the connection. constexpr bool operator==(const fvm_gap_junction&) const = default; - constexpr auto operator<=>(const fvm_gap_junction& o) { + constexpr auto operator<=>(const fvm_gap_junction& o) const { return std::tie(local_cv, peer_cv, local_idx, weight) <=> std::tie(o.local_cv, o.peer_cv, o.local_idx, o.weight); } }; From e72078a4ad132a270f2f79acbee77711a504120d Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 11 Sep 2024 07:14:31 +0200 Subject: [PATCH 09/13] Bump minimum MacOS version and disable fail fast for debugging. --- .github/workflows/test-matrix.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-matrix.yml b/.github/workflows/test-matrix.yml index 3e91b9d90f..00ed3a7b22 100644 --- a/.github/workflows/test-matrix.yml +++ b/.github/workflows/test-matrix.yml @@ -13,6 +13,7 @@ jobs: name: "CMake Matrix Test." runs-on: ${{ matrix.config.os }} strategy: + fail-fast: false matrix: config: - { @@ -37,7 +38,7 @@ jobs: } - { name: "MacOS Min", - os: "macos-12", + os: "macos-13", cc: "clang", cxx: "clang++", py: "3.9", From e546f668f579d0c92455a9b605e8378d0f3f5632 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 11 Sep 2024 07:55:47 +0200 Subject: [PATCH 10/13] Fix a few warnings uncovered by removing the suppression. --- doc/dependencies.csv | 2 +- python/CMakeLists.txt | 2 +- test/unit/test_expected.cpp | 5 +---- test/unit/test_morph_place.cpp | 3 --- test/unit/test_simd.cpp | 3 ++- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/doc/dependencies.csv b/doc/dependencies.csv index 5f1aee3c31..2eac7a26aa 100644 --- a/doc/dependencies.csv +++ b/doc/dependencies.csv @@ -5,7 +5,7 @@ Build option/target,Tool name,Minimum version,Notes,Update criteria --,GCC,12.0.0,,"* it is supported by the minimum version of CUDA. * it is available either by default or can be installed using standard package manager on the supported Linux versions." --,Clang,12.0,, ---,Apple Clang,13,Apple LLVM version 13.0.0 (clang-1300.x.y.z), +--,Apple Clang,15,Apple LLVM version 15.0.0 (clang-1500.x.y.z), ARB_GPU,Hip Clang,ROCm 3.9,HIP support is currently experimental., ARB_GPU,CUDA,12.0,,"* It is available on all of the target HPC systems (Piz Daint, Juwels Booster)" ARB_WITH_MPI,MPI,,Many MPI implementations are supported., diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9a42a09c7d..2f1f94ab31 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,6 +1,6 @@ include(GNUInstallDirs) -set(PYBIND11_CPP_STANDARD -std=c++17) +set(PYBIND11_CPP_STANDARD -std=c++20) if(ARB_USE_BUNDLED_PYBIND11) include(FindPythonModule) # required for find_python_module diff --git a/test/unit/test_expected.cpp b/test/unit/test_expected.cpp index 509918cb60..7e6803f5aa 100644 --- a/test/unit/test_expected.cpp +++ b/test/unit/test_expected.cpp @@ -1,11 +1,8 @@ #include #include -#include #include -#include "common.hpp" - using namespace arb::util; using std::in_place; @@ -315,7 +312,7 @@ struct Xswap { }; struct swap_can_throw { - friend void swap(swap_can_throw& s1, swap_can_throw& s2) noexcept(false) {} + friend void swap(swap_can_throw& s1, swap_can_throw& s2) noexcept(false) { std::swap(s1, s2); } }; } diff --git a/test/unit/test_morph_place.cpp b/test/unit/test_morph_place.cpp index 41f1ecb7bd..5ee2314120 100644 --- a/test/unit/test_morph_place.cpp +++ b/test/unit/test_morph_place.cpp @@ -27,9 +27,6 @@ struct v3 { friend v3 operator*(v3 p, double s) { return {s*p.x, s*p.y, s*p.z}; } - friend v3 operator*(double s, v3 p) { - return p*s; - } friend v3 operator/(v3 p, double s) { return p*(1./s); } diff --git a/test/unit/test_simd.cpp b/test/unit/test_simd.cpp index d3a572b327..87ea359cb4 100644 --- a/test/unit/test_simd.cpp +++ b/test/unit/test_simd.cpp @@ -93,7 +93,8 @@ namespace { constexpr unsigned nrounds = 20u; - constexpr int native_width = ::arb::simd::simd_abi::native_width::value; + // Used with SVE only. + constexpr int native_width [[maybe_unused]] = ::arb::simd::simd_abi::native_width::value; } template From 7f4cd06f627056780012e955cabcd38d29d4d6ad Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:07:31 +0200 Subject: [PATCH 11/13] Apply suggestions from code review Co-authored-by: boeschf <48126478+boeschf@users.noreply.github.com> --- arbor/include/arbor/util/any_ptr.hpp | 2 +- modcc/symge.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arbor/include/arbor/util/any_ptr.hpp b/arbor/include/arbor/util/any_ptr.hpp index c162478711..8e9df9d18d 100644 --- a/arbor/include/arbor/util/any_ptr.hpp +++ b/arbor/include/arbor/util/any_ptr.hpp @@ -61,7 +61,7 @@ struct ARB_SYMBOL_VISIBLE any_ptr { template ::value>> constexpr T as() const noexcept { - if (std::is_same::value) { + if constexpr (std::is_same_v) { return (T)ptr_; } else { diff --git a/modcc/symge.hpp b/modcc/symge.hpp index 4ed8a92370..a1419b7e4f 100644 --- a/modcc/symge.hpp +++ b/modcc/symge.hpp @@ -46,7 +46,7 @@ struct symbol_term { symbol left, right; symbol_term() = default; - symbol_term(const symbol left): left(std::move(left)) {} + symbol_term(symbol left): left(std::move(left)) {} symbol_term(symbol left, symbol right): left(std::move(left)), right(std::move(right)) {} bool is_zero() const { return !left || !right; } operator bool() const { return !is_zero(); } @@ -56,7 +56,7 @@ struct symbol_term_diff { symbol_term left, right; symbol_term_diff() = default; - symbol_term_diff(const symbol_term left): left(std::move(left)) {} + symbol_term_diff(symbol_term left): left(std::move(left)) {} symbol_term_diff(symbol_term left, symbol_term right): left(std::move(left)), right(std::move(right)) {} }; From aee5a53fd076c50fde3b0903bdeab2fe9f9383fe Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:41:50 +0200 Subject: [PATCH 12/13] Clean-up uuid --- arborenv/gpu_uuid.cpp | 10 ---------- arborenv/gpu_uuid.hpp | 16 ++++++++++------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/arborenv/gpu_uuid.cpp b/arborenv/gpu_uuid.cpp index d13f0ee4da..b6fd950532 100644 --- a/arborenv/gpu_uuid.cpp +++ b/arborenv/gpu_uuid.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "gpu_uuid.hpp" @@ -42,15 +41,6 @@ using arb::util::on_scope_exit; namespace arbenv { -// Strict lexographical ordering of GPU uids -std::strong_ordering operator<=>(const uuid& lhs, const uuid& rhs) { - for (auto i=0u; ilhs.bytes[i]) return std::strong_ordering::greater; - } - return return std::strong_ordering::equivalent; -} - std::ostream& operator<<(std::ostream& o, const uuid& id) { std::ios old_state(nullptr); old_state.copyfmt(o); diff --git a/arborenv/gpu_uuid.hpp b/arborenv/gpu_uuid.hpp index 3226d694b5..3f3a5f3714 100644 --- a/arborenv/gpu_uuid.hpp +++ b/arborenv/gpu_uuid.hpp @@ -13,13 +13,17 @@ namespace arbenv { struct alignas(sizeof(void*)) uuid { std::array bytes = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -}; - -// Test GPU uids for equality -bool operator==(const uuid& lhs, const uuid& rhs); -// Strict lexographical ordering of GPU uids -bool operator<(const uuid& lhs, const uuid& rhs); + bool operator==(const uuid&) const = default; + auto operator<=>(const uuid& rhs) const { + for (int ix = 0; bytes.size(); ++ix) { + if (auto res = bytes[ix] <=> rhs.bytes[ix]; res != 0) { + return res; + } + } + return std::strong_ordering::equivalent; + } +}; // Print uuid in big-endian format, e.g. f1fd7811-e4d3-4d54-abb7-efc579fb1e28 std::ostream& operator<<(std::ostream& o, const uuid& id); From 4721eb3fe8bcb2aa84b64fac85764bfca14117d8 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:42:39 +0200 Subject: [PATCH 13/13] Clean-up, re-private counter::V --- arbor/util/counter.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arbor/util/counter.hpp b/arbor/util/counter.hpp index 4dd2b6fbeb..9775b67683 100644 --- a/arbor/util/counter.hpp +++ b/arbor/util/counter.hpp @@ -1,8 +1,6 @@ #pragma once /* Present an integral value as an iterator, for integral-range 'containers' */ - -#include #include #include #include @@ -83,6 +81,7 @@ struct counter { counter& operator=(const counter&) = default; counter& operator=(counter&&) = default; +private: V v_; };