OpenCores
URL https://opencores.org/ocsvn/fpu100/fpu100/trunk

Subversion Repositories fpu100

[/] [fpu100/] [tags/] [arelease/] [test_bench/] [SoftFloat/] [softfloat/] [bits64/] [timesoftfloat.c] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jidan
 
2
/*============================================================================
3
 
4
This C source file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
5
Package, Release 2b.
6
 
7
Written by John R. Hauser.
8
 
9
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
10
been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
11
RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
12
AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
13
COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
14
EFFECTIVELY INDEMNIFY THE AUTHOR, JOHN HAUSER, (possibly via similar legal
15
warning) AGAINST ALL LOSSES, COSTS, OR OTHER PROBLEMS INCURRED BY THEIR
16
CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
17
 
18
Derivative works are acceptable, even for commercial purposes, so long as
19
(1) the source code for the derivative work includes prominent notice that
20
the work is derivative, and (2) the source code includes prominent notice with
21
these four paragraphs for those parts of this code that are retained.
22
 
23
=============================================================================*/
24
 
25
#include <stdlib.h>
26
#include <stdarg.h>
27
#include <string.h>
28
#include <stdio.h>
29
#include <time.h>
30
#include "milieu.h"
31
#include "softfloat.h"
32
 
33
enum {
34
    minIterations = 1000
35
};
36
 
37
static void fail( const char *message, ... )
38
{
39
    va_list varArgs;
40
 
41
    fputs( "timesoftfloat: ", stderr );
42
    va_start( varArgs, message );
43
    vfprintf( stderr, message, varArgs );
44
    va_end( varArgs );
45
    fputs( ".\n", stderr );
46
    exit( EXIT_FAILURE );
47
 
48
}
49
 
50
static char *functionName;
51
static char *roundingPrecisionName, *roundingModeName, *tininessModeName;
52
 
53
static void reportTime( int32 count, long clocks )
54
{
55
 
56
    printf(
57
        "%8.1f kops/s: %s",
58
        ( count / ( ( (float) clocks ) / CLOCKS_PER_SEC ) ) / 1000,
59
        functionName
60
    );
61
    if ( roundingModeName ) {
62
        if ( roundingPrecisionName ) {
63
            fputs( ", precision ", stdout );
64
            fputs( roundingPrecisionName, stdout );
65
        }
66
        fputs( ", rounding ", stdout );
67
        fputs( roundingModeName, stdout );
68
        if ( tininessModeName ) {
69
            fputs( ", tininess ", stdout );
70
            fputs( tininessModeName, stdout );
71
            fputs( " rounding", stdout );
72
        }
73
    }
74
    fputc( '\n', stdout );
75
 
76
}
77
 
78
enum {
79
    numInputs_int32 = 32
80
};
81
 
82
static const int32 inputs_int32[ numInputs_int32 ] = {
83
    0xFFFFBB79, 0x405CF80F, 0x00000000, 0xFFFFFD04,
84
    0xFFF20002, 0x0C8EF795, 0xF00011FF, 0x000006CA,
85
    0x00009BFE, 0xFF4862E3, 0x9FFFEFFE, 0xFFFFFFB7,
86
    0x0BFF7FFF, 0x0000F37A, 0x0011DFFE, 0x00000006,
87
    0xFFF02006, 0xFFFFF7D1, 0x10200003, 0xDE8DF765,
88
    0x00003E02, 0x000019E8, 0x0008FFFE, 0xFFFFFB5C,
89
    0xFFDF7FFE, 0x07C42FBF, 0x0FFFE3FF, 0x040B9F13,
90
    0xBFFFFFF8, 0x0001BF56, 0x000017F6, 0x000A908A
91
};
92
 
93
static void time_a_int32_z_float32( float32 function( int32 ) )
94
{
95
    clock_t startClock, endClock;
96
    int32 count, i;
97
    int8 inputNum;
98
 
99
    count = 0;
100
    inputNum = 0;
101
    startClock = clock();
102
    do {
103
        for ( i = minIterations; i; --i ) {
104
            function( inputs_int32[ inputNum ] );
105
            inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
106
        }
107
        count += minIterations;
108
    } while ( clock() - startClock < CLOCKS_PER_SEC );
109
    inputNum = 0;
110
    startClock = clock();
111
    for ( i = count; i; --i ) {
112
        function( inputs_int32[ inputNum ] );
113
        inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
114
    }
115
    endClock = clock();
116
    reportTime( count, endClock - startClock );
117
 
118
}
119
 
120
static void time_a_int32_z_float64( float64 function( int32 ) )
121
{
122
    clock_t startClock, endClock;
123
    int32 count, i;
124
    int8 inputNum;
125
 
126
    count = 0;
127
    inputNum = 0;
128
    startClock = clock();
129
    do {
130
        for ( i = minIterations; i; --i ) {
131
            function( inputs_int32[ inputNum ] );
132
            inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
133
        }
134
        count += minIterations;
135
    } while ( clock() - startClock < CLOCKS_PER_SEC );
136
    inputNum = 0;
137
    startClock = clock();
138
    for ( i = count; i; --i ) {
139
        function( inputs_int32[ inputNum ] );
140
        inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
141
    }
142
    endClock = clock();
143
    reportTime( count, endClock - startClock );
144
 
145
}
146
 
147
#ifdef FLOATX80
148
 
149
static void time_a_int32_z_floatx80( floatx80 function( int32 ) )
150
{
151
    clock_t startClock, endClock;
152
    int32 count, i;
153
    int8 inputNum;
154
 
155
    count = 0;
156
    inputNum = 0;
157
    startClock = clock();
158
    do {
159
        for ( i = minIterations; i; --i ) {
160
            function( inputs_int32[ inputNum ] );
161
            inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
162
        }
163
        count += minIterations;
164
    } while ( clock() - startClock < CLOCKS_PER_SEC );
165
    inputNum = 0;
166
    startClock = clock();
167
    for ( i = count; i; --i ) {
168
        function( inputs_int32[ inputNum ] );
169
        inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
170
    }
171
    endClock = clock();
172
    reportTime( count, endClock - startClock );
173
 
174
}
175
 
176
#endif
177
 
178
#ifdef FLOAT128
179
 
180
static void time_a_int32_z_float128( float128 function( int32 ) )
181
{
182
    clock_t startClock, endClock;
183
    int32 count, i;
184
    int8 inputNum;
185
 
186
    count = 0;
187
    inputNum = 0;
188
    startClock = clock();
189
    do {
190
        for ( i = minIterations; i; --i ) {
191
            function( inputs_int32[ inputNum ] );
192
            inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
193
        }
194
        count += minIterations;
195
    } while ( clock() - startClock < CLOCKS_PER_SEC );
196
    inputNum = 0;
197
    startClock = clock();
198
    for ( i = count; i; --i ) {
199
        function( inputs_int32[ inputNum ] );
200
        inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
201
    }
202
    endClock = clock();
203
    reportTime( count, endClock - startClock );
204
 
205
}
206
 
207
#endif
208
 
209
enum {
210
    numInputs_int64 = 32
211
};
212
 
213
static const int64 inputs_int64[ numInputs_int64 ] = {
214
    LIT64( 0xFBFFC3FFFFFFFFFF ),
215
    LIT64( 0x0000000003C589BC ),
216
    LIT64( 0x00000000400013FE ),
217
    LIT64( 0x0000000000186171 ),
218
    LIT64( 0xFFFFFFFFFFFEFBFA ),
219
    LIT64( 0xFFFFFD79E6DFFC73 ),
220
    LIT64( 0x0000000010001DFF ),
221
    LIT64( 0xDD1A0F0C78513710 ),
222
    LIT64( 0xFFFF83FFFFFEFFFE ),
223
    LIT64( 0x00756EBD1AD0C1C7 ),
224
    LIT64( 0x0003FDFFFFFFFFBE ),
225
    LIT64( 0x0007D0FB2C2CA951 ),
226
    LIT64( 0x0007FC0007FFFFFE ),
227
    LIT64( 0x0000001F942B18BB ),
228
    LIT64( 0x0000080101FFFFFE ),
229
    LIT64( 0xFFFFFFFFFFFF0978 ),
230
    LIT64( 0x000000000008BFFF ),
231
    LIT64( 0x0000000006F5AF08 ),
232
    LIT64( 0xFFDEFF7FFFFFFFFE ),
233
    LIT64( 0x0000000000000003 ),
234
    LIT64( 0x3FFFFFFFFF80007D ),
235
    LIT64( 0x0000000000000078 ),
236
    LIT64( 0xFFF80000007FDFFD ),
237
    LIT64( 0x1BBC775B78016AB0 ),
238
    LIT64( 0xFFF9001FFFFFFFFE ),
239
    LIT64( 0xFFFD4767AB98E43F ),
240
    LIT64( 0xFFFFFEFFFE00001E ),
241
    LIT64( 0xFFFFFFFFFFF04EFD ),
242
    LIT64( 0x07FFFFFFFFFFF7FF ),
243
    LIT64( 0xFFFC9EAA38F89050 ),
244
    LIT64( 0x00000020FBFFFFFE ),
245
    LIT64( 0x0000099AE6455357 )
246
};
247
 
248
static void time_a_int64_z_float32( float32 function( int64 ) )
249
{
250
    clock_t startClock, endClock;
251
    int32 count, i;
252
    int8 inputNum;
253
 
254
    count = 0;
255
    inputNum = 0;
256
    startClock = clock();
257
    do {
258
        for ( i = minIterations; i; --i ) {
259
            function( inputs_int64[ inputNum ] );
260
            inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
261
        }
262
        count += minIterations;
263
    } while ( clock() - startClock < CLOCKS_PER_SEC );
264
    inputNum = 0;
265
    startClock = clock();
266
    for ( i = count; i; --i ) {
267
        function( inputs_int64[ inputNum ] );
268
        inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
269
    }
270
    endClock = clock();
271
    reportTime( count, endClock - startClock );
272
 
273
}
274
 
275
static void time_a_int64_z_float64( float64 function( int64 ) )
276
{
277
    clock_t startClock, endClock;
278
    int32 count, i;
279
    int8 inputNum;
280
 
281
    count = 0;
282
    inputNum = 0;
283
    startClock = clock();
284
    do {
285
        for ( i = minIterations; i; --i ) {
286
            function( inputs_int64[ inputNum ] );
287
            inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
288
        }
289
        count += minIterations;
290
    } while ( clock() - startClock < CLOCKS_PER_SEC );
291
    inputNum = 0;
292
    startClock = clock();
293
    for ( i = count; i; --i ) {
294
        function( inputs_int64[ inputNum ] );
295
        inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
296
    }
297
    endClock = clock();
298
    reportTime( count, endClock - startClock );
299
 
300
}
301
 
302
#ifdef FLOATX80
303
 
304
static void time_a_int64_z_floatx80( floatx80 function( int64 ) )
305
{
306
    clock_t startClock, endClock;
307
    int32 count, i;
308
    int8 inputNum;
309
 
310
    count = 0;
311
    inputNum = 0;
312
    startClock = clock();
313
    do {
314
        for ( i = minIterations; i; --i ) {
315
            function( inputs_int64[ inputNum ] );
316
            inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
317
        }
318
        count += minIterations;
319
    } while ( clock() - startClock < CLOCKS_PER_SEC );
320
    inputNum = 0;
321
    startClock = clock();
322
    for ( i = count; i; --i ) {
323
        function( inputs_int64[ inputNum ] );
324
        inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
325
    }
326
    endClock = clock();
327
    reportTime( count, endClock - startClock );
328
 
329
}
330
 
331
#endif
332
 
333
#ifdef FLOAT128
334
 
335
static void time_a_int64_z_float128( float128 function( int64 ) )
336
{
337
    clock_t startClock, endClock;
338
    int32 count, i;
339
    int8 inputNum;
340
 
341
    count = 0;
342
    inputNum = 0;
343
    startClock = clock();
344
    do {
345
        for ( i = minIterations; i; --i ) {
346
            function( inputs_int64[ inputNum ] );
347
            inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
348
        }
349
        count += minIterations;
350
    } while ( clock() - startClock < CLOCKS_PER_SEC );
351
    inputNum = 0;
352
    startClock = clock();
353
    for ( i = count; i; --i ) {
354
        function( inputs_int64[ inputNum ] );
355
        inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
356
    }
357
    endClock = clock();
358
    reportTime( count, endClock - startClock );
359
 
360
}
361
 
362
#endif
363
 
364
enum {
365
    numInputs_float32 = 32
366
};
367
 
