Skip to content
Snippets Groups Projects
Commit eb5c35ba authored by Tim Rheinfels's avatar Tim Rheinfels
Browse files

campaigns: add campaign for observer abstraction and various sizes

parent 36cd936e
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,7 @@ CSRC = $(ALLCSRC) \
$(SRCDIR)/benchmarks.c \
$(SRCDIR)/benchmarks/memory.c \
$(SRCDIR)/benchmarks/blind_abstraction.c \
$(SRCDIR)/benchmarks/observer_abstraction.c \
$(SRCDIR)/main.c \
$(SRCDIR)/random.c \
$(SRCDIR)/serial.c \
......
## This file is part of the execution-time evaluation for the qronos observer abstractions.
## Copyright (C) 2022-2023 Tim Rheinfels <tim.rheinfels@fau.de>
## See https://gitlab.cs.fau.de/qronos-state-abstractions/execution-time
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
###
### @file benchmarks/observer_abstraction.py
###
### @brief Provides @p observer_abstraction.ObserverAbstraction, the @p benchmark.Benchmark
### subclass for the observer abstraction benchmark
###
### @author Tim Rheinfels <tim.rheinfels@fau.de>
###
import numpy as np
import json
from benchmark import Benchmark
from data import decode
###
### @brief Encapsulates the observer abstraction execution time benchmark
###
class ObserverAbstraction(Benchmark):
###
### @brief Validates the computations performed on the STM32 by running them
### again in numpy and comparing the results.
###
### @see benchmark.Benchmark._validate for parameters
###
def _validate(self, benchmark, key):
n_y = int(key)
for run in benchmark['tests']:
v = decode(run['setup']['v'])
rho = decode(run['setup']['rho'])
beta = decode(run['setup']['beta'])
assert(isinstance(v, float))
assert(isinstance(rho, float))
assert(isinstance(beta, float))
M_sqrt_T = decode(run['setup']['M_sqrt_T'])
y = decode(run['setup']['y'])
if n_y > 0:
assert(M_sqrt_T.shape == (n_y, n_y))
for i in range(n_y):
for j in range(i):
assert(np.isclose(M_sqrt_T[i, j], 0.0))
assert(np.all(np.linalg.eigvalsh(M_sqrt_T.T @ M_sqrt_T) > 0.0))
else:
assert(M_sqrt_T.size == 0)
assert(y.shape == (n_y,))
for i in range(benchmark['repetition_count']):
v = rho * v + beta + np.linalg.norm(M_sqrt_T @ y)
v_p = decode(run['teardown']['v_p'])
assert(np.isclose(v, v_p))
###
### @brief Constructor
###
### @see benchmark.Benchmark.__init__ for parameters
###
def __init__(self, data):
Benchmark.__init__(self, data, 'Observer Abstraction', r'observer_abstraction_([0-9]+)', lambda m: m.group(1))
......@@ -28,6 +28,7 @@
#include <benchmarks/campaign.h>
#include <benchmarks/blind_abstraction.h>
#include <benchmarks/observer_abstraction.h>
void benchmarks_run(void)
{
......@@ -41,5 +42,6 @@ void benchmarks_run(void)
// Comparative execution time benchmarks
benchmarks_run_blind_abstraction();
benchmarks_run_observer_abstraction();
}
......@@ -29,6 +29,7 @@
#include <string.h>
#include <benchmarks/blind_abstraction.h>
#include <benchmarks/observer_abstraction.h>
///
/// @brief Size of the padding in bytes used for checking memory violations
......@@ -49,7 +50,8 @@
/// @brief Actual benchmark memory
///
static float work[2u * PADDING
+ BENCHMARKS_BLIND_ABSTRACTION_WORK_SIZE
+ MAX(BENCHMARKS_BLIND_ABSTRACTION_WORK_SIZE,
BENCHMARKS_OBSERVER_ABSTRACTION_WORK_SIZE)
];
float * const benchmarks_memory = work + PADDING;
......
// This file is part of the execution-time evaluation for the qronos observer abstractions.
// Copyright (C) 2022-2023 Tim Rheinfels <tim.rheinfels@fau.de>
// See https://gitlab.cs.fau.de/qronos-state-abstractions/execution-time
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
///
/// @file benchmarks/observer_abstraction.c
///
/// @brief Provides the implementation of the observer abstraction execution time benchmark
///
/// @author Tim Rheinfels <tim.rheinfels@fau.de>
///
#include "observer_abstraction.h"
#include <stdlib.h>
#include <string.h>
#include <linalg.h>
#include <random.h>
#include <serial.h>
#include <benchmarks/campaign.h>
static float *M_sqrt_T = NULL; ///< Triangular matrix chol(LtPL) for the measurement vector's norm
static float *y = NULL; ///< Measurement vector
///
/// @brief Configures the memory layout and randomly initializes the data
///
static void setup_matrices(size_t n_y)
{
M_sqrt_T = benchmarks_memory;
y = M_sqrt_T + n_y*n_y;
random_matrix_cholesky(M_sqrt_T, n_y);
random_matrix(y, n_y, 1u);
serial_print_matrix("M_sqrt_T", M_sqrt_T, n_y, n_y);
serial_print_vector("y", y, n_y);
}
void benchmarks_run_observer_abstraction(void)
{
volatile float v;
float rho;
float beta;
#define SETUP(N_Y) { \
v = random_float(); \
rho = random_float(); \
beta = random_float(); \
serial_printf("\"v\": %u, \"rho\": %u, \"beta\": %u,\n", serial_encode(v), serial_encode(rho), serial_encode(beta)); \
setup_matrices(N_Y); \
}
#define TEARDOWN { \
serial_printf("\"v_p\": %u,\n", serial_encode(v)); \
}
#define CAMPAIGN(N_Y) { \
BENCHMARKS_CAMPAIGN("observer_abstraction_" #N_Y, \
{ \
float accu = 0.0f; \
for(size_t i = 0u; i < N_Y; ++i) { \
float accu_row = 0.0f; \
for(size_t j = i; j < N_Y; ++j) { \
accu_row += M_sqrt_T[(i*N_Y)+j] * y[j]; \
} \
accu += accu_row * accu_row; \
} \
v = rho*v + beta + sqrtf(accu); \
}, \
SETUP(N_Y), \
TEARDOWN, \
10u, \
10u \
) \
}
CAMPAIGN(1);
CAMPAIGN(2);
CAMPAIGN(3);
CAMPAIGN(4);
CAMPAIGN(5);
CAMPAIGN(6);
CAMPAIGN(7);
CAMPAIGN(8);
CAMPAIGN(9);
CAMPAIGN(10);
CAMPAIGN(11);
CAMPAIGN(12);
CAMPAIGN(13);
CAMPAIGN(14);
CAMPAIGN(15);
CAMPAIGN(16);
CAMPAIGN(17);
CAMPAIGN(18);
CAMPAIGN(19);
CAMPAIGN(20);
CAMPAIGN(21);
CAMPAIGN(22);
CAMPAIGN(23);
CAMPAIGN(24);
CAMPAIGN(25);
CAMPAIGN(26);
CAMPAIGN(27);
CAMPAIGN(28);
CAMPAIGN(29);
CAMPAIGN(30);
CAMPAIGN(31);
CAMPAIGN(32);
CAMPAIGN(33);
CAMPAIGN(34);
CAMPAIGN(35);
CAMPAIGN(36);
CAMPAIGN(37);
CAMPAIGN(38);
CAMPAIGN(39);
CAMPAIGN(40);
CAMPAIGN(41);
CAMPAIGN(42);
CAMPAIGN(43);
CAMPAIGN(44);
CAMPAIGN(45);
CAMPAIGN(46);
CAMPAIGN(47);
CAMPAIGN(48);
CAMPAIGN(49);
CAMPAIGN(50);
CAMPAIGN(51);
CAMPAIGN(52);
CAMPAIGN(53);
CAMPAIGN(54);
CAMPAIGN(55);
CAMPAIGN(56);
CAMPAIGN(57);
CAMPAIGN(58);
CAMPAIGN(59);
CAMPAIGN(60);
}
// This file is part of the execution-time evaluation for the qronos observer abstractions.
// Copyright (C) 2022-2023 Tim Rheinfels <tim.rheinfels@fau.de>
// See https://gitlab.cs.fau.de/qronos-state-abstractions/execution-time
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
///
/// @file benchmarks/observer_abstraction.h
///
/// @brief Provides the interface for the observer abstraction execution time benchmark
///
/// @author Tim Rheinfels <tim.rheinfels@fau.de>
///
#ifndef BENCHMARKS_OBSERVERABSTRACTION_H
#define BENCHMARKS_OBSERVERABSTRACTION_H
#include <benchmarks/memory.h>
///
/// @brief Memory required for running the observer abstraction execution time benchmark
///
#define BENCHMARKS_OBSERVER_ABSTRACTION_WORK_SIZE (N_Y_MAX * N_Y_MAX + N_Y_MAX)
///
/// @brief Runs the observer abstraction execution time benchmark
///
/// This function measures the execution time needed in order to update the
/// blind abstraction proposed in @cite ECRTS23-Rheinfels by equation (8a).
///
void benchmarks_run_observer_abstraction(void);
#endif // BENCHMARKS_OBSERVERABSTRACTION_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment