From a13f42db89ede499bf94185a6a37a4126f7b1cc6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 4 Oct 2026 16:34:23 +0000 Subject: [PATCH 1/2] fix(test): link newlib-nano's float printf into the QEMU test runtime The QEMU test executables link newlib-nano, whose printf has no float conversions unless _printf_float is linked. std::ostream << float formats through vsnprintf("%.*g"), which then returned a bogus length (the address of its output buffer); libstdc++'s num_put allocas that many bytes, the stack pointer wraps below zero, the next push bus-faults, the fault entry cannot stack, and QEMU stops with "Lockup: can't escalate 3 to HardFault". TestGradientCheck.expect_gradient_near_reports_wrong_component is the first test whose failure message prints a float, so numerical.math_test aborted there; any failing float expectation would have done the same instead of reporting. numerical_link_qemu_runtime now links _printf_float into every QEMU test target. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HKhRVwu8yvxdKJgNo17oNc --- cmake/QemuHelpers.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/QemuHelpers.cmake b/cmake/QemuHelpers.cmake index 84480bc..23e679a 100644 --- a/cmake/QemuHelpers.cmake +++ b/cmake/QemuHelpers.cmake @@ -11,4 +11,8 @@ function(numerical_link_qemu_runtime target) hal.qemu.cortex gmock_main ) + # newlib-nano's printf has no float conversions unless _printf_float is linked. Without them the + # vsnprintf behind std::ostream << float returns a bogus length, libstdc++ allocas that many bytes, + # and the first failure message that prints a float wraps the stack pointer and locks up the core. + target_link_options(${target} PRIVATE "LINKER:--undefined=_printf_float") endfunction() From de7be5f7461e020728236f5f15c6ade591b5ffcd Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 4 Oct 2026 15:23:23 +0000 Subject: [PATCH 2/2] perf!: stop setting optimization options per header and per function GCC does not inline a callee whose optimization options differ from its caller's. Every header bracketed its body with #pragma GCC optimize("O3", "fast-math"), and OPTIMIZE_FOR_SPEED added optimize("-O3") and optimize("-ffast-math"), so each toolbox function had options of its own: it could not be inlined into the consumer's code, and it could not inline the consumer's or the standard library's small helpers either. In e-foc's FOC firmware, together with e-foc's own scoped pragmas, that left 256 out-of-line calls to helpers of 12 bytes or less on the three cycle-gated paths. With one set of options for the whole build there are 11, and the 20 kHz inner loop costs 26 % fewer cycles. - OPTIMIZE_FOR_SPEED expands to always_inline, hot and inline when NumericalToolbox_ENABLE_OPTIMIZATIONS is defined, for GCC and Clang alike, and to nothing otherwise. - Drop the push_options/optimize/pop_options bracket from all 104 headers. - AGENTS.md, CLAUDE.md, the Copilot instructions, the agents, the roadmap and the performance guide forbid optimize pragmas and attributes, and leave the optimization level and floating-point model to the consumer, for whole translation units: -O2 or -O3 with -ffast-math -fno-finite-math-only for embedded targets. BREAKING CHANGE: toolbox code no longer builds at O3 with fast-math on its own. Consumers that want those optimizations pass them for whole translation units, e.g. -ffast-math -fno-finite-math-only. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HKhRVwu8yvxdKJgNo17oNc --- .claude/agents/algo-implementer.md | 2 +- .claude/agents/executor.md | 2 +- .claude/agents/planner.md | 2 +- .claude/agents/reviewer.md | 4 +- .github/agents/algo-implementer.agent.md | 2 +- .github/agents/executor.agent.md | 2 +- .github/agents/planner.agent.md | 2 +- .github/agents/reviewer.agent.md | 4 +- .github/copilot-instructions.md | 2 +- .../numerical-cpp.instructions.md | 23 ++---- AGENTS.md | 35 ++++----- CLAUDE.md | 2 +- ROADMAP.md | 4 +- doc/analysis/DiscreteWaveletTransform.md | 2 +- doc/filters/passive/BiquadCascade.md | 4 +- doc/math/MatrixNorms.md | 2 +- doc/performance-optimization/README.md | 71 +++++++++---------- numerical/analysis/ConvolutionCorrelation.hpp | 9 --- numerical/analysis/Decibels.hpp | 9 --- .../analysis/DiscreteCosineTransform.hpp | 9 --- .../analysis/DiscreteWaveletTransform.hpp | 9 --- .../FastFourierTransformRadix2Impl.hpp | 9 --- numerical/analysis/GoertzelAlgorithm.hpp | 9 --- numerical/analysis/HilbertTransform.hpp | 9 --- numerical/analysis/MelFilterbank.hpp | 9 --- numerical/analysis/Mfcc.hpp | 9 --- numerical/analysis/PowerDensitySpectrum.hpp | 9 --- .../analysis/RealFastFourierTransform.hpp | 9 --- numerical/analysis/SignalDetectors.hpp | 9 --- numerical/analysis/TwiddleFactorsTable.hpp | 9 --- numerical/analysis/windowing/Windowing.hpp | 9 --- .../control_analysis/ContinuousToDiscrete.hpp | 8 --- .../ControllabilityObservability.hpp | 9 --- .../control_analysis/FrequencyResponse.hpp | 9 --- numerical/control_analysis/RootLocus.hpp | 9 --- .../TransferFunctionStateSpace.hpp | 9 --- .../implementations/BangBangHysteresis.hpp | 9 --- .../implementations/DeadbeatControl.hpp | 9 --- .../implementations/Feedforward2Dof.hpp | 9 --- .../GainScheduledController.hpp | 9 --- .../IntegralStateFeedbackLqi.hpp | 9 --- .../implementations/LeadLagCompensator.hpp | 9 --- numerical/controllers/implementations/Lqg.hpp | 9 --- numerical/controllers/implementations/Lqr.hpp | 9 --- .../implementations/LuenbergerObserver.hpp | 9 --- numerical/controllers/implementations/Mpc.hpp | 9 --- .../implementations/PidIncremental.hpp | 9 --- .../implementations/SaturationRateLimiter.hpp | 9 --- .../offline/ExpectationMaximization.hpp | 9 --- .../estimators/offline/LinearRegression.hpp | 9 --- .../estimators/offline/PolynomialFitting.hpp | 9 --- .../estimators/offline/TotalLeastSquares.hpp | 9 --- numerical/estimators/offline/YuleWalker.hpp | 9 --- .../estimators/online/LmsAdaptiveFilter.hpp | 9 --- .../online/RecursiveLeastSquares.hpp | 9 --- .../filters/active/AhrsMadgwickMahony.hpp | 9 --- numerical/filters/active/AlphaBetaFilter.hpp | 9 --- .../filters/active/ComplementaryFilter.hpp | 9 --- .../filters/active/ExtendedKalmanFilter.hpp | 9 --- numerical/filters/active/KalmanFilter.hpp | 9 --- numerical/filters/active/KalmanFilterBase.hpp | 9 --- numerical/filters/active/KalmanSmoother.hpp | 9 --- .../filters/active/SquareRootKalmanFilter.hpp | 9 --- .../filters/active/UnscentedKalmanFilter.hpp | 9 --- numerical/filters/passive/BiquadCascade.hpp | 9 --- numerical/filters/passive/CicFilter.hpp | 9 --- .../passive/ExponentialMovingAverage.hpp | 9 --- numerical/filters/passive/Fir.hpp | 9 --- numerical/filters/passive/Iir.hpp | 9 --- numerical/filters/passive/IirFilterDesign.hpp | 9 --- numerical/filters/passive/MedianFilter.hpp | 9 --- numerical/filters/passive/MovingAverage.hpp | 9 --- numerical/filters/passive/NotchCombFilter.hpp | 9 --- .../filters/passive/SavitzkyGolayFilter.hpp | 9 --- numerical/math/CholeskyDecomposition.hpp | 9 --- numerical/math/CompilerOptimizations.hpp | 6 +- numerical/math/ComplexNumber.hpp | 9 --- numerical/math/ConsistencyMetrics.hpp | 9 --- numerical/math/Cordic.hpp | 9 --- numerical/math/Geometry3D.hpp | 9 --- numerical/math/GivensRotation.hpp | 9 --- numerical/math/HouseholderTransform.hpp | 9 --- numerical/math/LinearTimeInvariant.hpp | 9 --- numerical/math/Math.hpp | 9 --- numerical/math/Matrix.hpp | 9 --- numerical/math/MatrixExponential.hpp | 8 --- numerical/math/MatrixNorms.hpp | 8 --- numerical/math/MatrixOperations.hpp | 9 --- numerical/math/QNumber.hpp | 9 --- numerical/math/Quaternion.hpp | 9 --- numerical/math/RecursiveBuffer.hpp | 9 --- numerical/math/StepResponseMetrics.hpp | 9 --- numerical/math/Toeplitz.hpp | 9 --- numerical/math/Tolerance.hpp | 9 --- numerical/math/TriangularSolve.hpp | 9 --- numerical/math/platform/MathArm.hpp | 9 --- .../nonlinear_control/BacksteppingControl.hpp | 9 --- .../FeedbackLinearization.hpp | 9 --- .../ModelReferenceAdaptiveControl.hpp | 9 --- numerical/optimization/Adam.hpp | 9 --- .../optimization/BayesianOptimization.hpp | 9 --- numerical/optimization/GradientDescent.hpp | 9 --- numerical/optimization/Sgd.hpp | 9 --- numerical/regularization/L1.hpp | 9 --- numerical/regularization/L2.hpp | 9 --- .../ActiveDisturbanceRejection.hpp | 9 --- .../robust_control/DisturbanceObserver.hpp | 9 --- .../robust_control/HInfinityStateFeedback.hpp | 9 --- .../robust_control/SlidingModeControl.hpp | 9 --- numerical/solvers/ConditionNumber.hpp | 8 --- .../DiscreteAlgebraicRiccatiEquation.hpp | 9 --- numerical/solvers/DormandPrince45.hpp | 9 --- numerical/solvers/DurandKerner.hpp | 9 --- numerical/solvers/GaussianElimination.hpp | 9 --- numerical/solvers/JacobiEigenSolver.hpp | 9 --- numerical/solvers/LevinsonDurbin.hpp | 9 --- numerical/solvers/LuDecomposition.hpp | 9 --- numerical/solvers/LyapunovSylvester.hpp | 9 --- numerical/solvers/QrDecomposition.hpp | 9 --- numerical/solvers/RungeKuttaIntegrators.hpp | 9 --- .../solvers/SingularValueDecomposition.hpp | 9 --- numerical/solvers/SpectralRadius.hpp | 9 --- roadmap/DEPLOYMENT.md | 3 +- roadmap/README.md | 8 --- roadmap/math/SE3Transform/implementation.md | 4 +- 125 files changed, 70 insertions(+), 1048 deletions(-) diff --git a/.claude/agents/algo-implementer.md b/.claude/agents/algo-implementer.md index 959dcf7..ffec778 100644 --- a/.claude/agents/algo-implementer.md +++ b/.claude/agents/algo-implementer.md @@ -28,5 +28,5 @@ from its `roadmap///` spec into the codebase, following both exact - **No comments** (except license/`NOLINT`). Allman braces, brace-init. - **Tests**: `TEST_F` on `float`, `StrictMock` only, anonymous-namespace fixture; implement EXACTLY the spec's cases — no redundant or extra tests. -- **Embedded**: scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded**: no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. - **Terse**: no preamble/postamble, no plan restatement, no narration; don't re-read files; batch reads. diff --git a/.claude/agents/executor.md b/.claude/agents/executor.md index d12784c..cea9231 100644 --- a/.claude/agents/executor.md +++ b/.claude/agents/executor.md @@ -1,6 +1,6 @@ --- name: executor -description: Implement code changes in numerical-toolbox — float-only templates, no heap, embedded pragmas, TEST_F on float, CMake wiring, docs. Needs a clear task or plan. +description: Implement code changes in numerical-toolbox — float-only templates, no heap, forced inlining on hot paths, TEST_F on float, CMake wiring, docs. Needs a clear task or plan. model: claude-sonnet-4-6 tools: [Read, Write, Edit, Bash, TodoWrite] --- diff --git a/.claude/agents/planner.md b/.claude/agents/planner.md index 30fd10e..3f98085 100644 --- a/.claude/agents/planner.md +++ b/.claude/agents/planner.md @@ -25,7 +25,7 @@ Canonical rules: `AGENTS.md`. Produce plans only — no code edits. - [ ] No heap; no recursion; tests too - [ ] `template` + `static_assert(std::is_floating_point_v)`; `float` only - [ ] `TEST_F` on `float` — no `TYPED_TEST`; `StrictMock` only; never plain `TEST()` - - [ ] scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths + - [ ] no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` on hot paths - [ ] `doc/` update planned **Terse**: no preamble/postamble, no plan restatement; don't re-read files; batch reads. diff --git a/.claude/agents/reviewer.md b/.claude/agents/reviewer.md index 7a64c59..8179420 100644 --- a/.claude/agents/reviewer.md +++ b/.claude/agents/reviewer.md @@ -1,6 +1,6 @@ --- name: reviewer -description: Review code changes against numerical-toolbox standards — no heap, float-only templates, embedded pragmas, TEST_F on float, SOLID, docs. Does NOT modify files. +description: Review code changes against numerical-toolbox standards — no heap, float-only templates, forced inlining on hot paths, TEST_F on float, SOLID, docs. Does NOT modify files. model: claude-sonnet-4-6 tools: [Read, Bash] --- @@ -35,7 +35,7 @@ End with totals + verdict: APPROVE / REQUEST CHANGES. - [ ] `extern template` guarded by `#ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD`. **Embedded optimizations (WARNING)** -- [ ] `#pragma GCC push_options` + `optimize("O3","fast-math")` after `#pragma once`, matching `pop_options` at end of algorithm headers (no TU leak; none in test `.cpp`). +- [ ] No `#pragma GCC optimize` and no `optimize` attribute anywhere (they stop GCC inlining across the boundary). - [ ] `OPTIMIZE_FOR_SPEED` on `Filter/Compute/Update/Solve/Step`. **Namespaces (WARNING)** diff --git a/.github/agents/algo-implementer.agent.md b/.github/agents/algo-implementer.agent.md index 52855b9..51c6887 100644 --- a/.github/agents/algo-implementer.agent.md +++ b/.github/agents/algo-implementer.agent.md @@ -31,5 +31,5 @@ Authoritative rules: `AGENTS.md`. Recipe: `roadmap/DEPLOYMENT.md`. Follow both e - **No comments** (except license/`NOLINT`). Allman braces, brace-init. - **Tests**: `TEST_F` on `float`, `StrictMock` only, anonymous-namespace fixture; implement EXACTLY the spec's cases — no redundant or extra tests. -- **Embedded**: scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded**: no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. - **Terse**: no preamble/postamble, no plan restatement, no narration; don't re-read files; batch reads. diff --git a/.github/agents/executor.agent.md b/.github/agents/executor.agent.md index 3f16e93..07f50f7 100644 --- a/.github/agents/executor.agent.md +++ b/.github/agents/executor.agent.md @@ -1,5 +1,5 @@ --- -description: "Implement code changes in numerical-toolbox — float-only templates, no heap, embedded pragmas, TEST_F on float, CMake wiring, docs. Needs a clear task or plan." +description: "Implement code changes in numerical-toolbox — float-only templates, no heap, forced inlining on hot paths, TEST_F on float, CMake wiring, docs. Needs a clear task or plan." tools: [read, edit, search, execute, todo] model: "Claude Sonnet 4.6" handoffs: diff --git a/.github/agents/planner.agent.md b/.github/agents/planner.agent.md index 85c5c7c..e674630 100644 --- a/.github/agents/planner.agent.md +++ b/.github/agents/planner.agent.md @@ -28,7 +28,7 @@ Canonical rules: `AGENTS.md`. Produce plans only — no code edits. - [ ] No heap; no recursion; tests too - [ ] `template` + `static_assert(std::is_floating_point_v)`; `float` only - [ ] `TEST_F` on `float` — no `TYPED_TEST`; `StrictMock` only; never plain `TEST()` - - [ ] scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths + - [ ] no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` on hot paths - [ ] `doc/` update planned **Terse**: no preamble/postamble, no plan restatement; don't re-read files; batch reads. diff --git a/.github/agents/reviewer.agent.md b/.github/agents/reviewer.agent.md index 64b6be2..5b7ac01 100644 --- a/.github/agents/reviewer.agent.md +++ b/.github/agents/reviewer.agent.md @@ -1,5 +1,5 @@ --- -description: "Review code changes against numerical-toolbox standards: no heap, float-only templates, embedded pragmas, TEST_F on float, SOLID, docs. Does NOT modify files." +description: "Review code changes against numerical-toolbox standards: no heap, float-only templates, forced inlining on hot paths, TEST_F on float, SOLID, docs. Does NOT modify files." tools: [read, search] model: "claude-sonnet-4-6" handoffs: @@ -41,7 +41,7 @@ End with totals + verdict: APPROVE / REQUEST CHANGES. - [ ] `extern template` guarded by `#ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD`. **Embedded optimizations (WARNING)** -- [ ] `#pragma GCC push_options` + `optimize("O3","fast-math")` after `#pragma once`, matching `pop_options` at end of algorithm headers (no TU leak; none in test `.cpp`). +- [ ] No `#pragma GCC optimize` and no `optimize` attribute anywhere (they stop GCC inlining across the boundary). - [ ] `OPTIMIZE_FOR_SPEED` on `Filter/Compute/Update/Solve/Step`. **Namespaces (WARNING)** diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index fbe7cdf..f2a7187 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -6,7 +6,7 @@ Code-file specifics: `.github/instructions/` (applyTo-scoped). Deployment recipe Essentials (full detail in AGENTS.md): - **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too. - **Float-only** — generic `template` + `static_assert(std::is_floating_point_v)`; instantiate/test `float`; no Q15/Q31. -- **Embedded** — scoped `#pragma GCC push_options` / `optimize("O3","fast-math")` … `pop_options` (never leak to the TU) + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded** — no `#pragma GCC optimize` / `optimize` attribute (they block inlining); the consumer sets optimization flags per TU; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. - **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase. - **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases. - **No exceptions** — `std::optional`/status enums; interfaces `virtual ~I() = default`. diff --git a/.github/instructions/numerical-cpp.instructions.md b/.github/instructions/numerical-cpp.instructions.md index 442cf55..7bd0802 100644 --- a/.github/instructions/numerical-cpp.instructions.md +++ b/.github/instructions/numerical-cpp.instructions.md @@ -1,5 +1,5 @@ --- -description: "Numerical C++ rules (float-only): no heap, bounded containers, generic template instantiated for float, embedded pragmas, Allman/brace-init, SOLID, const-correct. Canonical: AGENTS.md." +description: "Numerical C++ rules (float-only): no heap, bounded containers, generic template instantiated for float, forced inlining on hot paths, Allman/brace-init, SOLID, const-correct. Canonical: AGENTS.md." applyTo: "**/*.{hpp,cpp,h}" --- @@ -41,26 +41,11 @@ To replace a function with a platform-specific implementation, define the corres ## Embedded Optimizations -Every algorithm header MUST bracket its body with a scoped pragma, so the options never leak into the including translation unit: +Never use `#pragma GCC optimize` or the `optimize` attribute. GCC does not inline a callee whose optimization options differ from its caller's, so options set per header or per function turn every small helper on a hot path into an out-of-line call. Optimization level and floating-point flags are the consumer's, applied to whole translation units (embedded: `-O2`/`-O3` with `-ffast-math -fno-finite-math-only`). -```cpp -#pragma once +Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot-path methods: `Compute()`, `Filter()`, `Calculate()`, `Solve()`, `Update()`, `Step()`. It forces inlining when `NumericalToolbox_ENABLE_OPTIMIZATIONS` is defined and expands to nothing otherwise. -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - -// ... includes and header body ... - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif -``` - -The `pop_options` block is the last thing in the header. Never use the pragma in test `.cpp` files. - -Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot-path methods: `Compute()`, `Filter()`, `Calculate()`, `Solve()`, `Update()`, `Step()`. +Use `math::IsFinite` for finiteness checks: a consumer may still build with `-ffinite-math-only`. ## Naming diff --git a/AGENTS.md b/AGENTS.md index d094f98..0a13925 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,29 +22,18 @@ resource-constrained embedded systems. Real-time, deterministic, no heap. `infra::BoundedDeque::WithMaxSize`, `infra::BoundedList::WithMaxSize`, `std::array`, `std::optional`. Stack/static only. No recursion. **Tests too.** -## Embedded optimizations (algorithm headers) - -```cpp -#pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif -#include "numerical/math/CompilerOptimizations.hpp" - -// ... header body ... - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif -``` - -The `pop_options` block is the **last thing in the header**: the pragma must never leak into the -including translation unit (it would silently apply fast-math, e.g. folded NaN checks and -reassociation, to unrelated code). Use `math::IsFinite` for finiteness checks. Test `.cpp` files -never use the pragma. - -`OPTIMIZE_FOR_SPEED` on hot paths (`Filter/Compute/Update/Solve/Step`). Pure interfaces exempt. +## Embedded optimizations + +- **No `#pragma GCC optimize` and no `optimize` attribute**, in headers or sources. GCC does not + inline a callee whose optimization options differ from its caller's, so options set per header or + per function turn every small helper on a hot path (element access, accessors, `math::` wrappers) + into an out-of-line call. +- The optimization level and floating-point model belong to the consumer and apply to whole + translation units. For embedded targets: `-O2` or `-O3` with `-ffast-math -fno-finite-math-only`. +- `OPTIMIZE_FOR_SPEED` on hot paths (`Filter/Compute/Update/Solve/Step`). Pure interfaces exempt. + With `NumericalToolbox_ENABLE_OPTIMIZATIONS` it forces inlining (`always_inline`, `hot`, `inline`); + without it, it expands to nothing. +- Use `math::IsFinite` for finiteness checks: a consumer may still build with `-ffinite-math-only`. ## Style diff --git a/CLAUDE.md b/CLAUDE.md index 1e46464..994b533 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,7 +6,7 @@ Code-file specifics: `.github/instructions/`. Deployment recipe: `roadmap/DEPLOY Essentials (full detail in AGENTS.md): - **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too. - **Float-only** — generic `template` + `static_assert(std::is_floating_point_v)`; instantiate/test `float`; no Q15/Q31. -- **Embedded** — scoped `#pragma GCC push_options` / `optimize("O3","fast-math")` … `pop_options` (never leak to the TU) + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded** — no `#pragma GCC optimize` / `optimize` attribute (they block inlining); the consumer sets optimization flags per TU; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths. - **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase. - **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases. - **No exceptions** — `std::optional`/status enums; interfaces `virtual ~I() = default`. diff --git a/ROADMAP.md b/ROADMAP.md index 69b4bd9..9d25061 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -3,7 +3,7 @@ Prioritized backlog of reusable numerical components for generic embedded applications, ordered **easiest → hardest to implement** within the constraints of this library (templated on `float` / `math::Q15` / `math::Q31`, no heap, bounded containers, -`#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` hot paths, typed tests, `doc/` page). +`OPTIMIZE_FOR_SPEED` hot paths, typed tests, `doc/` page). Difficulty legend: @@ -52,7 +52,7 @@ on bounded `math::Vector`/`math::Matrix` inputs; tests are `TEST_F` on `float`. Every new component should follow the established repository conventions: - [ ] Header-only template supporting `float` / `math::Q15` / `math::Q31` (or *float-first* where noted) -- [ ] Scoped `#pragma GCC push_options` / `optimize("O3", "fast-math")` after `#pragma once`, `pop_options` at end of file; `OPTIMIZE_FOR_SPEED` on hot paths +- [ ] No `#pragma GCC optimize` / `optimize` attribute; `OPTIMIZE_FOR_SPEED` on hot paths - [ ] No heap, no recursion, bounded containers (`infra::BoundedVector`, `std::array`) - [ ] `static_assert` on supported types and dimensions - [ ] Typed tests (`TYPED_TEST`) for multi-type components; `TEST_F` for single-type; `StrictMock` only diff --git a/doc/analysis/DiscreteWaveletTransform.md b/doc/analysis/DiscreteWaveletTransform.md index 8e2f517..b7e59a8 100644 --- a/doc/analysis/DiscreteWaveletTransform.md +++ b/doc/analysis/DiscreteWaveletTransform.md @@ -115,7 +115,7 @@ $$\hat{x} = [1.0,\; 2.0,\; 3.0,\; 4.0] \checkmark$$ - **Filter length vs. signal length.** At each level the signal halves; once it equals $P$ the periodic convolution wraps completely. Stop decomposition before the signal shorter than the filter length to avoid artefacts. -- **Fast-math reordering.** With `#pragma GCC optimize("fast-math")` floating-point associativity +- **Fast-math reordering.** With `-ffast-math` floating-point associativity relaxes; reconstruction residuals may reach $10^{-5}$ rather than $10^{-7}$ for 32-bit floats. ## Variants & Generalizations diff --git a/doc/filters/passive/BiquadCascade.md b/doc/filters/passive/BiquadCascade.md index 2920bae..4274525 100644 --- a/doc/filters/passive/BiquadCascade.md +++ b/doc/filters/passive/BiquadCascade.md @@ -94,8 +94,8 @@ Input $[1, 0, 0, \ldots]$ → output $[1, 0, 0, \ldots]$ — identity passthroug $|z| = 1$. Finite-precision rounding can move a pole just outside, causing instability. Use $Q \leq 30$ in single precision; double precision or lattice realizations for higher $Q$. - **Denormal floats**: small state values approaching the denormal range stall the FPU pipeline - on many embedded cores. Enabling flush-to-zero (FTZ) or the fast-math pragma prevents this - at the cost of negligible numerical error. + on many embedded cores. Enabling flush-to-zero (FTZ) prevents this at the cost of negligible + numerical error. - **DC gain normalization**: the RBJ low-pass has unity DC gain by construction. Gain-staging between sections is not required; each section's output is well-scaled relative to its input. diff --git a/doc/math/MatrixNorms.md b/doc/math/MatrixNorms.md index 9df1653..4756a02 100644 --- a/doc/math/MatrixNorms.md +++ b/doc/math/MatrixNorms.md @@ -59,7 +59,7 @@ Vector $\mathbf{v} = [3,\, 4]^\top$: $\|\mathbf{v}\|_2 = 5$, and $\hat{\mathbf{v **Zero vector normalisation** — dividing by $\|\mathbf{v}\|_2 = 0$ is undefined. The implementation returns an empty optional for near-zero norms. -**Fast-math semantics** — `#pragma GCC optimize("fast-math")` may reorder floating-point operations. The norms are sums of non-negative values, so reordering does not change the sign of the result, but catastrophic cancellation can still occur for near-zero off-diagonal entries. +**Fast-math semantics** — `-ffast-math` may reorder floating-point operations. The norms are sums of non-negative values, so reordering does not change the sign of the result, but catastrophic cancellation can still occur for near-zero off-diagonal entries. **Non-square matrices** — FrobeniusNorm, OneNorm, and InfinityNorm apply to any $m \times n$ matrix. diff --git a/doc/performance-optimization/README.md b/doc/performance-optimization/README.md index adc2ef8..31699fa 100644 --- a/doc/performance-optimization/README.md +++ b/doc/performance-optimization/README.md @@ -44,19 +44,23 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") ### Fast-Math Considerations -```cpp -// Enables aggressive floating-point optimizations -// WARNING: May change numerical behavior slightly -#pragma GCC optimize("fast-math") +```cmake +# Aggressive floating-point optimizations for whole translation units, keeping NaN/Inf checks +add_compile_options(-ffast-math -fno-finite-math-only) ``` Effects of `-ffast-math`: -- Assumes no NaN or Infinity -- Allows reordering of operations +- No `errno` from math functions, so `sqrtf` becomes a single `vsqrt.f32` +- Allows reordering of operations and reciprocal multiplication instead of division - Enables FMA (Fused Multiply-Add) instructions +- `-ffinite-math-only` (part of `-ffast-math`) assumes no NaN or Infinity and folds `std::isnan`/`std::isfinite` - May break IEEE 754 compliance -**Use only when**: You control all inputs and don't need strict IEEE behavior. +**Use only when**: You control all inputs and don't need strict IEEE behavior. Keep +`-fno-finite-math-only` unless no code relies on NaN or Infinity checks. + +Set these options for whole translation units, never per function: see +[Optimization Options Must Match Across Calls](#optimization-options-must-match-across-calls). --- @@ -135,10 +139,17 @@ inline constexpr std::array sineLUT = []() { #define HOT_FUNCTION __attribute__((hot)) // Combined macro for critical functions -#define OPTIMIZE_FOR_SPEED \ - __attribute__((always_inline, hot, optimize("-O3"), optimize("-ffast-math"))) inline +#define OPTIMIZE_FOR_SPEED __attribute__((always_inline, hot)) inline ``` +#### Optimization Options Must Match Across Calls + +GCC does not inline a function into a caller whose optimization options differ from its own. +`#pragma GCC optimize` and `__attribute__((optimize(...)))` give the functions they cover options of +their own, so every small helper such a function calls — element access, accessors, unit wrappers — +stays an out-of-line call, and the functions themselves are no longer inlined into their callers. +Choose the optimization level and floating-point flags for whole translation units instead. + ### 5. Prefer Fixed-Size Types ```cpp @@ -204,32 +215,16 @@ set(CMAKE_CXX_FLAGS_DEBUG "-Og -g" CACHE STRING "Debug flags" FORCE) - Register allocation - Still debuggable (variable inspection works) -### Solution 2: Per-File Optimization Pragmas - -```cpp -// Bracket the performance-critical code; never leave the options active for the rest of the TU -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - -// Performance-critical implementation... +### Solution 2: Per-Translation-Unit Options -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif -``` - -### Solution 3: Per-Function Attributes - -```cpp -__attribute__((optimize("-O3"))) -void CriticalFunction() { - // This function is always optimized -} +```cmake +# Build the performance-critical sources optimized while the rest stays debuggable +set_source_files_properties(Controller.cpp PROPERTIES COMPILE_OPTIONS "$<$:-O2>") ``` -**Note**: Function-level attributes don't propagate to callees. Use file-level pragmas for better results. +Every function in a translation unit shares its options, so inlining is unaffected. Do not use +`#pragma GCC optimize` or `__attribute__((optimize(...)))` instead: see +[Optimization Options Must Match Across Calls](#optimization-options-must-match-across-calls). --- @@ -430,13 +425,11 @@ struct GoodStruct { ## Quick Reference Card -### GCC Optimization Pragmas -```cpp -#pragma GCC optimize("O3") // Maximum speed -#pragma GCC optimize("Os") // Minimum size -#pragma GCC optimize("fast-math") // Aggressive FP -#pragma GCC push_options // Save current options -#pragma GCC pop_options // Restore options +### Optimization Flags (whole translation units) +```cmake +add_compile_options(-O3) # Maximum speed +add_compile_options(-Os) # Minimum size +add_compile_options(-ffast-math -fno-finite-math-only) # Aggressive FP, NaN/Inf checks kept ``` ### Function Attributes diff --git a/numerical/analysis/ConvolutionCorrelation.hpp b/numerical/analysis/ConvolutionCorrelation.hpp index 9cc3e38..c4e4aef 100644 --- a/numerical/analysis/ConvolutionCorrelation.hpp +++ b/numerical/analysis/ConvolutionCorrelation.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/analysis/FastFourierTransform.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/ComplexNumber.hpp" @@ -159,7 +154,3 @@ namespace analysis FastFourierTransform&); #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/Decibels.hpp b/numerical/analysis/Decibels.hpp index 6574d28..23157de 100644 --- a/numerical/analysis/Decibels.hpp +++ b/numerical/analysis/Decibels.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -49,7 +44,3 @@ namespace analysis return ToDecibels(maxRatio) - ToDecibels(minRatio); } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/DiscreteCosineTransform.hpp b/numerical/analysis/DiscreteCosineTransform.hpp index 9dbc51b..224ac1c 100644 --- a/numerical/analysis/DiscreteCosineTransform.hpp +++ b/numerical/analysis/DiscreteCosineTransform.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "numerical/analysis/FastFourierTransform.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -113,7 +108,3 @@ namespace analysis extern template class DiscreteCosineTransform; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/DiscreteWaveletTransform.hpp b/numerical/analysis/DiscreteWaveletTransform.hpp index c54287e..1ffdfb5 100644 --- a/numerical/analysis/DiscreteWaveletTransform.hpp +++ b/numerical/analysis/DiscreteWaveletTransform.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -261,7 +256,3 @@ namespace analysis extern template class DiscreteWaveletTransform; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/FastFourierTransformRadix2Impl.hpp b/numerical/analysis/FastFourierTransformRadix2Impl.hpp index acc3392..8d56c54 100644 --- a/numerical/analysis/FastFourierTransformRadix2Impl.hpp +++ b/numerical/analysis/FastFourierTransformRadix2Impl.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "numerical/analysis/FastFourierTransform.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -144,7 +139,3 @@ namespace analysis extern template class FastFourierTransformRadix2Impl; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/GoertzelAlgorithm.hpp b/numerical/analysis/GoertzelAlgorithm.hpp index ad08c6e..cea3075 100644 --- a/numerical/analysis/GoertzelAlgorithm.hpp +++ b/numerical/analysis/GoertzelAlgorithm.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/ComplexNumber.hpp" @@ -124,7 +119,3 @@ namespace analysis extern template class GoertzelAlgorithm; } #endif - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/HilbertTransform.hpp b/numerical/analysis/HilbertTransform.hpp index 8496b5b..ccf63a7 100644 --- a/numerical/analysis/HilbertTransform.hpp +++ b/numerical/analysis/HilbertTransform.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "numerical/analysis/FastFourierTransform.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -165,7 +160,3 @@ namespace analysis extern template class HilbertFir; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/MelFilterbank.hpp b/numerical/analysis/MelFilterbank.hpp index 1d48d8e..23897aa 100644 --- a/numerical/analysis/MelFilterbank.hpp +++ b/numerical/analysis/MelFilterbank.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -174,7 +169,3 @@ namespace analysis extern template class MelFilterbank; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/Mfcc.hpp b/numerical/analysis/Mfcc.hpp index 5c9ea75..779187c 100644 --- a/numerical/analysis/Mfcc.hpp +++ b/numerical/analysis/Mfcc.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "infra/util/ReallyAssert.hpp" #include "numerical/analysis/MelFilterbank.hpp" @@ -125,7 +120,3 @@ namespace analysis extern template class Mfcc; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/PowerDensitySpectrum.hpp b/numerical/analysis/PowerDensitySpectrum.hpp index f215c42..848d676 100644 --- a/numerical/analysis/PowerDensitySpectrum.hpp +++ b/numerical/analysis/PowerDensitySpectrum.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/analysis/FastFourierTransform.hpp" #include "numerical/analysis/windowing/Windowing.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -129,7 +124,3 @@ namespace analysis extern template class PowerSpectralDensity, test::TwiddleFactorsStub, 0>; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/RealFastFourierTransform.hpp b/numerical/analysis/RealFastFourierTransform.hpp index d4d4525..7914096 100644 --- a/numerical/analysis/RealFastFourierTransform.hpp +++ b/numerical/analysis/RealFastFourierTransform.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "numerical/analysis/FastFourierTransform.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -124,7 +119,3 @@ namespace analysis extern template class RealFastFourierTransform; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/SignalDetectors.hpp b/numerical/analysis/SignalDetectors.hpp index b2422ee..b60c966 100644 --- a/numerical/analysis/SignalDetectors.hpp +++ b/numerical/analysis/SignalDetectors.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -135,7 +130,3 @@ namespace analysis extern template class RmsEnvelope; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/TwiddleFactorsTable.hpp b/numerical/analysis/TwiddleFactorsTable.hpp index 5a76d47..0909fcb 100644 --- a/numerical/analysis/TwiddleFactorsTable.hpp +++ b/numerical/analysis/TwiddleFactorsTable.hpp @@ -5,11 +5,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace analysis { template @@ -42,7 +37,3 @@ namespace analysis extern template class TwiddleFactorsTable; } #endif - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/analysis/windowing/Windowing.hpp b/numerical/analysis/windowing/Windowing.hpp index 3e915c1..ef825db 100644 --- a/numerical/analysis/windowing/Windowing.hpp +++ b/numerical/analysis/windowing/Windowing.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/QNumber.hpp" @@ -127,7 +122,3 @@ namespace windowing extern template class RectangularWindow; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/control_analysis/ContinuousToDiscrete.hpp b/numerical/control_analysis/ContinuousToDiscrete.hpp index bfc9483..f090825 100644 --- a/numerical/control_analysis/ContinuousToDiscrete.hpp +++ b/numerical/control_analysis/ContinuousToDiscrete.hpp @@ -1,8 +1,4 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/Math.hpp" @@ -179,7 +175,3 @@ namespace control_analysis extern template class ContinuousToDiscrete; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/control_analysis/ControllabilityObservability.hpp b/numerical/control_analysis/ControllabilityObservability.hpp index 9cc3ba0..2934ed5 100644 --- a/numerical/control_analysis/ControllabilityObservability.hpp +++ b/numerical/control_analysis/ControllabilityObservability.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/Math.hpp" @@ -243,7 +238,3 @@ namespace control_analysis math::Matrix&, std::size_t, std::size_t, float); #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/control_analysis/FrequencyResponse.hpp b/numerical/control_analysis/FrequencyResponse.hpp index 69bd9e1..0e39258 100644 --- a/numerical/control_analysis/FrequencyResponse.hpp +++ b/numerical/control_analysis/FrequencyResponse.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" @@ -110,7 +105,3 @@ namespace control_analysis extern template class FrequencyResponse; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/control_analysis/RootLocus.hpp b/numerical/control_analysis/RootLocus.hpp index f55f07c..005f364 100644 --- a/numerical/control_analysis/RootLocus.hpp +++ b/numerical/control_analysis/RootLocus.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -140,7 +135,3 @@ namespace control_analysis extern template class RootLocus; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/control_analysis/TransferFunctionStateSpace.hpp b/numerical/control_analysis/TransferFunctionStateSpace.hpp index b2c3d6a..d32ae95 100644 --- a/numerical/control_analysis/TransferFunctionStateSpace.hpp +++ b/numerical/control_analysis/TransferFunctionStateSpace.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/Matrix.hpp" @@ -167,7 +162,3 @@ namespace control_analysis extern template class TransferFunctionStateSpace; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/BangBangHysteresis.hpp b/numerical/controllers/implementations/BangBangHysteresis.hpp index 0f306b6..84a254f 100644 --- a/numerical/controllers/implementations/BangBangHysteresis.hpp +++ b/numerical/controllers/implementations/BangBangHysteresis.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include @@ -74,7 +69,3 @@ namespace controllers extern template class BangBangHysteresis; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/DeadbeatControl.hpp b/numerical/controllers/implementations/DeadbeatControl.hpp index 5d312eb..8934459 100644 --- a/numerical/controllers/implementations/DeadbeatControl.hpp +++ b/numerical/controllers/implementations/DeadbeatControl.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/interfaces/StateFeedbackController.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" @@ -148,7 +143,3 @@ namespace controllers extern template class DeadbeatControl; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/Feedforward2Dof.hpp b/numerical/controllers/implementations/Feedforward2Dof.hpp index 05ecd27..365001b 100644 --- a/numerical/controllers/implementations/Feedforward2Dof.hpp +++ b/numerical/controllers/implementations/Feedforward2Dof.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/SaturationRateLimiter.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include @@ -78,7 +73,3 @@ namespace controllers extern template class Feedforward2Dof; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/GainScheduledController.hpp b/numerical/controllers/implementations/GainScheduledController.hpp index 0b2b74d..ffe0003 100644 --- a/numerical/controllers/implementations/GainScheduledController.hpp +++ b/numerical/controllers/implementations/GainScheduledController.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include #include @@ -94,7 +89,3 @@ namespace controllers extern template class GainScheduledController; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp b/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp index 03a2c66..dfc899c 100644 --- a/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp +++ b/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/Lqr.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" @@ -172,7 +167,3 @@ namespace controllers extern template class IntegralStateFeedbackLqi; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/LeadLagCompensator.hpp b/numerical/controllers/implementations/LeadLagCompensator.hpp index 6379ccc..4f67038 100644 --- a/numerical/controllers/implementations/LeadLagCompensator.hpp +++ b/numerical/controllers/implementations/LeadLagCompensator.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include @@ -74,7 +69,3 @@ namespace controllers extern template class LeadLagCompensator; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/Lqg.hpp b/numerical/controllers/implementations/Lqg.hpp index 3189e9d..b350d59 100644 --- a/numerical/controllers/implementations/Lqg.hpp +++ b/numerical/controllers/implementations/Lqg.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/Lqr.hpp" #include "numerical/controllers/interfaces/OutputFeedbackController.hpp" #include "numerical/filters/active/KalmanFilter.hpp" @@ -103,7 +98,3 @@ namespace controllers extern template class Lqg; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/Lqr.hpp b/numerical/controllers/implementations/Lqr.hpp index 516f928..3aca891 100644 --- a/numerical/controllers/implementations/Lqr.hpp +++ b/numerical/controllers/implementations/Lqr.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/controllers/interfaces/StateFeedbackController.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -145,7 +140,3 @@ namespace controllers extern template class Lqr; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/LuenbergerObserver.hpp b/numerical/controllers/implementations/LuenbergerObserver.hpp index 8fdf914..33c15f2 100644 --- a/numerical/controllers/implementations/LuenbergerObserver.hpp +++ b/numerical/controllers/implementations/LuenbergerObserver.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/solvers/GaussianElimination.hpp" @@ -143,7 +138,3 @@ namespace controllers extern template class LuenbergerObserver; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/Mpc.hpp b/numerical/controllers/implementations/Mpc.hpp index 0ca8b15..8004dd6 100644 --- a/numerical/controllers/implementations/Mpc.hpp +++ b/numerical/controllers/implementations/Mpc.hpp @@ -8,11 +8,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace controllers { template @@ -309,7 +304,3 @@ namespace controllers extern template class Mpc; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/PidIncremental.hpp b/numerical/controllers/implementations/PidIncremental.hpp index 2318920..e822bc0 100644 --- a/numerical/controllers/implementations/PidIncremental.hpp +++ b/numerical/controllers/implementations/PidIncremental.hpp @@ -4,11 +4,6 @@ #include "numerical/controllers/interfaces/PidDriver.hpp" #include "numerical/math/CompilerOptimizations.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace controllers { template @@ -235,7 +230,3 @@ namespace controllers extern template class PidIncrementalSynchronous; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/controllers/implementations/SaturationRateLimiter.hpp b/numerical/controllers/implementations/SaturationRateLimiter.hpp index bf24b81..c28abc9 100644 --- a/numerical/controllers/implementations/SaturationRateLimiter.hpp +++ b/numerical/controllers/implementations/SaturationRateLimiter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include #include @@ -101,7 +96,3 @@ namespace controllers extern template class SlewLimitedSaturation; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/offline/ExpectationMaximization.hpp b/numerical/estimators/offline/ExpectationMaximization.hpp index bb0c89a..79e5943 100644 --- a/numerical/estimators/offline/ExpectationMaximization.hpp +++ b/numerical/estimators/offline/ExpectationMaximization.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/filters/active/KalmanSmoother.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" @@ -227,7 +222,3 @@ namespace estimators extern template class ExpectationMaximization<4, 2, 20>; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/offline/LinearRegression.hpp b/numerical/estimators/offline/LinearRegression.hpp index d624a34..158381c 100644 --- a/numerical/estimators/offline/LinearRegression.hpp +++ b/numerical/estimators/offline/LinearRegression.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/estimators/Estimator.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/solvers/QrDecomposition.hpp" @@ -77,7 +72,3 @@ namespace estimators extern template class LinearRegression; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/offline/PolynomialFitting.hpp b/numerical/estimators/offline/PolynomialFitting.hpp index d9f630f..41b0f7d 100644 --- a/numerical/estimators/offline/PolynomialFitting.hpp +++ b/numerical/estimators/offline/PolynomialFitting.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include "numerical/solvers/QrDecomposition.hpp" @@ -73,7 +68,3 @@ namespace estimators extern template class PolynomialFitting; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/offline/TotalLeastSquares.hpp b/numerical/estimators/offline/TotalLeastSquares.hpp index 655d42e..70cf072 100644 --- a/numerical/estimators/offline/TotalLeastSquares.hpp +++ b/numerical/estimators/offline/TotalLeastSquares.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -84,7 +79,3 @@ namespace estimators extern template class TotalLeastSquares; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/offline/YuleWalker.hpp b/numerical/estimators/offline/YuleWalker.hpp index 7fe8411..887c6f6 100644 --- a/numerical/estimators/offline/YuleWalker.hpp +++ b/numerical/estimators/offline/YuleWalker.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include "numerical/math/Statistics.hpp" @@ -125,7 +120,3 @@ namespace estimators extern template class YuleWalker; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/online/LmsAdaptiveFilter.hpp b/numerical/estimators/online/LmsAdaptiveFilter.hpp index 49bffdc..c16090d 100644 --- a/numerical/estimators/online/LmsAdaptiveFilter.hpp +++ b/numerical/estimators/online/LmsAdaptiveFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include #include @@ -121,7 +116,3 @@ namespace estimators extern template class LmsAdaptiveFilter; } #endif - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/estimators/online/RecursiveLeastSquares.hpp b/numerical/estimators/online/RecursiveLeastSquares.hpp index 1e8a38c..f9977d6 100644 --- a/numerical/estimators/online/RecursiveLeastSquares.hpp +++ b/numerical/estimators/online/RecursiveLeastSquares.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/estimators/Estimator.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -147,7 +142,3 @@ namespace estimators extern template class RecursiveLeastSquares; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/AhrsMadgwickMahony.hpp b/numerical/filters/active/AhrsMadgwickMahony.hpp index bffa68d..e3cab51 100644 --- a/numerical/filters/active/AhrsMadgwickMahony.hpp +++ b/numerical/filters/active/AhrsMadgwickMahony.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Geometry3D.hpp" #include "numerical/math/Math.hpp" @@ -300,7 +295,3 @@ namespace filters extern template class AhrsFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/AlphaBetaFilter.hpp b/numerical/filters/active/AlphaBetaFilter.hpp index 7b1de44..e801b26 100644 --- a/numerical/filters/active/AlphaBetaFilter.hpp +++ b/numerical/filters/active/AlphaBetaFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" @@ -153,7 +148,3 @@ namespace filters extern template class AlphaBetaFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/ComplementaryFilter.hpp b/numerical/filters/active/ComplementaryFilter.hpp index a45fdcc..8d8f094 100644 --- a/numerical/filters/active/ComplementaryFilter.hpp +++ b/numerical/filters/active/ComplementaryFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -108,7 +103,3 @@ namespace filters extern template class ComplementaryFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/ExtendedKalmanFilter.hpp b/numerical/filters/active/ExtendedKalmanFilter.hpp index 5698a20..1261fe3 100644 --- a/numerical/filters/active/ExtendedKalmanFilter.hpp +++ b/numerical/filters/active/ExtendedKalmanFilter.hpp @@ -5,11 +5,6 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/MatrixOperations.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace filters { template @@ -126,7 +121,3 @@ namespace filters extern template class ExtendedKalmanFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/KalmanFilter.hpp b/numerical/filters/active/KalmanFilter.hpp index bf1e45a..4c5f657 100644 --- a/numerical/filters/active/KalmanFilter.hpp +++ b/numerical/filters/active/KalmanFilter.hpp @@ -5,11 +5,6 @@ #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/MatrixOperations.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace filters { template @@ -136,7 +131,3 @@ namespace filters extern template class KalmanFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/KalmanFilterBase.hpp b/numerical/filters/active/KalmanFilterBase.hpp index 1b2db1d..a8b25bc 100644 --- a/numerical/filters/active/KalmanFilterBase.hpp +++ b/numerical/filters/active/KalmanFilterBase.hpp @@ -5,11 +5,6 @@ #include "numerical/math/MatrixOperations.hpp" #include "numerical/solvers/GaussianElimination.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace filters { namespace detail @@ -176,7 +171,3 @@ namespace filters extern template class KalmanFilterBase; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/KalmanSmoother.hpp b/numerical/filters/active/KalmanSmoother.hpp index 416513c..70d07d0 100644 --- a/numerical/filters/active/KalmanSmoother.hpp +++ b/numerical/filters/active/KalmanSmoother.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CholeskyDecomposition.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" @@ -249,7 +244,3 @@ namespace filters extern template class KalmanSmoother<4, 2, 20>; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/SquareRootKalmanFilter.hpp b/numerical/filters/active/SquareRootKalmanFilter.hpp index a1c7ae1..6fd0e47 100644 --- a/numerical/filters/active/SquareRootKalmanFilter.hpp +++ b/numerical/filters/active/SquareRootKalmanFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/filters/active/KalmanFilterBase.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/GivensRotation.hpp" @@ -224,7 +219,3 @@ namespace filters extern template class SquareRootKalmanFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/active/UnscentedKalmanFilter.hpp b/numerical/filters/active/UnscentedKalmanFilter.hpp index 71a87b5..78ab608 100644 --- a/numerical/filters/active/UnscentedKalmanFilter.hpp +++ b/numerical/filters/active/UnscentedKalmanFilter.hpp @@ -10,11 +10,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace filters { struct UkfParameters @@ -284,7 +279,3 @@ namespace filters extern template class UnscentedKalmanFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/BiquadCascade.hpp b/numerical/filters/passive/BiquadCascade.hpp index 0b0c499..de6da89 100644 --- a/numerical/filters/passive/BiquadCascade.hpp +++ b/numerical/filters/passive/BiquadCascade.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -204,7 +199,3 @@ namespace filters::passive extern template class BiquadCascade; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/CicFilter.hpp b/numerical/filters/passive/CicFilter.hpp index c456a57..f2a6b3e 100644 --- a/numerical/filters/passive/CicFilter.hpp +++ b/numerical/filters/passive/CicFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include #include @@ -121,7 +116,3 @@ namespace filters::passive extern template class CicDecimator; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/ExponentialMovingAverage.hpp b/numerical/filters/passive/ExponentialMovingAverage.hpp index a167dd9..e426ede 100644 --- a/numerical/filters/passive/ExponentialMovingAverage.hpp +++ b/numerical/filters/passive/ExponentialMovingAverage.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include #include @@ -73,7 +68,3 @@ namespace filters::passive extern template class ExponentialMovingAverage; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/Fir.hpp b/numerical/filters/passive/Fir.hpp index 7dfbeaf..40d7dca 100644 --- a/numerical/filters/passive/Fir.hpp +++ b/numerical/filters/passive/Fir.hpp @@ -3,11 +3,6 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/RecursiveBuffer.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace filters::passive { template @@ -60,7 +55,3 @@ namespace filters::passive extern template class Fir; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/Iir.hpp b/numerical/filters/passive/Iir.hpp index 700f012..34887df 100644 --- a/numerical/filters/passive/Iir.hpp +++ b/numerical/filters/passive/Iir.hpp @@ -3,11 +3,6 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/RecursiveBuffer.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace filters::passive { template @@ -71,7 +66,3 @@ namespace filters::passive extern template class Iir; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/IirFilterDesign.hpp b/numerical/filters/passive/IirFilterDesign.hpp index 9cb5904..e675cab 100644 --- a/numerical/filters/passive/IirFilterDesign.hpp +++ b/numerical/filters/passive/IirFilterDesign.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/filters/passive/BiquadCascade.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/ComplexNumber.hpp" @@ -512,7 +507,3 @@ namespace filters::passive extern template class IirFilterDesign; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/MedianFilter.hpp b/numerical/filters/passive/MedianFilter.hpp index cc4c51b..d923218 100644 --- a/numerical/filters/passive/MedianFilter.hpp +++ b/numerical/filters/passive/MedianFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include #include @@ -73,7 +68,3 @@ namespace filters::passive extern template class MedianFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/MovingAverage.hpp b/numerical/filters/passive/MovingAverage.hpp index 437b16e..35eaf5a 100644 --- a/numerical/filters/passive/MovingAverage.hpp +++ b/numerical/filters/passive/MovingAverage.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/RecursiveBuffer.hpp" @@ -65,7 +60,3 @@ namespace filters::passive extern template class MovingAverage; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/NotchCombFilter.hpp b/numerical/filters/passive/NotchCombFilter.hpp index f1cec4e..b1e42a7 100644 --- a/numerical/filters/passive/NotchCombFilter.hpp +++ b/numerical/filters/passive/NotchCombFilter.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -127,7 +122,3 @@ namespace filters::passive extern template class CombFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/filters/passive/SavitzkyGolayFilter.hpp b/numerical/filters/passive/SavitzkyGolayFilter.hpp index 68ca730..af91bd9 100644 --- a/numerical/filters/passive/SavitzkyGolayFilter.hpp +++ b/numerical/filters/passive/SavitzkyGolayFilter.hpp @@ -1,11 +1,6 @@ // Copyright 2024 Numerical Toolbox Contributors. All rights reserved. #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CholeskyDecomposition.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include @@ -128,7 +123,3 @@ namespace filters::passive extern template class SavitzkyGolayFilter; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/CholeskyDecomposition.hpp b/numerical/math/CholeskyDecomposition.hpp index 4424f4d..3c2dcae 100644 --- a/numerical/math/CholeskyDecomposition.hpp +++ b/numerical/math/CholeskyDecomposition.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -118,7 +113,3 @@ namespace math extern template class CholeskyDecomposition; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/CompilerOptimizations.hpp b/numerical/math/CompilerOptimizations.hpp index b9d1fba..a0c7fc0 100644 --- a/numerical/math/CompilerOptimizations.hpp +++ b/numerical/math/CompilerOptimizations.hpp @@ -1,11 +1,7 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) && defined(NumericalToolbox_ENABLE_OPTIMIZATIONS) -#define OPTIMIZE_FOR_SPEED __attribute__((always_inline, hot, optimize("-O3"), optimize("-ffast-math"))) inline -#elif defined(__clang__) && defined(NumericalToolbox_ENABLE_OPTIMIZATIONS) +#if (defined(__GNUC__) || defined(__clang__)) && defined(NumericalToolbox_ENABLE_OPTIMIZATIONS) #define OPTIMIZE_FOR_SPEED __attribute__((always_inline, hot)) inline -#elif defined(_MSC_VER) -#define OPTIMIZE_FOR_SPEED #else #define OPTIMIZE_FOR_SPEED #endif diff --git a/numerical/math/ComplexNumber.hpp b/numerical/math/ComplexNumber.hpp index 3a22cab..2638b53 100644 --- a/numerical/math/ComplexNumber.hpp +++ b/numerical/math/ComplexNumber.hpp @@ -3,11 +3,6 @@ #include "numerical/math/QNumber.hpp" #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace math { template @@ -140,7 +135,3 @@ namespace math extern template class Complex; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/ConsistencyMetrics.hpp b/numerical/math/ConsistencyMetrics.hpp index 06c369d..1014e57 100644 --- a/numerical/math/ConsistencyMetrics.hpp +++ b/numerical/math/ConsistencyMetrics.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CholeskyDecomposition.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" @@ -108,7 +103,3 @@ namespace math extern template class ConsistencyMetrics; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Cordic.hpp b/numerical/math/Cordic.hpp index 86b0873..7850935 100644 --- a/numerical/math/Cordic.hpp +++ b/numerical/math/Cordic.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -183,7 +178,3 @@ namespace math extern template class Cordic; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Geometry3D.hpp b/numerical/math/Geometry3D.hpp index a02be99..340a62d 100644 --- a/numerical/math/Geometry3D.hpp +++ b/numerical/math/Geometry3D.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -90,7 +85,3 @@ namespace math return math::Sqrt(DotProduct(v, v)); } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/GivensRotation.hpp b/numerical/math/GivensRotation.hpp index 114f698..91e5d21 100644 --- a/numerical/math/GivensRotation.hpp +++ b/numerical/math/GivensRotation.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include @@ -54,7 +49,3 @@ namespace math y = newY; } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/HouseholderTransform.hpp b/numerical/math/HouseholderTransform.hpp index e9b906c..735a4ef 100644 --- a/numerical/math/HouseholderTransform.hpp +++ b/numerical/math/HouseholderTransform.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -82,7 +77,3 @@ namespace math } } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/LinearTimeInvariant.hpp b/numerical/math/LinearTimeInvariant.hpp index c89a325..f04c564 100644 --- a/numerical/math/LinearTimeInvariant.hpp +++ b/numerical/math/LinearTimeInvariant.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" @@ -70,7 +65,3 @@ namespace math }; } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Math.hpp b/numerical/math/Math.hpp index 8962848..eed45f7 100644 --- a/numerical/math/Math.hpp +++ b/numerical/math/Math.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include #include #include @@ -331,7 +326,3 @@ namespace math #endif #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Matrix.hpp b/numerical/math/Matrix.hpp index f0b0bf1..18bca0e 100644 --- a/numerical/math/Matrix.hpp +++ b/numerical/math/Matrix.hpp @@ -5,11 +5,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace math { template @@ -368,7 +363,3 @@ namespace math extern template class Matrix; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/MatrixExponential.hpp b/numerical/math/MatrixExponential.hpp index ae68792..784d9d7 100644 --- a/numerical/math/MatrixExponential.hpp +++ b/numerical/math/MatrixExponential.hpp @@ -1,8 +1,4 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -187,7 +183,3 @@ namespace math extern template class MatrixExponential; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/MatrixNorms.hpp b/numerical/math/MatrixNorms.hpp index 738a947..0c8fb22 100644 --- a/numerical/math/MatrixNorms.hpp +++ b/numerical/math/MatrixNorms.hpp @@ -1,8 +1,4 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -96,7 +92,3 @@ namespace math return result; } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/MatrixOperations.hpp b/numerical/math/MatrixOperations.hpp index a38d185..2fbe1ed 100644 --- a/numerical/math/MatrixOperations.hpp +++ b/numerical/math/MatrixOperations.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include @@ -26,7 +21,3 @@ namespace math return a * m * a.Transpose(); } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/QNumber.hpp b/numerical/math/QNumber.hpp index a94f5f3..e42923b 100644 --- a/numerical/math/QNumber.hpp +++ b/numerical/math/QNumber.hpp @@ -7,11 +7,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace math { inline constexpr double pi = std::numbers::pi; @@ -266,7 +261,3 @@ namespace math extern template class QNumber; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Quaternion.hpp b/numerical/math/Quaternion.hpp index d6e03f7..1903efc 100644 --- a/numerical/math/Quaternion.hpp +++ b/numerical/math/Quaternion.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Geometry3D.hpp" #include "numerical/math/Math.hpp" @@ -292,7 +287,3 @@ namespace math extern template class Quaternion; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/RecursiveBuffer.hpp b/numerical/math/RecursiveBuffer.hpp index c602884..5a0cb4e 100644 --- a/numerical/math/RecursiveBuffer.hpp +++ b/numerical/math/RecursiveBuffer.hpp @@ -4,11 +4,6 @@ #include #include -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace math { struct IndexRelative @@ -102,7 +97,3 @@ namespace math extern template class RecursiveBuffer; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/StepResponseMetrics.hpp b/numerical/math/StepResponseMetrics.hpp index ee40421..bf0fdb7 100644 --- a/numerical/math/StepResponseMetrics.hpp +++ b/numerical/math/StepResponseMetrics.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -115,7 +110,3 @@ namespace math return reference - tailMean; } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Toeplitz.hpp b/numerical/math/Toeplitz.hpp index a6d304f..3eec6bd 100644 --- a/numerical/math/Toeplitz.hpp +++ b/numerical/math/Toeplitz.hpp @@ -4,11 +4,6 @@ #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace math { template @@ -169,7 +164,3 @@ namespace math extern template class ToeplitzMatrix; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/Tolerance.hpp b/numerical/math/Tolerance.hpp index d0d7168..959bbbf 100644 --- a/numerical/math/Tolerance.hpp +++ b/numerical/math/Tolerance.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - namespace math { template @@ -13,7 +8,3 @@ namespace math return 1e-3f; } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/TriangularSolve.hpp b/numerical/math/TriangularSolve.hpp index f2a3461..bbd5e36 100644 --- a/numerical/math/TriangularSolve.hpp +++ b/numerical/math/TriangularSolve.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -85,7 +80,3 @@ namespace math return x; } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/math/platform/MathArm.hpp b/numerical/math/platform/MathArm.hpp index 195436a..8c87433 100644 --- a/numerical/math/platform/MathArm.hpp +++ b/numerical/math/platform/MathArm.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include #include #include @@ -757,7 +752,3 @@ namespace math #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/nonlinear_control/BacksteppingControl.hpp b/numerical/nonlinear_control/BacksteppingControl.hpp index 65dc0ab..3c33f5b 100644 --- a/numerical/nonlinear_control/BacksteppingControl.hpp +++ b/numerical/nonlinear_control/BacksteppingControl.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" @@ -106,7 +101,3 @@ namespace nonlinear_control extern template class BacksteppingControl; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/nonlinear_control/FeedbackLinearization.hpp b/numerical/nonlinear_control/FeedbackLinearization.hpp index 2002874..4478560 100644 --- a/numerical/nonlinear_control/FeedbackLinearization.hpp +++ b/numerical/nonlinear_control/FeedbackLinearization.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include "numerical/solvers/GaussianElimination.hpp" @@ -75,7 +70,3 @@ namespace nonlinear_control extern template class FeedbackLinearization; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp b/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp index c39a267..52e18cc 100644 --- a/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp +++ b/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" @@ -127,7 +122,3 @@ namespace nonlinear_control extern template class ModelReferenceAdaptiveControl; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/optimization/Adam.hpp b/numerical/optimization/Adam.hpp index 5a676a3..7d792b3 100644 --- a/numerical/optimization/Adam.hpp +++ b/numerical/optimization/Adam.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/optimization/StepOptimizer.hpp" @@ -86,7 +81,3 @@ namespace optimization extern template class Adam; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/optimization/BayesianOptimization.hpp b/numerical/optimization/BayesianOptimization.hpp index b1b5cd3..b54aa85 100644 --- a/numerical/optimization/BayesianOptimization.hpp +++ b/numerical/optimization/BayesianOptimization.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -314,7 +309,3 @@ namespace optimization extern template class BayesianOptimization<2, 20, 100>; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/optimization/GradientDescent.hpp b/numerical/optimization/GradientDescent.hpp index 75c32d0..fd5c840 100644 --- a/numerical/optimization/GradientDescent.hpp +++ b/numerical/optimization/GradientDescent.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/optimization/Optimizer.hpp" #include @@ -74,7 +69,3 @@ namespace optimization extern template class GradientDescent; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/optimization/Sgd.hpp b/numerical/optimization/Sgd.hpp index 9ff9df8..cb8db07 100644 --- a/numerical/optimization/Sgd.hpp +++ b/numerical/optimization/Sgd.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/optimization/StepOptimizer.hpp" @@ -64,7 +59,3 @@ namespace optimization extern template class Sgd; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/regularization/L1.hpp b/numerical/regularization/L1.hpp index 3e6c350..af1787f 100644 --- a/numerical/regularization/L1.hpp +++ b/numerical/regularization/L1.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/regularization/Regularization.hpp" @@ -65,7 +60,3 @@ namespace regularization extern template class L1; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/regularization/L2.hpp b/numerical/regularization/L2.hpp index 8a363fa..b36ce7a 100644 --- a/numerical/regularization/L2.hpp +++ b/numerical/regularization/L2.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/regularization/Regularization.hpp" @@ -58,7 +53,3 @@ namespace regularization extern template class L2; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/robust_control/ActiveDisturbanceRejection.hpp b/numerical/robust_control/ActiveDisturbanceRejection.hpp index a2ba72b..114e40f 100644 --- a/numerical/robust_control/ActiveDisturbanceRejection.hpp +++ b/numerical/robust_control/ActiveDisturbanceRejection.hpp @@ -3,11 +3,6 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" @@ -159,7 +154,3 @@ namespace robust_control extern template class ActiveDisturbanceRejectionControl; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/robust_control/DisturbanceObserver.hpp b/numerical/robust_control/DisturbanceObserver.hpp index c122907..2ed0102 100644 --- a/numerical/robust_control/DisturbanceObserver.hpp +++ b/numerical/robust_control/DisturbanceObserver.hpp @@ -1,11 +1,6 @@ // Copyright (c) 2024, Numerical Toolbox Contributors. All rights reserved. #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/filters/passive/BiquadCascade.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" @@ -163,7 +158,3 @@ namespace robust_control extern template class DisturbanceObserver; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/robust_control/HInfinityStateFeedback.hpp b/numerical/robust_control/HInfinityStateFeedback.hpp index cc5ba3d..8a3b0a8 100644 --- a/numerical/robust_control/HInfinityStateFeedback.hpp +++ b/numerical/robust_control/HInfinityStateFeedback.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CholeskyDecomposition.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" @@ -278,7 +273,3 @@ namespace robust_control extern template class HInfinityStateFeedback; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/robust_control/SlidingModeControl.hpp b/numerical/robust_control/SlidingModeControl.hpp index 3514838..e2bb3fc 100644 --- a/numerical/robust_control/SlidingModeControl.hpp +++ b/numerical/robust_control/SlidingModeControl.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/LinearTimeInvariant.hpp" @@ -128,7 +123,3 @@ namespace robust_control extern template class SlidingModeControl; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/ConditionNumber.hpp b/numerical/solvers/ConditionNumber.hpp index d6f057d..efff5bf 100644 --- a/numerical/solvers/ConditionNumber.hpp +++ b/numerical/solvers/ConditionNumber.hpp @@ -1,8 +1,4 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -37,7 +33,3 @@ namespace solvers return normA * normInv; } } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp b/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp index 895834b..2875bbb 100644 --- a/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp +++ b/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include "numerical/math/QNumber.hpp" @@ -124,7 +119,3 @@ namespace solvers extern template class DiscreteAlgebraicRiccatiEquation; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/DormandPrince45.hpp b/numerical/solvers/DormandPrince45.hpp index 96a8361..d0a1ba7 100644 --- a/numerical/solvers/DormandPrince45.hpp +++ b/numerical/solvers/DormandPrince45.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -254,7 +249,3 @@ namespace solvers extern template class DormandPrince45; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/DurandKerner.hpp b/numerical/solvers/DurandKerner.hpp index 2402f45..d178c6f 100644 --- a/numerical/solvers/DurandKerner.hpp +++ b/numerical/solvers/DurandKerner.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/BoundedVector.hpp" #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" @@ -173,7 +168,3 @@ namespace solvers extern template class DurandKerner; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/GaussianElimination.hpp b/numerical/solvers/GaussianElimination.hpp index 71c9e5a..974da0d 100644 --- a/numerical/solvers/GaussianElimination.hpp +++ b/numerical/solvers/GaussianElimination.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" @@ -185,7 +180,3 @@ namespace solvers extern template class GaussianElimination; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/JacobiEigenSolver.hpp b/numerical/solvers/JacobiEigenSolver.hpp index 0cf89d5..f4fb8e9 100644 --- a/numerical/solvers/JacobiEigenSolver.hpp +++ b/numerical/solvers/JacobiEigenSolver.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/GivensRotation.hpp" #include "numerical/math/Math.hpp" @@ -169,7 +164,3 @@ namespace solvers extern template class JacobiEigenSolver; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/LevinsonDurbin.hpp b/numerical/solvers/LevinsonDurbin.hpp index c1cc0ee..d507b1a 100644 --- a/numerical/solvers/LevinsonDurbin.hpp +++ b/numerical/solvers/LevinsonDurbin.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Toeplitz.hpp" #include "numerical/solvers/Solver.hpp" @@ -106,7 +101,3 @@ namespace solvers extern template class LevinsonDurbin; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/LuDecomposition.hpp b/numerical/solvers/LuDecomposition.hpp index b8a3bfc..23a5499 100644 --- a/numerical/solvers/LuDecomposition.hpp +++ b/numerical/solvers/LuDecomposition.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -176,7 +171,3 @@ namespace solvers extern template class LuDecomposition; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/LyapunovSylvester.hpp b/numerical/solvers/LyapunovSylvester.hpp index 94ce15c..f75b562 100644 --- a/numerical/solvers/LyapunovSylvester.hpp +++ b/numerical/solvers/LyapunovSylvester.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include "numerical/solvers/LuDecomposition.hpp" @@ -147,7 +142,3 @@ namespace solvers extern template class SylvesterSolver; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/QrDecomposition.hpp b/numerical/solvers/QrDecomposition.hpp index 1215913..112c8df 100644 --- a/numerical/solvers/QrDecomposition.hpp +++ b/numerical/solvers/QrDecomposition.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/GivensRotation.hpp" #include "numerical/math/HouseholderTransform.hpp" @@ -173,7 +168,3 @@ namespace solvers extern template class QrDecomposition; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/RungeKuttaIntegrators.hpp b/numerical/solvers/RungeKuttaIntegrators.hpp index a1b6fb7..63206eb 100644 --- a/numerical/solvers/RungeKuttaIntegrators.hpp +++ b/numerical/solvers/RungeKuttaIntegrators.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Matrix.hpp" #include "numerical/solvers/OdeSystem.hpp" @@ -90,7 +85,3 @@ namespace solvers extern template class RungeKutta4; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/SingularValueDecomposition.hpp b/numerical/solvers/SingularValueDecomposition.hpp index 50a5deb..dd31a8a 100644 --- a/numerical/solvers/SingularValueDecomposition.hpp +++ b/numerical/solvers/SingularValueDecomposition.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "infra/util/ReallyAssert.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/GivensRotation.hpp" @@ -533,7 +528,3 @@ namespace solvers extern template class SingularValueDecomposition; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/numerical/solvers/SpectralRadius.hpp b/numerical/solvers/SpectralRadius.hpp index 3755bc3..c1fbb0d 100644 --- a/numerical/solvers/SpectralRadius.hpp +++ b/numerical/solvers/SpectralRadius.hpp @@ -1,10 +1,5 @@ #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" @@ -98,7 +93,3 @@ namespace solvers extern template class SpectralRadius; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif diff --git a/roadmap/DEPLOYMENT.md b/roadmap/DEPLOYMENT.md index 6933ebb..63ab214 100644 --- a/roadmap/DEPLOYMENT.md +++ b/roadmap/DEPLOYMENT.md @@ -4,8 +4,7 @@ Turn one `roadmap///` spec into shipped code. Rules: `../AGENTS.md Read the spec's three files first (`implementation.md`, `tests.md`, `explanation.md`), then: 1. **Header** `numerical//.hpp` - - `#pragma once` → `#pragma GCC push_options` + `#pragma GCC optimize("O3","fast-math")` (GCC-only guard) → - `#include "numerical/math/CompilerOptimizations.hpp"`; end the file with `#pragma GCC pop_options`. + - `#pragma once` → `#include "numerical/math/CompilerOptimizations.hpp"`; no `#pragma GCC optimize`. - `template` with `static_assert(std::is_floating_point_v, " supports floating-point types");`. - Implement per `implementation.md`; `OPTIMIZE_FOR_SPEED` on the hot path(s). diff --git a/roadmap/README.md b/roadmap/README.md index 65f9407..461d716 100644 --- a/roadmap/README.md +++ b/roadmap/README.md @@ -37,10 +37,6 @@ Header shape (mirroring existing components such as `Fir.hpp`): ```cpp #pragma once -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC push_options -#pragma GCC optimize("O3", "fast-math") -#endif #include "numerical/math/CompilerOptimizations.hpp" namespace @@ -57,10 +53,6 @@ namespace extern template class ; #endif } - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC pop_options -#endif ``` Coverage `.cpp`: diff --git a/roadmap/math/SE3Transform/implementation.md b/roadmap/math/SE3Transform/implementation.md index 4e90173..942b498 100644 --- a/roadmap/math/SE3Transform/implementation.md +++ b/roadmap/math/SE3Transform/implementation.md @@ -77,8 +77,8 @@ function Log(): # inverse of Exp ## Deployment -- Header: `numerical/math/SE3Transform.hpp` — `#pragma once` → - `#pragma GCC optimize("O3","fast-math")`, `OPTIMIZE_FOR_SPEED` on `operator*`/`Apply`, and +- Header: `numerical/math/SE3Transform.hpp` — `#pragma once`, `OPTIMIZE_FOR_SPEED` on + `operator*`/`Apply`, and `extern template class SE3;` under `#ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD`. - Coverage: `numerical/math/SE3Transform.cpp` → `template class SE3;` - Test: `numerical/math/test/TestSE3Transform.cpp`