fft-run.c
3.89 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//
// fft-run.c: this file is part of the SL program suite.
//
// Copyright (C) 2020-2022 daiteq.
//
//
#include <stdint.h>
#include <stdio.h>
#if !defined(__riscv) && (USEDBSP==BSP_RTEMS)
#define USE_RTEMS 1
#endif
#if USE_RTEMS
#include <stdio.h> /* standard I/O */
#include <stdlib.h> /* for exit - 1 occurrence */
#include <math.h>
#include <rtems.h>
#include <sys/timespec.h>
#include <sys/unistd.h>
#else
#include "../common_sys_header.inc"
#endif
#define counter_t long unsigned 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]))
#if USE_RTEMS
#define dtime clock
#else
unsigned dtime(void)
{
return get_usec();
}
#endif
#define Y_FFT_ARRAY_SIZE ((1<<TABLE_SIZE)) // * sizeof(cpx_t))
cpx_t y_fft[Y_FFT_ARRAY_SIZE];
#if USE_RTEMS
rtems_task Init(
rtems_task_argument ignored
)
#else
int main(void)
#endif
{
#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;
system_init();
#if defined (PACKED)
printf("FFT - SINGLE PRECISION, PACKED\n");
#else
printf("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]);
printf("\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));
}
printf("\n");
}
printf("Done!\n");
//#ifndef NOHWCONF
do {
unsigned ticks_lo, ticks_hi, insns_lo, insns_hi, fpop_lo, fpop_hi, fpld_lo, fpld_hi, fpst_lo, fpst_hi;
sysregs_stop();
sysregs_read_ext(&ticks_lo, &ticks_hi, &insns_lo, &insns_hi, &fpop_lo, &fpop_hi, &fpld_lo, &fpld_hi, &fpst_lo, &fpst_hi);
if (ticks_hi)
printf("TEST EXECUTED IN (%u * 2^32 + %u) TICKS AND (%u * 2^32 + %u) INSTRUCTIONS, FPU: FPOP (%u * 2^32 + %u) FPLD (%u * 2^32 + %u) FPST (%u * 2^32 + %u) \n\n", ticks_hi, ticks_lo, insns_hi, insns_lo, fpop_hi, fpop_lo, fpld_hi, fpld_lo, fpst_hi, fpst_lo);
else
printf("TEST EXECUTED IN %u TICKS AND %u INSTRUCTIONS, FPU: FPOP %u FPLD %u FPST %u \n\n", ticks_lo, insns_lo, fpop_lo, fpld_lo, fpst_lo);
} while(0);
//#endif /* NOHWCONF */
printf("\n\nEND OF TEST\n\n");
system_done();
return 0;
}
#if USE_RTEMS
/* configuration information */
#include <bsp.h>
/* NOTICE: the clock driver is explicitly disabled */
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#if 0
#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
#endif
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_INIT
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
#include <rtems/confdefs.h>
#endif