fft-run.c
3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// fft-run.c: this file is part of the SL program suite.
//
// Copyright (C) 2020, 2021 daiteq.
//
//
// #include <stdint.h>
#include <leon-myuart.h>
#include <sysregs.h>
#include <lconf.h>
#include <my_printf.h>
/* for clearing BSS section */
extern unsigned long __bss_start; /* start address for the .bss section. defined in linker script */
extern unsigned long _end; /* end address for the .bss section. defined in linker script */
#define counter_t int
#define putchar m_putchar
// extern FILE *stduart;
// extern FILE *dbgstdout;
void report_perf(int sz, int b, const char *pre, counter_t t, counter_t i) {
printf("%s %d %u %lu %lu\n", pre, b, sz, t, i);
}
#ifndef TABLE_SIZE
#define TABLE_SIZE 10
#endif
#include "fft.h"
#include "fft_impl4.c"
__attribute__((always_inline))
unsigned delta(counter_t end, counter_t start) {
return (start <= end) ? (end - start) : ((0xffffffffu-end) + start + 1);
}
#ifndef BLOCKSIZES
#define BLOCKSIZES 1,2,4,8,16,30
#endif
static const int blocksizes[] = { BLOCKSIZES };
#define NBLSZ (sizeof(blocksizes)/sizeof(blocksizes[0]))
#define dtime clock
#define Y_FFT_ARRAY_SIZE ((1<<TABLE_SIZE)) // * sizeof(cpx_t))
cpx_t y_fft[Y_FFT_ARRAY_SIZE];
int main(void)
{
#ifndef LSZ
#define LSZ 1
#endif
counter_t c1, c2;
counter_t i1, i2;
// cpx_t *y_fft = (cpx_t*)calloc((1<<TABLE_SIZE), sizeof(cpx_t));
// dbgstdout = stduart;
/* reset BSS section to zero */
for(unsigned long *pMem = &__bss_start; pMem < &_end;) {
*(pMem++) = 0;
}
init_uart();
init_timer();
// init_softfloat();
#ifndef NOHWCONF
do {
// printf(" > Y_FFT #elms=%d size=%d <\n", Y_FFT_ARRAY_SIZE, sizeof(y_fft));
lconf_type lconf;
lconf_fpu_type lconf_fpu;
lconf_swar_type lconf_swar;
get_lconf(&lconf);
get_lconf_fpu(&lconf_fpu);
get_lconf_swar(&lconf_swar);
report_lconf(&lconf);
if ((lconf.fpu==FPU_DAIFPU)||(lconf.fpu==FPU_MEIKO))
report_lconf_fpu(&lconf_fpu);
report_lconf_swar(&lconf_swar);
sysregs_init();
} while(0);
#endif /* NOHWCONF */
#if defined (PACKED)
m_print("FFT - SINGLE PRECISION, PACKED\n");
#else
m_print("FFT - SINGLE PRECISION, NORMAL\n");
#endif
unsigned i;
printf("Columns:\nLN2(SZ)\tINSNS");
for (i = 0; i < NBLSZ; i++)
printf("\tCC_BLK%d", blocksizes[i]);
putchar('\n');
#ifdef NOIOTIME
sysregs_init();
#endif
unsigned M;
for (M = 1; M <= TABLE_SIZE; M++) {
unsigned N = 1 << M;
printf("%u ", N);
for (i = 0; i < NBLSZ; i++) {
unsigned blocksize = blocksizes[i];
#ifdef NOIOTIME
sysregs_start();
#endif
c1 = dtime(); //mtperf_sample1(MTPERF_CLOCKS);
// i1 = mtperf_sample1(MTPERF_EXECUTED_INSNS);
FFT_1(M, y_fft, N/2, sc_table_ptr, blocksize);
c2 = dtime(); //mtperf_sample1(MTPERF_CLOCKS);
// i2 = mtperf_sample1(MTPERF_EXECUTED_INSNS);
#ifdef NOIOTIME
sysregs_stop();
#endif
if (i == 0) {
// printf("\t%u", delta(i2, i1));
printf("\t");
}
printf("\t%u", delta(c2, c1));
}
putchar('\n');
}
printf("Done!\n");
#ifndef NOHWCONF
do {
unsigned ticks_lo, ticks_hi, insns_lo, insns_hi;
sysregs_stop();
sysregs_read(&ticks_lo, &ticks_hi, &insns_lo, &insns_hi);
if (ticks_hi)
printf("TEST EXECUTED IN (%u * 2^32 + %u) TICKS AND (%u * 2^32 + %u) INSTRUCTIONS\n\n", ticks_hi, ticks_lo, insns_hi, insns_lo);
else
printf("TEST EXECUTED IN %u TICKS AND %u INSTRUCTIONS\n\n", ticks_lo, insns_lo);
} while(0);
#endif /* NOHWCONF */
m_print("\n\nEND OF TEST\n\n");
__asm__("ta 1; nop; nop;");
}