368
static const float32 inputs_float32[ numInputs_float32 ] = {
369
    0x4EFA0000, 0xC1D0B328, 0x80000000, 0x3E69A31E,
370
    0xAF803EFF, 0x3F800000, 0x17BF8000, 0xE74A301A,
371
    0x4E010003, 0x7EE3C75D, 0xBD803FE0, 0xBFFEFF00,
372
    0x7981F800, 0x431FFFFC, 0xC100C000, 0x3D87EFFF,
373
    0x4103FEFE, 0xBC000007, 0xBF01F7FF, 0x4E6C6B5C,
374
    0xC187FFFE, 0xC58B9F13, 0x4F88007F, 0xDF004007,
375
    0xB7FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,
376
    0xDB428661, 0x33F89B1F, 0xA3BFEFFF, 0x537BFFBE
377
};
378
 
379
static void time_a_float32_z_int32( int32 function( float32 ) )
380
{
381
    clock_t startClock, endClock;
382
    int32 count, i;
383
    int8 inputNum;
384
 
385
    count = 0;
386
    inputNum = 0;
387
    startClock = clock();
388
    do {
389
        for ( i = minIterations; i; --i ) {
390
            function( inputs_float32[ inputNum ] );
391
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
392
        }
393
        count += minIterations;
394
    } while ( clock() - startClock < CLOCKS_PER_SEC );
395
    inputNum = 0;
396
    startClock = clock();
397
    for ( i = count; i; --i ) {
398
        function( inputs_float32[ inputNum ] );
399
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
400
    }
401
    endClock = clock();
402
    reportTime( count, endClock - startClock );
403
 
404
}
405
 
406
static void time_a_float32_z_int64( int64 function( float32 ) )
407
{
408
    clock_t startClock, endClock;
409
    int32 count, i;
410
    int8 inputNum;
411
 
412
    count = 0;
413
    inputNum = 0;
414
    startClock = clock();
415
    do {
416
        for ( i = minIterations; i; --i ) {
417
            function( inputs_float32[ inputNum ] );
418
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
419
        }
420
        count += minIterations;
421
    } while ( clock() - startClock < CLOCKS_PER_SEC );
422
    inputNum = 0;
423
    startClock = clock();
424
    for ( i = count; i; --i ) {
425
        function( inputs_float32[ inputNum ] );
426
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
427
    }
428
    endClock = clock();
429
    reportTime( count, endClock - startClock );
430
 
431
}
432
 
433
static void time_a_float32_z_float64( float64 function( float32 ) )
434
{
435
    clock_t startClock, endClock;
436
    int32 count, i;
437
    int8 inputNum;
438
 
439
    count = 0;
440
    inputNum = 0;
441
    startClock = clock();
442
    do {
443
        for ( i = minIterations; i; --i ) {
444
            function( inputs_float32[ inputNum ] );
445
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
446
        }
447
        count += minIterations;
448
    } while ( clock() - startClock < CLOCKS_PER_SEC );
449
    inputNum = 0;
450
    startClock = clock();
451
    for ( i = count; i; --i ) {
452
        function( inputs_float32[ inputNum ] );
453
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
454
    }
455
    endClock = clock();
456
    reportTime( count, endClock - startClock );
457
 
458
}
459
 
460
#ifdef FLOATX80
461
 
462
static void time_a_float32_z_floatx80( floatx80 function( float32 ) )
463
{
464
    clock_t startClock, endClock;
465
    int32 count, i;
466
    int8 inputNum;
467
 
468
    count = 0;
469
    inputNum = 0;
470
    startClock = clock();
471
    do {
472
        for ( i = minIterations; i; --i ) {
473
            function( inputs_float32[ inputNum ] );
474
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
475
        }
476
        count += minIterations;
477
    } while ( clock() - startClock < CLOCKS_PER_SEC );
478
    inputNum = 0;
479
    startClock = clock();
480
    for ( i = count; i; --i ) {
481
        function( inputs_float32[ inputNum ] );
482
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
483
    }
484
    endClock = clock();
485
    reportTime( count, endClock - startClock );
486
 
487
}
488
 
489
#endif
490
 
491
#ifdef FLOAT128
492
 
493
static void time_a_float32_z_float128( float128 function( float32 ) )
494
{
495
    clock_t startClock, endClock;
496
    int32 count, i;
497
    int8 inputNum;
498
 
499
    count = 0;
500
    inputNum = 0;
501
    startClock = clock();
502
    do {
503
        for ( i = minIterations; i; --i ) {
504
            function( inputs_float32[ inputNum ] );
505
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
506
        }
507
        count += minIterations;
508
    } while ( clock() - startClock < CLOCKS_PER_SEC );
509
    inputNum = 0;
510
    startClock = clock();
511
    for ( i = count; i; --i ) {
512
        function( inputs_float32[ inputNum ] );
513
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
514
    }
515
    endClock = clock();
516
    reportTime( count, endClock - startClock );
517
 
518
}
519
 
520
#endif
521
 
522
static void time_az_float32( float32 function( float32 ) )
523
{
524
    clock_t startClock, endClock;
525
    int32 count, i;
526
    int8 inputNum;
527
 
528
    count = 0;
529
    inputNum = 0;
530
    startClock = clock();
531
    do {
532
        for ( i = minIterations; i; --i ) {
533
            function( inputs_float32[ inputNum ] );
534
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
535
        }
536
        count += minIterations;
537
    } while ( clock() - startClock < CLOCKS_PER_SEC );
538
    inputNum = 0;
539
    startClock = clock();
540
    for ( i = count; i; --i ) {
541
        function( inputs_float32[ inputNum ] );
542
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
543
    }
544
    endClock = clock();
545
    reportTime( count, endClock - startClock );
546
 
547
}
548
 
