From d54b032174fb325345e891e375f8f73f1aabad71 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Mon, 20 Jan 2025 09:38:38 +0100 Subject: [PATCH 1/9] use link time optimization for CI release build Signed-off-by: Tony Xiang --- CMakePresets.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index f108ed991b..7dbab65378 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -254,7 +254,10 @@ }, { "name": "ci-clang-release", - "inherits": "clang-release" + "inherits": "clang-release", + "cacheVariables": { + "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE" + } }, { "name": "ci-gcc-debug", @@ -270,7 +273,10 @@ "name": "ci-gcc-release", "inherits": [ "gcc-release" - ] + ], + "cacheVariables": { + "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE" + } }, { "name": "ci-sonar", From 108dfc3227c8c59d8c21652ec8439204afaaa5c8 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Mon, 20 Jan 2025 09:58:55 +0100 Subject: [PATCH 2/9] try to turn off odr violation check in address santitizer Signed-off-by: Tony Xiang --- CMakePresets.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakePresets.json b/CMakePresets.json index 7dbab65378..89896f5efa 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -276,6 +276,9 @@ ], "cacheVariables": { "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE" + }, + "environment": { + "ASAN_OPTIONS": "detect_odr_violation=0" } }, { From 204db405d0b04882e9653fd915d7fe2aa31013be Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Mon, 20 Jan 2025 10:53:08 +0100 Subject: [PATCH 3/9] try define separately Signed-off-by: Tony Xiang --- .../power_grid_model/math_solver/measured_values.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp index 2b90c4999b..a5ad484545 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp @@ -498,9 +498,16 @@ template class MeasuredValues { } // process one object - static constexpr auto default_status_checker = [](auto x) -> bool { return x; }; + struct DefaultStatusChecker { + template + bool operator()(T x) const { + return x; + } + }; + + static constexpr DefaultStatusChecker default_status_checker{}; - template + template static Idx process_one_object(Idx const object, grouped_idx_vector_type auto const& sensors_per_object, std::vector const& object_status, std::vector> const& input_data, From e916cd0832fd3ca769b599f5f872b0dac71f9dca Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Mon, 20 Jan 2025 10:54:31 +0100 Subject: [PATCH 4/9] format Signed-off-by: Tony Xiang --- .../include/power_grid_model/math_solver/measured_values.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp index a5ad484545..16e8d6ec33 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp @@ -499,10 +499,7 @@ template class MeasuredValues { // process one object struct DefaultStatusChecker { - template - bool operator()(T x) const { - return x; - } + template bool operator()(T x) const { return x; } }; static constexpr DefaultStatusChecker default_status_checker{}; From 923adffff9a88f66d30755b807a76c4b57653424 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Tue, 21 Jan 2025 14:48:03 +0100 Subject: [PATCH 5/9] try to enable LTO for clang-tidy Signed-off-by: Tony Xiang --- CMakePresets.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 89896f5efa..722dcea9fd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -129,7 +129,11 @@ "CMAKE_C_CLANG_TIDY": "clang-tidy", "CMAKE_CXX_CLANG_TIDY": "clang-tidy", "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++" + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE" + }, + "environment": { + "ASAN_OPTIONS": "detect_odr_violation=0" }, "inherits": "unix-base", "hidden": true From e60dac115be4d8943c28a66cc2295f026c3b6659 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Tue, 21 Jan 2025 15:23:19 +0100 Subject: [PATCH 6/9] Revert "try to enable LTO for clang-tidy" This reverts commit 923adffff9a88f66d30755b807a76c4b57653424. --- CMakePresets.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 722dcea9fd..89896f5efa 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -129,11 +129,7 @@ "CMAKE_C_CLANG_TIDY": "clang-tidy", "CMAKE_CXX_CLANG_TIDY": "clang-tidy", "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE" - }, - "environment": { - "ASAN_OPTIONS": "detect_odr_violation=0" + "CMAKE_CXX_COMPILER": "clang++" }, "inherits": "unix-base", "hidden": true From 96f1626bd1c8879367454a3e853ead8c94845ab9 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Tue, 21 Jan 2025 15:26:40 +0100 Subject: [PATCH 7/9] DCO Remediation Commit for Tony Xiang I, Tony Xiang , hereby add my Signed-off-by to this commit: e60dac115be4d8943c28a66cc2295f026c3b6659 Signed-off-by: Tony Xiang From 85405959c0fd2cda2b9d8928bf609e37eac80130 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Tue, 21 Jan 2025 15:51:56 +0100 Subject: [PATCH 8/9] fix other lambda issues Signed-off-by: Tony Xiang --- .../include/power_grid_model/common/common.hpp | 6 ++++++ .../include/power_grid_model/main_model_impl.hpp | 6 ++---- .../power_grid_model/include/power_grid_model/topology.hpp | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp index 43c6d78ce3..9b465962c7 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp @@ -91,4 +91,10 @@ using IntSVector = std::vector; template concept is_in_list_c = (std::same_as, Ts> || ...); +// functor to include all +struct IncludeAll { + constexpr bool operator()(Idx /*ignored*/) const { return true; } +}; +constexpr IncludeAll include_all{}; + } // namespace power_grid_model diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp index a512fc8347..9113e1844e 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp @@ -1014,8 +1014,6 @@ class MainModelImpl, ComponentLis return math_param_increment; } - static constexpr auto include_all = [](Idx) { return true; }; - /** This is a heavily templated member function because it operates on many different variables of many *different types, but the essence is ever the same: filling one member (vector) of the calculation calc_input *struct (soa) with the right calculation symmetric or asymmetric calculation parameters, in the same order as @@ -1068,7 +1066,7 @@ class MainModelImpl, ComponentLis */ template (CalcStructOut::*comp_vect), class ComponentIn, - std::invocable PredicateIn = decltype(include_all)> + std::invocable PredicateIn = IncludeAll> requires std::convertible_to, bool> static void prepare_input(MainModelState const& state, std::vector const& components, std::vector& calc_input, PredicateIn include = include_all) { @@ -1087,7 +1085,7 @@ class MainModelImpl, ComponentLis template (CalcStructOut::*comp_vect), class ComponentIn, - std::invocable PredicateIn = decltype(include_all)> + std::invocable PredicateIn = IncludeAll> requires std::convertible_to, bool> static void prepare_input(MainModelState const& state, std::vector const& components, std::vector& calc_input, diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp index 5968ebfcbe..96f49d225b 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp @@ -429,8 +429,6 @@ class Topology { } } - static constexpr auto include_all = [](Idx) { return true; }; - // proxy class to find the coupled object in math model in the coupling process to a single type object // given a particular component index struct SingleTypeObjectFinder { @@ -481,7 +479,7 @@ class Topology { // The coupling element should be pre-allocated in coupling // Only connect the component if include(component_i) returns true template + typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = IncludeAll> requires std::invocable, MathModelTopology&> && grouped_idx_vector_type< std::remove_reference_t>> From 3ef44455f2e989399e90c99fa461f76a3601f2a9 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Tue, 21 Jan 2025 16:02:19 +0100 Subject: [PATCH 9/9] generic include all Signed-off-by: Tony Xiang --- .../power_grid_model/include/power_grid_model/common/common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp index 9b465962c7..740d405311 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp @@ -93,7 +93,7 @@ concept is_in_list_c = (std::same_as, Ts> || ...); // functor to include all struct IncludeAll { - constexpr bool operator()(Idx /*ignored*/) const { return true; } + template constexpr bool operator()(T&&... /*ignored*/) const { return true; } }; constexpr IncludeAll include_all{};