Skip to content

Commit a4be26e

Browse files
Merge pull request #877 from PowerGridModel/feature/use-lto-for-ci-release
use link time optimization for CI release build
2 parents d094684 + 3ef4445 commit a4be26e

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

CMakePresets.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@
254254
},
255255
{
256256
"name": "ci-clang-release",
257-
"inherits": "clang-release"
257+
"inherits": "clang-release",
258+
"cacheVariables": {
259+
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE"
260+
}
258261
},
259262
{
260263
"name": "ci-gcc-debug",
@@ -270,7 +273,13 @@
270273
"name": "ci-gcc-release",
271274
"inherits": [
272275
"gcc-release"
273-
]
276+
],
277+
"cacheVariables": {
278+
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE"
279+
},
280+
"environment": {
281+
"ASAN_OPTIONS": "detect_odr_violation=0"
282+
}
274283
},
275284
{
276285
"name": "ci-sonar",

power_grid_model_c/power_grid_model/include/power_grid_model/common/common.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,10 @@ using IntSVector = std::vector<IntS>;
9191
template <class T, class... Ts>
9292
concept is_in_list_c = (std::same_as<std::remove_const_t<T>, Ts> || ...);
9393

94+
// functor to include all
95+
struct IncludeAll {
96+
template <class... T> constexpr bool operator()(T&&... /*ignored*/) const { return true; }
97+
};
98+
constexpr IncludeAll include_all{};
99+
94100
} // namespace power_grid_model

power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,6 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
10141014
return math_param_increment;
10151015
}
10161016

1017-
static constexpr auto include_all = [](Idx) { return true; };
1018-
10191017
/** This is a heavily templated member function because it operates on many different variables of many
10201018
*different types, but the essence is ever the same: filling one member (vector) of the calculation calc_input
10211019
*struct (soa) with the right calculation symmetric or asymmetric calculation parameters, in the same order as
@@ -1068,7 +1066,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
10681066
*/
10691067
template <calculation_input_type CalcStructOut, typename CalcParamOut,
10701068
std::vector<CalcParamOut>(CalcStructOut::*comp_vect), class ComponentIn,
1071-
std::invocable<Idx> PredicateIn = decltype(include_all)>
1069+
std::invocable<Idx> PredicateIn = IncludeAll>
10721070
requires std::convertible_to<std::invoke_result_t<PredicateIn, Idx>, bool>
10731071
static void prepare_input(MainModelState const& state, std::vector<Idx2D> const& components,
10741072
std::vector<CalcStructOut>& calc_input, PredicateIn include = include_all) {
@@ -1087,7 +1085,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
10871085

10881086
template <calculation_input_type CalcStructOut, typename CalcParamOut,
10891087
std::vector<CalcParamOut>(CalcStructOut::*comp_vect), class ComponentIn,
1090-
std::invocable<Idx> PredicateIn = decltype(include_all)>
1088+
std::invocable<Idx> PredicateIn = IncludeAll>
10911089
requires std::convertible_to<std::invoke_result_t<PredicateIn, Idx>, bool>
10921090
static void prepare_input(MainModelState const& state, std::vector<Idx2D> const& components,
10931091
std::vector<CalcStructOut>& calc_input,

power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,13 @@ template <symmetry_tag sym> class MeasuredValues {
498498
}
499499

500500
// process one object
501-
static constexpr auto default_status_checker = [](auto x) -> bool { return x; };
501+
struct DefaultStatusChecker {
502+
template <class T> bool operator()(T x) const { return x; }
503+
};
504+
505+
static constexpr DefaultStatusChecker default_status_checker{};
502506

503-
template <class TS, class StatusChecker = decltype(default_status_checker)>
507+
template <class TS, class StatusChecker = DefaultStatusChecker>
504508
static Idx process_one_object(Idx const object, grouped_idx_vector_type auto const& sensors_per_object,
505509
std::vector<TS> const& object_status,
506510
std::vector<PowerSensorCalcParam<sym>> const& input_data,

power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ class Topology {
429429
}
430430
}
431431

432-
static constexpr auto include_all = [](Idx) { return true; };
433-
434432
// proxy class to find the coupled object in math model in the coupling process to a single type object
435433
// given a particular component index
436434
struct SingleTypeObjectFinder {
@@ -481,7 +479,7 @@ class Topology {
481479
// The coupling element should be pre-allocated in coupling
482480
// Only connect the component if include(component_i) returns true
483481
template <Idx (MathModelTopology::*n_obj_fn)() const, typename GetMathTopoComponent,
484-
typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = decltype(include_all)>
482+
typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = IncludeAll>
485483
requires std::invocable<std::remove_cvref_t<GetMathTopoComponent>, MathModelTopology&> &&
486484
grouped_idx_vector_type<
487485
std::remove_reference_t<std::invoke_result_t<GetMathTopoComponent, MathModelTopology&>>>

0 commit comments

Comments
 (0)