1 /* $NetBSD: timesoftfloat.c,v 1.1 2000/06/06 08:15:11 bjh21 Exp $ */
4 ===============================================================================
6 This C source file is part of the SoftFloat IEC/IEEE Floating-point
7 Arithmetic Package, Release 2a.
9 Written by John R. Hauser. This work was made possible in part by the
10 International Computer Science Institute, located at Suite 600, 1947 Center
11 Street, Berkeley, California 94704. Funding was partially provided by the
12 National Science Foundation under grant MIP-9311980. The original version
13 of this code was written as part of a project to build a fixed-point vector
14 processor in collaboration with the University of California at Berkeley,
15 overseen by Profs. Nelson Morgan and John Wawrzynek. More information
16 is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
17 arithmetic/SoftFloat.html'.
19 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
20 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
21 TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
22 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
23 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
25 Derivative works are acceptable, even for commercial purposes, so long as
26 (1) they include prominent notice that the work is derivative, and (2) they
27 include prominent notice akin to these four paragraphs for those parts of
28 this code that are retained.
30 ===============================================================================
33 #include <sys/cdefs.h>
40 #include "softfloat.h"
46 static void fail( const char *message, ... )
50 fputs( "timesoftfloat: ", stderr );
51 va_start( varArgs, message );
52 vfprintf( stderr, message, varArgs );
54 fputs( ".\n", stderr );
59 static char *functionName;
60 static char *roundingPrecisionName, *roundingModeName, *tininessModeName;
62 static void reportTime( int32 count, long clocks )
67 ( count / ( ( (float) clocks ) / CLOCKS_PER_SEC ) ) / 1000,
70 if ( roundingModeName ) {
71 if ( roundingPrecisionName ) {
72 fputs( ", precision ", stdout );
73 fputs( roundingPrecisionName, stdout );
75 fputs( ", rounding ", stdout );
76 fputs( roundingModeName, stdout );
77 if ( tininessModeName ) {
78 fputs( ", tininess ", stdout );
79 fputs( tininessModeName, stdout );
80 fputs( " rounding", stdout );
83 fputc( '\n', stdout );
91 static const int32 inputs_int32[ numInputs_int32 ] = {
92 0xFFFFBB79, 0x405CF80F, 0x00000000, 0xFFFFFD04,
93 0xFFF20002, 0x0C8EF795, 0xF00011FF, 0x000006CA,
94 0x00009BFE, 0xFF4862E3, 0x9FFFEFFE, 0xFFFFFFB7,
95 0x0BFF7FFF, 0x0000F37A, 0x0011DFFE, 0x00000006,
96 0xFFF02006, 0xFFFFF7D1, 0x10200003, 0xDE8DF765,
97 0x00003E02, 0x000019E8, 0x0008FFFE, 0xFFFFFB5C,
98 0xFFDF7FFE, 0x07C42FBF, 0x0FFFE3FF, 0x040B9F13,
99 0xBFFFFFF8, 0x0001BF56, 0x000017F6, 0x000A908A
102 static void time_a_int32_z_float32( float32 function( int32 ) )
104 clock_t startClock, endClock;
110 startClock = clock();
112 for ( i = minIterations; i; --i ) {
113 function( inputs_int32[ inputNum ] );
114 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
116 count += minIterations;
117 } while ( clock() - startClock < CLOCKS_PER_SEC );
119 startClock = clock();
120 for ( i = count; i; --i ) {
121 function( inputs_int32[ inputNum ] );
122 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
125 reportTime( count, endClock - startClock );
129 static void time_a_int32_z_float64( float64 function( int32 ) )
131 clock_t startClock, endClock;
137 startClock = clock();
139 for ( i = minIterations; i; --i ) {
140 function( inputs_int32[ inputNum ] );
141 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
143 count += minIterations;
144 } while ( clock() - startClock < CLOCKS_PER_SEC );
146 startClock = clock();
147 for ( i = count; i; --i ) {
148 function( inputs_int32[ inputNum ] );
149 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
152 reportTime( count, endClock - startClock );
158 static void time_a_int32_z_floatx80( floatx80 function( int32 ) )
160 clock_t startClock, endClock;
166 startClock = clock();
168 for ( i = minIterations; i; --i ) {
169 function( inputs_int32[ inputNum ] );
170 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
172 count += minIterations;
173 } while ( clock() - startClock < CLOCKS_PER_SEC );
175 startClock = clock();
176 for ( i = count; i; --i ) {
177 function( inputs_int32[ inputNum ] );
178 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
181 reportTime( count, endClock - startClock );
189 static void time_a_int32_z_float128( float128 function( int32 ) )
191 clock_t startClock, endClock;
197 startClock = clock();
199 for ( i = minIterations; i; --i ) {
200 function( inputs_int32[ inputNum ] );
201 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
203 count += minIterations;
204 } while ( clock() - startClock < CLOCKS_PER_SEC );
206 startClock = clock();
207 for ( i = count; i; --i ) {
208 function( inputs_int32[ inputNum ] );
209 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
212 reportTime( count, endClock - startClock );
222 static const int64 inputs_int64[ numInputs_int64 ] = {
223 LIT64( 0xFBFFC3FFFFFFFFFF ),
224 LIT64( 0x0000000003C589BC ),
225 LIT64( 0x00000000400013FE ),
226 LIT64( 0x0000000000186171 ),
227 LIT64( 0xFFFFFFFFFFFEFBFA ),
228 LIT64( 0xFFFFFD79E6DFFC73 ),
229 LIT64( 0x0000000010001DFF ),
230 LIT64( 0xDD1A0F0C78513710 ),
231 LIT64( 0xFFFF83FFFFFEFFFE ),
232 LIT64( 0x00756EBD1AD0C1C7 ),
233 LIT64( 0x0003FDFFFFFFFFBE ),
234 LIT64( 0x0007D0FB2C2CA951 ),
235 LIT64( 0x0007FC0007FFFFFE ),
236 LIT64( 0x0000001F942B18BB ),
237 LIT64( 0x0000080101FFFFFE ),
238 LIT64( 0xFFFFFFFFFFFF0978 ),
239 LIT64( 0x000000000008BFFF ),
240 LIT64( 0x0000000006F5AF08 ),
241 LIT64( 0xFFDEFF7FFFFFFFFE ),
242 LIT64( 0x0000000000000003 ),
243 LIT64( 0x3FFFFFFFFF80007D ),
244 LIT64( 0x0000000000000078 ),
245 LIT64( 0xFFF80000007FDFFD ),
246 LIT64( 0x1BBC775B78016AB0 ),
247 LIT64( 0xFFF9001FFFFFFFFE ),
248 LIT64( 0xFFFD4767AB98E43F ),
249 LIT64( 0xFFFFFEFFFE00001E ),
250 LIT64( 0xFFFFFFFFFFF04EFD ),
251 LIT64( 0x07FFFFFFFFFFF7FF ),
252 LIT64( 0xFFFC9EAA38F89050 ),
253 LIT64( 0x00000020FBFFFFFE ),
254 LIT64( 0x0000099AE6455357 )
257 static void time_a_int64_z_float32( float32 function( int64 ) )
259 clock_t startClock, endClock;
265 startClock = clock();
267 for ( i = minIterations; i; --i ) {
268 function( inputs_int64[ inputNum ] );
269 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
271 count += minIterations;
272 } while ( clock() - startClock < CLOCKS_PER_SEC );
274 startClock = clock();
275 for ( i = count; i; --i ) {
276 function( inputs_int64[ inputNum ] );
277 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
280 reportTime( count, endClock - startClock );
284 static void time_a_int64_z_float64( float64 function( int64 ) )
286 clock_t startClock, endClock;
292 startClock = clock();
294 for ( i = minIterations; i; --i ) {
295 function( inputs_int64[ inputNum ] );
296 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
298 count += minIterations;
299 } while ( clock() - startClock < CLOCKS_PER_SEC );
301 startClock = clock();
302 for ( i = count; i; --i ) {
303 function( inputs_int64[ inputNum ] );
304 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
307 reportTime( count, endClock - startClock );
313 static void time_a_int64_z_floatx80( floatx80 function( int64 ) )
315 clock_t startClock, endClock;
321 startClock = clock();
323 for ( i = minIterations; i; --i ) {
324 function( inputs_int64[ inputNum ] );
325 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
327 count += minIterations;
328 } while ( clock() - startClock < CLOCKS_PER_SEC );
330 startClock = clock();
331 for ( i = count; i; --i ) {
332 function( inputs_int64[ inputNum ] );
333 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
336 reportTime( count, endClock - startClock );
344 static void time_a_int64_z_float128( float128 function( int64 ) )
346 clock_t startClock, endClock;
352 startClock = clock();
354 for ( i = minIterations; i; --i ) {
355 function( inputs_int64[ inputNum ] );
356 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
358 count += minIterations;
359 } while ( clock() - startClock < CLOCKS_PER_SEC );
361 startClock = clock();
362 for ( i = count; i; --i ) {
363 function( inputs_int64[ inputNum ] );
364 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
367 reportTime( count, endClock - startClock );
374 numInputs_float32 = 32
377 static const float32 inputs_float32[ numInputs_float32 ] = {
378 0x4EFA0000, 0xC1D0B328, 0x80000000, 0x3E69A31E,
379 0xAF803EFF, 0x3F800000, 0x17BF8000, 0xE74A301A,
380 0x4E010003, 0x7EE3C75D, 0xBD803FE0, 0xBFFEFF00,
381 0x7981F800, 0x431FFFFC, 0xC100C000, 0x3D87EFFF,
382 0x4103FEFE, 0xBC000007, 0xBF01F7FF, 0x4E6C6B5C,
383 0xC187FFFE, 0xC58B9F13, 0x4F88007F, 0xDF004007,
384 0xB7FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,
385 0xDB428661, 0x33F89B1F, 0xA3BFEFFF, 0x537BFFBE
388 static void time_a_float32_z_int32( int32 function( float32 ) )
390 clock_t startClock, endClock;
396 startClock = clock();
398 for ( i = minIterations; i; --i ) {
399 function( inputs_float32[ inputNum ] );
400 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
402 count += minIterations;
403 } while ( clock() - startClock < CLOCKS_PER_SEC );
405 startClock = clock();
406 for ( i = count; i; --i ) {
407 function( inputs_float32[ inputNum ] );
408 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
411 reportTime( count, endClock - startClock );
415 static void time_a_float32_z_int64( int64 function( float32 ) )
417 clock_t startClock, endClock;
423 startClock = clock();
425 for ( i = minIterations; i; --i ) {
426 function( inputs_float32[ inputNum ] );
427 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
429 count += minIterations;
430 } while ( clock() - startClock < CLOCKS_PER_SEC );
432 startClock = clock();
433 for ( i = count; i; --i ) {
434 function( inputs_float32[ inputNum ] );
435 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
438 reportTime( count, endClock - startClock );
442 static void time_a_float32_z_float64( float64 function( float32 ) )
444 clock_t startClock, endClock;
450 startClock = clock();
452 for ( i = minIterations; i; --i ) {
453 function( inputs_float32[ inputNum ] );
454 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
456 count += minIterations;
457 } while ( clock() - startClock < CLOCKS_PER_SEC );
459 startClock = clock();
460 for ( i = count; i; --i ) {
461 function( inputs_float32[ inputNum ] );
462 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
465 reportTime( count, endClock - startClock );
471 static void time_a_float32_z_floatx80( floatx80 function( float32 ) )
473 clock_t startClock, endClock;
479 startClock = clock();
481 for ( i = minIterations; i; --i ) {
482 function( inputs_float32[ inputNum ] );
483 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
485 count += minIterations;
486 } while ( clock() - startClock < CLOCKS_PER_SEC );
488 startClock = clock();
489 for ( i = count; i; --i ) {
490 function( inputs_float32[ inputNum ] );
491 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
494 reportTime( count, endClock - startClock );
502 static void time_a_float32_z_float128( float128 function( float32 ) )
504 clock_t startClock, endClock;
510 startClock = clock();
512 for ( i = minIterations; i; --i ) {
513 function( inputs_float32[ inputNum ] );
514 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
516 count += minIterations;
517 } while ( clock() - startClock < CLOCKS_PER_SEC );
519 startClock = clock();
520 for ( i = count; i; --i ) {
521 function( inputs_float32[ inputNum ] );
522 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
525 reportTime( count, endClock - startClock );
531 static void time_az_float32( float32 function( float32 ) )
533 clock_t startClock, endClock;
539 startClock = clock();
541 for ( i = minIterations; i; --i ) {
542 function( inputs_float32[ inputNum ] );
543 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
545 count += minIterations;
546 } while ( clock() - startClock < CLOCKS_PER_SEC );
548 startClock = clock();
549 for ( i = count; i; --i ) {
550 function( inputs_float32[ inputNum ] );
551 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
554 reportTime( count, endClock - startClock );
558 static void time_ab_float32_z_flag( flag function( float32, float32 ) )
560 clock_t startClock, endClock;
562 int8 inputNumA, inputNumB;
567 startClock = clock();
569 for ( i = minIterations; i; --i ) {
571 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
572 inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
573 if ( inputNumA == 0 ) ++inputNumB;
574 inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
576 count += minIterations;
577 } while ( clock() - startClock < CLOCKS_PER_SEC );
580 startClock = clock();
581 for ( i = count; i; --i ) {
583 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
584 inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
585 if ( inputNumA == 0 ) ++inputNumB;
586 inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
589 reportTime( count, endClock - startClock );
593 static void time_abz_float32( float32 function( float32, float32 ) )
595 clock_t startClock, endClock;
597 int8 inputNumA, inputNumB;
602 startClock = clock();
604 for ( i = minIterations; i; --i ) {
606 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
607 inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
608 if ( inputNumA == 0 ) ++inputNumB;
609 inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
611 count += minIterations;
612 } while ( clock() - startClock < CLOCKS_PER_SEC );
615 startClock = clock();
616 for ( i = count; i; --i ) {
618 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
619 inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
620 if ( inputNumA == 0 ) ++inputNumB;
621 inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
624 reportTime( count, endClock - startClock );
628 static const float32 inputs_float32_pos[ numInputs_float32 ] = {
629 0x4EFA0000, 0x41D0B328, 0x00000000, 0x3E69A31E,
630 0x2F803EFF, 0x3F800000, 0x17BF8000, 0x674A301A,
631 0x4E010003, 0x7EE3C75D, 0x3D803FE0, 0x3FFEFF00,
632 0x7981F800, 0x431FFFFC, 0x4100C000, 0x3D87EFFF,
633 0x4103FEFE, 0x3C000007, 0x3F01F7FF, 0x4E6C6B5C,
634 0x4187FFFE, 0x458B9F13, 0x4F88007F, 0x5F004007,
635 0x37FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,
636 0x5B428661, 0x33F89B1F, 0x23BFEFFF, 0x537BFFBE
639 static void time_az_float32_pos( float32 function( float32 ) )
641 clock_t startClock, endClock;
647 startClock = clock();
649 for ( i = minIterations; i; --i ) {
650 function( inputs_float32_pos[ inputNum ] );
651 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
653 count += minIterations;
654 } while ( clock() - startClock < CLOCKS_PER_SEC );
656 startClock = clock();
657 for ( i = count; i; --i ) {
658 function( inputs_float32_pos[ inputNum ] );
659 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
662 reportTime( count, endClock - startClock );
667 numInputs_float64 = 32
670 static const float64 inputs_float64[ numInputs_float64 ] = {
671 LIT64( 0x422FFFC008000000 ),
672 LIT64( 0xB7E0000480000000 ),
673 LIT64( 0xF3FD2546120B7935 ),
674 LIT64( 0x3FF0000000000000 ),
675 LIT64( 0xCE07F766F09588D6 ),
676 LIT64( 0x8000000000000000 ),
677 LIT64( 0x3FCE000400000000 ),
678 LIT64( 0x8313B60F0032BED8 ),
679 LIT64( 0xC1EFFFFFC0002000 ),
680 LIT64( 0x3FB3C75D224F2B0F ),
681 LIT64( 0x7FD00000004000FF ),
682 LIT64( 0xA12FFF8000001FFF ),
683 LIT64( 0x3EE0000000FE0000 ),
684 LIT64( 0x0010000080000004 ),
685 LIT64( 0x41CFFFFE00000020 ),
686 LIT64( 0x40303FFFFFFFFFFD ),
687 LIT64( 0x3FD000003FEFFFFF ),
688 LIT64( 0xBFD0000010000000 ),
689 LIT64( 0xB7FC6B5C16CA55CF ),
690 LIT64( 0x413EEB940B9D1301 ),
691 LIT64( 0xC7E00200001FFFFF ),
692 LIT64( 0x47F00021FFFFFFFE ),
693 LIT64( 0xBFFFFFFFF80000FF ),
694 LIT64( 0xC07FFFFFE00FFFFF ),
695 LIT64( 0x001497A63740C5E8 ),
696 LIT64( 0xC4BFFFE0001FFFFF ),
697 LIT64( 0x96FFDFFEFFFFFFFF ),
698 LIT64( 0x403FC000000001FE ),
699 LIT64( 0xFFD00000000001F6 ),
700 LIT64( 0x0640400002000000 ),
701 LIT64( 0x479CEE1E4F789FE0 ),
702 LIT64( 0xC237FFFFFFFFFDFE )
705 static void time_a_float64_z_int32( int32 function( float64 ) )
707 clock_t startClock, endClock;
713 startClock = clock();
715 for ( i = minIterations; i; --i ) {
716 function( inputs_float64[ inputNum ] );
717 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
719 count += minIterations;
720 } while ( clock() - startClock < CLOCKS_PER_SEC );
722 startClock = clock();
723 for ( i = count; i; --i ) {
724 function( inputs_float64[ inputNum ] );
725 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
728 reportTime( count, endClock - startClock );
732 static void time_a_float64_z_int64( int64 function( float64 ) )
734 clock_t startClock, endClock;
740 startClock = clock();
742 for ( i = minIterations; i; --i ) {
743 function( inputs_float64[ inputNum ] );
744 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
746 count += minIterations;
747 } while ( clock() - startClock < CLOCKS_PER_SEC );
749 startClock = clock();
750 for ( i = count; i; --i ) {
751 function( inputs_float64[ inputNum ] );
752 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
755 reportTime( count, endClock - startClock );
759 static void time_a_float64_z_float32( float32 function( float64 ) )
761 clock_t startClock, endClock;
767 startClock = clock();
769 for ( i = minIterations; i; --i ) {
770 function( inputs_float64[ inputNum ] );
771 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
773 count += minIterations;
774 } while ( clock() - startClock < CLOCKS_PER_SEC );
776 startClock = clock();
777 for ( i = count; i; --i ) {
778 function( inputs_float64[ inputNum ] );
779 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
782 reportTime( count, endClock - startClock );
788 static void time_a_float64_z_floatx80( floatx80 function( float64 ) )
790 clock_t startClock, endClock;
796 startClock = clock();
798 for ( i = minIterations; i; --i ) {
799 function( inputs_float64[ inputNum ] );
800 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
802 count += minIterations;
803 } while ( clock() - startClock < CLOCKS_PER_SEC );
805 startClock = clock();
806 for ( i = count; i; --i ) {
807 function( inputs_float64[ inputNum ] );
808 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
811 reportTime( count, endClock - startClock );
819 static void time_a_float64_z_float128( float128 function( float64 ) )
821 clock_t startClock, endClock;
827 startClock = clock();
829 for ( i = minIterations; i; --i ) {
830 function( inputs_float64[ inputNum ] );
831 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
833 count += minIterations;
834 } while ( clock() - startClock < CLOCKS_PER_SEC );
836 startClock = clock();
837 for ( i = count; i; --i ) {
838 function( inputs_float64[ inputNum ] );
839 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
842 reportTime( count, endClock - startClock );
848 static void time_az_float64( float64 function( float64 ) )
850 clock_t startClock, endClock;
856 startClock = clock();
858 for ( i = minIterations; i; --i ) {
859 function( inputs_float64[ inputNum ] );
860 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
862 count += minIterations;
863 } while ( clock() - startClock < CLOCKS_PER_SEC );
865 startClock = clock();
866 for ( i = count; i; --i ) {
867 function( inputs_float64[ inputNum ] );
868 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
871 reportTime( count, endClock - startClock );
875 static void time_ab_float64_z_flag( flag function( float64, float64 ) )
877 clock_t startClock, endClock;
879 int8 inputNumA, inputNumB;
884 startClock = clock();
886 for ( i = minIterations; i; --i ) {
888 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
889 inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
890 if ( inputNumA == 0 ) ++inputNumB;
891 inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
893 count += minIterations;
894 } while ( clock() - startClock < CLOCKS_PER_SEC );
897 startClock = clock();
898 for ( i = count; i; --i ) {
900 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
901 inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
902 if ( inputNumA == 0 ) ++inputNumB;
903 inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
906 reportTime( count, endClock - startClock );
910 static void time_abz_float64( float64 function( float64, float64 ) )
912 clock_t startClock, endClock;
914 int8 inputNumA, inputNumB;
919 startClock = clock();
921 for ( i = minIterations; i; --i ) {
923 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
924 inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
925 if ( inputNumA == 0 ) ++inputNumB;
926 inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
928 count += minIterations;
929 } while ( clock() - startClock < CLOCKS_PER_SEC );
932 startClock = clock();
933 for ( i = count; i; --i ) {
935 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
936 inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
937 if ( inputNumA == 0 ) ++inputNumB;
938 inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
941 reportTime( count, endClock - startClock );
945 static const float64 inputs_float64_pos[ numInputs_float64 ] = {
946 LIT64( 0x422FFFC008000000 ),
947 LIT64( 0x37E0000480000000 ),
948 LIT64( 0x73FD2546120B7935 ),
949 LIT64( 0x3FF0000000000000 ),
950 LIT64( 0x4E07F766F09588D6 ),
951 LIT64( 0x0000000000000000 ),
952 LIT64( 0x3FCE000400000000 ),
953 LIT64( 0x0313B60F0032BED8 ),
954 LIT64( 0x41EFFFFFC0002000 ),
955 LIT64( 0x3FB3C75D224F2B0F ),
956 LIT64( 0x7FD00000004000FF ),
957 LIT64( 0x212FFF8000001FFF ),
958 LIT64( 0x3EE0000000FE0000 ),
959 LIT64( 0x0010000080000004 ),
960 LIT64( 0x41CFFFFE00000020 ),
961 LIT64( 0x40303FFFFFFFFFFD ),
962 LIT64( 0x3FD000003FEFFFFF ),
963 LIT64( 0x3FD0000010000000 ),
964 LIT64( 0x37FC6B5C16CA55CF ),
965 LIT64( 0x413EEB940B9D1301 ),
966 LIT64( 0x47E00200001FFFFF ),
967 LIT64( 0x47F00021FFFFFFFE ),
968 LIT64( 0x3FFFFFFFF80000FF ),
969 LIT64( 0x407FFFFFE00FFFFF ),
970 LIT64( 0x001497A63740C5E8 ),
971 LIT64( 0x44BFFFE0001FFFFF ),
972 LIT64( 0x16FFDFFEFFFFFFFF ),
973 LIT64( 0x403FC000000001FE ),
974 LIT64( 0x7FD00000000001F6 ),
975 LIT64( 0x0640400002000000 ),
976 LIT64( 0x479CEE1E4F789FE0 ),
977 LIT64( 0x4237FFFFFFFFFDFE )
980 static void time_az_float64_pos( float64 function( float64 ) )
982 clock_t startClock, endClock;
988 startClock = clock();
990 for ( i = minIterations; i; --i ) {
991 function( inputs_float64_pos[ inputNum ] );
992 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
994 count += minIterations;
995 } while ( clock() - startClock < CLOCKS_PER_SEC );
997 startClock = clock();
998 for ( i = count; i; --i ) {
999 function( inputs_float64_pos[ inputNum ] );
1000 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
1003 reportTime( count, endClock - startClock );
1010 numInputs_floatx80 = 32
1013 static const struct {
1016 } inputs_floatx80[ numInputs_floatx80 ] = {
1017 { 0xC03F, LIT64( 0xA9BE15A19C1E8B62 ) },
1018 { 0x8000, LIT64( 0x0000000000000000 ) },
1019 { 0x75A8, LIT64( 0xE59591E4788957A5 ) },
1020 { 0xBFFF, LIT64( 0xFFF0000000000040 ) },
1021 { 0x0CD8, LIT64( 0xFC000000000007FE ) },
1022 { 0x43BA, LIT64( 0x99A4000000000000 ) },
1023 { 0x3FFF, LIT64( 0x8000000000000000 ) },
1024 { 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },
1025 { 0x403E, LIT64( 0xFFF0000000002000 ) },
1026 { 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },
1027 { 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },
1028 { 0x737A, LIT64( 0x800000007FFDFFFE ) },
1029 { 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },
1030 { 0xBBFE, LIT64( 0x8000040000001FFE ) },
1031 { 0xC002, LIT64( 0xFF80000000000020 ) },
1032 { 0xDE8D, LIT64( 0xFFFFFFFFFFE00004 ) },
1033 { 0xC004, LIT64( 0x8000000000003FFB ) },
1034 { 0x407F, LIT64( 0x800000000003FFFE ) },
1035 { 0xC000, LIT64( 0xA459EE6A5C16CA55 ) },
1036 { 0x8003, LIT64( 0xC42CBF7399AEEB94 ) },
1037 { 0xBF7F, LIT64( 0xF800000000000006 ) },
1038 { 0xC07F, LIT64( 0xBF56BE8871F28FEA ) },
1039 { 0xC07E, LIT64( 0xFFFF77FFFFFFFFFE ) },
1040 { 0xADC9, LIT64( 0x8000000FFFFFFFDE ) },
1041 { 0xC001, LIT64( 0xEFF7FFFFFFFFFFFF ) },
1042 { 0x4001, LIT64( 0xBE84F30125C497A6 ) },
1043 { 0xC06B, LIT64( 0xEFFFFFFFFFFFFFFF ) },
1044 { 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },
1045 { 0x87E9, LIT64( 0x81FFFFFFFFFFFBFF ) },
1046 { 0xA63F, LIT64( 0x801FFFFFFEFFFFFE ) },
1047 { 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },
1048 { 0x4018, LIT64( 0x8000000000080003 ) }
1051 static void time_a_floatx80_z_int32( int32 function( floatx80 ) )
1053 clock_t startClock, endClock;
1060 startClock = clock();
1062 for ( i = minIterations; i; --i ) {
1063 a.low = inputs_floatx80[ inputNum ].low;
1064 a.high = inputs_floatx80[ inputNum ].high;
1066 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1068 count += minIterations;
1069 } while ( clock() - startClock < CLOCKS_PER_SEC );
1071 startClock = clock();
1072 for ( i = count; i; --i ) {
1073 a.low = inputs_floatx80[ inputNum ].low;
1074 a.high = inputs_floatx80[ inputNum ].high;
1076 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1079 reportTime( count, endClock - startClock );
1083 static void time_a_floatx80_z_int64( int64 function( floatx80 ) )
1085 clock_t startClock, endClock;
1092 startClock = clock();
1094 for ( i = minIterations; i; --i ) {
1095 a.low = inputs_floatx80[ inputNum ].low;
1096 a.high = inputs_floatx80[ inputNum ].high;
1098 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1100 count += minIterations;
1101 } while ( clock() - startClock < CLOCKS_PER_SEC );
1103 startClock = clock();
1104 for ( i = count; i; --i ) {
1105 a.low = inputs_floatx80[ inputNum ].low;
1106 a.high = inputs_floatx80[ inputNum ].high;
1108 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1111 reportTime( count, endClock - startClock );
1115 static void time_a_floatx80_z_float32( float32 function( floatx80 ) )
1117 clock_t startClock, endClock;
1124 startClock = clock();
1126 for ( i = minIterations; i; --i ) {
1127 a.low = inputs_floatx80[ inputNum ].low;
1128 a.high = inputs_floatx80[ inputNum ].high;
1130 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1132 count += minIterations;
1133 } while ( clock() - startClock < CLOCKS_PER_SEC );
1135 startClock = clock();
1136 for ( i = count; i; --i ) {
1137 a.low = inputs_floatx80[ inputNum ].low;
1138 a.high = inputs_floatx80[ inputNum ].high;
1140 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1143 reportTime( count, endClock - startClock );
1147 static void time_a_floatx80_z_float64( float64 function( floatx80 ) )
1149 clock_t startClock, endClock;
1156 startClock = clock();
1158 for ( i = minIterations; i; --i ) {
1159 a.low = inputs_floatx80[ inputNum ].low;
1160 a.high = inputs_floatx80[ inputNum ].high;
1162 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1164 count += minIterations;
1165 } while ( clock() - startClock < CLOCKS_PER_SEC );
1167 startClock = clock();
1168 for ( i = count; i; --i ) {
1169 a.low = inputs_floatx80[ inputNum ].low;
1170 a.high = inputs_floatx80[ inputNum ].high;
1172 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1175 reportTime( count, endClock - startClock );
1181 static void time_a_floatx80_z_float128( float128 function( floatx80 ) )
1183 clock_t startClock, endClock;
1190 startClock = clock();
1192 for ( i = minIterations; i; --i ) {
1193 a.low = inputs_floatx80[ inputNum ].low;
1194 a.high = inputs_floatx80[ inputNum ].high;
1196 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1198 count += minIterations;
1199 } while ( clock() - startClock < CLOCKS_PER_SEC );
1201 startClock = clock();
1202 for ( i = count; i; --i ) {
1203 a.low = inputs_floatx80[ inputNum ].low;
1204 a.high = inputs_floatx80[ inputNum ].high;
1206 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1209 reportTime( count, endClock - startClock );
1215 static void time_az_floatx80( floatx80 function( floatx80 ) )
1217 clock_t startClock, endClock;
1224 startClock = clock();
1226 for ( i = minIterations; i; --i ) {
1227 a.low = inputs_floatx80[ inputNum ].low;
1228 a.high = inputs_floatx80[ inputNum ].high;
1230 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1232 count += minIterations;
1233 } while ( clock() - startClock < CLOCKS_PER_SEC );
1235 startClock = clock();
1236 for ( i = count; i; --i ) {
1237 a.low = inputs_floatx80[ inputNum ].low;
1238 a.high = inputs_floatx80[ inputNum ].high;
1240 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1243 reportTime( count, endClock - startClock );
1247 static void time_ab_floatx80_z_flag( flag function( floatx80, floatx80 ) )
1249 clock_t startClock, endClock;
1251 int8 inputNumA, inputNumB;
1257 startClock = clock();
1259 for ( i = minIterations; i; --i ) {
1260 a.low = inputs_floatx80[ inputNumA ].low;
1261 a.high = inputs_floatx80[ inputNumA ].high;
1262 b.low = inputs_floatx80[ inputNumB ].low;
1263 b.high = inputs_floatx80[ inputNumB ].high;
1265 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1266 if ( inputNumA == 0 ) ++inputNumB;
1267 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1269 count += minIterations;
1270 } while ( clock() - startClock < CLOCKS_PER_SEC );
1273 startClock = clock();
1274 for ( i = count; i; --i ) {
1275 a.low = inputs_floatx80[ inputNumA ].low;
1276 a.high = inputs_floatx80[ inputNumA ].high;
1277 b.low = inputs_floatx80[ inputNumB ].low;
1278 b.high = inputs_floatx80[ inputNumB ].high;
1280 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1281 if ( inputNumA == 0 ) ++inputNumB;
1282 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1285 reportTime( count, endClock - startClock );
1289 static void time_abz_floatx80( floatx80 function( floatx80, floatx80 ) )
1291 clock_t startClock, endClock;
1293 int8 inputNumA, inputNumB;
1299 startClock = clock();
1301 for ( i = minIterations; i; --i ) {
1302 a.low = inputs_floatx80[ inputNumA ].low;
1303 a.high = inputs_floatx80[ inputNumA ].high;
1304 b.low = inputs_floatx80[ inputNumB ].low;
1305 b.high = inputs_floatx80[ inputNumB ].high;
1307 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1308 if ( inputNumA == 0 ) ++inputNumB;
1309 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1311 count += minIterations;
1312 } while ( clock() - startClock < CLOCKS_PER_SEC );
1315 startClock = clock();
1316 for ( i = count; i; --i ) {
1317 a.low = inputs_floatx80[ inputNumA ].low;
1318 a.high = inputs_floatx80[ inputNumA ].high;
1319 b.low = inputs_floatx80[ inputNumB ].low;
1320 b.high = inputs_floatx80[ inputNumB ].high;
1322 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1323 if ( inputNumA == 0 ) ++inputNumB;
1324 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1327 reportTime( count, endClock - startClock );
1331 static const struct {
1334 } inputs_floatx80_pos[ numInputs_floatx80 ] = {
1335 { 0x403F, LIT64( 0xA9BE15A19C1E8B62 ) },
1336 { 0x0000, LIT64( 0x0000000000000000 ) },
1337 { 0x75A8, LIT64( 0xE59591E4788957A5 ) },
1338 { 0x3FFF, LIT64( 0xFFF0000000000040 ) },
1339 { 0x0CD8, LIT64( 0xFC000000000007FE ) },
1340 { 0x43BA, LIT64( 0x99A4000000000000 ) },
1341 { 0x3FFF, LIT64( 0x8000000000000000 ) },
1342 { 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },
1343 { 0x403E, LIT64( 0xFFF0000000002000 ) },
1344 { 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },
1345 { 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },
1346 { 0x737A, LIT64( 0x800000007FFDFFFE ) },
1347 { 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },
1348 { 0x3BFE, LIT64( 0x8000040000001FFE ) },
1349 { 0x4002, LIT64( 0xFF80000000000020 ) },
1350 { 0x5E8D, LIT64( 0xFFFFFFFFFFE00004 ) },
1351 { 0x4004, LIT64( 0x8000000000003FFB ) },
1352 { 0x407F, LIT64( 0x800000000003FFFE ) },
1353 { 0x4000, LIT64( 0xA459EE6A5C16CA55 ) },
1354 { 0x0003, LIT64( 0xC42CBF7399AEEB94 ) },
1355 { 0x3F7F, LIT64( 0xF800000000000006 ) },
1356 { 0x407F, LIT64( 0xBF56BE8871F28FEA ) },
1357 { 0x407E, LIT64( 0xFFFF77FFFFFFFFFE ) },
1358 { 0x2DC9, LIT64( 0x8000000FFFFFFFDE ) },
1359 { 0x4001, LIT64( 0xEFF7FFFFFFFFFFFF ) },
1360 { 0x4001, LIT64( 0xBE84F30125C497A6 ) },
1361 { 0x406B, LIT64( 0xEFFFFFFFFFFFFFFF ) },
1362 { 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },
1363 { 0x07E9, LIT64( 0x81FFFFFFFFFFFBFF ) },
1364 { 0x263F, LIT64( 0x801FFFFFFEFFFFFE ) },
1365 { 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },
1366 { 0x4018, LIT64( 0x8000000000080003 ) }
1369 static void time_az_floatx80_pos( floatx80 function( floatx80 ) )
1371 clock_t startClock, endClock;
1378 startClock = clock();
1380 for ( i = minIterations; i; --i ) {
1381 a.low = inputs_floatx80_pos[ inputNum ].low;
1382 a.high = inputs_floatx80_pos[ inputNum ].high;
1384 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1386 count += minIterations;
1387 } while ( clock() - startClock < CLOCKS_PER_SEC );
1389 startClock = clock();
1390 for ( i = count; i; --i ) {
1391 a.low = inputs_floatx80_pos[ inputNum ].low;
1392 a.high = inputs_floatx80_pos[ inputNum ].high;
1394 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1397 reportTime( count, endClock - startClock );
1406 numInputs_float128 = 32
1409 static const struct {
1411 } inputs_float128[ numInputs_float128 ] = {
1412 { LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },
1413 { LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },
1414 { LIT64( 0x85F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },
1415 { LIT64( 0xF2B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },
1416 { LIT64( 0x8000000000000000 ), LIT64( 0x0000000000000000 ) },
1417 { LIT64( 0xBFFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },
1418 { LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },
1419 { LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },
1420 { LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },
1421 { LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },
1422 { LIT64( 0xBF7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },
1423 { LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },
1424 { LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },
1425 { LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },
1426 { LIT64( 0xBFFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },
1427 { LIT64( 0xBDB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },
1428 { LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },
1429 { LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },
1430 { LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },
1431 { LIT64( 0x8001000000000000 ), LIT64( 0x0000001000000001 ) },
1432 { LIT64( 0xC036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },
1433 { LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },
1434 { LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },
1435 { LIT64( 0xBFFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },
1436 { LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },
1437 { LIT64( 0xB5CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },
1438 { LIT64( 0xE228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },
1439 { LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },
1440 { LIT64( 0xC1AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },
1441 { LIT64( 0xC96F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },
1442 { LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },
1443 { LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }
1446 static void time_a_float128_z_int32( int32 function( float128 ) )
1448 clock_t startClock, endClock;
1455 startClock = clock();
1457 for ( i = minIterations; i; --i ) {
1458 a.low = inputs_float128[ inputNum ].low;
1459 a.high = inputs_float128[ inputNum ].high;
1461 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1463 count += minIterations;
1464 } while ( clock() - startClock < CLOCKS_PER_SEC );
1466 startClock = clock();
1467 for ( i = count; i; --i ) {
1468 a.low = inputs_float128[ inputNum ].low;
1469 a.high = inputs_float128[ inputNum ].high;
1471 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1474 reportTime( count, endClock - startClock );
1478 static void time_a_float128_z_int64( int64 function( float128 ) )
1480 clock_t startClock, endClock;
1487 startClock = clock();
1489 for ( i = minIterations; i; --i ) {
1490 a.low = inputs_float128[ inputNum ].low;
1491 a.high = inputs_float128[ inputNum ].high;
1493 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1495 count += minIterations;
1496 } while ( clock() - startClock < CLOCKS_PER_SEC );
1498 startClock = clock();
1499 for ( i = count; i; --i ) {
1500 a.low = inputs_float128[ inputNum ].low;
1501 a.high = inputs_float128[ inputNum ].high;
1503 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1506 reportTime( count, endClock - startClock );
1510 static void time_a_float128_z_float32( float32 function( float128 ) )
1512 clock_t startClock, endClock;
1519 startClock = clock();
1521 for ( i = minIterations; i; --i ) {
1522 a.low = inputs_float128[ inputNum ].low;
1523 a.high = inputs_float128[ inputNum ].high;
1525 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1527 count += minIterations;
1528 } while ( clock() - startClock < CLOCKS_PER_SEC );
1530 startClock = clock();
1531 for ( i = count; i; --i ) {
1532 a.low = inputs_float128[ inputNum ].low;
1533 a.high = inputs_float128[ inputNum ].high;
1535 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1538 reportTime( count, endClock - startClock );
1542 static void time_a_float128_z_float64( float64 function( float128 ) )
1544 clock_t startClock, endClock;
1551 startClock = clock();
1553 for ( i = minIterations; i; --i ) {
1554 a.low = inputs_float128[ inputNum ].low;
1555 a.high = inputs_float128[ inputNum ].high;
1557 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1559 count += minIterations;
1560 } while ( clock() - startClock < CLOCKS_PER_SEC );
1562 startClock = clock();
1563 for ( i = count; i; --i ) {
1564 a.low = inputs_float128[ inputNum ].low;
1565 a.high = inputs_float128[ inputNum ].high;
1567 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1570 reportTime( count, endClock - startClock );
1576 static void time_a_float128_z_floatx80( floatx80 function( float128 ) )
1578 clock_t startClock, endClock;
1585 startClock = clock();
1587 for ( i = minIterations; i; --i ) {
1588 a.low = inputs_float128[ inputNum ].low;
1589 a.high = inputs_float128[ inputNum ].high;
1591 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1593 count += minIterations;
1594 } while ( clock() - startClock < CLOCKS_PER_SEC );
1596 startClock = clock();
1597 for ( i = count; i; --i ) {
1598 a.low = inputs_float128[ inputNum ].low;
1599 a.high = inputs_float128[ inputNum ].high;
1601 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1604 reportTime( count, endClock - startClock );
1610 static void time_az_float128( float128 function( float128 ) )
1612 clock_t startClock, endClock;
1619 startClock = clock();
1621 for ( i = minIterations; i; --i ) {
1622 a.low = inputs_float128[ inputNum ].low;
1623 a.high = inputs_float128[ inputNum ].high;
1625 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1627 count += minIterations;
1628 } while ( clock() - startClock < CLOCKS_PER_SEC );
1630 startClock = clock();
1631 for ( i = count; i; --i ) {
1632 a.low = inputs_float128[ inputNum ].low;
1633 a.high = inputs_float128[ inputNum ].high;
1635 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1638 reportTime( count, endClock - startClock );
1642 static void time_ab_float128_z_flag( flag function( float128, float128 ) )
1644 clock_t startClock, endClock;
1646 int8 inputNumA, inputNumB;
1652 startClock = clock();
1654 for ( i = minIterations; i; --i ) {
1655 a.low = inputs_float128[ inputNumA ].low;
1656 a.high = inputs_float128[ inputNumA ].high;
1657 b.low = inputs_float128[ inputNumB ].low;
1658 b.high = inputs_float128[ inputNumB ].high;
1660 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1661 if ( inputNumA == 0 ) ++inputNumB;
1662 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1664 count += minIterations;
1665 } while ( clock() - startClock < CLOCKS_PER_SEC );
1668 startClock = clock();
1669 for ( i = count; i; --i ) {
1670 a.low = inputs_float128[ inputNumA ].low;
1671 a.high = inputs_float128[ inputNumA ].high;
1672 b.low = inputs_float128[ inputNumB ].low;
1673 b.high = inputs_float128[ inputNumB ].high;
1675 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1676 if ( inputNumA == 0 ) ++inputNumB;
1677 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1680 reportTime( count, endClock - startClock );
1684 static void time_abz_float128( float128 function( float128, float128 ) )
1686 clock_t startClock, endClock;
1688 int8 inputNumA, inputNumB;
1694 startClock = clock();
1696 for ( i = minIterations; i; --i ) {
1697 a.low = inputs_float128[ inputNumA ].low;
1698 a.high = inputs_float128[ inputNumA ].high;
1699 b.low = inputs_float128[ inputNumB ].low;
1700 b.high = inputs_float128[ inputNumB ].high;
1702 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1703 if ( inputNumA == 0 ) ++inputNumB;
1704 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1706 count += minIterations;
1707 } while ( clock() - startClock < CLOCKS_PER_SEC );
1710 startClock = clock();
1711 for ( i = count; i; --i ) {
1712 a.low = inputs_float128[ inputNumA ].low;
1713 a.high = inputs_float128[ inputNumA ].high;
1714 b.low = inputs_float128[ inputNumB ].low;
1715 b.high = inputs_float128[ inputNumB ].high;
1717 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1718 if ( inputNumA == 0 ) ++inputNumB;
1719 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1722 reportTime( count, endClock - startClock );
1726 static const struct {
1728 } inputs_float128_pos[ numInputs_float128 ] = {
1729 { LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },
1730 { LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },
1731 { LIT64( 0x05F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },
1732 { LIT64( 0x72B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },
1733 { LIT64( 0x0000000000000000 ), LIT64( 0x0000000000000000 ) },
1734 { LIT64( 0x3FFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },
1735 { LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },
1736 { LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },
1737 { LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },
1738 { LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },
1739 { LIT64( 0x3F7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },
1740 { LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },
1741 { LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },
1742 { LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },
1743 { LIT64( 0x3FFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },
1744 { LIT64( 0x3DB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },
1745 { LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },
1746 { LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },
1747 { LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },
1748 { LIT64( 0x0001000000000000 ), LIT64( 0x0000001000000001 ) },
1749 { LIT64( 0x4036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },
1750 { LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },
1751 { LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },
1752 { LIT64( 0x3FFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },
1753 { LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },
1754 { LIT64( 0x35CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },
1755 { LIT64( 0x6228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },
1756 { LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },
1757 { LIT64( 0x41AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },
1758 { LIT64( 0x496F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },
1759 { LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },
1760 { LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }
1763 static void time_az_float128_pos( float128 function( float128 ) )
1765 clock_t startClock, endClock;
1772 startClock = clock();
1774 for ( i = minIterations; i; --i ) {
1775 a.low = inputs_float128_pos[ inputNum ].low;
1776 a.high = inputs_float128_pos[ inputNum ].high;
1778 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1780 count += minIterations;
1781 } while ( clock() - startClock < CLOCKS_PER_SEC );
1783 startClock = clock();
1784 for ( i = count; i; --i ) {
1785 a.low = inputs_float128_pos[ inputNum ].low;
1786 a.high = inputs_float128_pos[ inputNum ].high;
1788 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1791 reportTime( count, endClock - startClock );
1798 INT32_TO_FLOAT32 = 1,
1815 FLOAT32_TO_INT32_ROUND_TO_ZERO,
1817 FLOAT32_TO_INT64_ROUND_TO_ZERO,
1820 FLOAT32_TO_FLOATX80,
1823 FLOAT32_TO_FLOAT128,
1825 FLOAT32_ROUND_TO_INT,
1835 FLOAT32_EQ_SIGNALING,
1839 FLOAT64_TO_INT32_ROUND_TO_ZERO,
1841 FLOAT64_TO_INT64_ROUND_TO_ZERO,
1844 FLOAT64_TO_FLOATX80,
1847 FLOAT64_TO_FLOAT128,
1849 FLOAT64_ROUND_TO_INT,
1859 FLOAT64_EQ_SIGNALING,
1864 FLOATX80_TO_INT32_ROUND_TO_ZERO,
1866 FLOATX80_TO_INT64_ROUND_TO_ZERO,
1867 FLOATX80_TO_FLOAT32,
1868 FLOATX80_TO_FLOAT64,
1870 FLOATX80_TO_FLOAT128,
1872 FLOATX80_ROUND_TO_INT,
1882 FLOATX80_EQ_SIGNALING,
1888 FLOAT128_TO_INT32_ROUND_TO_ZERO,
1890 FLOAT128_TO_INT64_ROUND_TO_ZERO,
1891 FLOAT128_TO_FLOAT32,
1892 FLOAT128_TO_FLOAT64,
1894 FLOAT128_TO_FLOATX80,
1896 FLOAT128_ROUND_TO_INT,
1906 FLOAT128_EQ_SIGNALING,
1916 flag roundingPrecision, roundingMode;
1917 flag tininessMode, tininessModeAtReducedPrecision;
1918 } functions[ NUM_FUNCTIONS ] = {
1919 { 0, 0, 0, 0, 0, 0 },
1920 { "int32_to_float32", 1, FALSE, TRUE, FALSE, FALSE },
1921 { "int32_to_float64", 1, FALSE, FALSE, FALSE, FALSE },
1923 { "int32_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },
1926 { "int32_to_float128", 1, FALSE, FALSE, FALSE, FALSE },
1928 { "int64_to_float32", 1, FALSE, TRUE, FALSE, FALSE },
1929 { "int64_to_float64", 1, FALSE, TRUE, FALSE, FALSE },
1931 { "int64_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },
1934 { "int64_to_float128", 1, FALSE, FALSE, FALSE, FALSE },
1936 { "float32_to_int32", 1, FALSE, TRUE, FALSE, FALSE },
1937 { "float32_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1938 { "float32_to_int64", 1, FALSE, TRUE, FALSE, FALSE },
1939 { "float32_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1940 { "float32_to_float64", 1, FALSE, FALSE, FALSE, FALSE },
1942 { "float32_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },
1945 { "float32_to_float128", 1, FALSE, FALSE, FALSE, FALSE },
1947 { "float32_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },
1948 { "float32_add", 2, FALSE, TRUE, FALSE, FALSE },
1949 { "float32_sub", 2, FALSE, TRUE, FALSE, FALSE },
1950 { "float32_mul", 2, FALSE, TRUE, TRUE, FALSE },
1951 { "float32_div", 2, FALSE, TRUE, FALSE, FALSE },
1952 { "float32_rem", 2, FALSE, FALSE, FALSE, FALSE },
1953 { "float32_sqrt", 1, FALSE, TRUE, FALSE, FALSE },
1954 { "float32_eq", 2, FALSE, FALSE, FALSE, FALSE },
1955 { "float32_le", 2, FALSE, FALSE, FALSE, FALSE },
1956 { "float32_lt", 2, FALSE, FALSE, FALSE, FALSE },
1957 { "float32_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },
1958 { "float32_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },
1959 { "float32_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },
1960 { "float64_to_int32", 1, FALSE, TRUE, FALSE, FALSE },
1961 { "float64_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1962 { "float64_to_int64", 1, FALSE, TRUE, FALSE, FALSE },
1963 { "float64_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1964 { "float64_to_float32", 1, FALSE, TRUE, TRUE, FALSE },
1966 { "float64_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },
1969 { "float64_to_float128", 1, FALSE, FALSE, FALSE, FALSE },
1971 { "float64_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },
1972 { "float64_add", 2, FALSE, TRUE, FALSE, FALSE },
1973 { "float64_sub", 2, FALSE, TRUE, FALSE, FALSE },
1974 { "float64_mul", 2, FALSE, TRUE, TRUE, FALSE },
1975 { "float64_div", 2, FALSE, TRUE, FALSE, FALSE },
1976 { "float64_rem", 2, FALSE, FALSE, FALSE, FALSE },
1977 { "float64_sqrt", 1, FALSE, TRUE, FALSE, FALSE },
1978 { "float64_eq", 2, FALSE, FALSE, FALSE, FALSE },
1979 { "float64_le", 2, FALSE, FALSE, FALSE, FALSE },
1980 { "float64_lt", 2, FALSE, FALSE, FALSE, FALSE },
1981 { "float64_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },
1982 { "float64_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },
1983 { "float64_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },
1985 { "floatx80_to_int32", 1, FALSE, TRUE, FALSE, FALSE },
1986 { "floatx80_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1987 { "floatx80_to_int64", 1, FALSE, TRUE, FALSE, FALSE },
1988 { "floatx80_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1989 { "floatx80_to_float32", 1, FALSE, TRUE, TRUE, FALSE },
1990 { "floatx80_to_float64", 1, FALSE, TRUE, TRUE, FALSE },
1992 { "floatx80_to_float128", 1, FALSE, FALSE, FALSE, FALSE },
1994 { "floatx80_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },
1995 { "floatx80_add", 2, TRUE, TRUE, FALSE, TRUE },
1996 { "floatx80_sub", 2, TRUE, TRUE, FALSE, TRUE },
1997 { "floatx80_mul", 2, TRUE, TRUE, TRUE, TRUE },
1998 { "floatx80_div", 2, TRUE, TRUE, FALSE, TRUE },
1999 { "floatx80_rem", 2, FALSE, FALSE, FALSE, FALSE },
2000 { "floatx80_sqrt", 1, TRUE, TRUE, FALSE, FALSE },
2001 { "floatx80_eq", 2, FALSE, FALSE, FALSE, FALSE },
2002 { "floatx80_le", 2, FALSE, FALSE, FALSE, FALSE },
2003 { "floatx80_lt", 2, FALSE, FALSE, FALSE, FALSE },
2004 { "floatx80_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },
2005 { "floatx80_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },
2006 { "floatx80_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },
2009 { "float128_to_int32", 1, FALSE, TRUE, FALSE, FALSE },
2010 { "float128_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
2011 { "float128_to_int64", 1, FALSE, TRUE, FALSE, FALSE },
2012 { "float128_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
2013 { "float128_to_float32", 1, FALSE, TRUE, TRUE, FALSE },
2014 { "float128_to_float64", 1, FALSE, TRUE, TRUE, FALSE },
2016 { "float128_to_floatx80", 1, FALSE, TRUE, TRUE, FALSE },
2018 { "float128_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },
2019 { "float128_add", 2, FALSE, TRUE, FALSE, FALSE },
2020 { "float128_sub", 2, FALSE, TRUE, FALSE, FALSE },
2021 { "float128_mul", 2, FALSE, TRUE, TRUE, FALSE },
2022 { "float128_div", 2, FALSE, TRUE, FALSE, FALSE },
2023 { "float128_rem", 2, FALSE, FALSE, FALSE, FALSE },
2024 { "float128_sqrt", 1, FALSE, TRUE, FALSE, FALSE },
2025 { "float128_eq", 2, FALSE, FALSE, FALSE, FALSE },
2026 { "float128_le", 2, FALSE, FALSE, FALSE, FALSE },
2027 { "float128_lt", 2, FALSE, FALSE, FALSE, FALSE },
2028 { "float128_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },
2029 { "float128_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },
2030 { "float128_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },
2035 ROUND_NEAREST_EVEN = 1,
2042 TININESS_BEFORE_ROUNDING = 1,
2043 TININESS_AFTER_ROUNDING,
2048 timeFunctionVariety(
2050 int8 roundingPrecision,
2058 functionName = functions[ functionCode ].name;
2059 if ( roundingPrecision == 32 ) {
2060 roundingPrecisionName = "32";
2062 else if ( roundingPrecision == 64 ) {
2063 roundingPrecisionName = "64";
2065 else if ( roundingPrecision == 80 ) {
2066 roundingPrecisionName = "80";
2069 roundingPrecisionName = NULL;
2072 floatx80_rounding_precision = roundingPrecision;
2074 switch ( roundingMode ) {
2076 roundingModeName = NULL;
2077 roundingCode = float_round_nearest_even;
2079 case ROUND_NEAREST_EVEN:
2080 roundingModeName = "nearest_even";
2081 roundingCode = float_round_nearest_even;
2084 roundingModeName = "to_zero";
2085 roundingCode = float_round_to_zero;
2088 roundingModeName = "down";
2089 roundingCode = float_round_down;
2092 roundingModeName = "up";
2093 roundingCode = float_round_up;
2096 float_rounding_mode = roundingCode;
2097 switch ( tininessMode ) {
2099 tininessModeName = NULL;
2100 tininessCode = float_tininess_after_rounding;
2102 case TININESS_BEFORE_ROUNDING:
2103 tininessModeName = "before";
2104 tininessCode = float_tininess_before_rounding;
2106 case TININESS_AFTER_ROUNDING:
2107 tininessModeName = "after";
2108 tininessCode = float_tininess_after_rounding;
2111 float_detect_tininess = tininessCode;
2112 switch ( functionCode ) {
2113 case INT32_TO_FLOAT32:
2114 time_a_int32_z_float32( int32_to_float32 );
2116 case INT32_TO_FLOAT64:
2117 time_a_int32_z_float64( int32_to_float64 );
2120 case INT32_TO_FLOATX80:
2121 time_a_int32_z_floatx80( int32_to_floatx80 );
2125 case INT32_TO_FLOAT128:
2126 time_a_int32_z_float128( int32_to_float128 );
2129 case INT64_TO_FLOAT32:
2130 time_a_int64_z_float32( int64_to_float32 );
2132 case INT64_TO_FLOAT64:
2133 time_a_int64_z_float64( int64_to_float64 );
2136 case INT64_TO_FLOATX80:
2137 time_a_int64_z_floatx80( int64_to_floatx80 );
2141 case INT64_TO_FLOAT128:
2142 time_a_int64_z_float128( int64_to_float128 );
2145 case FLOAT32_TO_INT32:
2146 time_a_float32_z_int32( float32_to_int32 );
2148 case FLOAT32_TO_INT32_ROUND_TO_ZERO:
2149 time_a_float32_z_int32( float32_to_int32_round_to_zero );
2151 case FLOAT32_TO_INT64:
2152 time_a_float32_z_int64( float32_to_int64 );
2154 case FLOAT32_TO_INT64_ROUND_TO_ZERO:
2155 time_a_float32_z_int64( float32_to_int64_round_to_zero );
2157 case FLOAT32_TO_FLOAT64:
2158 time_a_float32_z_float64( float32_to_float64 );
2161 case FLOAT32_TO_FLOATX80:
2162 time_a_float32_z_floatx80( float32_to_floatx80 );
2166 case FLOAT32_TO_FLOAT128:
2167 time_a_float32_z_float128( float32_to_float128 );
2170 case FLOAT32_ROUND_TO_INT:
2171 time_az_float32( float32_round_to_int );
2174 time_abz_float32( float32_add );
2177 time_abz_float32( float32_sub );
2180 time_abz_float32( float32_mul );
2183 time_abz_float32( float32_div );
2186 time_abz_float32( float32_rem );
2189 time_az_float32_pos( float32_sqrt );
2192 time_ab_float32_z_flag( float32_eq );
2195 time_ab_float32_z_flag( float32_le );
2198 time_ab_float32_z_flag( float32_lt );
2200 case FLOAT32_EQ_SIGNALING:
2201 time_ab_float32_z_flag( float32_eq_signaling );
2203 case FLOAT32_LE_QUIET:
2204 time_ab_float32_z_flag( float32_le_quiet );
2206 case FLOAT32_LT_QUIET:
2207 time_ab_float32_z_flag( float32_lt_quiet );
2209 case FLOAT64_TO_INT32:
2210 time_a_float64_z_int32( float64_to_int32 );
2212 case FLOAT64_TO_INT32_ROUND_TO_ZERO:
2213 time_a_float64_z_int32( float64_to_int32_round_to_zero );
2215 case FLOAT64_TO_INT64:
2216 time_a_float64_z_int64( float64_to_int64 );
2218 case FLOAT64_TO_INT64_ROUND_TO_ZERO:
2219 time_a_float64_z_int64( float64_to_int64_round_to_zero );
2221 case FLOAT64_TO_FLOAT32:
2222 time_a_float64_z_float32( float64_to_float32 );
2225 case FLOAT64_TO_FLOATX80:
2226 time_a_float64_z_floatx80( float64_to_floatx80 );
2230 case FLOAT64_TO_FLOAT128:
2231 time_a_float64_z_float128( float64_to_float128 );
2234 case FLOAT64_ROUND_TO_INT:
2235 time_az_float64( float64_round_to_int );
2238 time_abz_float64( float64_add );
2241 time_abz_float64( float64_sub );
2244 time_abz_float64( float64_mul );
2247 time_abz_float64( float64_div );
2250 time_abz_float64( float64_rem );
2253 time_az_float64_pos( float64_sqrt );
2256 time_ab_float64_z_flag( float64_eq );
2259 time_ab_float64_z_flag( float64_le );
2262 time_ab_float64_z_flag( float64_lt );
2264 case FLOAT64_EQ_SIGNALING:
2265 time_ab_float64_z_flag( float64_eq_signaling );
2267 case FLOAT64_LE_QUIET:
2268 time_ab_float64_z_flag( float64_le_quiet );
2270 case FLOAT64_LT_QUIET:
2271 time_ab_float64_z_flag( float64_lt_quiet );
2274 case FLOATX80_TO_INT32:
2275 time_a_floatx80_z_int32( floatx80_to_int32 );
2277 case FLOATX80_TO_INT32_ROUND_TO_ZERO:
2278 time_a_floatx80_z_int32( floatx80_to_int32_round_to_zero );
2280 case FLOATX80_TO_INT64:
2281 time_a_floatx80_z_int64( floatx80_to_int64 );
2283 case FLOATX80_TO_INT64_ROUND_TO_ZERO:
2284 time_a_floatx80_z_int64( floatx80_to_int64_round_to_zero );
2286 case FLOATX80_TO_FLOAT32:
2287 time_a_floatx80_z_float32( floatx80_to_float32 );
2289 case FLOATX80_TO_FLOAT64:
2290 time_a_floatx80_z_float64( floatx80_to_float64 );
2293 case FLOATX80_TO_FLOAT128:
2294 time_a_floatx80_z_float128( floatx80_to_float128 );
2297 case FLOATX80_ROUND_TO_INT:
2298 time_az_floatx80( floatx80_round_to_int );
2301 time_abz_floatx80( floatx80_add );
2304 time_abz_floatx80( floatx80_sub );
2307 time_abz_floatx80( floatx80_mul );
2310 time_abz_floatx80( floatx80_div );
2313 time_abz_floatx80( floatx80_rem );
2316 time_az_floatx80_pos( floatx80_sqrt );
2319 time_ab_floatx80_z_flag( floatx80_eq );
2322 time_ab_floatx80_z_flag( floatx80_le );
2325 time_ab_floatx80_z_flag( floatx80_lt );
2327 case FLOATX80_EQ_SIGNALING:
2328 time_ab_floatx80_z_flag( floatx80_eq_signaling );
2330 case FLOATX80_LE_QUIET:
2331 time_ab_floatx80_z_flag( floatx80_le_quiet );
2333 case FLOATX80_LT_QUIET:
2334 time_ab_floatx80_z_flag( floatx80_lt_quiet );
2338 case FLOAT128_TO_INT32:
2339 time_a_float128_z_int32( float128_to_int32 );
2341 case FLOAT128_TO_INT32_ROUND_TO_ZERO:
2342 time_a_float128_z_int32( float128_to_int32_round_to_zero );
2344 case FLOAT128_TO_INT64:
2345 time_a_float128_z_int64( float128_to_int64 );
2347 case FLOAT128_TO_INT64_ROUND_TO_ZERO:
2348 time_a_float128_z_int64( float128_to_int64_round_to_zero );
2350 case FLOAT128_TO_FLOAT32:
2351 time_a_float128_z_float32( float128_to_float32 );
2353 case FLOAT128_TO_FLOAT64:
2354 time_a_float128_z_float64( float128_to_float64 );
2357 case FLOAT128_TO_FLOATX80:
2358 time_a_float128_z_floatx80( float128_to_floatx80 );
2361 case FLOAT128_ROUND_TO_INT:
2362 time_az_float128( float128_round_to_int );
2365 time_abz_float128( float128_add );
2368 time_abz_float128( float128_sub );
2371 time_abz_float128( float128_mul );
2374 time_abz_float128( float128_div );
2377 time_abz_float128( float128_rem );
2380 time_az_float128_pos( float128_sqrt );
2383 time_ab_float128_z_flag( float128_eq );
2386 time_ab_float128_z_flag( float128_le );
2389 time_ab_float128_z_flag( float128_lt );
2391 case FLOAT128_EQ_SIGNALING:
2392 time_ab_float128_z_flag( float128_eq_signaling );
2394 case FLOAT128_LE_QUIET:
2395 time_ab_float128_z_flag( float128_le_quiet );
2397 case FLOAT128_LT_QUIET:
2398 time_ab_float128_z_flag( float128_lt_quiet );
2408 int8 roundingPrecisionIn,
2409 int8 roundingModeIn,
2413 int8 roundingPrecision, roundingMode, tininessMode;
2415 roundingPrecision = 32;
2417 if ( ! functions[ functionCode ].roundingPrecision ) {
2418 roundingPrecision = 0;
2420 else if ( roundingPrecisionIn ) {
2421 roundingPrecision = roundingPrecisionIn;
2423 for ( roundingMode = 1;
2424 roundingMode < NUM_ROUNDINGMODES;
2427 if ( ! functions[ functionCode ].roundingMode ) {
2430 else if ( roundingModeIn ) {
2431 roundingMode = roundingModeIn;
2433 for ( tininessMode = 1;
2434 tininessMode < NUM_TININESSMODES;
2437 if ( ( roundingPrecision == 32 )
2438 || ( roundingPrecision == 64 ) ) {
2439 if ( ! functions[ functionCode ]
2440 .tininessModeAtReducedPrecision
2444 else if ( tininessModeIn ) {
2445 tininessMode = tininessModeIn;
2449 if ( ! functions[ functionCode ].tininessMode ) {
2452 else if ( tininessModeIn ) {
2453 tininessMode = tininessModeIn;
2456 timeFunctionVariety(
2457 functionCode, roundingPrecision, roundingMode, tininessMode
2459 if ( tininessModeIn || ! tininessMode ) break;
2461 if ( roundingModeIn || ! roundingMode ) break;
2463 if ( roundingPrecisionIn || ! roundingPrecision ) break;
2464 if ( roundingPrecision == 80 ) {
2467 else if ( roundingPrecision == 64 ) {
2468 roundingPrecision = 80;
2470 else if ( roundingPrecision == 32 ) {
2471 roundingPrecision = 64;
2477 main( int argc, char **argv )
2480 flag functionArgument;
2482 int8 operands, roundingPrecision, roundingMode, tininessMode;
2484 if ( argc <= 1 ) goto writeHelpMessage;
2485 functionArgument = FALSE;
2488 roundingPrecision = 0;
2493 while ( argc && ( argPtr = argv[ 0 ] ) ) {
2494 if ( argPtr[ 0 ] == '-' ) ++argPtr;
2495 if ( strcmp( argPtr, "help" ) == 0 ) {
2498 "timesoftfloat [<option>...] <function>\n"
2499 " <option>: (* is default)\n"
2500 " -help --Write this message and exit.\n"
2502 " -precision32 --Only time rounding precision equivalent to float32.\n"
2503 " -precision64 --Only time rounding precision equivalent to float64.\n"
2504 " -precision80 --Only time maximum rounding precision.\n"
2506 " -nearesteven --Only time rounding to nearest/even.\n"
2507 " -tozero --Only time rounding to zero.\n"
2508 " -down --Only time rounding down.\n"
2509 " -up --Only time rounding up.\n"
2510 " -tininessbefore --Only time underflow tininess before rounding.\n"
2511 " -tininessafter --Only time underflow tininess after rounding.\n"
2513 " int32_to_<float> <float>_add <float>_eq\n"
2514 " <float>_to_int32 <float>_sub <float>_le\n"
2515 " <float>_to_int32_round_to_zero <float>_mul <float>_lt\n"
2516 " int64_to_<float> <float>_div <float>_eq_signaling\n"
2517 " <float>_to_int64 <float>_rem <float>_le_quiet\n"
2518 " <float>_to_int64_round_to_zero <float>_lt_quiet\n"
2519 " <float>_to_<float>\n"
2520 " <float>_round_to_int\n"
2522 " -all1 --All 1-operand functions.\n"
2523 " -all2 --All 2-operand functions.\n"
2524 " -all --All functions.\n"
2526 " float32 --Single precision.\n"
2527 " float64 --Double precision.\n"
2529 " floatx80 --Extended double precision.\n"
2532 " float128 --Quadruple precision.\n"
2537 return EXIT_SUCCESS;
2540 else if ( strcmp( argPtr, "precision32" ) == 0 ) {
2541 roundingPrecision = 32;
2543 else if ( strcmp( argPtr, "precision64" ) == 0 ) {
2544 roundingPrecision = 64;
2546 else if ( strcmp( argPtr, "precision80" ) == 0 ) {
2547 roundingPrecision = 80;
2550 else if ( ( strcmp( argPtr, "nearesteven" ) == 0 )
2551 || ( strcmp( argPtr, "nearest_even" ) == 0 ) ) {
2552 roundingMode = ROUND_NEAREST_EVEN;
2554 else if ( ( strcmp( argPtr, "tozero" ) == 0 )
2555 || ( strcmp( argPtr, "to_zero" ) == 0 ) ) {
2556 roundingMode = ROUND_TO_ZERO;
2558 else if ( strcmp( argPtr, "down" ) == 0 ) {
2559 roundingMode = ROUND_DOWN;
2561 else if ( strcmp( argPtr, "up" ) == 0 ) {
2562 roundingMode = ROUND_UP;
2564 else if ( strcmp( argPtr, "tininessbefore" ) == 0 ) {
2565 tininessMode = TININESS_BEFORE_ROUNDING;
2567 else if ( strcmp( argPtr, "tininessafter" ) == 0 ) {
2568 tininessMode = TININESS_AFTER_ROUNDING;
2570 else if ( strcmp( argPtr, "all1" ) == 0 ) {
2571 functionArgument = TRUE;
2575 else if ( strcmp( argPtr, "all2" ) == 0 ) {
2576 functionArgument = TRUE;
2580 else if ( strcmp( argPtr, "all" ) == 0 ) {
2581 functionArgument = TRUE;
2586 for ( functionCode = 1;
2587 functionCode < NUM_FUNCTIONS;
2590 if ( strcmp( argPtr, functions[ functionCode ].name ) == 0 ) {
2594 if ( functionCode == NUM_FUNCTIONS ) {
2595 fail( "Invalid option or function `%s'", argv[ 0 ] );
2597 functionArgument = TRUE;
2602 if ( ! functionArgument ) fail( "Function argument required" );
2603 if ( functionCode ) {
2605 functionCode, roundingPrecision, roundingMode, tininessMode );
2607 else if ( operands == 1 ) {
2608 for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2610 if ( functions[ functionCode ].numInputs == 1 ) {
2612 functionCode, roundingPrecision, roundingMode, tininessMode
2617 else if ( operands == 2 ) {
2618 for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2620 if ( functions[ functionCode ].numInputs == 2 ) {
2622 functionCode, roundingPrecision, roundingMode, tininessMode
2628 for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2631 functionCode, roundingPrecision, roundingMode, tininessMode );
2634 return EXIT_SUCCESS;