@@ -17,7 +17,7 @@ double float_rand(double min, double max)
1717 return min + scale * (max - min );
1818}
1919
20- __attribute__ ((__noinline__ )) void generate_vector_32 (_Decimal32 * buffer , size_t buffer_len )
20+ __attribute__ ((__noinline__ )) void generate_vector_32 (_decimal32_t * buffer , size_t buffer_len )
2121{
2222 size_t i = 0 ;
2323 while (i < buffer_len )
@@ -27,7 +27,7 @@ __attribute__ ((__noinline__)) void generate_vector_32(_Decimal32* buffer, size_
2727 }
2828}
2929
30- __attribute__ ((__noinline__ )) void test_comparisons_32 (_Decimal32 * data , const char * label )
30+ __attribute__ ((__noinline__ )) void test_comparisons_32 (_decimal32_t * data , const char * label )
3131{
3232 struct timespec t1 , t2 ;
3333 clock_gettime (CLOCK_MONOTONIC , & t1 );
@@ -38,8 +38,8 @@ __attribute__ ((__noinline__)) void test_comparisons_32(_Decimal32* data, const
3838 {
3939 for (size_t k = 0 ; k < K - 1 ; ++ k )
4040 {
41- _Decimal32 val1 = data [k ];
42- _Decimal32 val2 = data [k + 1 ];
41+ _decimal32_t val1 = data [k ];
42+ _decimal32_t val2 = data [k + 1 ];
4343
4444 s += (size_t )(val1 > val2 );
4545 s += (size_t )(val1 >= val2 );
@@ -56,7 +56,7 @@ __attribute__ ((__noinline__)) void test_comparisons_32(_Decimal32* data, const
5656 printf ("Comparisons <%-10s >: %-10" PRIu64 " us (s=%zu)\n" , label , elapsed_time_us , s );
5757}
5858
59- __attribute__ ((__noinline__ )) void generate_vector_64 (_Decimal64 * buffer , size_t buffer_len )
59+ __attribute__ ((__noinline__ )) void generate_vector_64 (_decimal64_t * buffer , size_t buffer_len )
6060{
6161 size_t i = 0 ;
6262 while (i < buffer_len )
@@ -66,7 +66,7 @@ __attribute__ ((__noinline__)) void generate_vector_64(_Decimal64* buffer, size_
6666 }
6767}
6868
69- __attribute__ ((__noinline__ )) void test_comparisons_64 (_Decimal64 * data , const char * label )
69+ __attribute__ ((__noinline__ )) void test_comparisons_64 (_decimal64_t * data , const char * label )
7070{
7171 struct timespec t1 , t2 ;
7272 clock_gettime (CLOCK_MONOTONIC , & t1 );
@@ -77,8 +77,8 @@ __attribute__ ((__noinline__)) void test_comparisons_64(_Decimal64* data, const
7777 {
7878 for (size_t k = 0 ; k < K - 1 ; ++ k )
7979 {
80- _Decimal64 val1 = data [k ];
81- _Decimal64 val2 = data [k + 1 ];
80+ _decimal64_t val1 = data [k ];
81+ _decimal64_t val2 = data [k + 1 ];
8282
8383 s += (size_t )(val1 > val2 );
8484 s += (size_t )(val1 >= val2 );
@@ -95,7 +95,7 @@ __attribute__ ((__noinline__)) void test_comparisons_64(_Decimal64* data, const
9595 printf ("Comparisons <%-10s >: %-10" PRIu64 " us (s=%zu)\n" , label , elapsed_time_us , s );
9696}
9797
98- __attribute__ ((__noinline__ )) void generate_vector_128 (_Decimal128 * buffer , size_t buffer_len )
98+ __attribute__ ((__noinline__ )) void generate_vector_128 (_decimal128_t * buffer , size_t buffer_len )
9999{
100100 size_t i = 0 ;
101101 while (i < buffer_len )
@@ -105,7 +105,7 @@ __attribute__ ((__noinline__)) void generate_vector_128(_Decimal128* buffer, siz
105105 }
106106}
107107
108- __attribute__ ((__noinline__ )) void test_comparisons_128 (_Decimal128 * data , const char * label )
108+ __attribute__ ((__noinline__ )) void test_comparisons_128 (_decimal128_t * data , const char * label )
109109{
110110 struct timespec t1 , t2 ;
111111 clock_gettime (CLOCK_MONOTONIC , & t1 );
@@ -116,8 +116,8 @@ __attribute__ ((__noinline__)) void test_comparisons_128(_Decimal128* data, cons
116116 {
117117 for (size_t k = 0 ; k < K - 1 ; ++ k )
118118 {
119- _Decimal128 val1 = data [k ];
120- _Decimal128 val2 = data [k + 1 ];
119+ _decimal128_t val1 = data [k ];
120+ _decimal128_t val2 = data [k + 1 ];
121121
122122 s += (size_t )(val1 > val2 );
123123 s += (size_t )(val1 >= val2 );
@@ -134,28 +134,28 @@ __attribute__ ((__noinline__)) void test_comparisons_128(_Decimal128* data, cons
134134 printf ("Comparisons <%-10s>: %-10" PRIu64 " us (s=%zu)\n" , label , elapsed_time_us , s );
135135}
136136
137- typedef _Decimal32 (* operation_32 )(_Decimal32 , _Decimal32 );
137+ typedef _decimal32_t (* operation_32 )(_decimal32_t , _decimal32_t );
138138
139- __attribute__ ((__noinline__ )) _Decimal32 add_32 (_Decimal32 a , _Decimal32 b )
139+ __attribute__ ((__noinline__ )) _decimal32_t add_32 (_decimal32_t a , _decimal32_t b )
140140{
141141 return a + b ;
142142}
143- __attribute__ ((__noinline__ )) _Decimal32 sub_32 (_Decimal32 a , _Decimal32 b )
143+ __attribute__ ((__noinline__ )) _decimal32_t sub_32 (_decimal32_t a , _decimal32_t b )
144144{
145145 return a - b ;
146146}
147147
148- __attribute__ ((__noinline__ )) _Decimal32 mul_32 (_Decimal32 a , _Decimal32 b )
148+ __attribute__ ((__noinline__ )) _decimal32_t mul_32 (_decimal32_t a , _decimal32_t b )
149149{
150150 return a * b ;
151151}
152152
153- __attribute__ ((__noinline__ )) _Decimal32 div_32 (_Decimal32 a , _Decimal32 b )
153+ __attribute__ ((__noinline__ )) _decimal32_t div_32 (_decimal32_t a , _decimal32_t b )
154154{
155155 return a / b ;
156156}
157157
158- __attribute__ ((__noinline__ )) void test_two_element_operation_32 (_Decimal32 * data , operation_32 op , const char * label , const char * op_label )
158+ __attribute__ ((__noinline__ )) void test_two_element_operation_32 (_decimal32_t * data , operation_32 op , const char * label , const char * op_label )
159159{
160160 struct timespec t1 , t2 ;
161161 clock_gettime (CLOCK_MONOTONIC , & t1 );
@@ -166,8 +166,8 @@ __attribute__ ((__noinline__)) void test_two_element_operation_32(_Decimal32* da
166166 {
167167 for (size_t k = 0 ; k < K - 1 ; ++ k )
168168 {
169- _Decimal32 val1 = data [k ];
170- _Decimal32 val2 = data [k + 1 ];
169+ _decimal32_t val1 = data [k ];
170+ _decimal32_t val2 = data [k + 1 ];
171171
172172 s += (size_t )op (val1 , val2 );
173173 }
@@ -179,29 +179,29 @@ __attribute__ ((__noinline__)) void test_two_element_operation_32(_Decimal32* da
179179 printf ("%-15s<%-10s >: %-10" PRIu64 " us (s=%zu)\n" , op_label , label , elapsed_time_us , s );
180180}
181181
182- typedef _Decimal64 (* operation_64 )(_Decimal64 , _Decimal64 );
182+ typedef _decimal64_t (* operation_64 )(_decimal64_t , _decimal64_t );
183183
184- __attribute__ ((__noinline__ )) _Decimal64 add_64 (_Decimal64 a , _Decimal64 b )
184+ __attribute__ ((__noinline__ )) _decimal64_t add_64 (_decimal64_t a , _decimal64_t b )
185185{
186186 return a + b ;
187187}
188188
189- __attribute__ ((__noinline__ )) _Decimal64 sub_64 (_Decimal64 a , _Decimal64 b )
189+ __attribute__ ((__noinline__ )) _decimal64_t sub_64 (_decimal64_t a , _decimal64_t b )
190190{
191191 return a - b ;
192192}
193193
194- __attribute__ ((__noinline__ )) _Decimal64 mul_64 (_Decimal64 a , _Decimal64 b )
194+ __attribute__ ((__noinline__ )) _decimal64_t mul_64 (_decimal64_t a , _decimal64_t b )
195195{
196196 return a * b ;
197197}
198198
199- __attribute__ ((__noinline__ )) _Decimal64 div_64 (_Decimal64 a , _Decimal64 b )
199+ __attribute__ ((__noinline__ )) _decimal64_t div_64 (_decimal64_t a , _decimal64_t b )
200200{
201201 return a / b ;
202202}
203203
204- __attribute__ ((__noinline__ )) void test_two_element_operation_64 (_Decimal64 * data , operation_64 op , const char * label , const char * op_label )
204+ __attribute__ ((__noinline__ )) void test_two_element_operation_64 (_decimal64_t * data , operation_64 op , const char * label , const char * op_label )
205205{
206206 struct timespec t1 , t2 ;
207207 clock_gettime (CLOCK_MONOTONIC , & t1 );
@@ -212,8 +212,8 @@ __attribute__ ((__noinline__)) void test_two_element_operation_64(_Decimal64* da
212212 {
213213 for (size_t k = 0 ; k < K - 1 ; ++ k )
214214 {
215- _Decimal64 val1 = data [k ];
216- _Decimal64 val2 = data [k + 1 ];
215+ _decimal64_t val1 = data [k ];
216+ _decimal64_t val2 = data [k + 1 ];
217217
218218 s += (size_t )op (val1 , val2 );
219219 }
@@ -225,29 +225,29 @@ __attribute__ ((__noinline__)) void test_two_element_operation_64(_Decimal64* da
225225 printf ("%-15s<%-10s >: %-10" PRIu64 " us (s=%zu)\n" , op_label , label , elapsed_time_us , s );
226226}
227227
228- typedef _Decimal128 (* operation_128 )(_Decimal128 , _Decimal128 );
228+ typedef _decimal128_t (* operation_128 )(_decimal128_t , _decimal128_t );
229229
230- __attribute__ ((__noinline__ )) _Decimal128 add_128 (_Decimal128 a , _Decimal128 b )
230+ __attribute__ ((__noinline__ )) _decimal128_t add_128 (_decimal128_t a , _decimal128_t b )
231231{
232232 return a + b ;
233233}
234234
235- __attribute__ ((__noinline__ )) _Decimal128 sub_128 (_Decimal128 a , _Decimal128 b )
235+ __attribute__ ((__noinline__ )) _decimal128_t sub_128 (_decimal128_t a , _decimal128_t b )
236236{
237237 return a - b ;
238238}
239239
240- __attribute__ ((__noinline__ )) _Decimal128 mul_128 (_Decimal128 a , _Decimal128 b )
240+ __attribute__ ((__noinline__ )) _decimal128_t mul_128 (_decimal128_t a , _decimal128_t b )
241241{
242242 return a * b ;
243243}
244244
245- __attribute__ ((__noinline__ )) _Decimal128 div_128 (_Decimal128 a , _Decimal128 b )
245+ __attribute__ ((__noinline__ )) _decimal128_t div_128 (_decimal128_t a , _decimal128_t b )
246246{
247247 return a / b ;
248248}
249249
250- __attribute__ ((__noinline__ )) void test_two_element_operation_128 (_Decimal128 * data , operation_128 op , const char * label , const char * op_label )
250+ __attribute__ ((__noinline__ )) void test_two_element_operation_128 (_decimal128_t * data , operation_128 op , const char * label , const char * op_label )
251251{
252252 struct timespec t1 , t2 ;
253253 clock_gettime (CLOCK_MONOTONIC , & t1 );
@@ -258,8 +258,8 @@ __attribute__ ((__noinline__)) void test_two_element_operation_128(_Decimal128*
258258 {
259259 for (size_t k = 0 ; k < K - 1 ; ++ k )
260260 {
261- _Decimal128 val1 = data [k ];
262- _Decimal128 val2 = data [k + 1 ];
261+ _decimal128_t val1 = data [k ];
262+ _decimal128_t val2 = data [k + 1 ];
263263
264264 s += (size_t )op (val1 , val2 );
265265 }
@@ -276,9 +276,9 @@ int main()
276276 // One time init of random number generator
277277 srand (time (NULL ));
278278
279- _Decimal32 * d32_array = malloc (K * sizeof (_Decimal32 ));
280- _Decimal64 * d64_array = malloc (K * sizeof (_Decimal64 ));
281- _Decimal128 * d128_array = malloc (K * sizeof (_Decimal128 ));
279+ _decimal32_t * d32_array = malloc (K * sizeof (_decimal32_t ));
280+ _decimal64_t * d64_array = malloc (K * sizeof (_decimal64_t ));
281+ _decimal128_t * d128_array = malloc (K * sizeof (_decimal128_t ));
282282
283283 if (d32_array == NULL || d64_array == NULL || d128_array == NULL )
284284 {
@@ -288,37 +288,37 @@ int main()
288288 printf ("===== Comparisons =====\n" );
289289
290290 generate_vector_32 (d32_array , K );
291- test_comparisons_32 (d32_array , "_Decimal32 " );
291+ test_comparisons_32 (d32_array , "_decimal32_t " );
292292
293293 generate_vector_64 (d64_array , K );
294- test_comparisons_64 (d64_array , "_Decimal64 " );
294+ test_comparisons_64 (d64_array , "_decimal64_t " );
295295
296296 generate_vector_128 (d128_array , K );
297- test_comparisons_128 (d128_array , "_Decimal128 " );
297+ test_comparisons_128 (d128_array , "_decimal128_t " );
298298
299299 printf ("\n===== Addition =====\n" );
300300
301- test_two_element_operation_32 (d32_array , add_32 , "_Decimal32 " , "Addition" );
302- test_two_element_operation_64 (d64_array , add_64 , "_Decimal64 " , "Addition" );
303- test_two_element_operation_128 (d128_array , add_128 , "_Decimal128 " , "Addition" );
301+ test_two_element_operation_32 (d32_array , add_32 , "_decimal32_t " , "Addition" );
302+ test_two_element_operation_64 (d64_array , add_64 , "_decimal64_t " , "Addition" );
303+ test_two_element_operation_128 (d128_array , add_128 , "_decimal128_t " , "Addition" );
304304
305305 printf ("\n===== Subtraction =====\n" );
306306
307- test_two_element_operation_32 (d32_array , sub_32 , "_Decimal32 " , "Subtraction" );
308- test_two_element_operation_64 (d64_array , sub_64 , "_Decimal64 " , "Subtraction" );
309- test_two_element_operation_128 (d128_array , sub_128 , "_Decimal128 " , "Subtraction" );
307+ test_two_element_operation_32 (d32_array , sub_32 , "_decimal32_t " , "Subtraction" );
308+ test_two_element_operation_64 (d64_array , sub_64 , "_decimal64_t " , "Subtraction" );
309+ test_two_element_operation_128 (d128_array , sub_128 , "_decimal128_t " , "Subtraction" );
310310
311311 printf ("\n===== Multiplication =====\n" );
312312
313- test_two_element_operation_32 (d32_array , mul_32 , "_Decimal32 " , "Multiplication" );
314- test_two_element_operation_64 (d64_array , mul_64 , "_Decimal64 " , "Multiplication" );
315- test_two_element_operation_128 (d128_array , mul_128 , "_Decimal128 " , "Multiplication" );
313+ test_two_element_operation_32 (d32_array , mul_32 , "_decimal32_t " , "Multiplication" );
314+ test_two_element_operation_64 (d64_array , mul_64 , "_decimal64_t " , "Multiplication" );
315+ test_two_element_operation_128 (d128_array , mul_128 , "_decimal128_t " , "Multiplication" );
316316
317317 printf ("\n===== Division =====\n" );
318318
319- test_two_element_operation_32 (d32_array , div_32 , "_Decimal32 " , "Division" );
320- test_two_element_operation_64 (d64_array , div_64 , "_Decimal64 " , "Division" );
321- test_two_element_operation_128 (d128_array , div_128 , "_Decimal128 " , "Division" );
319+ test_two_element_operation_32 (d32_array , div_32 , "_decimal32_t " , "Division" );
320+ test_two_element_operation_64 (d64_array , div_64 , "_decimal64_t " , "Division" );
321+ test_two_element_operation_128 (d128_array , div_128 , "_decimal128_t " , "Division" );
322322
323323 free (d32_array );
324324 free (d64_array );
0 commit comments