Add Benchmark to App. TODO: Test Benchmark in other kernels.
This commit is contained in:
commit
1e9d974476
|
@ -31,8 +31,11 @@
|
||||||
#define ARRAY_SIZE(ar) (int) (sizeof(ar) / sizeof((ar)[0]))
|
#define ARRAY_SIZE(ar) (int) (sizeof(ar) / sizeof((ar)[0]))
|
||||||
#define FAIL_IF(condition, error_code) if (condition) return (error_code)
|
#define FAIL_IF(condition, error_code) if (condition) return (error_code)
|
||||||
|
|
||||||
|
#ifdef DBG
|
||||||
|
#undef DBG
|
||||||
|
#endif
|
||||||
#ifdef SLRE_DEBUG
|
#ifdef SLRE_DEBUG
|
||||||
#define DBG(x) printf x
|
#define DBG(x) printf x;
|
||||||
#else
|
#else
|
||||||
#define DBG(x)
|
#define DBG(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* statemate.c
|
* statemate.c
|
||||||
*
|
*
|
||||||
* This code was automatically generated by
|
* This code was automatically generated by
|
||||||
* the STAtechart Real-time-Code generator STARC
|
* the STAtechart Real-bm_time-Code generator STARC
|
||||||
* which was developed at C-LAB.
|
* which was developed at C-LAB.
|
||||||
*
|
*
|
||||||
* The original StateChart specifies an experimental
|
* The original StateChart specifies an experimental
|
||||||
|
@ -170,7 +170,7 @@ char FH_DU__MFHA_old;
|
||||||
#define FH_TUERMODUL_CTRL__END_REVERS_copy_IDX 23
|
#define FH_TUERMODUL_CTRL__END_REVERS_copy_IDX 23
|
||||||
#define FH_TUERMODUL__EINKLEMMUNG_IDX 24
|
#define FH_TUERMODUL__EINKLEMMUNG_IDX 24
|
||||||
|
|
||||||
static unsigned long time;
|
static unsigned long bm_time;
|
||||||
char stable;
|
char stable;
|
||||||
char step;
|
char step;
|
||||||
|
|
||||||
|
@ -193,39 +193,39 @@ char BLOCK_ERKENNUNG_CTRL_BLOCK_ERKENNUNG_CTRL_next_state; /** 2 bits **/
|
||||||
|
|
||||||
void interface(void) {
|
void interface(void) {
|
||||||
if (SYS_bit_get(Bitlist, entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL_IDX))
|
if (SYS_bit_get(Bitlist, entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL_IDX))
|
||||||
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL = time;
|
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL = bm_time;
|
||||||
if (SYS_bit_get(Bitlist, entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL_IDX) ||
|
if (SYS_bit_get(Bitlist, entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL_IDX) ||
|
||||||
SYS_bit_get(Bitlist, exited_BEREIT_FH_TUERMODUL_CTRL_IDX))
|
SYS_bit_get(Bitlist, exited_BEREIT_FH_TUERMODUL_CTRL_IDX))
|
||||||
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRLexited_BEREIT_FH_TUERMODUL_CTRL =
|
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRLexited_BEREIT_FH_TUERMODUL_CTRL =
|
||||||
time;
|
bm_time;
|
||||||
if ((sc_FH_TUERMODUL_CTRL_2375_2 != 0) &&
|
if ((sc_FH_TUERMODUL_CTRL_2375_2 != 0) &&
|
||||||
(time - sc_FH_TUERMODUL_CTRL_2375_2 >= 0.5)) {
|
(bm_time - sc_FH_TUERMODUL_CTRL_2375_2 >= 0.5)) {
|
||||||
FH_TUERMODUL__MFHA_copy = 0;
|
FH_TUERMODUL__MFHA_copy = 0;
|
||||||
sc_FH_TUERMODUL_CTRL_2375_2 = 0;
|
sc_FH_TUERMODUL_CTRL_2375_2 = 0;
|
||||||
}
|
}
|
||||||
if ((sc_FH_TUERMODUL_CTRL_2352_1 != 0) &&
|
if ((sc_FH_TUERMODUL_CTRL_2352_1 != 0) &&
|
||||||
(time - sc_FH_TUERMODUL_CTRL_2352_1 >= 0.5)) {
|
(bm_time - sc_FH_TUERMODUL_CTRL_2352_1 >= 0.5)) {
|
||||||
FH_TUERMODUL__MFHZ_copy = 0;
|
FH_TUERMODUL__MFHZ_copy = 0;
|
||||||
sc_FH_TUERMODUL_CTRL_2352_1 = 0;
|
sc_FH_TUERMODUL_CTRL_2352_1 = 0;
|
||||||
}
|
}
|
||||||
if ((sc_FH_TUERMODUL_CTRL_2329_1 != 0) &&
|
if ((sc_FH_TUERMODUL_CTRL_2329_1 != 0) &&
|
||||||
(time - sc_FH_TUERMODUL_CTRL_2329_1 >= 0.5)) {
|
(bm_time - sc_FH_TUERMODUL_CTRL_2329_1 >= 0.5)) {
|
||||||
FH_TUERMODUL__MFHZ_copy = 0;
|
FH_TUERMODUL__MFHZ_copy = 0;
|
||||||
sc_FH_TUERMODUL_CTRL_2329_1 = 0;
|
sc_FH_TUERMODUL_CTRL_2329_1 = 0;
|
||||||
}
|
}
|
||||||
if ((sc_FH_TUERMODUL_CTRL_1781_10 != 0) &&
|
if ((sc_FH_TUERMODUL_CTRL_1781_10 != 0) &&
|
||||||
(time - sc_FH_TUERMODUL_CTRL_1781_10 >= 0.5)) {
|
(bm_time - sc_FH_TUERMODUL_CTRL_1781_10 >= 0.5)) {
|
||||||
sc_FH_TUERMODUL_CTRL_1781_10 = 0;
|
sc_FH_TUERMODUL_CTRL_1781_10 = 0;
|
||||||
}
|
}
|
||||||
if ((sc_FH_TUERMODUL_CTRL_1739_10 != 0) &&
|
if ((sc_FH_TUERMODUL_CTRL_1739_10 != 0) &&
|
||||||
(time - sc_FH_TUERMODUL_CTRL_1739_10 >= 0.5)) {
|
(bm_time - sc_FH_TUERMODUL_CTRL_1739_10 >= 0.5)) {
|
||||||
sc_FH_TUERMODUL_CTRL_1739_10 = 0;
|
sc_FH_TUERMODUL_CTRL_1739_10 = 0;
|
||||||
}
|
}
|
||||||
if ((SYS_bit_get(Bitlist,
|
if ((SYS_bit_get(Bitlist,
|
||||||
entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRL_IDX) ||
|
entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRL_IDX) ||
|
||||||
BLOCK_ERKENNUNG_CTRL__N != BLOCK_ERKENNUNG_CTRL__N_old))
|
BLOCK_ERKENNUNG_CTRL__N != BLOCK_ERKENNUNG_CTRL__N_old))
|
||||||
tm_entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRLch_BLOCK_ERKENNUNG_CTRL__N_copy =
|
tm_entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRLch_BLOCK_ERKENNUNG_CTRL__N_copy =
|
||||||
time;
|
bm_time;
|
||||||
|
|
||||||
} /** interface **/
|
} /** interface **/
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
((FH_TUERMODUL__MFHZ))) {
|
((FH_TUERMODUL__MFHZ))) {
|
||||||
stable = 0;
|
stable = 0;
|
||||||
FH_TUERMODUL__MFHZ_copy = 0;
|
FH_TUERMODUL__MFHZ_copy = 0;
|
||||||
sc_FH_TUERMODUL_CTRL_2329_1 = time;
|
sc_FH_TUERMODUL_CTRL_2329_1 = bm_time;
|
||||||
|
|
||||||
B_FH_TUERMODUL_CTRL_next_state = 3;
|
B_FH_TUERMODUL_CTRL_next_state = 3;
|
||||||
INITIALISIERT_FH_TUERMODUL_CTRL_next_state = 3;
|
INITIALISIERT_FH_TUERMODUL_CTRL_next_state = 3;
|
||||||
|
@ -538,7 +538,7 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
((FH_TUERMODUL__MFHA))) {
|
((FH_TUERMODUL__MFHA))) {
|
||||||
stable = 0;
|
stable = 0;
|
||||||
FH_TUERMODUL__MFHA_copy = 0;
|
FH_TUERMODUL__MFHA_copy = 0;
|
||||||
sc_FH_TUERMODUL_CTRL_2375_2 = time;
|
sc_FH_TUERMODUL_CTRL_2375_2 = bm_time;
|
||||||
|
|
||||||
B_FH_TUERMODUL_CTRL_next_state = 2;
|
B_FH_TUERMODUL_CTRL_next_state = 2;
|
||||||
NICHT_INITIALISIERT_NICHT_INITIALISIERT_next_state = 3;
|
NICHT_INITIALISIERT_NICHT_INITIALISIERT_next_state = 3;
|
||||||
|
@ -548,7 +548,7 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
((FH_TUERMODUL__MFHZ))) {
|
((FH_TUERMODUL__MFHZ))) {
|
||||||
stable = 0;
|
stable = 0;
|
||||||
FH_TUERMODUL__MFHZ_copy = 0;
|
FH_TUERMODUL__MFHZ_copy = 0;
|
||||||
sc_FH_TUERMODUL_CTRL_2352_1 = time;
|
sc_FH_TUERMODUL_CTRL_2352_1 = bm_time;
|
||||||
|
|
||||||
B_FH_TUERMODUL_CTRL_next_state = 2;
|
B_FH_TUERMODUL_CTRL_next_state = 2;
|
||||||
NICHT_INITIALISIERT_NICHT_INITIALISIERT_next_state = 3;
|
NICHT_INITIALISIERT_NICHT_INITIALISIERT_next_state = 3;
|
||||||
|
@ -657,7 +657,7 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
SYS_bit_clr(Bitlist, active_EINKLEMMSCHUTZ_CTRL_copy_IDX);
|
SYS_bit_clr(Bitlist, active_EINKLEMMSCHUTZ_CTRL_copy_IDX);
|
||||||
FH_TUERMODUL__MFHZ_copy = 0;
|
FH_TUERMODUL__MFHZ_copy = 0;
|
||||||
|
|
||||||
sc_FH_TUERMODUL_CTRL_1781_10 = time;
|
sc_FH_TUERMODUL_CTRL_1781_10 = bm_time;
|
||||||
FH_TUERMODUL__MFHA_copy = 1;
|
FH_TUERMODUL__MFHA_copy = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
MANUELL_SCHLIESSEN_FH_TUERMODUL_CTRL_next_state = 1;
|
MANUELL_SCHLIESSEN_FH_TUERMODUL_CTRL_next_state = 1;
|
||||||
SYS_bit_clr(Bitlist, active_EINKLEMMSCHUTZ_CTRL_copy_IDX);
|
SYS_bit_clr(Bitlist, active_EINKLEMMSCHUTZ_CTRL_copy_IDX);
|
||||||
|
|
||||||
sc_FH_TUERMODUL_CTRL_1739_10 = time;
|
sc_FH_TUERMODUL_CTRL_1739_10 = bm_time;
|
||||||
FH_TUERMODUL__MFHA_copy = 1;
|
FH_TUERMODUL__MFHA_copy = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -799,7 +799,7 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
if ((step == 1 &&
|
if ((step == 1 &&
|
||||||
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRLexited_BEREIT_FH_TUERMODUL_CTRL !=
|
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRLexited_BEREIT_FH_TUERMODUL_CTRL !=
|
||||||
0 &&
|
0 &&
|
||||||
(time -
|
(bm_time -
|
||||||
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRLexited_BEREIT_FH_TUERMODUL_CTRL ==
|
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRLexited_BEREIT_FH_TUERMODUL_CTRL ==
|
||||||
1)) &&
|
1)) &&
|
||||||
((FH_TUERMODUL__MFHZ || FH_TUERMODUL__MFHA))) {
|
((FH_TUERMODUL__MFHZ || FH_TUERMODUL__MFHA))) {
|
||||||
|
@ -817,7 +817,8 @@ void generic_FH_TUERMODUL_CTRL(void) {
|
||||||
{
|
{
|
||||||
if ((step == 1 &&
|
if ((step == 1 &&
|
||||||
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL != 0 &&
|
tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL != 0 &&
|
||||||
(time - tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL == 3)) &&
|
(bm_time - tm_entered_WIEDERHOLSPERRE_FH_TUERMODUL_CTRL ==
|
||||||
|
3)) &&
|
||||||
(((!(FH_TUERMODUL__MFHZ || FH_TUERMODUL__MFHA)) &&
|
(((!(FH_TUERMODUL__MFHZ || FH_TUERMODUL__MFHA)) &&
|
||||||
FH_TUERMODUL_CTRL__N > 0))) {
|
FH_TUERMODUL_CTRL__N > 0))) {
|
||||||
stable = 0;
|
stable = 0;
|
||||||
|
@ -965,7 +966,7 @@ void generic_BLOCK_ERKENNUNG_CTRL(void) {
|
||||||
if (step == 1 &&
|
if (step == 1 &&
|
||||||
tm_entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRLch_BLOCK_ERKENNUNG_CTRL__N_copy !=
|
tm_entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRLch_BLOCK_ERKENNUNG_CTRL__N_copy !=
|
||||||
0 &&
|
0 &&
|
||||||
(time -
|
(bm_time -
|
||||||
tm_entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRLch_BLOCK_ERKENNUNG_CTRL__N_copy ==
|
tm_entered_EINSCHALTSTROM_MESSEN_BLOCK_ERKENNUNG_CTRLch_BLOCK_ERKENNUNG_CTRL__N_copy ==
|
||||||
0.002)) {
|
0.002)) {
|
||||||
BLOCK_ERKENNUNG_CTRL__N = BLOCK_ERKENNUNG_CTRL__N + 1;
|
BLOCK_ERKENNUNG_CTRL__N = BLOCK_ERKENNUNG_CTRL__N + 1;
|
||||||
|
@ -1001,7 +1002,7 @@ void generic_BLOCK_ERKENNUNG_CTRL(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FH_DU(void) {
|
void FH_DU(void) {
|
||||||
time = 1; /**SYS_get_clock()**/
|
bm_time = 1; /**SYS_get_clock()**/
|
||||||
stable = 0;
|
stable = 0;
|
||||||
step = 0;
|
step = 0;
|
||||||
while (!stable) {
|
while (!stable) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# SRC_FILES := beebsc.c benchmark.c
|
# SRC_FILES := beebsc.c benchmark.c
|
||||||
SRC_FILES := $(wildcard src/*/*.c)
|
SRC_FILES += $(wildcard *.c)
|
||||||
|
|
||||||
# include $(APPDIR)/Application.mk
|
# include $(APPDIR)/Application.mk
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -12,14 +12,16 @@
|
||||||
#ifndef BEEBSC_H
|
#ifndef BEEBSC_H
|
||||||
#define BEEBSC_H
|
#define BEEBSC_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* BEEBS fixes RAND_MAX to its lowest permitted value, 2^15-1 */
|
/* BEEBS fixes RAND_MAX to its lowest permitted value, 2^15-1 */
|
||||||
|
|
||||||
#ifdef RAND_MAX
|
#ifdef RAND_MAX
|
||||||
#undef RAND_MAX
|
#undef RAND_MAX
|
||||||
#define RAND_MAX ((1U << 15) - 1)
|
|
||||||
#endif
|
#endif
|
||||||
|
#define RAND_MAX ((1U << 15) - 1)
|
||||||
|
|
||||||
/* Common understanding of a "small value" (epsilon) for floating point
|
/* Common understanding of a "small value" (epsilon) for floating point
|
||||||
comparisons. */
|
comparisons. */
|
||||||
|
@ -36,10 +38,13 @@
|
||||||
|
|
||||||
This function just*/
|
This function just*/
|
||||||
|
|
||||||
|
// #define assert_beebs(expr) \
|
||||||
|
// { \
|
||||||
|
// if (!(expr)) exit(1); \
|
||||||
|
// }
|
||||||
|
|
||||||
#define assert_beebs(expr) \
|
#define assert_beebs(expr) \
|
||||||
{ \
|
{ assert(expr); }
|
||||||
if (!(expr)) exit(1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define float_eq_beebs(exp, actual) (fabsf(exp - actual) < VERIFY_FLOAT_EPS)
|
#define float_eq_beebs(exp, actual) (fabsf(exp - actual) < VERIFY_FLOAT_EPS)
|
||||||
#define float_neq_beebs(exp, actual) !float_eq_beebs(exp, actual)
|
#define float_neq_beebs(exp, actual) !float_eq_beebs(exp, actual)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <support.h>
|
#include <support.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <transform.h>
|
||||||
|
|
||||||
extern benchmark_handle mont64_handle;
|
extern benchmark_handle mont64_handle;
|
||||||
extern benchmark_handle crc32_handle;
|
extern benchmark_handle crc32_handle;
|
||||||
|
@ -31,6 +32,7 @@ extern benchmark_handle libwikisort_handle;
|
||||||
typedef struct BenchmarkPair {
|
typedef struct BenchmarkPair {
|
||||||
benchmark_handle *handle;
|
benchmark_handle *handle;
|
||||||
char name[15];
|
char name[15];
|
||||||
|
pthread_t task_ptr;
|
||||||
float time;
|
float time;
|
||||||
} BenchmarkPair;
|
} BenchmarkPair;
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ BenchmarkPair bmh_list[] = {
|
||||||
{.handle = &huffbench_handle, .name = "huffbench", .time = 0}, //
|
{.handle = &huffbench_handle, .name = "huffbench", .time = 0}, //
|
||||||
{.handle = &matmult_int_handle, .name = "matmult-int", .time = 0}, //
|
{.handle = &matmult_int_handle, .name = "matmult-int", .time = 0}, //
|
||||||
{.handle = &libminver_handle, .name = "libminver", .time = 0}, //
|
{.handle = &libminver_handle, .name = "libminver", .time = 0}, //
|
||||||
{.handle = &nobody_handle, .name = "nobody", .time = 0}, //
|
{.handle = &nobody_handle, .name = "nbody", .time = 0}, //
|
||||||
{.handle = &nettle_aes_handle, .name = "nettle-aes", .time = 0}, //
|
{.handle = &nettle_aes_handle, .name = "nettle-aes", .time = 0}, //
|
||||||
{.handle = &nettle_sha256_handle, .name = "nettle-sha256", .time = 0}, //
|
{.handle = &nettle_sha256_handle, .name = "nettle-sha256", .time = 0}, //
|
||||||
{.handle = &libnsichneu_handle, .name = "libnsichneu", .time = 0}, //
|
{.handle = &libnsichneu_handle, .name = "libnsichneu", .time = 0}, //
|
||||||
|
@ -63,24 +65,23 @@ BenchmarkPair bmh_list[] = {
|
||||||
float benchmark_time[25];
|
float benchmark_time[25];
|
||||||
|
|
||||||
extern benchmark_handle *get_benchmark_list();
|
extern benchmark_handle *get_benchmark_list();
|
||||||
extern void add_benchmark_handle(benchmark_handle *);
|
extern void add_benchmark_handle(benchmark_handle *head, benchmark_handle *);
|
||||||
|
|
||||||
int store_idx = 0;
|
|
||||||
float tmp_diff = 0.0;
|
float tmp_diff = 0.0;
|
||||||
|
|
||||||
float global_diff = 0.0;
|
float global_diff = 0.0;
|
||||||
clock_t start_time = 0, end_time = 0;
|
void start_trigger(clock_t *start_time) { *start_time = PrivGetTickTime(); }
|
||||||
void start_trigger(void) { start_time = clock(); }
|
void stop_trigger(clock_t *end_time) { *end_time = PrivGetTickTime(); }
|
||||||
void stop_trigger(void) { end_time = clock(); }
|
|
||||||
|
|
||||||
void init_benchmark_runset() {
|
void init_benchmark_runset(benchmark_handle *head) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (bmh_list[i].handle != NULL) {
|
while (bmh_list[i].handle != NULL) {
|
||||||
add_benchmark_handle(bmh_list[i++].handle);
|
add_benchmark_handle(head, bmh_list[i++].handle);
|
||||||
}
|
}
|
||||||
|
global_diff = 0;
|
||||||
}
|
}
|
||||||
void organize_result(const benchmark_handle *handle) {
|
void organize_result(const benchmark_handle *handle, clock_t start_time,
|
||||||
tmp_diff = (float)(end_time - start_time) / CLOCKS_PER_SEC;
|
clock_t end_time) {
|
||||||
|
tmp_diff = (float)(end_time - start_time) / TICK_PER_SECOND;
|
||||||
global_diff += tmp_diff;
|
global_diff += tmp_diff;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (bmh_list[i].handle != NULL) {
|
while (bmh_list[i].handle != NULL) {
|
||||||
|
@ -101,42 +102,69 @@ void print_result() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int run_benchmark() {
|
int done_cnt = 0;
|
||||||
int i = 0;
|
pthread_mutex_t case_mu;
|
||||||
|
sem_t syn_sem;
|
||||||
|
void *run_one_example(void *arg) {
|
||||||
|
const benchmark_handle *handle = arg;
|
||||||
|
assert(handle != NULL);
|
||||||
|
clock_t start_time = 0, end_time = 0;
|
||||||
|
handle->handle.benchmark_func->initialise_benchmark();
|
||||||
|
handle->handle.benchmark_func->warm_caches(WARMUP_HEAT);
|
||||||
|
start_trigger(&start_time);
|
||||||
|
volatile int result = handle->handle.benchmark_func->benchmark();
|
||||||
|
stop_trigger(&end_time);
|
||||||
|
|
||||||
|
int correct = handle->handle.benchmark_func->verify_benchmark(result);
|
||||||
|
if (!correct) {
|
||||||
|
printf("[EmBench] Wrong result!.\n");
|
||||||
|
}
|
||||||
|
PrivMutexObtain(&case_mu);
|
||||||
|
organize_result(handle, start_time, end_time);
|
||||||
|
PrivMutexAbandon(&case_mu);
|
||||||
|
PrivSemaphoreAbandon(&syn_sem);
|
||||||
|
done_cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_attr_t case_attr;
|
||||||
|
void *run_benchmark(void *args) {
|
||||||
|
done_cnt = 0;
|
||||||
volatile int result;
|
volatile int result;
|
||||||
int correct;
|
int correct;
|
||||||
|
|
||||||
init_benchmark_runset();
|
benchmark_handle head = {
|
||||||
|
.handle.magic_number = MAGIC_NUMBER,
|
||||||
|
.next = NULL,
|
||||||
|
};
|
||||||
|
init_benchmark_runset(&head);
|
||||||
|
printf("[BENCHMARK] Start Benchmark running.\n");
|
||||||
|
|
||||||
benchmark_handle *cur_handle = get_benchmark_list()->next;
|
case_attr.schedparam.sched_priority = 30;
|
||||||
|
case_attr.stacksize = 16384;
|
||||||
|
PrivSemaphoreCreate(&syn_sem, 0, -20);
|
||||||
|
PrivMutexCreate(&case_mu, 0);
|
||||||
|
|
||||||
|
benchmark_handle *cur_handle = head.next;
|
||||||
while (NULL != cur_handle) {
|
while (NULL != cur_handle) {
|
||||||
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
||||||
cur_handle->handle.benchmark_func->initialise_benchmark();
|
PrivTaskCreate(&cur_handle->task_ptr, &case_attr, run_one_example,
|
||||||
cur_handle->handle.benchmark_func->warm_caches(WARMUP_HEAT);
|
(void *)cur_handle);
|
||||||
|
|
||||||
start_trigger();
|
|
||||||
result = cur_handle->handle.benchmark_func->benchmark();
|
|
||||||
stop_trigger();
|
|
||||||
|
|
||||||
correct = cur_handle->handle.benchmark_func->verify_benchmark(result);
|
|
||||||
if (!correct) {
|
|
||||||
printf("[EmBench] Wrong result!.\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
organize_result(cur_handle);
|
|
||||||
|
|
||||||
cur_handle = cur_handle->next;
|
cur_handle = cur_handle->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct timespec abstime;
|
||||||
|
abstime.tv_sec = 10;
|
||||||
|
PrivSemaphoreObtainWait(&syn_sem, &abstime);
|
||||||
print_result();
|
print_result();
|
||||||
return (!correct);
|
printf("[BENCHMARK] Global Time Diff: %f, Done: %d\n", global_diff, done_cnt);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int embenchmark() {
|
static int embenchmark(void) {
|
||||||
run_benchmark();
|
run_benchmark(NULL);
|
||||||
printf("[BENCHMARK] Global Time Diff: %f\n", global_diff);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PRIV_SHELL_CMD_FUNCTION(embenchmark, run embenchmark, PRIV_SHELL_CMD_MAIN_ATTR);
|
PRIV_SHELL_CMD_FUNCTION(embenchmark, benchmark, PRIV_SHELL_CMD_MAIN_ATTR);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <transform.h>
|
||||||
|
|
||||||
#define CPU_MHZ 1000
|
#define CPU_MHZ 5
|
||||||
|
|
||||||
/* Benchmarks must implement verify_benchmark, which must return -1 if no
|
/* Benchmarks must implement verify_benchmark, which must return -1 if no
|
||||||
verification is done. */
|
verification is done. */
|
||||||
|
@ -38,8 +39,6 @@ static int verify_benchmark(int result);
|
||||||
/* Standard functions implemented for each board */
|
/* Standard functions implemented for each board */
|
||||||
|
|
||||||
void initialise_board(void);
|
void initialise_board(void);
|
||||||
void start_trigger(void);
|
|
||||||
void stop_trigger(void);
|
|
||||||
|
|
||||||
/* Every benchmark implements this for one-off data initialization. This is
|
/* Every benchmark implements this for one-off data initialization. This is
|
||||||
only used for initialization that is independent of how often benchmark ()
|
only used for initialization that is independent of how often benchmark ()
|
||||||
|
@ -80,6 +79,7 @@ typedef struct benchmark_handle {
|
||||||
benchmark_t *benchmark_func;
|
benchmark_t *benchmark_func;
|
||||||
} handle;
|
} handle;
|
||||||
struct benchmark_handle *next;
|
struct benchmark_handle *next;
|
||||||
|
pthread_t task_ptr;
|
||||||
} benchmark_handle;
|
} benchmark_handle;
|
||||||
|
|
||||||
static benchmark_handle *get_benchmark_list() {
|
static benchmark_handle *get_benchmark_list() {
|
||||||
|
@ -90,7 +90,7 @@ static benchmark_handle *get_benchmark_list() {
|
||||||
return &head;
|
return &head;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_benchmark_handle(benchmark_handle *bh) {
|
static void add_benchmark_handle(benchmark_handle *head, benchmark_handle *bh) {
|
||||||
if (NULL == bh) {
|
if (NULL == bh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,8 @@ static void add_benchmark_handle(benchmark_handle *bh) {
|
||||||
NULL == bh->handle.benchmark_func->verify_benchmark) {
|
NULL == bh->handle.benchmark_func->verify_benchmark) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bh->next = get_benchmark_list()->next;
|
bh->next = head->next;
|
||||||
get_benchmark_list()->next = bh;
|
head->next = bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Local simplified versions of library functions */
|
/* Local simplified versions of library functions */
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* See the Mulan PSL v2 for more details.
|
* See the Mulan PSL v2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
__STACKSIZE__ = 4096;
|
__STACKSIZE__ = 16384;
|
||||||
OUTPUT_ARCH( "riscv" )
|
OUTPUT_ARCH( "riscv" )
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
|
|
|
@ -497,7 +497,7 @@ endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ifeq ($(CONFIG_BENCHMARK), y)
|
ifeq ($(CONFIG_APP_BENCHMARK), y)
|
||||||
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/support
|
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/support
|
||||||
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/cubic \
|
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/cubic \
|
||||||
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/picojpeg \
|
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/picojpeg \
|
||||||
|
@ -505,7 +505,7 @@ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/c
|
||||||
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/sglib-combined \
|
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/sglib-combined \
|
||||||
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/slre \
|
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/slre \
|
||||||
-lm
|
-lm
|
||||||
# endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_TOOL_SHELL), y)
|
ifeq ($(CONFIG_TOOL_SHELL), y)
|
||||||
|
|
Loading…
Reference in New Issue