PandA-2024.02
support.h
Go to the documentation of this file.
1 #include <inttypes.h>
2 #include <stdlib.h>
3 
5 char* readfile(int fd);
6 char* find_section_start(char* s, int n);
7 
9 #define SECTION_TERMINATED -1
10 int parse_string(char* s, char* arr, int n); // n==-1 : %%-terminated
11 int parse_uint8_t_array(char* s, uint8_t* arr, int n);
12 int parse_uint16_t_array(char* s, uint16_t* arr, int n);
13 int parse_uint32_t_array(char* s, uint32_t* arr, int n);
14 int parse_uint64_t_array(char* s, uint64_t* arr, int n);
15 int parse_int8_t_array(char* s, int8_t* arr, int n);
16 int parse_int16_t_array(char* s, int16_t* arr, int n);
17 int parse_int32_t_array(char* s, int32_t* arr, int n);
18 int parse_int64_t_array(char* s, int64_t* arr, int n);
19 int parse_float_array(char* s, float* arr, int n);
20 int parse_double_array(char* s, double* arr, int n);
21 
23 int write_string(int fd, char* arr, int n);
24 int write_uint8_t_array(int fd, uint8_t* arr, int n);
25 int write_uint16_t_array(int fd, uint16_t* arr, int n);
26 int write_uint32_t_array(int fd, uint32_t* arr, int n);
27 int write_uint64_t_array(int fd, uint64_t* arr, int n);
28 int write_int8_t_array(int fd, int8_t* arr, int n);
29 int write_int16_t_array(int fd, int16_t* arr, int n);
30 int write_int32_t_array(int fd, int32_t* arr, int n);
31 int write_int64_t_array(int fd, int64_t* arr, int n);
32 int write_float_array(int fd, float* arr, int n);
33 int write_double_array(int fd, double* arr, int n);
34 
35 int write_section_header(int fd);
36 
38 void run_benchmark(void* vargs);
39 void input_to_data(int fd, void* vdata);
40 void data_to_input(int fd, void* vdata);
41 void output_to_data(int fd, void* vdata);
42 void data_to_output(int fd, void* vdata);
43 int check_data(void* vdata);
44 
45 extern int INPUT_SIZE;
46 
48 // Macro trick to automatically expand TYPE into the appropriate function
49 // (S)et (T)ype (A)nd (C)oncatenate
50 #define __STAC_EXPANDED(f_pfx, t, f_sfx) f_pfx##t##f_sfx
51 #define STAC(f_pfx, t, f_sfx) __STAC_EXPANDED(f_pfx, t, f_sfx)
52 // Invoke like this:
53 // #define TYPE int32_t
54 // STAC(write_,TYPE,_array)(fd, array, n);
55 // where array is of type (TYPE *)
56 // This translates to:
57 // write_int32_t_array(fd, array, n);
58 
59 #ifndef MAX_ULP
60 #define MAX_ULP 1.0l
61 #endif
62 
63 #define FLOAT_EXC_OVF 0
64 #define FLOAT_EXC_STD 1
65 #define FLOAT_EXC_SAT 2
66 
67 #define FLOAT_RND_NONE 0
68 #define FLOAT_RND_NEVN 1
69 
70 #define IEEE64_FRAC_BITS 52
71 #define IEEE64_EXP_BITS 11
72 #define IEEE64_EXP_BIAS -1023
73 #define IEEE_RND FLOAT_RND_NEVN
74 #define IEEE_EXC FLOAT_EXC_STD
75 #define IEEE_ONE 1
76 #define IEEE_SUBNORM 1
77 #define IEEE_SIGN -1
78 
79 #define IEEE64_SPEC_ARGS \
80  IEEE64_EXP_BITS, IEEE64_FRAC_BITS, IEEE64_EXP_BIAS, IEEE_RND, IEEE_EXC, IEEE_ONE, IEEE_SUBNORM, IEEE_SIGN
81 
82 #ifndef TEST_FRAC_BITS
83 #define TEST_FRAC_BITS IEEE64_FRAC_BITS
84 #endif
85 #ifndef TEST_EXP_BITS
86 #define TEST_EXP_BITS IEEE64_EXP_BITS
87 #endif
88 #ifndef TEST_EXP_BIAS
89 #define TEST_EXP_BIAS IEEE64_EXP_BIAS
90 #endif
91 #ifndef TEST_RND
92 #define TEST_RND IEEE_RND
93 #endif
94 #ifndef TEST_EXC
95 #define TEST_EXC IEEE_EXC
96 #endif
97 #ifndef TEST_ONE
98 #define TEST_ONE IEEE_ONE
99 #endif
100 #ifndef TEST_SUBNORM
101 #define TEST_SUBNORM 0
102 #endif
103 #ifndef TEST_SIGN
104 #define TEST_SIGN IEEE_SIGN
105 #endif
106 #define TEST_SPEC_ARGS \
107  TEST_EXP_BITS, TEST_FRAC_BITS, TEST_EXP_BIAS, TEST_RND, TEST_EXC, TEST_ONE, TEST_SUBNORM, TEST_SIGN
108 
109 #ifdef CUSTOM_INTERFACE
110 #ifdef __BAMBU_SIM__
111 #define DATA_TYPE unsigned long long
112 #else
113 #define DATA_TYPE double
114 #endif
115 
116 #include <milieu.h>
117 #include <softfloat.h>
118 
119 #define __float_to_in(in) __float_cast(in, IEEE64_SPEC_ARGS, TEST_SPEC_ARGS)
120 #define __out_to_float(out) __float_cast(out, TEST_SPEC_ARGS, IEEE64_SPEC_ARGS)
121 
122 typedef union
123 {
124  double d;
125  unsigned long long u;
126 } vc_t;
127 #else
128 #define DATA_TYPE double
129 
130 #define __float_to_in(in) in
131 #define __out_to_float(out) out
132 
133 typedef union
134 {
135  double d;
136  double u;
137 } vc_t;
138 #endif
139 
140 #define __float_recast(in) __out_to_float(__float_to_in(in))
141 
142 #include <mdpi/mdpi_user.h>
double u
Definition: support.h:136
int write_int32_t_array(int fd, int32_t *arr, int n)
double d
Definition: support.h:135
int parse_uint32_t_array(char *s, uint32_t *arr, int n)
void data_to_output(int fd, void *vdata)
Definition: local_support.c:63
char * find_section_start(char *s, int n)
Definition: support.c:56
int write_uint16_t_array(int fd, uint16_t *arr, int n)
void data_to_input(int fd, void *vdata)
Definition: local_support.c:34
void run_benchmark(void *vargs)
Definition: local_support.c:6
int parse_uint64_t_array(char *s, uint64_t *arr, int n)
int parse_int32_t_array(char *s, int32_t *arr, int n)
int write_float_array(int fd, float *arr, int n)
int parse_int16_t_array(char *s, int16_t *arr, int n)
int write_double_array(int fd, double *arr, int n)
int write_string(int fd, char *arr, int n)
int write_section_header(int fd)
int write_uint64_t_array(int fd, uint64_t *arr, int n)
int write_uint32_t_array(int fd, uint32_t *arr, int n)
int parse_string(char *s, char *arr, int n)
Definition: support.c:77
int write_int16_t_array(int fd, int16_t *arr, int n)
char * readfile(int fd)
Definition: support.c:34
int parse_uint16_t_array(char *s, uint16_t *arr, int n)
int write_int8_t_array(int fd, int8_t *arr, int n)
int write_int64_t_array(int fd, int64_t *arr, int n)
int write_uint8_t_array(int fd, uint8_t *arr, int n)
void output_to_data(int fd, void *vdata)
Definition: local_support.c:49
void input_to_data(int fd, void *vdata)
Definition: local_support.c:18
int check_data(void *vdata, void *vref)
Definition: local_support.c:70
int parse_double_array(char *s, double *arr, int n)
Definition: support.h:133
int parse_uint8_t_array(char *s, uint8_t *arr, int n)
int parse_float_array(char *s, float *arr, int n)
int parse_int8_t_array(char *s, int8_t *arr, int n)
int INPUT_SIZE
Definition: local_support.c:4
int parse_int64_t_array(char *s, int64_t *arr, int n)

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