Skip to content

Use link time optimization for CI release build #877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 21, 2025
13 changes: 11 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@
},
{
"name": "ci-clang-release",
"inherits": "clang-release"
"inherits": "clang-release",
"cacheVariables": {
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE"
}
},
{
"name": "ci-gcc-debug",
Expand All @@ -270,7 +273,13 @@
"name": "ci-gcc-release",
"inherits": [
"gcc-release"
]
],
"cacheVariables": {
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE"
},
"environment": {
"ASAN_OPTIONS": "detect_odr_violation=0"
}
},
{
"name": "ci-sonar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,10 @@ using IntSVector = std::vector<IntS>;
template <class T, class... Ts>
concept is_in_list_c = (std::same_as<std::remove_const_t<T>, Ts> || ...);

// functor to include all
struct IncludeAll {
template <class... T> constexpr bool operator()(T&&... /*ignored*/) const { return true; }
};
constexpr IncludeAll include_all{};

} // namespace power_grid_model
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,6 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, 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
Expand Down Expand Up @@ -1068,7 +1066,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis
*/
template <calculation_input_type CalcStructOut, typename CalcParamOut,
std::vector<CalcParamOut>(CalcStructOut::*comp_vect), class ComponentIn,
std::invocable<Idx> PredicateIn = decltype(include_all)>
std::invocable<Idx> PredicateIn = IncludeAll>
requires std::convertible_to<std::invoke_result_t<PredicateIn, Idx>, bool>
static void prepare_input(MainModelState const& state, std::vector<Idx2D> const& components,
std::vector<CalcStructOut>& calc_input, PredicateIn include = include_all) {
Expand All @@ -1087,7 +1085,7 @@ class MainModelImpl<ExtraRetrievableTypes<ExtraRetrievableType...>, ComponentLis

template <calculation_input_type CalcStructOut, typename CalcParamOut,
std::vector<CalcParamOut>(CalcStructOut::*comp_vect), class ComponentIn,
std::invocable<Idx> PredicateIn = decltype(include_all)>
std::invocable<Idx> PredicateIn = IncludeAll>
requires std::convertible_to<std::invoke_result_t<PredicateIn, Idx>, bool>
static void prepare_input(MainModelState const& state, std::vector<Idx2D> const& components,
std::vector<CalcStructOut>& calc_input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,13 @@ template <symmetry_tag sym> class MeasuredValues {
}

// process one object
static constexpr auto default_status_checker = [](auto x) -> bool { return x; };
struct DefaultStatusChecker {
template <class T> bool operator()(T x) const { return x; }
};

static constexpr DefaultStatusChecker default_status_checker{};

template <class TS, class StatusChecker = decltype(default_status_checker)>
template <class TS, class StatusChecker = DefaultStatusChecker>
static Idx process_one_object(Idx const object, grouped_idx_vector_type auto const& sensors_per_object,
std::vector<TS> const& object_status,
std::vector<PowerSensorCalcParam<sym>> const& input_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 <Idx (MathModelTopology::*n_obj_fn)() const, typename GetMathTopoComponent,
typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = decltype(include_all)>
typename ObjectFinder = SingleTypeObjectFinder, typename Predicate = IncludeAll>
requires std::invocable<std::remove_cvref_t<GetMathTopoComponent>, MathModelTopology&> &&
grouped_idx_vector_type<
std::remove_reference_t<std::invoke_result_t<GetMathTopoComponent, MathModelTopology&>>>
Expand Down
Loading