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