549
static void time_ab_float32_z_flag( flag function( float32, float32 ) )
550
{
551
    clock_t startClock, endClock;
552
    int32 count, i;
553
    int8 inputNumA, inputNumB;
554
 
555
    count = 0;
556
    inputNumA = 0;
557
    inputNumB = 0;
558
    startClock = clock();
559
    do {
560
        for ( i = minIterations; i; --i ) {
561
            function(
562
                inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
563
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
564
            if ( inputNumA == 0 ) ++inputNumB;
565
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
566
        }
567
        count += minIterations;
568
    } while ( clock() - startClock < CLOCKS_PER_SEC );
569
    inputNumA = 0;
570
    inputNumB = 0;
571
    startClock = clock();
572
    for ( i = count; i; --i ) {
573
            function(
574
                inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
575
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
576
        if ( inputNumA == 0 ) ++inputNumB;
577
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
578
    }
579
    endClock = clock();
580
    reportTime( count, endClock - startClock );
581
 
582
}
583
 
584
static void time_abz_float32( float32 function( float32, float32 ) )
585
{
586
    clock_t startClock, endClock;
587
    int32 count, i;
588
    int8 inputNumA, inputNumB;
589
 
590
    count = 0;
591
    inputNumA = 0;
592
    inputNumB = 0;
593
    startClock = clock();
594
    do {
595
        for ( i = minIterations; i; --i ) {
596
            function(
597
                inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
598
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
599
            if ( inputNumA == 0 ) ++inputNumB;
600
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
601
        }
602
        count += minIterations;
603
    } while ( clock() - startClock < CLOCKS_PER_SEC );
604
    inputNumA = 0;
605
    inputNumB = 0;
606
    startClock = clock();
607
    for ( i = count; i; --i ) {
608
            function(
609
                inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
610
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
611
        if ( inputNumA == 0 ) ++inputNumB;
612
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
613
    }
614
    endClock = clock();
615
    reportTime( count, endClock - startClock );
616
 
617
}
618
 
619
static const float32 inputs_float32_pos[ numInputs_float32 ] = {
620
    0x4EFA0000, 0x41D0B328, 0x00000000, 0x3E69A31E,
621
    0x2F803EFF, 0x3F800000, 0x17BF8000, 0x674A301A,
622
    0x4E010003, 0x7EE3C75D, 0x3D803FE0, 0x3FFEFF00,
623
    0x7981F800, 0x431FFFFC, 0x4100C000, 0x3D87EFFF,
624
    0x4103FEFE, 0x3C000007, 0x3F01F7FF, 0x4E6C6B5C,
625
    0x4187FFFE, 0x458B9F13, 0x4F88007F, 0x5F004007,
626
    0x37FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,
627
    0x5B428661, 0x33F89B1F, 0x23BFEFFF, 0x537BFFBE
628
};
629
 
630
static void time_az_float32_pos( float32 function( float32 ) )
631
{
632
    clock_t startClock, endClock;
633
    int32 count, i;
634
    int8 inputNum;
635
 
636
    count = 0;
637
    inputNum = 0;
638
    startClock = clock();
639
    do {
640
        for ( i = minIterations; i; --i ) {
641
            function( inputs_float32_pos[ inputNum ] );
642
            inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
643
        }
644
        count += minIterations;
645
    } while ( clock() - startClock < CLOCKS_PER_SEC );
646
    inputNum = 0;
647
    startClock = clock();
648
    for ( i = count; i; --i ) {
649
        function( inputs_float32_pos[ inputNum ] );
650
        inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
651
    }
652
    endClock = clock();
653
    reportTime( count, endClock - startClock );
654
 
655
}
656
 
657
enum {
658
    numInputs_float64 = 32
659
};
660
 
661
static const float64 inputs_float64[ numInputs_float64 ] = {
662
    LIT64( 0x422FFFC008000000 ),
663
    LIT64( 0xB7E0000480000000 ),
664
    LIT64( 0xF3FD2546120B7935 ),
665
    LIT64( 0x3FF0000000000000 ),
666
    LIT64( 0xCE07F766F09588D6 ),
667
    LIT64( 0x8000000000000000 ),
668
    LIT64( 0x3FCE000400000000 ),
669
    LIT64( 0x8313B60F0032BED8 ),
670
    LIT64( 0xC1EFFFFFC0002000 ),
671
    LIT64( 0x3FB3C75D224F2B0F ),
672
    LIT64( 0x7FD00000004000FF ),
673
    LIT64( 0xA12FFF8000001FFF ),
674
    LIT64( 0x3EE0000000FE0000 ),
675
    LIT64( 0x0010000080000004 ),
676
    LIT64( 0x41CFFFFE00000020 ),
677
    LIT64( 0x40303FFFFFFFFFFD ),
678
    LIT64( 0x3FD000003FEFFFFF ),
679
    LIT64( 0xBFD0000010000000 ),
680
    LIT64( 0xB7FC6B5C16CA55CF ),
681
    LIT64( 0x413EEB940B9D1301 ),
682
    LIT64( 0xC7E00200001FFFFF ),
683
    LIT64( 0x47F00021FFFFFFFE ),
684
    LIT64( 0xBFFFFFFFF80000FF ),
685
    LIT64( 0xC07FFFFFE00FFFFF ),
686
    LIT64( 0x001497A63740C5E8 ),
687
    LIT64( 0xC4BFFFE0001FFFFF ),
688
    LIT64( 0x96FFDFFEFFFFFFFF ),
689
    LIT64( 0x403FC000000001FE ),
690
    LIT64( 0xFFD00000000001F6 ),
691
    LIT64( 0x0640400002000000 ),
692
    LIT64( 0x479CEE1E4F789FE0 ),
693
    LIT64( 0xC237FFFFFFFFFDFE )
694
};
695
 
696
static void time_a_float64_z_int32( int32 function( float64 ) )
697
{
698
    clock_t startClock, endClock;
699
    int32 count, i;
700
    int8 inputNum;
701
 
702
    count = 0;
703
    inputNum = 0;
704
    startClock = clock();
705
    do {
706
        for ( i = minIterations; i; --i ) {
707
            function( inputs_float64[ inputNum ] );
708
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
709
        }
710
        count += minIterations;
711
    } while ( clock() - startClock < CLOCKS_PER_SEC );
712
    inputNum = 0;
713
    startClock = clock();
714
    for ( i = count; i; --i ) {
715
        function( inputs_float64[ inputNum ] );
716
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
717
    }
718
    endClock = clock();
719
    reportTime( count, endClock - startClock );
720
 
721
}
722
 
723
static void time_a_float64_z_int64( int64 function( float64 ) )
724
{
725
    clock_t startClock, endClock;
726
    int32 count, i;
727
    int8 inputNum;
728
 
729
    count = 0;
730
    inputNum = 0;
731
    startClock = clock();
732
    do {
733
        for ( i = minIterations; i; --i ) {
734
            function( inputs_float64[ inputNum ] );
735
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
736
        }
737
        count += minIterations;
738
    } while ( clock() - startClock < CLOCKS_PER_SEC );
739
    inputNum = 0;
740
    startClock = clock();
741
    for ( i = count; i; --i ) {
742
        function( inputs_float64[ inputNum ] );
743
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
744
    }
745
    endClock = clock();
746
    reportTime( count, endClock - startClock );
747
 
748
}
749
 
750
static void time_a_float64_z_float32( float32 function( float64 ) )
751
{
752
    clock_t startClock, endClock;
753
    int32 count, i;
754
    int8 inputNum;
755
 
756
    count = 0;
757
    inputNum = 0;
758
    startClock = clock();
759
    do {
760
        for ( i = minIterations; i; --i ) {
761
            function( inputs_float64[ inputNum ] );
762
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
763
        }
764
        count += minIterations;
765
    } while ( clock() - startClock < CLOCKS_PER_SEC );
766
    inputNum = 0;
767
    startClock = clock();
768
    for ( i = count; i; --i ) {
769
        function( inputs_float64[ inputNum ] );
770
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
771
    }
772
    endClock = clock();
773
    reportTime( count, endClock - startClock );
774
 
775
}
776
 
777
#ifdef FLOATX80
778
 
779
static void time_a_float64_z_floatx80( floatx80 function( float64 ) )
780
{
781
    clock_t startClock, endClock;
782
    int32 count, i;
783
    int8 inputNum;
784
 
785
    count = 0;
786
    inputNum = 0;
787
    startClock = clock();
788
    do {
789
        for ( i = minIterations; i; --i ) {
790
            function( inputs_float64[ inputNum ] );
791
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
792
        }
793
        count += minIterations;
794
    } while ( clock() - startClock < CLOCKS_PER_SEC );
795
    inputNum = 0;
796
    startClock = clock();
797
    for ( i = count; i; --i ) {
798
        function( inputs_float64[ inputNum ] );
799
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
800
    }
801
    endClock = clock();
802
    reportTime( count, endClock - startClock );
803
 
804
}
805
 
806
#endif
807
 
808
#ifdef FLOAT128
809
 
810
static void time_a_float64_z_float128( float128 function( float64 ) )
811
{
812
    clock_t startClock, endClock;
813
    int32 count, i;
814
    int8 inputNum;
815
 
816
    count = 0;
817
    inputNum = 0;
818
    startClock = clock();
819
    do {
820
        for ( i = minIterations; i; --i ) {
821
            function( inputs_float64[ inputNum ] );
822
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
823
        }
824
        count += minIterations;
825
    } while ( clock() - startClock < CLOCKS_PER_SEC );
826
    inputNum = 0;
827
    startClock = clock();
828
    for ( i = count; i; --i ) {
829
        function( inputs_float64[ inputNum ] );
830
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
831
    }
832
    endClock = clock();
833
    reportTime( count, endClock - startClock );
834
 
835
}
836
 
837
#endif
838
 
839
static void time_az_float64( float64 function( float64 ) )
840
{
841
    clock_t startClock, endClock;
842
    int32 count, i;
843
    int8 inputNum;
844
 
845
    count = 0;
846
    inputNum = 0;
847
    startClock = clock();
848
    do {
849
        for ( i = minIterations; i; --i ) {
850
            function( inputs_float64[ inputNum ] );
851
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
852
        }
853
        count += minIterations;
854
    } while ( clock() - startClock < CLOCKS_PER_SEC );
855
    inputNum = 0;
856
    startClock = clock();
857
    for ( i = count; i; --i ) {
858
        function( inputs_float64[ inputNum ] );
859
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
860
    }
861
    endClock = clock();
862
    reportTime( count, endClock - startClock );
863
 
864
}
865
 
866
static void time_ab_float64_z_flag( flag function( float64, float64 ) )
867
{
868
    clock_t startClock, endClock;
869
    int32 count, i;
870
    int8 inputNumA, inputNumB;
871
 
872
    count = 0;
873
    inputNumA = 0;
874
    inputNumB = 0;
875
    startClock = clock();
876
    do {
877
        for ( i = minIterations; i; --i ) {
878
            function(
879
                inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
880
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
881
            if ( inputNumA == 0 ) ++inputNumB;
882
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
883
        }
884
        count += minIterations;
885
    } while ( clock() - startClock < CLOCKS_PER_SEC );
886
    inputNumA = 0;
887
    inputNumB = 0;
888
    startClock = clock();
889
    for ( i = count; i; --i ) {
890
            function(
891
                inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
892
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
893
        if ( inputNumA == 0 ) ++inputNumB;
894
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
895
    }
896
    endClock = clock();
897
    reportTime( count, endClock - startClock );
898
 
899
}
900
 
901
static void time_abz_float64( float64 function( float64, float64 ) )
902
{
903
    clock_t startClock, endClock;
904
    int32 count, i;
905
    int8 inputNumA, inputNumB;
906
 
907
    count = 0;
908
    inputNumA = 0;
909
    inputNumB = 0;
910
    startClock = clock();
911
    do {
912
        for ( i = minIterations; i; --i ) {
913
            function(
914
                inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
915
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
916
            if ( inputNumA == 0 ) ++inputNumB;
917
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
918
        }
919
        count += minIterations;
920
    } while ( clock() - startClock < CLOCKS_PER_SEC );
921
    inputNumA = 0;
922
    inputNumB = 0;
923
    startClock = clock();
924
    for ( i = count; i; --i ) {
925
            function(
926
                inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
927
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
928
        if ( inputNumA == 0 ) ++inputNumB;
929
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
930
    }
931
    endClock = clock();
932
    reportTime( count, endClock - startClock );
933
 
934
}
935
 
936
static const float64 inputs_float64_pos[ numInputs_float64 ] = {
937
    LIT64( 0x422FFFC008000000 ),
938
    LIT64( 0x37E0000480000000 ),
939
    LIT64( 0x73FD2546120B7935 ),
940
    LIT64( 0x3FF0000000000000 ),
941
    LIT64( 0x4E07F766F09588D6 ),
942
    LIT64( 0x0000000000000000 ),
943
    LIT64( 0x3FCE000400000000 ),
944
    LIT64( 0x0313B60F0032BED8 ),
945
    LIT64( 0x41EFFFFFC0002000 ),
946
    LIT64( 0x3FB3C75D224F2B0F ),
947
    LIT64( 0x7FD00000004000FF ),
948
    LIT64( 0x212FFF8000001FFF ),
949
    LIT64( 0x3EE0000000FE0000 ),
950
    LIT64( 0x0010000080000004 ),
951
    LIT64( 0x41CFFFFE00000020 ),
952
    LIT64( 0x40303FFFFFFFFFFD ),
953
    LIT64( 0x3FD000003FEFFFFF ),
954
    LIT64( 0x3FD0000010000000 ),
955
    LIT64( 0x37FC6B5C16CA55CF ),
956
    LIT64( 0x413EEB940B9D1301 ),
957
    LIT64( 0x47E00200001FFFFF ),
958
    LIT64( 0x47F00021FFFFFFFE ),
959
    LIT64( 0x3FFFFFFFF80000FF ),
960
    LIT64( 0x407FFFFFE00FFFFF ),
961
    LIT64( 0x001497A63740C5E8 ),
962
    LIT64( 0x44BFFFE0001FFFFF ),
963
    LIT64( 0x16FFDFFEFFFFFFFF ),
964
    LIT64( 0x403FC000000001FE ),
965
    LIT64( 0x7FD00000000001F6 ),
966
    LIT64( 0x0640400002000000 ),
967
    LIT64( 0x479CEE1E4F789FE0 ),
968
    LIT64( 0x4237FFFFFFFFFDFE )
969
};
970
 
971
static void time_az_float64_pos( float64 function( float64 ) )
972
{
973
    clock_t startClock, endClock;
974
    int32 count, i;
975
    int8 inputNum;
976
 
977
    count = 0;
978
    inputNum = 0;
979
    startClock = clock();
980
    do {
981
        for ( i = minIterations; i; --i ) {
982
            function( inputs_float64_pos[ inputNum ] );
983
            inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
984
        }
985
        count += minIterations;
986
    } while ( clock() - startClock < CLOCKS_PER_SEC );
987
    inputNum = 0;
988
    startClock = clock();
989
    for ( i = count; i; --i ) {
990
        function( inputs_float64_pos[ inputNum ] );
991
        inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
992
    }
993
    endClock = clock();
994
    reportTime( count, endClock - startClock );
995
 
996
}
997
 
998
#ifdef FLOATX80
999
 
1000
enum {
1001
    numInputs_floatx80 = 32
1002
};
1003
 
1004
static const struct {
1005
    bits16 high;
1006
    bits64 low;
1007
} inputs_floatx80[ numInputs_floatx80 ] = {
1008
    { 0xC03F, LIT64( 0xA9BE15A19C1E8B62 ) },
1009
    { 0x8000, LIT64( 0x0000000000000000 ) },
1010
    { 0x75A8, LIT64( 0xE59591E4788957A5 ) },
1011
    { 0xBFFF, LIT64( 0xFFF0000000000040 ) },
1012
    { 0x0CD8, LIT64( 0xFC000000000007FE ) },
1013
    { 0x43BA, LIT64( 0x99A4000000000000 ) },
1014
    { 0x3FFF, LIT64( 0x8000000000000000 ) },
1015
    { 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },
1016
    { 0x403E, LIT64( 0xFFF0000000002000 ) },
1017
    { 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },
1018
    { 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },
1019
    { 0x737A, LIT64( 0x800000007FFDFFFE ) },
1020
    { 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },
1021
    { 0xBBFE, LIT64( 0x8000040000001FFE ) },
1022
    { 0xC002, LIT64( 0xFF80000000000020 ) },
1023
    { 0xDE8D, LIT64( 0xFFFFFFFFFFE00004 ) },
1024
    { 0xC004, LIT64( 0x8000000000003FFB ) },
1025
    { 0x407F, LIT64( 0x800000000003FFFE ) },
1026
    { 0xC000, LIT64( 0xA459EE6A5C16CA55 ) },
1027
    { 0x8003, LIT64( 0xC42CBF7399AEEB94 ) },
1028
    { 0xBF7F, LIT64( 0xF800000000000006 ) },
1029
    { 0xC07F, LIT64( 0xBF56BE8871F28FEA ) },
1030
    { 0xC07E, LIT64( 0xFFFF77FFFFFFFFFE ) },
1031
    { 0xADC9, LIT64( 0x8000000FFFFFFFDE ) },
1032
    { 0xC001, LIT64( 0xEFF7FFFFFFFFFFFF ) },
1033
    { 0x4001, LIT64( 0xBE84F30125C497A6 ) },
1034
    { 0xC06B, LIT64( 0xEFFFFFFFFFFFFFFF ) },
1035
    { 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },
1036
    { 0x87E9, LIT64( 0x81FFFFFFFFFFFBFF ) },
1037
    { 0xA63F, LIT64( 0x801FFFFFFEFFFFFE ) },
1038
    { 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },
1039
    { 0x4018, LIT64( 0x8000000000080003 ) }
1040
};
1041
 
1042
static void time_a_floatx80_z_int32( int32 function( floatx80 ) )
1043
{
1044
    clock_t startClock, endClock;
1045
    int32 count, i;
1046
    int8 inputNum;
1047
    floatx80 a;
1048
 
1049
    count = 0;
1050
    inputNum = 0;
1051
    startClock = clock();
1052
    do {
1053
        for ( i = minIterations; i; --i ) {
1054
            a.low = inputs_floatx80[ inputNum ].low;
1055
            a.high = inputs_floatx80[ inputNum ].high;
1056
            function( a );
1057
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1058
        }
1059
        count += minIterations;
1060
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1061
    inputNum = 0;
1062
    startClock = clock();
1063
    for ( i = count; i; --i ) {
1064
        a.low = inputs_floatx80[ inputNum ].low;
1065
        a.high = inputs_floatx80[ inputNum ].high;
1066
        function( a );
1067
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1068
    }
1069
    endClock = clock();
1070
    reportTime( count, endClock - startClock );
1071
 
1072
}
1073
 
1074
static void time_a_floatx80_z_int64( int64 function( floatx80 ) )
1075
{
1076
    clock_t startClock, endClock;
1077
    int32 count, i;
1078
    int8 inputNum;
1079
    floatx80 a;
1080
 
1081
    count = 0;
1082
    inputNum = 0;
1083
    startClock = clock();
1084
    do {
1085
        for ( i = minIterations; i; --i ) {
1086
            a.low = inputs_floatx80[ inputNum ].low;
1087
            a.high = inputs_floatx80[ inputNum ].high;
1088
            function( a );
1089
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1090
        }
1091
        count += minIterations;
1092
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1093
    inputNum = 0;
1094
    startClock = clock();
1095
    for ( i = count; i; --i ) {
1096
        a.low = inputs_floatx80[ inputNum ].low;
1097
        a.high = inputs_floatx80[ inputNum ].high;
1098
        function( a );
1099
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1100
    }
1101
    endClock = clock();
1102
    reportTime( count, endClock - startClock );
1103
 
1104
}
1105
 
1106
static void time_a_floatx80_z_float32( float32 function( floatx80 ) )
1107
{
1108
    clock_t startClock, endClock;
1109
    int32 count, i;
1110
    int8 inputNum;
1111
    floatx80 a;
1112
 
1113
    count = 0;
1114
    inputNum = 0;
1115
    startClock = clock();
1116
    do {
1117
        for ( i = minIterations; i; --i ) {
1118
            a.low = inputs_floatx80[ inputNum ].low;
1119
            a.high = inputs_floatx80[ inputNum ].high;
1120
            function( a );
1121
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1122
        }
1123
        count += minIterations;
1124
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1125
    inputNum = 0;
1126
    startClock = clock();
1127
    for ( i = count; i; --i ) {
1128
        a.low = inputs_floatx80[ inputNum ].low;
1129
        a.high = inputs_floatx80[ inputNum ].high;
1130
        function( a );
1131
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1132
    }
1133
    endClock = clock();
1134
    reportTime( count, endClock - startClock );
1135
 
1136
}
1137
 
1138
static void time_a_floatx80_z_float64( float64 function( floatx80 ) )
1139
{
1140
    clock_t startClock, endClock;
1141
    int32 count, i;
1142
    int8 inputNum;
1143
    floatx80 a;
1144
 
1145
    count = 0;
1146
    inputNum = 0;
1147
    startClock = clock();
1148
    do {
1149
        for ( i = minIterations; i; --i ) {
1150
            a.low = inputs_floatx80[ inputNum ].low;
1151
            a.high = inputs_floatx80[ inputNum ].high;
1152
            function( a );
1153
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1154
        }
1155
        count += minIterations;
1156
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1157
    inputNum = 0;
1158
    startClock = clock();
1159
    for ( i = count; i; --i ) {
1160
        a.low = inputs_floatx80[ inputNum ].low;
1161
        a.high = inputs_floatx80[ inputNum ].high;
1162
        function( a );
1163
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1164
    }
1165
    endClock = clock();
1166
    reportTime( count, endClock - startClock );
1167
 
1168
}
1169
 
1170
#ifdef FLOAT128
1171
 
1172
static void time_a_floatx80_z_float128( float128 function( floatx80 ) )
1173
{
1174
    clock_t startClock, endClock;
1175
    int32 count, i;
1176
    int8 inputNum;
1177
    floatx80 a;
1178
 
1179
    count = 0;
1180
    inputNum = 0;
1181
    startClock = clock();
1182
    do {
1183
        for ( i = minIterations; i; --i ) {
1184
            a.low = inputs_floatx80[ inputNum ].low;
1185
            a.high = inputs_floatx80[ inputNum ].high;
1186
            function( a );
1187
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1188
        }
1189
        count += minIterations;
1190
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1191
    inputNum = 0;
1192
    startClock = clock();
1193
    for ( i = count; i; --i ) {
1194
        a.low = inputs_floatx80[ inputNum ].low;
1195
        a.high = inputs_floatx80[ inputNum ].high;
1196
        function( a );
1197
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1198
    }
1199
    endClock = clock();
1200
    reportTime( count, endClock - startClock );
1201
 
1202
}
1203
 
1204
#endif
1205
 
1206
static void time_az_floatx80( floatx80 function( floatx80 ) )
1207
{
1208
    clock_t startClock, endClock;
1209
    int32 count, i;
1210
    int8 inputNum;
1211
    floatx80 a;
1212
 
1213
    count = 0;
1214
    inputNum = 0;
1215
    startClock = clock();
1216
    do {
1217
        for ( i = minIterations; i; --i ) {
1218
            a.low = inputs_floatx80[ inputNum ].low;
1219
            a.high = inputs_floatx80[ inputNum ].high;
1220
            function( a );
1221
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1222
        }
1223
        count += minIterations;
1224
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1225
    inputNum = 0;
1226
    startClock = clock();
1227
    for ( i = count; i; --i ) {
1228
        a.low = inputs_floatx80[ inputNum ].low;
1229
        a.high = inputs_floatx80[ inputNum ].high;
1230
        function( a );
1231
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1232
    }
1233
    endClock = clock();
1234
    reportTime( count, endClock - startClock );
1235
 
1236
}
1237
 
1238
static void time_ab_floatx80_z_flag( flag function( floatx80, floatx80 ) )
1239
{
1240
    clock_t startClock, endClock;
1241
    int32 count, i;
1242
    int8 inputNumA, inputNumB;
1243
    floatx80 a, b;
1244
 
1245
    count = 0;
1246
    inputNumA = 0;
1247
    inputNumB = 0;
1248
    startClock = clock();
1249
    do {
1250
        for ( i = minIterations; i; --i ) {
1251
            a.low = inputs_floatx80[ inputNumA ].low;
1252
            a.high = inputs_floatx80[ inputNumA ].high;
1253
            b.low = inputs_floatx80[ inputNumB ].low;
1254
            b.high = inputs_floatx80[ inputNumB ].high;
1255
            function( a, b );
1256
            inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1257
            if ( inputNumA == 0 ) ++inputNumB;
1258
            inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1259
        }
1260
        count += minIterations;
1261
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1262
    inputNumA = 0;
1263
    inputNumB = 0;
1264
    startClock = clock();
1265
    for ( i = count; i; --i ) {
1266
        a.low = inputs_floatx80[ inputNumA ].low;
1267
        a.high = inputs_floatx80[ inputNumA ].high;
1268
        b.low = inputs_floatx80[ inputNumB ].low;
1269
        b.high = inputs_floatx80[ inputNumB ].high;
1270
        function( a, b );
1271
        inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1272
        if ( inputNumA == 0 ) ++inputNumB;
1273
        inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1274
    }
1275
    endClock = clock();
1276
    reportTime( count, endClock - startClock );
1277
 
1278
}
1279
 
1280
static void time_abz_floatx80( floatx80 function( floatx80, floatx80 ) )
1281
{
1282
    clock_t startClock, endClock;
1283
    int32 count, i;
1284
    int8 inputNumA, inputNumB;
1285
    floatx80 a, b;
1286
 
1287
    count = 0;
1288
    inputNumA = 0;
1289
    inputNumB = 0;
1290
    startClock = clock();
1291
    do {
1292
        for ( i = minIterations; i; --i ) {
1293
            a.low = inputs_floatx80[ inputNumA ].low;
1294
            a.high = inputs_floatx80[ inputNumA ].high;
1295
            b.low = inputs_floatx80[ inputNumB ].low;
1296
            b.high = inputs_floatx80[ inputNumB ].high;
1297
            function( a, b );
1298
            inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1299
            if ( inputNumA == 0 ) ++inputNumB;
1300
            inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1301
        }
1302
        count += minIterations;
1303
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1304
    inputNumA = 0;
1305
    inputNumB = 0;
1306
    startClock = clock();
1307
    for ( i = count; i; --i ) {
1308
        a.low = inputs_floatx80[ inputNumA ].low;
1309
        a.high = inputs_floatx80[ inputNumA ].high;
1310
        b.low = inputs_floatx80[ inputNumB ].low;
1311
        b.high = inputs_floatx80[ inputNumB ].high;
1312
        function( a, b );
1313
        inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1314
        if ( inputNumA == 0 ) ++inputNumB;
1315
        inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1316
    }
1317
    endClock = clock();
1318
    reportTime( count, endClock - startClock );
1319
 
1320
}
1321
 
1322
static const struct {
1323
    bits16 high;
1324
    bits64 low;
1325
} inputs_floatx80_pos[ numInputs_floatx80 ] = {
1326
    { 0x403F, LIT64( 0xA9BE15A19C1E8B62 ) },
1327
    { 0x0000, LIT64( 0x0000000000000000 ) },
1328
    { 0x75A8, LIT64( 0xE59591E4788957A5 ) },
1329
    { 0x3FFF, LIT64( 0xFFF0000000000040 ) },
1330
    { 0x0CD8, LIT64( 0xFC000000000007FE ) },
1331
    { 0x43BA, LIT64( 0x99A4000000000000 ) },
1332
    { 0x3FFF, LIT64( 0x8000000000000000 ) },
1333
    { 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },
1334
    { 0x403E, LIT64( 0xFFF0000000002000 ) },
1335
    { 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },
1336
    { 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },
1337
    { 0x737A, LIT64( 0x800000007FFDFFFE ) },
1338
    { 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },
1339
    { 0x3BFE, LIT64( 0x8000040000001FFE ) },
1340
    { 0x4002, LIT64( 0xFF80000000000020 ) },
1341
    { 0x5E8D, LIT64( 0xFFFFFFFFFFE00004 ) },
1342
    { 0x4004, LIT64( 0x8000000000003FFB ) },
1343
    { 0x407F, LIT64( 0x800000000003FFFE ) },
1344
    { 0x4000, LIT64( 0xA459EE6A5C16CA55 ) },
1345
    { 0x0003, LIT64( 0xC42CBF7399AEEB94 ) },
1346
    { 0x3F7F, LIT64( 0xF800000000000006 ) },
1347
    { 0x407F, LIT64( 0xBF56BE8871F28FEA ) },
1348
    { 0x407E, LIT64( 0xFFFF77FFFFFFFFFE ) },
1349
    { 0x2DC9, LIT64( 0x8000000FFFFFFFDE ) },
1350
    { 0x4001, LIT64( 0xEFF7FFFFFFFFFFFF ) },
1351
    { 0x4001, LIT64( 0xBE84F30125C497A6 ) },
1352
    { 0x406B, LIT64( 0xEFFFFFFFFFFFFFFF ) },
1353
    { 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },
1354
    { 0x07E9, LIT64( 0x81FFFFFFFFFFFBFF ) },
1355
    { 0x263F, LIT64( 0x801FFFFFFEFFFFFE ) },
1356
    { 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },
1357
    { 0x4018, LIT64( 0x8000000000080003 ) }
1358
};
1359
 
1360
static void time_az_floatx80_pos( floatx80 function( floatx80 ) )
1361
{
1362
    clock_t startClock, endClock;
1363
    int32 count, i;
1364
    int8 inputNum;
1365
    floatx80 a;
1366
 
1367
    count = 0;
1368
    inputNum = 0;
1369
    startClock = clock();
1370
    do {
1371
        for ( i = minIterations; i; --i ) {
1372
            a.low = inputs_floatx80_pos[ inputNum ].low;
1373
            a.high = inputs_floatx80_pos[ inputNum ].high;
1374
            function( a );
1375
            inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1376
        }
1377
        count += minIterations;
1378
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1379
    inputNum = 0;
1380
    startClock = clock();
1381
    for ( i = count; i; --i ) {
1382
        a.low = inputs_floatx80_pos[ inputNum ].low;
1383
        a.high = inputs_floatx80_pos[ inputNum ].high;
1384
        function( a );
1385
        inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1386
    }
1387
    endClock = clock();
1388
    reportTime( count, endClock - startClock );
1389
 
1390
}
1391
 
1392
#endif
1393
 
1394
#ifdef FLOAT128
1395
 
1396
enum {
1397
    numInputs_float128 = 32
1398
};
1399
 
1400
static const struct {
1401
    bits64 high, low;
1402
} inputs_float128[ numInputs_float128 ] = {
1403
    { LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },
1404
    { LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },
1405
    { LIT64( 0x85F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },
1406
    { LIT64( 0xF2B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },
1407
    { LIT64( 0x8000000000000000 ), LIT64( 0x0000000000000000 ) },
1408
    { LIT64( 0xBFFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },
1409
    { LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },
1410
    { LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },
1411
    { LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },
1412
    { LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },
1413
    { LIT64( 0xBF7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },
1414
    { LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },
1415
    { LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },
1416
    { LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },
1417
    { LIT64( 0xBFFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },
1418
    { LIT64( 0xBDB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },
1419
    { LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },
1420
    { LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },
1421
    { LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },
1422
    { LIT64( 0x8001000000000000 ), LIT64( 0x0000001000000001 ) },
1423
    { LIT64( 0xC036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },
1424
    { LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },
1425
    { LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },
1426
    { LIT64( 0xBFFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },
1427
    { LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },
1428
    { LIT64( 0xB5CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },
1429
    { LIT64( 0xE228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },
1430
    { LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },
1431
    { LIT64( 0xC1AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },
1432
    { LIT64( 0xC96F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },
1433
    { LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },
1434
    { LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }
1435
};
1436
 
1437
static void time_a_float128_z_int32( int32 function( float128 ) )
1438
{
1439
    clock_t startClock, endClock;
1440
    int32 count, i;
1441
    int8 inputNum;
1442
    float128 a;
1443
 
1444
    count = 0;
1445
    inputNum = 0;
1446
    startClock = clock();
1447
    do {
1448
        for ( i = minIterations; i; --i ) {
1449
            a.low = inputs_float128[ inputNum ].low;
1450
            a.high = inputs_float128[ inputNum ].high;
1451
            function( a );
1452
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1453
        }
1454
        count += minIterations;
1455
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1456
    inputNum = 0;
1457
    startClock = clock();
1458
    for ( i = count; i; --i ) {
1459
        a.low = inputs_float128[ inputNum ].low;
1460
        a.high = inputs_float128[ inputNum ].high;
1461
        function( a );
1462
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1463
    }
1464
    endClock = clock();
1465
    reportTime( count, endClock - startClock );
1466
 
1467
}
1468
 
1469
static void time_a_float128_z_int64( int64 function( float128 ) )
1470
{
1471
    clock_t startClock, endClock;
1472
    int32 count, i;
1473
    int8 inputNum;
1474
    float128 a;
1475
 
1476
    count = 0;
1477
    inputNum = 0;
1478
    startClock = clock();
1479
    do {
1480
        for ( i = minIterations; i; --i ) {
1481
            a.low = inputs_float128[ inputNum ].low;
1482
            a.high = inputs_float128[ inputNum ].high;
1483
            function( a );
1484
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1485
        }
1486
        count += minIterations;
1487
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1488
    inputNum = 0;
1489
    startClock = clock();
1490
    for ( i = count; i; --i ) {
1491
        a.low = inputs_float128[ inputNum ].low;
1492
        a.high = inputs_float128[ inputNum ].high;
1493
        function( a );
1494
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1495
    }
1496
    endClock = clock();
1497
    reportTime( count, endClock - startClock );
1498
 
1499
}
1500
 
1501
static void time_a_float128_z_float32( float32 function( float128 ) )
1502
{
1503
    clock_t startClock, endClock;
1504
    int32 count, i;
1505
    int8 inputNum;
1506
    float128 a;
1507
 
1508
    count = 0;
1509
    inputNum = 0;
1510
    startClock = clock();
1511
    do {
1512
        for ( i = minIterations; i; --i ) {
1513
            a.low = inputs_float128[ inputNum ].low;
1514
            a.high = inputs_float128[ inputNum ].high;
1515
            function( a );
1516
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1517
        }
1518
        count += minIterations;
1519
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1520
    inputNum = 0;
1521
    startClock = clock();
1522
    for ( i = count; i; --i ) {
1523
        a.low = inputs_float128[ inputNum ].low;
1524
        a.high = inputs_float128[ inputNum ].high;
1525
        function( a );
1526
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1527
    }
1528
    endClock = clock();
1529
    reportTime( count, endClock - startClock );
1530
 
1531
}
1532
 
1533
static void time_a_float128_z_float64( float64 function( float128 ) )
1534
{
1535
    clock_t startClock, endClock;
1536
    int32 count, i;
1537
    int8 inputNum;
1538
    float128 a;
1539
 
1540
    count = 0;
1541
    inputNum = 0;
1542
    startClock = clock();
1543
    do {
1544
        for ( i = minIterations; i; --i ) {
1545
            a.low = inputs_float128[ inputNum ].low;
1546
            a.high = inputs_float128[ inputNum ].high;
1547
            function( a );
1548
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1549
        }
1550
        count += minIterations;
1551
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1552
    inputNum = 0;
1553
    startClock = clock();
1554
    for ( i = count; i; --i ) {
1555
        a.low = inputs_float128[ inputNum ].low;
1556
        a.high = inputs_float128[ inputNum ].high;
1557
        function( a );
1558
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1559
    }
1560
    endClock = clock();
1561
    reportTime( count, endClock - startClock );
1562
 
1563
}
1564
 
1565
#ifdef FLOATX80
1566
 
1567
static void time_a_float128_z_floatx80( floatx80 function( float128 ) )
1568
{
1569
    clock_t startClock, endClock;
1570
    int32 count, i;
1571
    int8 inputNum;
1572
    float128 a;
1573
 
1574
    count = 0;
1575
    inputNum = 0;
1576
    startClock = clock();
1577
    do {
1578
        for ( i = minIterations; i; --i ) {
1579
            a.low = inputs_float128[ inputNum ].low;
1580
            a.high = inputs_float128[ inputNum ].high;
1581
            function( a );
1582
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1583
        }
1584
        count += minIterations;
1585
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1586
    inputNum = 0;
1587
    startClock = clock();
1588
    for ( i = count; i; --i ) {
1589
        a.low = inputs_float128[ inputNum ].low;
1590
        a.high = inputs_float128[ inputNum ].high;
1591
        function( a );
1592
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1593
    }
1594
    endClock = clock();
1595
    reportTime( count, endClock - startClock );
1596
 
1597
}
1598
 
1599
#endif
1600
 
1601
static void time_az_float128( float128 function( float128 ) )
1602
{
1603
    clock_t startClock, endClock;
1604
    int32 count, i;
1605
    int8 inputNum;
1606
    float128 a;
1607
 
1608
    count = 0;
1609
    inputNum = 0;
1610
    startClock = clock();
1611
    do {
1612
        for ( i = minIterations; i; --i ) {
1613
            a.low = inputs_float128[ inputNum ].low;
1614
            a.high = inputs_float128[ inputNum ].high;
1615
            function( a );
1616
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1617
        }
1618
        count += minIterations;
1619
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1620
    inputNum = 0;
1621
    startClock = clock();
1622
    for ( i = count; i; --i ) {
1623
        a.low = inputs_float128[ inputNum ].low;
1624
        a.high = inputs_float128[ inputNum ].high;
1625
        function( a );
1626
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1627
    }
1628
    endClock = clock();
1629
    reportTime( count, endClock - startClock );
1630
 
1631
}
1632
 
1633
static void time_ab_float128_z_flag( flag function( float128, float128 ) )
1634
{
1635
    clock_t startClock, endClock;
1636
    int32 count, i;
1637
    int8 inputNumA, inputNumB;
1638
    float128 a, b;
1639
 
1640
    count = 0;
1641
    inputNumA = 0;
1642
    inputNumB = 0;
1643
    startClock = clock();
1644
    do {
1645
        for ( i = minIterations; i; --i ) {
1646
            a.low = inputs_float128[ inputNumA ].low;
1647
            a.high = inputs_float128[ inputNumA ].high;
1648
            b.low = inputs_float128[ inputNumB ].low;
1649
            b.high = inputs_float128[ inputNumB ].high;
1650
            function( a, b );
1651
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1652
            if ( inputNumA == 0 ) ++inputNumB;
1653
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1654
        }
1655
        count += minIterations;
1656
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1657
    inputNumA = 0;
1658
    inputNumB = 0;
1659
    startClock = clock();
1660
    for ( i = count; i; --i ) {
1661
        a.low = inputs_float128[ inputNumA ].low;
1662
        a.high = inputs_float128[ inputNumA ].high;
1663
        b.low = inputs_float128[ inputNumB ].low;
1664
        b.high = inputs_float128[ inputNumB ].high;
1665
        function( a, b );
1666
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1667
        if ( inputNumA == 0 ) ++inputNumB;
1668
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1669
    }
1670
    endClock = clock();
1671
    reportTime( count, endClock - startClock );
1672
 
1673
}
1674
 
1675
static void time_abz_float128( float128 function( float128, float128 ) )
1676
{
1677
    clock_t startClock, endClock;
1678
    int32 count, i;
1679
    int8 inputNumA, inputNumB;
1680
    float128 a, b;
1681
 
1682
    count = 0;
1683
    inputNumA = 0;
1684
    inputNumB = 0;
1685
    startClock = clock();
1686
    do {
1687
        for ( i = minIterations; i; --i ) {
1688
            a.low = inputs_float128[ inputNumA ].low;
1689
            a.high = inputs_float128[ inputNumA ].high;
1690
            b.low = inputs_float128[ inputNumB ].low;
1691
            b.high = inputs_float128[ inputNumB ].high;
1692
            function( a, b );
1693
            inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1694
            if ( inputNumA == 0 ) ++inputNumB;
1695
            inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1696
        }
1697
        count += minIterations;
1698
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1699
    inputNumA = 0;
1700
    inputNumB = 0;
1701
    startClock = clock();
1702
    for ( i = count; i; --i ) {
1703
        a.low = inputs_float128[ inputNumA ].low;
1704
        a.high = inputs_float128[ inputNumA ].high;
1705
        b.low = inputs_float128[ inputNumB ].low;
1706
        b.high = inputs_float128[ inputNumB ].high;
1707
        function( a, b );
1708
        inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1709
        if ( inputNumA == 0 ) ++inputNumB;
1710
        inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1711
    }
1712
    endClock = clock();
1713
    reportTime( count, endClock - startClock );
1714
 
1715
}
1716
 
1717
static const struct {
1718
    bits64 high, low;
1719
} inputs_float128_pos[ numInputs_float128 ] = {
1720
    { LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },
1721
    { LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },
1722
    { LIT64( 0x05F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },
1723
    { LIT64( 0x72B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },
1724
    { LIT64( 0x0000000000000000 ), LIT64( 0x0000000000000000 ) },
1725
    { LIT64( 0x3FFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },
1726
    { LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },
1727
    { LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },
1728
    { LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },
1729
    { LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },
1730
    { LIT64( 0x3F7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },
1731
    { LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },
1732
    { LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },
1733
    { LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },
1734
    { LIT64( 0x3FFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },
1735
    { LIT64( 0x3DB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },
1736
    { LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },
1737
    { LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },
1738
    { LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },
1739
    { LIT64( 0x0001000000000000 ), LIT64( 0x0000001000000001 ) },
1740
    { LIT64( 0x4036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },
1741
    { LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },
1742
    { LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },
1743
    { LIT64( 0x3FFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },
1744
    { LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },
1745
    { LIT64( 0x35CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },
1746
    { LIT64( 0x6228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },
1747
    { LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },
1748
    { LIT64( 0x41AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },
1749
    { LIT64( 0x496F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },
1750
    { LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },
1751
    { LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }
1752
};
1753
 
1754
static void time_az_float128_pos( float128 function( float128 ) )
1755
{
1756
    clock_t startClock, endClock;
1757
    int32 count, i;
1758
    int8 inputNum;
1759
    float128 a;
1760
 
1761
    count = 0;
1762
    inputNum = 0;
1763
    startClock = clock();
1764
    do {
1765
        for ( i = minIterations; i; --i ) {
1766
            a.low = inputs_float128_pos[ inputNum ].low;
1767
            a.high = inputs_float128_pos[ inputNum ].high;
1768
            function( a );
1769
            inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1770
        }
1771
        count += minIterations;
1772
    } while ( clock() - startClock < CLOCKS_PER_SEC );
1773
    inputNum = 0;
1774
    startClock = clock();
1775
    for ( i = count; i; --i ) {
1776
        a.low = inputs_float128_pos[ inputNum ].low;
1777
        a.high = inputs_float128_pos[ inputNum ].high;
1778
        function( a );
1779
        inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1780
    }
1781
    endClock = clock();
1782
    reportTime( count, endClock - startClock );
1783
 
1784
}
1785
 
1786
#endif
1787
 
1788
enum {
1789
    INT32_TO_FLOAT32 = 1,
1790
    INT32_TO_FLOAT64,
1791
#ifdef FLOATX80
1792
    INT32_TO_FLOATX80,
1793
#endif
1794
#ifdef FLOAT128
1795
    INT32_TO_FLOAT128,
1796
#endif
1797
    INT64_TO_FLOAT32,
1798
    INT64_TO_FLOAT64,
1799
#ifdef FLOATX80
1800
    INT64_TO_FLOATX80,
1801
#endif
1802
#ifdef FLOAT128
1803
    INT64_TO_FLOAT128,
1804
#endif
1805
    FLOAT32_TO_INT32,
1806
    FLOAT32_TO_INT32_ROUND_TO_ZERO,
1807
    FLOAT32_TO_INT64,
1808
    FLOAT32_TO_INT64_ROUND_TO_ZERO,
1809
    FLOAT32_TO_FLOAT64,
1810
#ifdef FLOATX80
1811
    FLOAT32_TO_FLOATX80,
1812
#endif
1813
#ifdef FLOAT128
1814
    FLOAT32_TO_FLOAT128,
1815
#endif
1816
    FLOAT32_ROUND_TO_INT,
1817
    FLOAT32_ADD,
1818
    FLOAT32_SUB,
1819
    FLOAT32_MUL,
1820
    FLOAT32_DIV,
1821
    FLOAT32_REM,
1822
    FLOAT32_SQRT,
1823
    FLOAT32_EQ,
1824
    FLOAT32_LE,
1825
    FLOAT32_LT,
1826
    FLOAT32_EQ_SIGNALING,
1827
    FLOAT32_LE_QUIET,
1828
    FLOAT32_LT_QUIET,
1829
    FLOAT64_TO_INT32,
1830
    FLOAT64_TO_INT32_ROUND_TO_ZERO,
1831
    FLOAT64_TO_INT64,
1832
    FLOAT64_TO_INT64_ROUND_TO_ZERO,
1833
    FLOAT64_TO_FLOAT32,
1834
#ifdef FLOATX80
1835
    FLOAT64_TO_FLOATX80,
1836
#endif
1837
#ifdef FLOAT128
1838
    FLOAT64_TO_FLOAT128,
1839
#endif
1840
    FLOAT64_ROUND_TO_INT,
1841
    FLOAT64_ADD,
1842
    FLOAT64_SUB,
1843
    FLOAT64_MUL,
1844
    FLOAT64_DIV,
1845
    FLOAT64_REM,
1846
    FLOAT64_SQRT,
1847
    FLOAT64_EQ,
1848
    FLOAT64_LE,
1849
    FLOAT64_LT,
1850
    FLOAT64_EQ_SIGNALING,
1851
    FLOAT64_LE_QUIET,
1852
    FLOAT64_LT_QUIET,
1853
#ifdef FLOATX80
1854
    FLOATX80_TO_INT32,
1855
    FLOATX80_TO_INT32_ROUND_TO_ZERO,
1856
    FLOATX80_TO_INT64,
1857
    FLOATX80_TO_INT64_ROUND_TO_ZERO,
1858
    FLOATX80_TO_FLOAT32,
1859
    FLOATX80_TO_FLOAT64,
1860
#ifdef FLOAT128
1861
    FLOATX80_TO_FLOAT128,
1862
#endif
1863
    FLOATX80_ROUND_TO_INT,
1864
    FLOATX80_ADD,
1865
    FLOATX80_SUB,
1866
    FLOATX80_MUL,
1867
    FLOATX80_DIV,
1868
    FLOATX80_REM,
1869
    FLOATX80_SQRT,
1870
    FLOATX80_EQ,
1871
    FLOATX80_LE,
1872
    FLOATX80_LT,
1873
    FLOATX80_EQ_SIGNALING,
1874
    FLOATX80_LE_QUIET,
1875
    FLOATX80_LT_QUIET,
1876
#endif
1877
#ifdef FLOAT128
1878
    FLOAT128_TO_INT32,
1879
    FLOAT128_TO_INT32_ROUND_TO_ZERO,
1880
    FLOAT128_TO_INT64,
1881
    FLOAT128_TO_INT64_ROUND_TO_ZERO,
1882
    FLOAT128_TO_FLOAT32,
1883
    FLOAT128_TO_FLOAT64,
1884
#ifdef FLOATX80
1885
    FLOAT128_TO_FLOATX80,
1886
#endif
1887
    FLOAT128_ROUND_TO_INT,
1888
    FLOAT128_ADD,
1889
    FLOAT128_SUB,
1890
    FLOAT128_MUL,
1891
    FLOAT128_DIV,
1892
    FLOAT128_REM,
1893
    FLOAT128_SQRT,
1894
    FLOAT128_EQ,
1895
    FLOAT128_LE,
1896
    FLOAT128_LT,
1897
    FLOAT128_EQ_SIGNALING,
1898
    FLOAT128_LE_QUIET,
1899
    FLOAT128_LT_QUIET,
1900
#endif
1901
    NUM_FUNCTIONS
1902
};
1903
 
1904
static struct {
1905
    char *name;
1906
    int8 numInputs;
1907
    flag roundingPrecision, roundingMode;
1908
    flag tininessMode, tininessModeAtReducedPrecision;
1909
} functions[ NUM_FUNCTIONS ] = {
1910
    { 0, 0, 0, 0, 0, 0 },
1911
    { "int32_to_float32",                1, FALSE, TRUE,  FALSE, FALSE },
1912
    { "int32_to_float64",                1, FALSE, FALSE, FALSE, FALSE },
1913
#ifdef FLOATX80
1914
    { "int32_to_floatx80",               1, FALSE, FALSE, FALSE, FALSE },
1915
#endif
1916
#ifdef FLOAT128
1917
    { "int32_to_float128",               1, FALSE, FALSE, FALSE, FALSE },
1918
#endif
1919
    { "int64_to_float32",                1, FALSE, TRUE,  FALSE, FALSE },
1920
    { "int64_to_float64",                1, FALSE, TRUE,  FALSE, FALSE },
1921
#ifdef FLOATX80
1922
    { "int64_to_floatx80",               1, FALSE, FALSE, FALSE, FALSE },
1923
#endif
1924
#ifdef FLOAT128
1925
    { "int64_to_float128",               1, FALSE, FALSE, FALSE, FALSE },
1926
#endif
1927
    { "float32_to_int32",                1, FALSE, TRUE,  FALSE, FALSE },
1928
    { "float32_to_int32_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1929
    { "float32_to_int64",                1, FALSE, TRUE,  FALSE, FALSE },
1930
    { "float32_to_int64_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1931
    { "float32_to_float64",              1, FALSE, FALSE, FALSE, FALSE },
1932
#ifdef FLOATX80
1933
    { "float32_to_floatx80",             1, FALSE, FALSE, FALSE, FALSE },
1934
#endif
1935
#ifdef FLOAT128
1936
    { "float32_to_float128",             1, FALSE, FALSE, FALSE, FALSE },
1937
#endif
1938
    { "float32_round_to_int",            1, FALSE, TRUE,  FALSE, FALSE },
1939
    { "float32_add",                     2, FALSE, TRUE,  FALSE, FALSE },
1940
    { "float32_sub",                     2, FALSE, TRUE,  FALSE, FALSE },
1941
    { "float32_mul",                     2, FALSE, TRUE,  TRUE,  FALSE },
1942
    { "float32_div",                     2, FALSE, TRUE,  FALSE, FALSE },
1943
    { "float32_rem",                     2, FALSE, FALSE, FALSE, FALSE },
1944
    { "float32_sqrt",                    1, FALSE, TRUE,  FALSE, FALSE },
1945
    { "float32_eq",                      2, FALSE, FALSE, FALSE, FALSE },
1946
    { "float32_le",                      2, FALSE, FALSE, FALSE, FALSE },
1947
    { "float32_lt",                      2, FALSE, FALSE, FALSE, FALSE },
1948
    { "float32_eq_signaling",            2, FALSE, FALSE, FALSE, FALSE },
1949
    { "float32_le_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1950
    { "float32_lt_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1951
    { "float64_to_int32",                1, FALSE, TRUE,  FALSE, FALSE },
1952
    { "float64_to_int32_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1953
    { "float64_to_int64",                1, FALSE, TRUE,  FALSE, FALSE },
1954
    { "float64_to_int64_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1955
    { "float64_to_float32",              1, FALSE, TRUE,  TRUE,  FALSE },
1956
#ifdef FLOATX80
1957
    { "float64_to_floatx80",             1, FALSE, FALSE, FALSE, FALSE },
1958
#endif
1959
#ifdef FLOAT128
1960
    { "float64_to_float128",             1, FALSE, FALSE, FALSE, FALSE },
1961
#endif
1962
    { "float64_round_to_int",            1, FALSE, TRUE,  FALSE, FALSE },
1963
    { "float64_add",                     2, FALSE, TRUE,  FALSE, FALSE },
1964
    { "float64_sub",                     2, FALSE, TRUE,  FALSE, FALSE },
1965
    { "float64_mul",                     2, FALSE, TRUE,  TRUE,  FALSE },
1966
    { "float64_div",                     2, FALSE, TRUE,  FALSE, FALSE },
1967
    { "float64_rem",                     2, FALSE, FALSE, FALSE, FALSE },
1968
    { "float64_sqrt",                    1, FALSE, TRUE,  FALSE, FALSE },
1969
    { "float64_eq",                      2, FALSE, FALSE, FALSE, FALSE },
1970
    { "float64_le",                      2, FALSE, FALSE, FALSE, FALSE },
1971
    { "float64_lt",                      2, FALSE, FALSE, FALSE, FALSE },
1972
    { "float64_eq_signaling",            2, FALSE, FALSE, FALSE, FALSE },
1973
    { "float64_le_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1974
    { "float64_lt_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1975
#ifdef FLOATX80
1976
    { "floatx80_to_int32",               1, FALSE, TRUE,  FALSE, FALSE },
1977
    { "floatx80_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1978
    { "floatx80_to_int64",               1, FALSE, TRUE,  FALSE, FALSE },
1979
    { "floatx80_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1980
    { "floatx80_to_float32",             1, FALSE, TRUE,  TRUE,  FALSE },
1981
    { "floatx80_to_float64",             1, FALSE, TRUE,  TRUE,  FALSE },
1982
#ifdef FLOAT128
1983
    { "floatx80_to_float128",            1, FALSE, FALSE, FALSE, FALSE },
1984
#endif
1985
    { "floatx80_round_to_int",           1, FALSE, TRUE,  FALSE, FALSE },
1986
    { "floatx80_add",                    2, TRUE,  TRUE,  FALSE, TRUE  },
1987
    { "floatx80_sub",                    2, TRUE,  TRUE,  FALSE, TRUE  },
1988
    { "floatx80_mul",                    2, TRUE,  TRUE,  TRUE,  TRUE  },
1989
    { "floatx80_div",                    2, TRUE,  TRUE,  FALSE, TRUE  },
1990
    { "floatx80_rem",                    2, FALSE, FALSE, FALSE, FALSE },
1991
    { "floatx80_sqrt",                   1, TRUE,  TRUE,  FALSE, FALSE },
1992
    { "floatx80_eq",                     2, FALSE, FALSE, FALSE, FALSE },
1993
    { "floatx80_le",                     2, FALSE, FALSE, FALSE, FALSE },
1994
    { "floatx80_lt",                     2, FALSE, FALSE, FALSE, FALSE },
1995
    { "floatx80_eq_signaling",           2, FALSE, FALSE, FALSE, FALSE },
1996
    { "floatx80_le_quiet",               2, FALSE, FALSE, FALSE, FALSE },
1997
    { "floatx80_lt_quiet",               2, FALSE, FALSE, FALSE, FALSE },
1998
#endif
1999
#ifdef FLOAT128
2000
    { "float128_to_int32",               1, FALSE, TRUE,  FALSE, FALSE },
2001
    { "float128_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
2002
    { "float128_to_int64",               1, FALSE, TRUE,  FALSE, FALSE },
2003
    { "float128_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
2004
    { "float128_to_float32",             1, FALSE, TRUE,  TRUE,  FALSE },
2005
    { "float128_to_float64",             1, FALSE, TRUE,  TRUE,  FALSE },
2006
#ifdef FLOATX80
2007
    { "float128_to_floatx80",            1, FALSE, TRUE,  TRUE,  FALSE },
2008
#endif
2009
    { "float128_round_to_int",           1, FALSE, TRUE,  FALSE, FALSE },
2010
    { "float128_add",                    2, FALSE, TRUE,  FALSE, FALSE },
2011
    { "float128_sub",                    2, FALSE, TRUE,  FALSE, FALSE },
2012
    { "float128_mul",                    2, FALSE, TRUE,  TRUE,  FALSE },
2013
    { "float128_div",                    2, FALSE, TRUE,  FALSE, FALSE },
2014
    { "float128_rem",                    2, FALSE, FALSE, FALSE, FALSE },
2015
    { "float128_sqrt",                   1, FALSE, TRUE,  FALSE, FALSE },
2016
    { "float128_eq",                     2, FALSE, FALSE, FALSE, FALSE },
2017
    { "float128_le",                     2, FALSE, FALSE, FALSE, FALSE },
2018
    { "float128_lt",                     2, FALSE, FALSE, FALSE, FALSE },
2019
    { "float128_eq_signaling",           2, FALSE, FALSE, FALSE, FALSE },
2020
    { "float128_le_quiet",               2, FALSE, FALSE, FALSE, FALSE },
2021
    { "float128_lt_quiet",               2, FALSE, FALSE, FALSE, FALSE },
2022
#endif
2023
};
2024
 
2025
enum {
2026
    ROUND_NEAREST_EVEN = 1,
2027
    ROUND_TO_ZERO,
2028
    ROUND_DOWN,
2029
    ROUND_UP,
2030
    NUM_ROUNDINGMODES
2031
};
2032
enum {
2033
    TININESS_BEFORE_ROUNDING = 1,
2034
    TININESS_AFTER_ROUNDING,
2035
    NUM_TININESSMODES
2036
};
2037
 
2038
static void
2039
 timeFunctionVariety(
2040
     uint8 functionCode,
2041
     int8 roundingPrecision,
2042
     int8 roundingMode,
2043
     int8 tininessMode
2044
 )
2045
{
2046
    uint8 roundingCode;
2047
    int8 tininessCode;
2048
 
2049
    functionName = functions[ functionCode ].name;
2050
    if ( roundingPrecision == 32 ) {
2051
        roundingPrecisionName = "32";
2052
    }
2053
    else if ( roundingPrecision == 64 ) {
2054
        roundingPrecisionName = "64";
2055
    }
2056
    else if ( roundingPrecision == 80 ) {
2057
        roundingPrecisionName = "80";
2058
    }
2059
    else {
2060
        roundingPrecisionName = 0;
2061
    }
2062
#ifdef FLOATX80
2063
    floatx80_rounding_precision = roundingPrecision;
2064
#endif
2065
    switch ( roundingMode ) {
2066
     case 0:
2067
        roundingModeName = 0;
2068
        roundingCode = float_round_nearest_even;
2069
        break;
2070
     case ROUND_NEAREST_EVEN:
2071
        roundingModeName = "nearest_even";
2072
        roundingCode = float_round_nearest_even;
2073
        break;
2074
     case ROUND_TO_ZERO:
2075
        roundingModeName = "to_zero";
2076
        roundingCode = float_round_to_zero;
2077
        break;
2078
     case ROUND_DOWN:
2079
        roundingModeName = "down";
2080
        roundingCode = float_round_down;
2081
        break;
2082
     case ROUND_UP:
2083
        roundingModeName = "up";
2084
        roundingCode = float_round_up;
2085
        break;
2086
    }
2087
    float_rounding_mode = roundingCode;
2088
    switch ( tininessMode ) {
2089
     case 0:
2090
        tininessModeName = 0;
2091
        tininessCode = float_tininess_after_rounding;
2092
        break;
2093
     case TININESS_BEFORE_ROUNDING:
2094
        tininessModeName = "before";
2095
        tininessCode = float_tininess_before_rounding;
2096
        break;
2097
     case TININESS_AFTER_ROUNDING:
2098
        tininessModeName = "after";
2099
        tininessCode = float_tininess_after_rounding;
2100
        break;
2101
    }
2102
    float_detect_tininess = tininessCode;
2103
    switch ( functionCode ) {
2104
     case INT32_TO_FLOAT32:
2105
        time_a_int32_z_float32( int32_to_float32 );
2106
        break;
2107
     case INT32_TO_FLOAT64:
2108
        time_a_int32_z_float64( int32_to_float64 );
2109
        break;
2110
#ifdef FLOATX80
2111
     case INT32_TO_FLOATX80:
2112
        time_a_int32_z_floatx80( int32_to_floatx80 );
2113
        break;
2114
#endif
2115
#ifdef FLOAT128
2116
     case INT32_TO_FLOAT128:
2117
        time_a_int32_z_float128( int32_to_float128 );
2118
        break;
2119
#endif
2120
     case INT64_TO_FLOAT32:
2121
        time_a_int64_z_float32( int64_to_float32 );
2122
        break;
2123
     case INT64_TO_FLOAT64:
2124
        time_a_int64_z_float64( int64_to_float64 );
2125
        break;
2126
#ifdef FLOATX80
2127
     case INT64_TO_FLOATX80:
2128
        time_a_int64_z_floatx80( int64_to_floatx80 );
2129
        break;
2130
#endif
2131
#ifdef FLOAT128
2132
     case INT64_TO_FLOAT128:
2133
        time_a_int64_z_float128( int64_to_float128 );
2134
        break;
2135
#endif
2136
     case FLOAT32_TO_INT32:
2137
        time_a_float32_z_int32( float32_to_int32 );
2138
        break;
2139
     case FLOAT32_TO_INT32_ROUND_TO_ZERO:
2140
        time_a_float32_z_int32( float32_to_int32_round_to_zero );
2141
        break;
2142
     case FLOAT32_TO_INT64:
2143
        time_a_float32_z_int64( float32_to_int64 );
2144
        break;
2145
     case FLOAT32_TO_INT64_ROUND_TO_ZERO:
2146
        time_a_float32_z_int64( float32_to_int64_round_to_zero );
2147
        break;
2148
     case FLOAT32_TO_FLOAT64:
2149
        time_a_float32_z_float64( float32_to_float64 );
2150
        break;
2151
#ifdef FLOATX80
2152
     case FLOAT32_TO_FLOATX80:
2153
        time_a_float32_z_floatx80( float32_to_floatx80 );
2154
        break;
2155
#endif
2156
#ifdef FLOAT128
2157
     case FLOAT32_TO_FLOAT128:
2158
        time_a_float32_z_float128( float32_to_float128 );
2159
        break;
2160
#endif
2161
     case FLOAT32_ROUND_TO_INT:
2162
        time_az_float32( float32_round_to_int );
2163
        break;
2164
     case FLOAT32_ADD:
2165
        time_abz_float32( float32_add );
2166
        break;
2167
     case FLOAT32_SUB:
2168
        time_abz_float32( float32_sub );
2169
        break;
2170
     case FLOAT32_MUL:
2171
        time_abz_float32( float32_mul );
2172
        break;
2173
     case FLOAT32_DIV:
2174
        time_abz_float32( float32_div );
2175
        break;
2176
     case FLOAT32_REM:
2177
        time_abz_float32( float32_rem );
2178
        break;
2179
     case FLOAT32_SQRT:
2180
        time_az_float32_pos( float32_sqrt );
2181
        break;
2182
     case FLOAT32_EQ:
2183
        time_ab_float32_z_flag( float32_eq );
2184
        break;
2185
     case FLOAT32_LE:
2186
        time_ab_float32_z_flag( float32_le );
2187
        break;
2188
     case FLOAT32_LT:
2189
        time_ab_float32_z_flag( float32_lt );
2190
        break;
2191
     case FLOAT32_EQ_SIGNALING:
2192
        time_ab_float32_z_flag( float32_eq_signaling );
2193
        break;
2194
     case FLOAT32_LE_QUIET:
2195
        time_ab_float32_z_flag( float32_le_quiet );
2196
        break;
2197
     case FLOAT32_LT_QUIET:
2198
        time_ab_float32_z_flag( float32_lt_quiet );
2199
        break;
2200
     case FLOAT64_TO_INT32:
2201
        time_a_float64_z_int32( float64_to_int32 );
2202
        break;
2203
     case FLOAT64_TO_INT32_ROUND_TO_ZERO:
2204
        time_a_float64_z_int32( float64_to_int32_round_to_zero );
2205
        break;
2206
     case FLOAT64_TO_INT64:
2207
        time_a_float64_z_int64( float64_to_int64 );
2208
        break;
2209
     case FLOAT64_TO_INT64_ROUND_TO_ZERO:
2210
        time_a_float64_z_int64( float64_to_int64_round_to_zero );
2211
        break;
2212
     case FLOAT64_TO_FLOAT32:
2213
        time_a_float64_z_float32( float64_to_float32 );
2214
        break;
2215
#ifdef FLOATX80
2216
     case FLOAT64_TO_FLOATX80:
2217
        time_a_float64_z_floatx80( float64_to_floatx80 );
2218
        break;
2219
#endif
2220
#ifdef FLOAT128
2221
     case FLOAT64_TO_FLOAT128:
2222
        time_a_float64_z_float128( float64_to_float128 );
2223
        break;
2224
#endif
2225
     case FLOAT64_ROUND_TO_INT:
2226
        time_az_float64( float64_round_to_int );
2227
        break;
2228
     case FLOAT64_ADD:
2229
        time_abz_float64( float64_add );
2230
        break;
2231
     case FLOAT64_SUB:
2232
        time_abz_float64( float64_sub );
2233
        break;
2234
     case FLOAT64_MUL:
2235
        time_abz_float64( float64_mul );
2236
        break;
2237
     case FLOAT64_DIV:
2238
        time_abz_float64( float64_div );
2239
        break;
2240
     case FLOAT64_REM:
2241
        time_abz_float64( float64_rem );
2242
        break;
2243
     case FLOAT64_SQRT:
2244
        time_az_float64_pos( float64_sqrt );
2245
        break;
2246
     case FLOAT64_EQ:
2247
        time_ab_float64_z_flag( float64_eq );
2248
        break;
2249
     case FLOAT64_LE:
2250
        time_ab_float64_z_flag( float64_le );
2251
        break;
2252
     case FLOAT64_LT:
2253
        time_ab_float64_z_flag( float64_lt );
2254
        break;
2255
     case FLOAT64_EQ_SIGNALING:
2256
        time_ab_float64_z_flag( float64_eq_signaling );
2257
        break;
2258
     case FLOAT64_LE_QUIET:
2259
        time_ab_float64_z_flag( float64_le_quiet );
2260
        break;
2261
     case FLOAT64_LT_QUIET:
2262
        time_ab_float64_z_flag( float64_lt_quiet );
2263
        break;
2264
#ifdef FLOATX80
2265
     case FLOATX80_TO_INT32:
2266
        time_a_floatx80_z_int32( floatx80_to_int32 );
2267
        break;
2268
     case FLOATX80_TO_INT32_ROUND_TO_ZERO:
2269
        time_a_floatx80_z_int32( floatx80_to_int32_round_to_zero );
2270
        break;
2271
     case FLOATX80_TO_INT64:
2272
        time_a_floatx80_z_int64( floatx80_to_int64 );
2273
        break;
2274
     case FLOATX80_TO_INT64_ROUND_TO_ZERO:
2275
        time_a_floatx80_z_int64( floatx80_to_int64_round_to_zero );
2276
        break;
2277
     case FLOATX80_TO_FLOAT32:
2278
        time_a_floatx80_z_float32( floatx80_to_float32 );
2279
        break;
2280
     case FLOATX80_TO_FLOAT64:
2281
        time_a_floatx80_z_float64( floatx80_to_float64 );
2282
        break;
2283
#ifdef FLOAT128
2284
     case FLOATX80_TO_FLOAT128:
2285
        time_a_floatx80_z_float128( floatx80_to_float128 );
2286
        break;
2287
#endif
2288
     case FLOATX80_ROUND_TO_INT:
2289
        time_az_floatx80( floatx80_round_to_int );
2290
        break;
2291
     case FLOATX80_ADD:
2292
        time_abz_floatx80( floatx80_add );
2293
        break;
2294
     case FLOATX80_SUB:
2295
        time_abz_floatx80( floatx80_sub );
2296
        break;
2297
     case FLOATX80_MUL:
2298
        time_abz_floatx80( floatx80_mul );
2299
        break;
2300
     case FLOATX80_DIV:
2301
        time_abz_floatx80( floatx80_div );
2302
        break;
2303
     case FLOATX80_REM:
2304
        time_abz_floatx80( floatx80_rem );
2305
        break;
2306
     case FLOATX80_SQRT:
2307
        time_az_floatx80_pos( floatx80_sqrt );
2308
        break;
2309
     case FLOATX80_EQ:
2310
        time_ab_floatx80_z_flag( floatx80_eq );
2311
        break;
2312
     case FLOATX80_LE:
2313
        time_ab_floatx80_z_flag( floatx80_le );
2314
        break;
2315
     case FLOATX80_LT:
2316
        time_ab_floatx80_z_flag( floatx80_lt );
2317
        break;
2318
     case FLOATX80_EQ_SIGNALING:
2319
        time_ab_floatx80_z_flag( floatx80_eq_signaling );
2320
        break;
2321
     case FLOATX80_LE_QUIET:
2322
        time_ab_floatx80_z_flag( floatx80_le_quiet );
2323
        break;
2324
     case FLOATX80_LT_QUIET:
2325
        time_ab_floatx80_z_flag( floatx80_lt_quiet );
2326
        break;
2327
#endif
2328
#ifdef FLOAT128
2329
     case FLOAT128_TO_INT32:
2330
        time_a_float128_z_int32( float128_to_int32 );
2331
        break;
2332
     case FLOAT128_TO_INT32_ROUND_TO_ZERO:
2333
        time_a_float128_z_int32( float128_to_int32_round_to_zero );
2334
        break;
2335
     case FLOAT128_TO_INT64:
2336
        time_a_float128_z_int64( float128_to_int64 );
2337
        break;
2338
     case FLOAT128_TO_INT64_ROUND_TO_ZERO:
2339
        time_a_float128_z_int64( float128_to_int64_round_to_zero );
2340
        break;
2341
     case FLOAT128_TO_FLOAT32:
2342
        time_a_float128_z_float32( float128_to_float32 );
2343
        break;
2344
     case FLOAT128_TO_FLOAT64:
2345
        time_a_float128_z_float64( float128_to_float64 );
2346
        break;
2347
#ifdef FLOATX80
2348
     case FLOAT128_TO_FLOATX80:
2349
        time_a_float128_z_floatx80( float128_to_floatx80 );
2350
        break;
2351
#endif
2352
     case FLOAT128_ROUND_TO_INT:
2353
        time_az_float128( float128_round_to_int );
2354
        break;
2355
     case FLOAT128_ADD:
2356
        time_abz_float128( float128_add );
2357
        break;
2358
     case FLOAT128_SUB:
2359
        time_abz_float128( float128_sub );
2360
        break;
2361
     case FLOAT128_MUL:
2362
        time_abz_float128( float128_mul );
2363
        break;
2364
     case FLOAT128_DIV:
2365
        time_abz_float128( float128_div );
2366
        break;
2367
     case FLOAT128_REM:
2368
        time_abz_float128( float128_rem );
2369
        break;
2370
     case FLOAT128_SQRT:
2371
        time_az_float128_pos( float128_sqrt );
2372
        break;
2373
     case FLOAT128_EQ:
2374
        time_ab_float128_z_flag( float128_eq );
2375
        break;
2376
     case FLOAT128_LE:
2377
        time_ab_float128_z_flag( float128_le );
2378
        break;
2379
     case FLOAT128_LT:
2380
        time_ab_float128_z_flag( float128_lt );
2381
        break;
2382
     case FLOAT128_EQ_SIGNALING:
2383
        time_ab_float128_z_flag( float128_eq_signaling );
2384
        break;
2385
     case FLOAT128_LE_QUIET:
2386
        time_ab_float128_z_flag( float128_le_quiet );
2387
        break;
2388
     case FLOAT128_LT_QUIET:
2389
        time_ab_float128_z_flag( float128_lt_quiet );
2390
        break;
2391
#endif
2392
    }
2393
 
2394
}
2395
 
2396
static void
2397
 timeFunction(
2398
     uint8 functionCode,
2399
     int8 roundingPrecisionIn,
2400
     int8 roundingModeIn,
2401
     int8 tininessModeIn
2402
 )
2403
{
2404
    int8 roundingPrecision, roundingMode, tininessMode;
2405
 
2406
    roundingPrecision = 32;
2407
    for (;;) {
2408
        if ( ! functions[ functionCode ].roundingPrecision ) {
2409
            roundingPrecision = 0;
2410
        }
2411
        else if ( roundingPrecisionIn ) {
2412
            roundingPrecision = roundingPrecisionIn;
2413
        }
2414
        for ( roundingMode = 1;
2415
              roundingMode < NUM_ROUNDINGMODES;
2416
              ++roundingMode
2417
            ) {
2418
            if ( ! functions[ functionCode ].roundingMode ) {
2419
                roundingMode = 0;
2420
            }
2421
            else if ( roundingModeIn ) {
2422
                roundingMode = roundingModeIn;
2423
            }
2424
            for ( tininessMode = 1;
2425
                  tininessMode < NUM_TININESSMODES;
2426
                  ++tininessMode
2427
                ) {
2428
                if (    ( roundingPrecision == 32 )
2429
                     || ( roundingPrecision == 64 ) ) {
2430
                    if ( ! functions[ functionCode ]
2431
                               .tininessModeAtReducedPrecision
2432
                       ) {
2433
                        tininessMode = 0;
2434
                    }
2435
                    else if ( tininessModeIn ) {
2436
                        tininessMode = tininessModeIn;
2437
                    }
2438
                }
2439
                else {
2440
                    if ( ! functions[ functionCode ].tininessMode ) {
2441
                        tininessMode = 0;
2442
                    }
2443
                    else if ( tininessModeIn ) {
2444
                        tininessMode = tininessModeIn;
2445
                    }
2446
                }
2447
                timeFunctionVariety(
2448
                    functionCode, roundingPrecision, roundingMode, tininessMode
2449
                );
2450
                if ( tininessModeIn || ! tininessMode ) break;
2451
            }
2452
            if ( roundingModeIn || ! roundingMode ) break;
2453
        }
2454
        if ( roundingPrecisionIn || ! roundingPrecision ) break;
2455
        if ( roundingPrecision == 80 ) {
2456
            break;
2457
        }
2458
        else if ( roundingPrecision == 64 ) {
2459
            roundingPrecision = 80;
2460
        }
2461
        else if ( roundingPrecision == 32 ) {
2462
            roundingPrecision = 64;
2463
        }
2464
    }
2465
 
2466
}
2467
 
2468
main( int argc, char **argv )
2469
{
2470
    char *argPtr;
2471
    flag functionArgument;
2472
    uint8 functionCode;
2473
    int8 operands, roundingPrecision, roundingMode, tininessMode;
2474
 
2475
    if ( argc <= 1 ) goto writeHelpMessage;
2476
    functionArgument = FALSE;
2477
    functionCode = 0;
2478
    operands = 0;
2479
    roundingPrecision = 0;
2480
    roundingMode = 0;
2481
    tininessMode = 0;
2482
    --argc;
2483
    ++argv;
2484
    while ( argc && ( argPtr = argv[ 0 ] ) ) {
2485
        if ( argPtr[ 0 ] == '-' ) ++argPtr;
2486
        if ( strcmp( argPtr, "help" ) == 0 ) {
2487
 writeHelpMessage:
2488
            fputs(
2489
"timesoftfloat [<option>...] <function>\n"
2490
"  <option>:  (* is default)\n"
2491
"    -help            --Write this message and exit.\n"
2492
#ifdef FLOATX80
2493
"    -precision32     --Only time rounding precision equivalent to float32.\n"
2494
"    -precision64     --Only time rounding precision equivalent to float64.\n"
2495
"    -precision80     --Only time maximum rounding precision.\n"
2496
#endif
2497
"    -nearesteven     --Only time rounding to nearest/even.\n"
2498
"    -tozero          --Only time rounding to zero.\n"
2499
"    -down            --Only time rounding down.\n"
2500
"    -up              --Only time rounding up.\n"
2501
"    -tininessbefore  --Only time underflow tininess before rounding.\n"
2502
"    -tininessafter   --Only time underflow tininess after rounding.\n"
2503
"  <function>:\n"
2504
"    int32_to_<float>                 <float>_add   <float>_eq\n"
2505
"    <float>_to_int32                 <float>_sub   <float>_le\n"
2506
"    <float>_to_int32_round_to_zero   <float>_mul   <float>_lt\n"
2507
"    int64_to_<float>                 <float>_div   <float>_eq_signaling\n"
2508
"    <float>_to_int64                 <float>_rem   <float>_le_quiet\n"
2509
"    <float>_to_int64_round_to_zero                 <float>_lt_quiet\n"
2510
"    <float>_to_<float>\n"
2511
"    <float>_round_to_int\n"
2512
"    <float>_sqrt\n"
2513
"    -all1            --All 1-operand functions.\n"
2514
"    -all2            --All 2-operand functions.\n"
2515
"    -all             --All functions.\n"
2516
"  <float>:\n"
2517
"    float32          --Single precision.\n"
2518
"    float64          --Double precision.\n"
2519
#ifdef FLOATX80
2520
"    floatx80         --Extended double precision.\n"
2521
#endif
2522
#ifdef FLOAT128
2523
"    float128         --Quadruple precision.\n"
2524
#endif
2525
                ,
2526
                stdout
2527
            );
2528
            return EXIT_SUCCESS;
2529
        }
2530
#ifdef FLOATX80
2531
        else if ( strcmp( argPtr, "precision32" ) == 0 ) {
2532
            roundingPrecision = 32;
2533
        }
2534
        else if ( strcmp( argPtr, "precision64" ) == 0 ) {
2535
            roundingPrecision = 64;
2536
        }
2537
        else if ( strcmp( argPtr, "precision80" ) == 0 ) {
2538
            roundingPrecision = 80;
2539
        }
2540
#endif
2541
        else if (    ( strcmp( argPtr, "nearesteven" ) == 0 )
2542
                  || ( strcmp( argPtr, "nearest_even" ) == 0 ) ) {
2543
            roundingMode = ROUND_NEAREST_EVEN;
2544
        }
2545
        else if (    ( strcmp( argPtr, "tozero" ) == 0 )
2546
                  || ( strcmp( argPtr, "to_zero" ) == 0 ) ) {
2547
            roundingMode = ROUND_TO_ZERO;
2548
        }
2549
        else if ( strcmp( argPtr, "down" ) == 0 ) {
2550
            roundingMode = ROUND_DOWN;
2551
        }
2552
        else if ( strcmp( argPtr, "up" ) == 0 ) {
2553
            roundingMode = ROUND_UP;
2554
        }
2555
        else if ( strcmp( argPtr, "tininessbefore" ) == 0 ) {
2556
            tininessMode = TININESS_BEFORE_ROUNDING;
2557
        }
2558
        else if ( strcmp( argPtr, "tininessafter" ) == 0 ) {
2559
            tininessMode = TININESS_AFTER_ROUNDING;
2560
        }
2561
        else if ( strcmp( argPtr, "all1" ) == 0 ) {
2562
            functionArgument = TRUE;
2563
            functionCode = 0;
2564
            operands = 1;
2565
        }
2566
        else if ( strcmp( argPtr, "all2" ) == 0 ) {
2567
            functionArgument = TRUE;
2568
            functionCode = 0;
2569
            operands = 2;
2570
        }
2571
        else if ( strcmp( argPtr, "all" ) == 0 ) {
2572
            functionArgument = TRUE;
2573
            functionCode = 0;
2574
            operands = 0;
2575
        }
2576
        else {
2577
            for ( functionCode = 1;
2578
                  functionCode < NUM_FUNCTIONS;
2579
                  ++functionCode
2580
                ) {
2581
                if ( strcmp( argPtr, functions[ functionCode ].name ) == 0 ) {
2582
                    break;
2583
                }
2584
            }
2585
            if ( functionCode == NUM_FUNCTIONS ) {
2586
                fail( "Invalid option or function `%s'", argv[ 0 ] );
2587
            }
2588
            functionArgument = TRUE;
2589
        }
2590
        --argc;
2591
        ++argv;
2592
    }
2593
    if ( ! functionArgument ) fail( "Function argument required" );
2594
    if ( functionCode ) {
2595
        timeFunction(
2596
            functionCode, roundingPrecision, roundingMode, tininessMode );
2597
    }
2598
    else if ( operands == 1 ) {
2599
        for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2600
            ) {
2601
            if ( functions[ functionCode ].numInputs == 1 ) {
2602
                timeFunction(
2603
                    functionCode, roundingPrecision, roundingMode, tininessMode
2604
                );
2605
            }
2606
        }
2607
    }
2608
    else if ( operands == 2 ) {
2609
        for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2610
            ) {
2611
            if ( functions[ functionCode ].numInputs == 2 ) {
2612
                timeFunction(
2613
                    functionCode, roundingPrecision, roundingMode, tininessMode
2614
                );
2615
            }
2616
        }
2617
    }
2618
    else {
2619
        for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2620
            ) {
2621
            timeFunction(
2622
                functionCode, roundingPrecision, roundingMode, tininessMode );
2623
        }
2624
    }
2625
    return EXIT_SUCCESS;
2626
 
2627
}
2628
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.