|
3-phase PV router
|
The integer datalog arithmetic on the target: exact results, and cycle counts against the float code it replaces. More...
#include <Arduino.h>#include <unity.h>#include <math.h>#include "../bench_report.h"#include "../halt_after_tests.h"#include "datalog_math.h"
Go to the source code of this file.
Classes | |
| struct | Cycles |
| Cycle statistics of one variant over all inputs. More... | |
Macros | |
| #define | MEASURE(stats, overhead, code) |
Functions | |
| static void | bench (const __FlashStringHelper *avgName, const __FlashStringHelper *maxName, const Cycles &stats) |
| The average and worst case of an integer function, for the CI history. | |
| void | loop () |
| static uint16_t | overhead () |
| static void | report (const __FlashStringHelper *name, const Cycles &stats) |
| void | setUp (void) |
| void | setup () |
| static void | startTimer () |
| void | tearDown (void) |
| void | test_isqrt_is_faster_than_float_sqrt (void) |
| void | test_isqrt_on_avr_edge_cases (void) |
| void | test_isqrt_on_avr_every_boundary (void) |
| Every rounding boundary of every root, on the target: the assembly loop is exact. | |
| void | test_vrms_is_faster_than_the_float_code (void) |
| void | test_vrms_on_avr_matches_the_float_code (void) |
| sqrtScaled() and vrms() on the target, against the float code, over the whole voltage range. | |
| void | test_watts_is_faster_than_the_float_code (void) |
Variables | |
| static const int32_t | averagePowers [] { 0L, 1L, -7L, 350L, -2000L, 8380L, -15000L, 60000L, -120000L, 228000L } |
| static volatile int32_t | inAveragePower |
| static volatile uint32_t | inMeanSquare |
| static volatile uint8_t | inPhase |
| static const uint32_t | meanSquares [] { 0UL, 1UL, 100UL, 5000UL, 45000UL, 67076UL, 67081UL, 70000UL, 150000UL, 262144UL } |
| static constexpr uint8_t | N_INPUTS { 10 } |
| static volatile int16_t | out16 |
| static volatile uint32_t | out32 |
| static volatile float | powerCal [] { 0.1432025F, 0.1432025F, 0.1432025F } |
| static constexpr float | powerCalConst [] { 0.1432025F, 0.1432025F, 0.1432025F } |
| static constexpr auto | powerFixed { Datalog::powerCalibration(powerCalConst) } |
| static volatile float | voltageCal [] { 0.888065256F, 0.888065256F, 0.888065256F } |
| static constexpr float | voltageCalConst [] { 0.888065256F, 0.888065256F, 0.888065256F } |
| static constexpr auto | voltageFixed { Datalog::voltageCalibration(100, voltageCalConst) } |
The integer datalog arithmetic on the target: exact results, and cycle counts against the float code it replaces.
datalog_math.h replaced, in the datalog (#120):
Definition in file test_main.cpp.
| #define MEASURE | ( | stats, | |
| overhead, | |||
| code ) |
Definition at line 85 of file test_main.cpp.
|
static |
The average and worst case of an integer function, for the CI history.
Definition at line 108 of file test_main.cpp.


| void loop | ( | ) |
Definition at line 303 of file test_main.cpp.
|
static |
|
static |
Definition at line 114 of file test_main.cpp.


| void setUp | ( | void | ) |
Definition at line 27 of file test_main.cpp.
| void setup | ( | ) |
|
static |
Definition at line 76 of file test_main.cpp.
| void tearDown | ( | void | ) |
Definition at line 28 of file test_main.cpp.
| void test_isqrt_is_faster_than_float_sqrt | ( | void | ) |
Definition at line 203 of file test_main.cpp.


| void test_isqrt_on_avr_edge_cases | ( | void | ) |
Definition at line 166 of file test_main.cpp.


| void test_isqrt_on_avr_every_boundary | ( | void | ) |
Every rounding boundary of every root, on the target: the assembly loop is exact.
round(sqrt(x)) changes from r to r + 1 between r^2 + r and r^2 + r + 1, since (r + 0.5)^2 = r^2 + r + 0.25. Checking r^2 - 1 (from r = 2), r^2, r^2 + r and r^2 + r + 1 for all 65536 roots covers every boundary of the 32-bit range (up to 65535^2 + 65535 = UINT32_MAX), and with them the largest remainders (worst cases of the 3-byte remainder) and the carries of each byte.
Definition at line 139 of file test_main.cpp.


| void test_vrms_is_faster_than_the_float_code | ( | void | ) |
Definition at line 235 of file test_main.cpp.


| void test_vrms_on_avr_matches_the_float_code | ( | void | ) |
sqrtScaled() and vrms() on the target, against the float code, over the whole voltage range.
Definition at line 182 of file test_main.cpp.


| void test_watts_is_faster_than_the_float_code | ( | void | ) |
Definition at line 260 of file test_main.cpp.


|
static |
Definition at line 41 of file test_main.cpp.
|
static |
Definition at line 45 of file test_main.cpp.
|
static |
Definition at line 44 of file test_main.cpp.
|
static |
Definition at line 46 of file test_main.cpp.
|
static |
Definition at line 40 of file test_main.cpp.
|
staticconstexpr |
Definition at line 42 of file test_main.cpp.
|
static |
Definition at line 48 of file test_main.cpp.
|
static |
Definition at line 47 of file test_main.cpp.
|
static |
Definition at line 31 of file test_main.cpp.
|
staticconstexpr |
Definition at line 34 of file test_main.cpp.
|
staticconstexpr |
Definition at line 36 of file test_main.cpp.
|
static |
Definition at line 32 of file test_main.cpp.
|
staticconstexpr |
Definition at line 35 of file test_main.cpp.
|
staticconstexpr |
Definition at line 37 of file test_main.cpp.