PandA-2024.02
local_support.c
Go to the documentation of this file.
1 #include "fft.h"
2 #include <string.h>
3 
4 int INPUT_SIZE = sizeof(struct bench_args_t);
5 
6 #define EPSILON ((TYPE)1.0e-6)
7 
8 void run_benchmark( void *vargs ) {
9  struct bench_args_t *args = (struct bench_args_t *)vargs;
10  fft1D_512( args->work_x, args->work_y);
11 }
12 
13 /* Input format:
14 %% Section 1
15 TYPE[512]: signal (real part)
16 %% Section 2
17 TYPE[512]: signal (complex part)
18 */
19 
20 void input_to_data(int fd, void *vdata) {
21  struct bench_args_t *data = (struct bench_args_t *)vdata;
22  char *p, *s;
23  // Load input string
24  p = readfile(fd);
25 
26  s = find_section_start(p,1);
27  STAC(parse_,TYPE,_array)(s, data->work_x, 512);
28 
29  s = find_section_start(p,2);
30  STAC(parse_,TYPE,_array)(s, data->work_y, 512);
31  free(p);
32 }
33 
34 void data_to_input(int fd, void *vdata) {
35  struct bench_args_t *data = (struct bench_args_t *)vdata;
36 
38  STAC(write_,TYPE,_array)(fd, data->work_x, 512);
39 
41  STAC(write_,TYPE,_array)(fd, data->work_y, 512);
42 }
43 
44 /* Output format:
45 %% Section 1
46 TYPE[512]: freq (real part)
47 %% Section 2
48 TYPE[512]: freq (complex part)
49 */
50 
51 void output_to_data(int fd, void *vdata) {
52  struct bench_args_t *data = (struct bench_args_t *)vdata;
53  char *p, *s;
54  // Load input string
55  p = readfile(fd);
56 
57  s = find_section_start(p,1);
58  STAC(parse_,TYPE,_array)(s, data->work_x, 512);
59 
60  s = find_section_start(p,2);
61  STAC(parse_,TYPE,_array)(s, data->work_y, 512);
62  free(p);
63 }
64 
65 void data_to_output(int fd, void *vdata) {
66  struct bench_args_t *data = (struct bench_args_t *)vdata;
67 
69  STAC(write_,TYPE,_array)(fd, data->work_x, 512);
70 
72  STAC(write_,TYPE,_array)(fd, data->work_y, 512);
73 }
74 
75 int check_data( void *vdata, void *vref ) {
76  struct bench_args_t *data = (struct bench_args_t *)vdata;
77  struct bench_args_t *ref = (struct bench_args_t *)vref;
78  int has_errors = 0;
79  int i;
80  double real_diff, img_diff;
81 
82  for(i=0; i<512; i++) {
83  real_diff = data->work_x[i] - ref->work_x[i];
84  img_diff = data->work_y[i] - ref->work_y[i];
85  has_errors |= (real_diff<-EPSILON) || (EPSILON<real_diff);
86  //if( has_errors )
87  //printf("%d (real): %f (%f)\n", i, real_diff, EPSILON);
88  has_errors |= (img_diff<-EPSILON) || (EPSILON<img_diff);
89  //if( has_errors )
90  //printf("%d (img): %f (%f)\n", i, img_diff, EPSILON);
91  }
92 
93  // Return true if it's correct.
94  return !has_errors;
95 }
void data_to_input(int fd, void *vdata)
Definition: local_support.c:34
int check_data(void *vdata, void *vref)
Definition: local_support.c:70
#define TYPE
Definition: backprop.h:21
#define STAC(f_pfx, t, f_sfx)
Definition: support.h:51
int INPUT_SIZE
Definition: local_support.c:4
void data_to_output(int fd, void *vdata)
Definition: local_support.c:63
int write_section_header(int fd)
void output_to_data(int fd, void *vdata)
Definition: local_support.c:49
char * readfile(int fd)
Definition: support.c:34
void input_to_data(int fd, void *vdata)
Definition: local_support.c:18
char * find_section_start(char *s, int n)
Definition: support.c:56
TYPE work_y[512]
Definition: fft.h:29
void fft1D_512(TYPE work_x[512], TYPE work_y[512])
Definition: fft.c:113
void run_benchmark(void *vargs)
Definition: local_support.c:6
#define EPSILON
Definition: local_support.c:6
TYPE work_x[512]
Definition: fft.h:28

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13