From ac924ce3ad8f406037f7d2d5664f6910efd148f5 Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Mon, 6 Jan 2025 23:32:19 +0100 Subject: [PATCH 1/2] Emit jumps rather than stores for conditions --- geometry/hilbert_body.hpp | 3 ++- numerics/osaca.hpp | 29 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/geometry/hilbert_body.hpp b/geometry/hilbert_body.hpp index 0dddcaed86..60c35c8e0e 100644 --- a/geometry/hilbert_body.hpp +++ b/geometry/hilbert_body.hpp @@ -48,7 +48,8 @@ auto Hilbert::Norm(T const& t) -> NormType { _MSC_FULL_VER == 193'933'523 || \ _MSC_FULL_VER == 194'033'813 || \ _MSC_FULL_VER == 194'134'120 || \ - _MSC_FULL_VER == 194'134'123) + _MSC_FULL_VER == 194'134'123 || \ + _MSC_FULL_VER == 194'234'435) template requires hilbert auto Hilbert::InnerProduct(T1 const& t1, T2 const& t2) diff --git a/numerics/osaca.hpp b/numerics/osaca.hpp index 3d5b032bcf..722121d23c 100644 --- a/numerics/osaca.hpp +++ b/numerics/osaca.hpp @@ -1,6 +1,6 @@ #pragma once -#define PRINCIPIA_USE_OSACA 0 +#define PRINCIPIA_USE_OSACA 1 // The macros OSACA_FUNCTION_BEGIN and OSACA_RETURN are used to analyse the // latency of a double -> double function, as measured, e.g., by the @@ -175,21 +175,26 @@ static bool volatile OSACA_loop_terminator = false; // The branch not taken, determined by evaluating the condition // `UNDER_OSACA_HYPOTHESES`, is eliminated by `if constexpr`; the condition is -// also compiled normally and assigned to a boolean; whether this results in any -// generated code depends on `OSACA_EVALUATE_CONDITIONS`. Note that, with -// `OSACA_EVALUATE_CONDITIONS`, in `OSACA_IF(p) { } OSACA_ELSE_IF(q) { }`, if -// `p` holds `UNDER_OSACA_HYPOTHESES`, code is generated to evaluate `p`, but -// not `q`. - -#define OSACA_IF(condition) \ - if constexpr (bool OSACA_CONDITION_QUALIFIER OSACA_computed_condition = \ - (condition); \ +// also compiled normally. Whether this results in any generated code depends +// on `OSACA_EVALUATE_CONDITIONS`. Note that, with `OSACA_EVALUATE_CONDITIONS`, +// in `OSACA_IF(p) { } OSACA_ELSE_IF(q) { }`, if `p` holds +// `UNDER_OSACA_HYPOTHESES`, code is generated to evaluate `p`, but not `q`. + +#define OSACA_IF(condition) \ + if constexpr (int const OSACA_evaluate = \ + UNDER_OSACA_HYPOTHESES(condition) \ + ? ((condition) ? 0 : OSACA_branch_not_taken()) \ + : ((condition) ? OSACA_branch_not_taken() : 0); \ UNDER_OSACA_HYPOTHESES(condition)) #if OSACA_EVALUATE_CONDITIONS -#define OSACA_CONDITION_QUALIFIER volatile +[[noreturn]] inline int OSACA_branch_not_taken() { + std::abort(); +} #else -#define OSACA_CONDITION_QUALIFIER +inline int OSACA_branch_not_taken() { + return 0; +} #endif #else // if !PRINCIPIA_USE_OSACA From e98c258b1dc82c8202158a2c77b3ea5208c812c8 Mon Sep 17 00:00:00 2001 From: Robin Leroy Date: Tue, 7 Jan 2025 00:09:26 +0100 Subject: [PATCH 2/2] turn it off --- numerics/osaca.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numerics/osaca.hpp b/numerics/osaca.hpp index 722121d23c..270fd06a04 100644 --- a/numerics/osaca.hpp +++ b/numerics/osaca.hpp @@ -1,6 +1,6 @@ #pragma once -#define PRINCIPIA_USE_OSACA 1 +#define PRINCIPIA_USE_OSACA 0 // The macros OSACA_FUNCTION_BEGIN and OSACA_RETURN are used to analyse the // latency of a double -> double function, as measured, e.g., by the