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 #include <stdlib.h> 35 #include <stdarg.h> 36 #include <string.h> 37 #include <stdio.h> 38 #include <time.h> 39 #include "milieu.h" 40 #include "softfloat.h" 41 42 enum { 43 minIterations = 1000 44 }; 45 46 static void fail( const char *message, ... ) 47 { 48 va_list varArgs; 49 50 fputs( "timesoftfloat: ", stderr ); 51 va_start( varArgs, message ); 52 vfprintf( stderr, message, varArgs ); 53 va_end( varArgs ); 54 fputs( ".\n", stderr ); 55 exit( EXIT_FAILURE ); 56 57 } 58 59 static char *functionName; 60 static char *roundingPrecisionName, *roundingModeName, *tininessModeName; 61 62 static void reportTime( int32 count, long clocks ) 63 { 64 65 printf( 66 "%8.1f kops/s: %s", 67 ( count / ( ( (float) clocks ) / CLOCKS_PER_SEC ) ) / 1000, 68 functionName 69 ); 70 if ( roundingModeName ) { 71 if ( roundingPrecisionName ) { 72 fputs( ", precision ", stdout ); 73 fputs( roundingPrecisionName, stdout ); 74 } 75 fputs( ", rounding ", stdout ); 76 fputs( roundingModeName, stdout ); 77 if ( tininessModeName ) { 78 fputs( ", tininess ", stdout ); 79 fputs( tininessModeName, stdout ); 80 fputs( " rounding", stdout ); 81 } 82 } 83 fputc( '\n', stdout ); 84 85 } 86 87 enum { 88 numInputs_int32 = 32 89 }; 90 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 100 }; 101 102 static void time_a_int32_z_float32( float32 function( int32 ) ) 103 { 104 clock_t startClock, endClock; 105 int32 count, i; 106 int8 inputNum; 107 108 count = 0; 109 inputNum = 0; 110 startClock = clock(); 111 do { 112 for ( i = minIterations; i; --i ) { 113 function( inputs_int32[ inputNum ] ); 114 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 115 } 116 count += minIterations; 117 } while ( clock() - startClock < CLOCKS_PER_SEC ); 118 inputNum = 0; 119 startClock = clock(); 120 for ( i = count; i; --i ) { 121 function( inputs_int32[ inputNum ] ); 122 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 123 } 124 endClock = clock(); 125 reportTime( count, endClock - startClock ); 126 127 } 128 129 static void time_a_int32_z_float64( float64 function( int32 ) ) 130 { 131 clock_t startClock, endClock; 132 int32 count, i; 133 int8 inputNum; 134 135 count = 0; 136 inputNum = 0; 137 startClock = clock(); 138 do { 139 for ( i = minIterations; i; --i ) { 140 function( inputs_int32[ inputNum ] ); 141 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 142 } 143 count += minIterations; 144 } while ( clock() - startClock < CLOCKS_PER_SEC ); 145 inputNum = 0; 146 startClock = clock(); 147 for ( i = count; i; --i ) { 148 function( inputs_int32[ inputNum ] ); 149 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 150 } 151 endClock = clock(); 152 reportTime( count, endClock - startClock ); 153 154 } 155 156 #ifdef FLOATX80 157 158 static void time_a_int32_z_floatx80( floatx80 function( int32 ) ) 159 { 160 clock_t startClock, endClock; 161 int32 count, i; 162 int8 inputNum; 163 164 count = 0; 165 inputNum = 0; 166 startClock = clock(); 167 do { 168 for ( i = minIterations; i; --i ) { 169 function( inputs_int32[ inputNum ] ); 170 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 171 } 172 count += minIterations; 173 } while ( clock() - startClock < CLOCKS_PER_SEC ); 174 inputNum = 0; 175 startClock = clock(); 176 for ( i = count; i; --i ) { 177 function( inputs_int32[ inputNum ] ); 178 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 179 } 180 endClock = clock(); 181 reportTime( count, endClock - startClock ); 182 183 } 184 185 #endif 186 187 #ifdef FLOAT128 188 189 static void time_a_int32_z_float128( float128 function( int32 ) ) 190 { 191 clock_t startClock, endClock; 192 int32 count, i; 193 int8 inputNum; 194 195 count = 0; 196 inputNum = 0; 197 startClock = clock(); 198 do { 199 for ( i = minIterations; i; --i ) { 200 function( inputs_int32[ inputNum ] ); 201 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 202 } 203 count += minIterations; 204 } while ( clock() - startClock < CLOCKS_PER_SEC ); 205 inputNum = 0; 206 startClock = clock(); 207 for ( i = count; i; --i ) { 208 function( inputs_int32[ inputNum ] ); 209 inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 ); 210 } 211 endClock = clock(); 212 reportTime( count, endClock - startClock ); 213 214 } 215 216 #endif 217 218 enum { 219 numInputs_int64 = 32 220 }; 221 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 ) 255 }; 256 257 static void time_a_int64_z_float32( float32 function( int64 ) ) 258 { 259 clock_t startClock, endClock; 260 int32 count, i; 261 int8 inputNum; 262 263 count = 0; 264 inputNum = 0; 265 startClock = clock(); 266 do { 267 for ( i = minIterations; i; --i ) { 268 function( inputs_int64[ inputNum ] ); 269 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 270 } 271 count += minIterations; 272 } while ( clock() - startClock < CLOCKS_PER_SEC ); 273 inputNum = 0; 274 startClock = clock(); 275 for ( i = count; i; --i ) { 276 function( inputs_int64[ inputNum ] ); 277 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 278 } 279 endClock = clock(); 280 reportTime( count, endClock - startClock ); 281 282 } 283 284 static void time_a_int64_z_float64( float64 function( int64 ) ) 285 { 286 clock_t startClock, endClock; 287 int32 count, i; 288 int8 inputNum; 289 290 count = 0; 291 inputNum = 0; 292 startClock = clock(); 293 do { 294 for ( i = minIterations; i; --i ) { 295 function( inputs_int64[ inputNum ] ); 296 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 297 } 298 count += minIterations; 299 } while ( clock() - startClock < CLOCKS_PER_SEC ); 300 inputNum = 0; 301 startClock = clock(); 302 for ( i = count; i; --i ) { 303 function( inputs_int64[ inputNum ] ); 304 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 305 } 306 endClock = clock(); 307 reportTime( count, endClock - startClock ); 308 309 } 310 311 #ifdef FLOATX80 312 313 static void time_a_int64_z_floatx80( floatx80 function( int64 ) ) 314 { 315 clock_t startClock, endClock; 316 int32 count, i; 317 int8 inputNum; 318 319 count = 0; 320 inputNum = 0; 321 startClock = clock(); 322 do { 323 for ( i = minIterations; i; --i ) { 324 function( inputs_int64[ inputNum ] ); 325 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 326 } 327 count += minIterations; 328 } while ( clock() - startClock < CLOCKS_PER_SEC ); 329 inputNum = 0; 330 startClock = clock(); 331 for ( i = count; i; --i ) { 332 function( inputs_int64[ inputNum ] ); 333 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 334 } 335 endClock = clock(); 336 reportTime( count, endClock - startClock ); 337 338 } 339 340 #endif 341 342 #ifdef FLOAT128 343 344 static void time_a_int64_z_float128( float128 function( int64 ) ) 345 { 346 clock_t startClock, endClock; 347 int32 count, i; 348 int8 inputNum; 349 350 count = 0; 351 inputNum = 0; 352 startClock = clock(); 353 do { 354 for ( i = minIterations; i; --i ) { 355 function( inputs_int64[ inputNum ] ); 356 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 357 } 358 count += minIterations; 359 } while ( clock() - startClock < CLOCKS_PER_SEC ); 360 inputNum = 0; 361 startClock = clock(); 362 for ( i = count; i; --i ) { 363 function( inputs_int64[ inputNum ] ); 364 inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 ); 365 } 366 endClock = clock(); 367 reportTime( count, endClock - startClock ); 368 369 } 370 371 #endif 372 373 enum { 374 numInputs_float32 = 32 375 }; 376 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 386 }; 387 388 static void time_a_float32_z_int32( int32 function( float32 ) ) 389 { 390 clock_t startClock, endClock; 391 int32 count, i; 392 int8 inputNum; 393 394 count = 0; 395 inputNum = 0; 396 startClock = clock(); 397 do { 398 for ( i = minIterations; i; --i ) { 399 function( inputs_float32[ inputNum ] ); 400 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 401 } 402 count += minIterations; 403 } while ( clock() - startClock < CLOCKS_PER_SEC ); 404 inputNum = 0; 405 startClock = clock(); 406 for ( i = count; i; --i ) { 407 function( inputs_float32[ inputNum ] ); 408 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 409 } 410 endClock = clock(); 411 reportTime( count, endClock - startClock ); 412 413 } 414 415 static void time_a_float32_z_int64( int64 function( float32 ) ) 416 { 417 clock_t startClock, endClock; 418 int32 count, i; 419 int8 inputNum; 420 421 count = 0; 422 inputNum = 0; 423 startClock = clock(); 424 do { 425 for ( i = minIterations; i; --i ) { 426 function( inputs_float32[ inputNum ] ); 427 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 428 } 429 count += minIterations; 430 } while ( clock() - startClock < CLOCKS_PER_SEC ); 431 inputNum = 0; 432 startClock = clock(); 433 for ( i = count; i; --i ) { 434 function( inputs_float32[ inputNum ] ); 435 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 436 } 437 endClock = clock(); 438 reportTime( count, endClock - startClock ); 439 440 } 441 442 static void time_a_float32_z_float64( float64 function( float32 ) ) 443 { 444 clock_t startClock, endClock; 445 int32 count, i; 446 int8 inputNum; 447 448 count = 0; 449 inputNum = 0; 450 startClock = clock(); 451 do { 452 for ( i = minIterations; i; --i ) { 453 function( inputs_float32[ inputNum ] ); 454 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 455 } 456 count += minIterations; 457 } while ( clock() - startClock < CLOCKS_PER_SEC ); 458 inputNum = 0; 459 startClock = clock(); 460 for ( i = count; i; --i ) { 461 function( inputs_float32[ inputNum ] ); 462 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 463 } 464 endClock = clock(); 465 reportTime( count, endClock - startClock ); 466 467 } 468 469 #ifdef FLOATX80 470 471 static void time_a_float32_z_floatx80( floatx80 function( float32 ) ) 472 { 473 clock_t startClock, endClock; 474 int32 count, i; 475 int8 inputNum; 476 477 count = 0; 478 inputNum = 0; 479 startClock = clock(); 480 do { 481 for ( i = minIterations; i; --i ) { 482 function( inputs_float32[ inputNum ] ); 483 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 484 } 485 count += minIterations; 486 } while ( clock() - startClock < CLOCKS_PER_SEC ); 487 inputNum = 0; 488 startClock = clock(); 489 for ( i = count; i; --i ) { 490 function( inputs_float32[ inputNum ] ); 491 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 492 } 493 endClock = clock(); 494 reportTime( count, endClock - startClock ); 495 496 } 497 498 #endif 499 500 #ifdef FLOAT128 501 502 static void time_a_float32_z_float128( float128 function( float32 ) ) 503 { 504 clock_t startClock, endClock; 505 int32 count, i; 506 int8 inputNum; 507 508 count = 0; 509 inputNum = 0; 510 startClock = clock(); 511 do { 512 for ( i = minIterations; i; --i ) { 513 function( inputs_float32[ inputNum ] ); 514 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 515 } 516 count += minIterations; 517 } while ( clock() - startClock < CLOCKS_PER_SEC ); 518 inputNum = 0; 519 startClock = clock(); 520 for ( i = count; i; --i ) { 521 function( inputs_float32[ inputNum ] ); 522 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 523 } 524 endClock = clock(); 525 reportTime( count, endClock - startClock ); 526 527 } 528 529 #endif 530 531 static void time_az_float32( float32 function( float32 ) ) 532 { 533 clock_t startClock, endClock; 534 int32 count, i; 535 int8 inputNum; 536 537 count = 0; 538 inputNum = 0; 539 startClock = clock(); 540 do { 541 for ( i = minIterations; i; --i ) { 542 function( inputs_float32[ inputNum ] ); 543 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 544 } 545 count += minIterations; 546 } while ( clock() - startClock < CLOCKS_PER_SEC ); 547 inputNum = 0; 548 startClock = clock(); 549 for ( i = count; i; --i ) { 550 function( inputs_float32[ inputNum ] ); 551 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 552 } 553 endClock = clock(); 554 reportTime( count, endClock - startClock ); 555 556 } 557 558 static void time_ab_float32_z_flag( flag function( float32, float32 ) ) 559 { 560 clock_t startClock, endClock; 561 int32 count, i; 562 int8 inputNumA, inputNumB; 563 564 count = 0; 565 inputNumA = 0; 566 inputNumB = 0; 567 startClock = clock(); 568 do { 569 for ( i = minIterations; i; --i ) { 570 function( 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 ); 575 } 576 count += minIterations; 577 } while ( clock() - startClock < CLOCKS_PER_SEC ); 578 inputNumA = 0; 579 inputNumB = 0; 580 startClock = clock(); 581 for ( i = count; i; --i ) { 582 function( 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 ); 587 } 588 endClock = clock(); 589 reportTime( count, endClock - startClock ); 590 591 } 592 593 static void time_abz_float32( float32 function( float32, float32 ) ) 594 { 595 clock_t startClock, endClock; 596 int32 count, i; 597 int8 inputNumA, inputNumB; 598 599 count = 0; 600 inputNumA = 0; 601 inputNumB = 0; 602 startClock = clock(); 603 do { 604 for ( i = minIterations; i; --i ) { 605 function( 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 ); 610 } 611 count += minIterations; 612 } while ( clock() - startClock < CLOCKS_PER_SEC ); 613 inputNumA = 0; 614 inputNumB = 0; 615 startClock = clock(); 616 for ( i = count; i; --i ) { 617 function( 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 ); 622 } 623 endClock = clock(); 624 reportTime( count, endClock - startClock ); 625 626 } 627 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 637 }; 638 639 static void time_az_float32_pos( float32 function( float32 ) ) 640 { 641 clock_t startClock, endClock; 642 int32 count, i; 643 int8 inputNum; 644 645 count = 0; 646 inputNum = 0; 647 startClock = clock(); 648 do { 649 for ( i = minIterations; i; --i ) { 650 function( inputs_float32_pos[ inputNum ] ); 651 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 652 } 653 count += minIterations; 654 } while ( clock() - startClock < CLOCKS_PER_SEC ); 655 inputNum = 0; 656 startClock = clock(); 657 for ( i = count; i; --i ) { 658 function( inputs_float32_pos[ inputNum ] ); 659 inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 ); 660 } 661 endClock = clock(); 662 reportTime( count, endClock - startClock ); 663 664 } 665 666 enum { 667 numInputs_float64 = 32 668 }; 669 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 ) 703 }; 704 705 static void time_a_float64_z_int32( int32 function( float64 ) ) 706 { 707 clock_t startClock, endClock; 708 int32 count, i; 709 int8 inputNum; 710 711 count = 0; 712 inputNum = 0; 713 startClock = clock(); 714 do { 715 for ( i = minIterations; i; --i ) { 716 function( inputs_float64[ inputNum ] ); 717 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 718 } 719 count += minIterations; 720 } while ( clock() - startClock < CLOCKS_PER_SEC ); 721 inputNum = 0; 722 startClock = clock(); 723 for ( i = count; i; --i ) { 724 function( inputs_float64[ inputNum ] ); 725 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 726 } 727 endClock = clock(); 728 reportTime( count, endClock - startClock ); 729 730 } 731 732 static void time_a_float64_z_int64( int64 function( float64 ) ) 733 { 734 clock_t startClock, endClock; 735 int32 count, i; 736 int8 inputNum; 737 738 count = 0; 739 inputNum = 0; 740 startClock = clock(); 741 do { 742 for ( i = minIterations; i; --i ) { 743 function( inputs_float64[ inputNum ] ); 744 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 745 } 746 count += minIterations; 747 } while ( clock() - startClock < CLOCKS_PER_SEC ); 748 inputNum = 0; 749 startClock = clock(); 750 for ( i = count; i; --i ) { 751 function( inputs_float64[ inputNum ] ); 752 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 753 } 754 endClock = clock(); 755 reportTime( count, endClock - startClock ); 756 757 } 758 759 static void time_a_float64_z_float32( float32 function( float64 ) ) 760 { 761 clock_t startClock, endClock; 762 int32 count, i; 763 int8 inputNum; 764 765 count = 0; 766 inputNum = 0; 767 startClock = clock(); 768 do { 769 for ( i = minIterations; i; --i ) { 770 function( inputs_float64[ inputNum ] ); 771 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 772 } 773 count += minIterations; 774 } while ( clock() - startClock < CLOCKS_PER_SEC ); 775 inputNum = 0; 776 startClock = clock(); 777 for ( i = count; i; --i ) { 778 function( inputs_float64[ inputNum ] ); 779 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 780 } 781 endClock = clock(); 782 reportTime( count, endClock - startClock ); 783 784 } 785 786 #ifdef FLOATX80 787 788 static void time_a_float64_z_floatx80( floatx80 function( float64 ) ) 789 { 790 clock_t startClock, endClock; 791 int32 count, i; 792 int8 inputNum; 793 794 count = 0; 795 inputNum = 0; 796 startClock = clock(); 797 do { 798 for ( i = minIterations; i; --i ) { 799 function( inputs_float64[ inputNum ] ); 800 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 801 } 802 count += minIterations; 803 } while ( clock() - startClock < CLOCKS_PER_SEC ); 804 inputNum = 0; 805 startClock = clock(); 806 for ( i = count; i; --i ) { 807 function( inputs_float64[ inputNum ] ); 808 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 809 } 810 endClock = clock(); 811 reportTime( count, endClock - startClock ); 812 813 } 814 815 #endif 816 817 #ifdef FLOAT128 818 819 static void time_a_float64_z_float128( float128 function( float64 ) ) 820 { 821 clock_t startClock, endClock; 822 int32 count, i; 823 int8 inputNum; 824 825 count = 0; 826 inputNum = 0; 827 startClock = clock(); 828 do { 829 for ( i = minIterations; i; --i ) { 830 function( inputs_float64[ inputNum ] ); 831 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 832 } 833 count += minIterations; 834 } while ( clock() - startClock < CLOCKS_PER_SEC ); 835 inputNum = 0; 836 startClock = clock(); 837 for ( i = count; i; --i ) { 838 function( inputs_float64[ inputNum ] ); 839 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 840 } 841 endClock = clock(); 842 reportTime( count, endClock - startClock ); 843 844 } 845 846 #endif 847 848 static void time_az_float64( float64 function( float64 ) ) 849 { 850 clock_t startClock, endClock; 851 int32 count, i; 852 int8 inputNum; 853 854 count = 0; 855 inputNum = 0; 856 startClock = clock(); 857 do { 858 for ( i = minIterations; i; --i ) { 859 function( inputs_float64[ inputNum ] ); 860 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 861 } 862 count += minIterations; 863 } while ( clock() - startClock < CLOCKS_PER_SEC ); 864 inputNum = 0; 865 startClock = clock(); 866 for ( i = count; i; --i ) { 867 function( inputs_float64[ inputNum ] ); 868 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 869 } 870 endClock = clock(); 871 reportTime( count, endClock - startClock ); 872 873 } 874 875 static void time_ab_float64_z_flag( flag function( float64, float64 ) ) 876 { 877 clock_t startClock, endClock; 878 int32 count, i; 879 int8 inputNumA, inputNumB; 880 881 count = 0; 882 inputNumA = 0; 883 inputNumB = 0; 884 startClock = clock(); 885 do { 886 for ( i = minIterations; i; --i ) { 887 function( 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 ); 892 } 893 count += minIterations; 894 } while ( clock() - startClock < CLOCKS_PER_SEC ); 895 inputNumA = 0; 896 inputNumB = 0; 897 startClock = clock(); 898 for ( i = count; i; --i ) { 899 function( 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 ); 904 } 905 endClock = clock(); 906 reportTime( count, endClock - startClock ); 907 908 } 909 910 static void time_abz_float64( float64 function( float64, float64 ) ) 911 { 912 clock_t startClock, endClock; 913 int32 count, i; 914 int8 inputNumA, inputNumB; 915 916 count = 0; 917 inputNumA = 0; 918 inputNumB = 0; 919 startClock = clock(); 920 do { 921 for ( i = minIterations; i; --i ) { 922 function( 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 ); 927 } 928 count += minIterations; 929 } while ( clock() - startClock < CLOCKS_PER_SEC ); 930 inputNumA = 0; 931 inputNumB = 0; 932 startClock = clock(); 933 for ( i = count; i; --i ) { 934 function( 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 ); 939 } 940 endClock = clock(); 941 reportTime( count, endClock - startClock ); 942 943 } 944 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 ) 978 }; 979 980 static void time_az_float64_pos( float64 function( float64 ) ) 981 { 982 clock_t startClock, endClock; 983 int32 count, i; 984 int8 inputNum; 985 986 count = 0; 987 inputNum = 0; 988 startClock = clock(); 989 do { 990 for ( i = minIterations; i; --i ) { 991 function( inputs_float64_pos[ inputNum ] ); 992 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 993 } 994 count += minIterations; 995 } while ( clock() - startClock < CLOCKS_PER_SEC ); 996 inputNum = 0; 997 startClock = clock(); 998 for ( i = count; i; --i ) { 999 function( inputs_float64_pos[ inputNum ] ); 1000 inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 ); 1001 } 1002 endClock = clock(); 1003 reportTime( count, endClock - startClock ); 1004 1005 } 1006 1007 #ifdef FLOATX80 1008 1009 enum { 1010 numInputs_floatx80 = 32 1011 }; 1012 1013 static const struct { 1014 bits16 high; 1015 bits64 low; 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 ) } 1049 }; 1050 1051 static void time_a_floatx80_z_int32( int32 function( floatx80 ) ) 1052 { 1053 clock_t startClock, endClock; 1054 int32 count, i; 1055 int8 inputNum; 1056 floatx80 a; 1057 1058 count = 0; 1059 inputNum = 0; 1060 startClock = clock(); 1061 do { 1062 for ( i = minIterations; i; --i ) { 1063 a.low = inputs_floatx80[ inputNum ].low; 1064 a.high = inputs_floatx80[ inputNum ].high; 1065 function( a ); 1066 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1067 } 1068 count += minIterations; 1069 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1070 inputNum = 0; 1071 startClock = clock(); 1072 for ( i = count; i; --i ) { 1073 a.low = inputs_floatx80[ inputNum ].low; 1074 a.high = inputs_floatx80[ inputNum ].high; 1075 function( a ); 1076 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1077 } 1078 endClock = clock(); 1079 reportTime( count, endClock - startClock ); 1080 1081 } 1082 1083 static void time_a_floatx80_z_int64( int64 function( floatx80 ) ) 1084 { 1085 clock_t startClock, endClock; 1086 int32 count, i; 1087 int8 inputNum; 1088 floatx80 a; 1089 1090 count = 0; 1091 inputNum = 0; 1092 startClock = clock(); 1093 do { 1094 for ( i = minIterations; i; --i ) { 1095 a.low = inputs_floatx80[ inputNum ].low; 1096 a.high = inputs_floatx80[ inputNum ].high; 1097 function( a ); 1098 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1099 } 1100 count += minIterations; 1101 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1102 inputNum = 0; 1103 startClock = clock(); 1104 for ( i = count; i; --i ) { 1105 a.low = inputs_floatx80[ inputNum ].low; 1106 a.high = inputs_floatx80[ inputNum ].high; 1107 function( a ); 1108 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1109 } 1110 endClock = clock(); 1111 reportTime( count, endClock - startClock ); 1112 1113 } 1114 1115 static void time_a_floatx80_z_float32( float32 function( floatx80 ) ) 1116 { 1117 clock_t startClock, endClock; 1118 int32 count, i; 1119 int8 inputNum; 1120 floatx80 a; 1121 1122 count = 0; 1123 inputNum = 0; 1124 startClock = clock(); 1125 do { 1126 for ( i = minIterations; i; --i ) { 1127 a.low = inputs_floatx80[ inputNum ].low; 1128 a.high = inputs_floatx80[ inputNum ].high; 1129 function( a ); 1130 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1131 } 1132 count += minIterations; 1133 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1134 inputNum = 0; 1135 startClock = clock(); 1136 for ( i = count; i; --i ) { 1137 a.low = inputs_floatx80[ inputNum ].low; 1138 a.high = inputs_floatx80[ inputNum ].high; 1139 function( a ); 1140 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1141 } 1142 endClock = clock(); 1143 reportTime( count, endClock - startClock ); 1144 1145 } 1146 1147 static void time_a_floatx80_z_float64( float64 function( floatx80 ) ) 1148 { 1149 clock_t startClock, endClock; 1150 int32 count, i; 1151 int8 inputNum; 1152 floatx80 a; 1153 1154 count = 0; 1155 inputNum = 0; 1156 startClock = clock(); 1157 do { 1158 for ( i = minIterations; i; --i ) { 1159 a.low = inputs_floatx80[ inputNum ].low; 1160 a.high = inputs_floatx80[ inputNum ].high; 1161 function( a ); 1162 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1163 } 1164 count += minIterations; 1165 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1166 inputNum = 0; 1167 startClock = clock(); 1168 for ( i = count; i; --i ) { 1169 a.low = inputs_floatx80[ inputNum ].low; 1170 a.high = inputs_floatx80[ inputNum ].high; 1171 function( a ); 1172 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1173 } 1174 endClock = clock(); 1175 reportTime( count, endClock - startClock ); 1176 1177 } 1178 1179 #ifdef FLOAT128 1180 1181 static void time_a_floatx80_z_float128( float128 function( floatx80 ) ) 1182 { 1183 clock_t startClock, endClock; 1184 int32 count, i; 1185 int8 inputNum; 1186 floatx80 a; 1187 1188 count = 0; 1189 inputNum = 0; 1190 startClock = clock(); 1191 do { 1192 for ( i = minIterations; i; --i ) { 1193 a.low = inputs_floatx80[ inputNum ].low; 1194 a.high = inputs_floatx80[ inputNum ].high; 1195 function( a ); 1196 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1197 } 1198 count += minIterations; 1199 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1200 inputNum = 0; 1201 startClock = clock(); 1202 for ( i = count; i; --i ) { 1203 a.low = inputs_floatx80[ inputNum ].low; 1204 a.high = inputs_floatx80[ inputNum ].high; 1205 function( a ); 1206 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1207 } 1208 endClock = clock(); 1209 reportTime( count, endClock - startClock ); 1210 1211 } 1212 1213 #endif 1214 1215 static void time_az_floatx80( floatx80 function( floatx80 ) ) 1216 { 1217 clock_t startClock, endClock; 1218 int32 count, i; 1219 int8 inputNum; 1220 floatx80 a; 1221 1222 count = 0; 1223 inputNum = 0; 1224 startClock = clock(); 1225 do { 1226 for ( i = minIterations; i; --i ) { 1227 a.low = inputs_floatx80[ inputNum ].low; 1228 a.high = inputs_floatx80[ inputNum ].high; 1229 function( a ); 1230 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1231 } 1232 count += minIterations; 1233 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1234 inputNum = 0; 1235 startClock = clock(); 1236 for ( i = count; i; --i ) { 1237 a.low = inputs_floatx80[ inputNum ].low; 1238 a.high = inputs_floatx80[ inputNum ].high; 1239 function( a ); 1240 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1241 } 1242 endClock = clock(); 1243 reportTime( count, endClock - startClock ); 1244 1245 } 1246 1247 static void time_ab_floatx80_z_flag( flag function( floatx80, floatx80 ) ) 1248 { 1249 clock_t startClock, endClock; 1250 int32 count, i; 1251 int8 inputNumA, inputNumB; 1252 floatx80 a, b; 1253 1254 count = 0; 1255 inputNumA = 0; 1256 inputNumB = 0; 1257 startClock = clock(); 1258 do { 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; 1264 function( a, b ); 1265 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 ); 1266 if ( inputNumA == 0 ) ++inputNumB; 1267 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 ); 1268 } 1269 count += minIterations; 1270 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1271 inputNumA = 0; 1272 inputNumB = 0; 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; 1279 function( a, b ); 1280 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 ); 1281 if ( inputNumA == 0 ) ++inputNumB; 1282 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 ); 1283 } 1284 endClock = clock(); 1285 reportTime( count, endClock - startClock ); 1286 1287 } 1288 1289 static void time_abz_floatx80( floatx80 function( floatx80, floatx80 ) ) 1290 { 1291 clock_t startClock, endClock; 1292 int32 count, i; 1293 int8 inputNumA, inputNumB; 1294 floatx80 a, b; 1295 1296 count = 0; 1297 inputNumA = 0; 1298 inputNumB = 0; 1299 startClock = clock(); 1300 do { 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; 1306 function( a, b ); 1307 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 ); 1308 if ( inputNumA == 0 ) ++inputNumB; 1309 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 ); 1310 } 1311 count += minIterations; 1312 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1313 inputNumA = 0; 1314 inputNumB = 0; 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; 1321 function( a, b ); 1322 inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 ); 1323 if ( inputNumA == 0 ) ++inputNumB; 1324 inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 ); 1325 } 1326 endClock = clock(); 1327 reportTime( count, endClock - startClock ); 1328 1329 } 1330 1331 static const struct { 1332 bits16 high; 1333 bits64 low; 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 ) } 1367 }; 1368 1369 static void time_az_floatx80_pos( floatx80 function( floatx80 ) ) 1370 { 1371 clock_t startClock, endClock; 1372 int32 count, i; 1373 int8 inputNum; 1374 floatx80 a; 1375 1376 count = 0; 1377 inputNum = 0; 1378 startClock = clock(); 1379 do { 1380 for ( i = minIterations; i; --i ) { 1381 a.low = inputs_floatx80_pos[ inputNum ].low; 1382 a.high = inputs_floatx80_pos[ inputNum ].high; 1383 function( a ); 1384 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1385 } 1386 count += minIterations; 1387 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1388 inputNum = 0; 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; 1393 function( a ); 1394 inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 ); 1395 } 1396 endClock = clock(); 1397 reportTime( count, endClock - startClock ); 1398 1399 } 1400 1401 #endif 1402 1403 #ifdef FLOAT128 1404 1405 enum { 1406 numInputs_float128 = 32 1407 }; 1408 1409 static const struct { 1410 bits64 high, low; 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 ) } 1444 }; 1445 1446 static void time_a_float128_z_int32( int32 function( float128 ) ) 1447 { 1448 clock_t startClock, endClock; 1449 int32 count, i; 1450 int8 inputNum; 1451 float128 a; 1452 1453 count = 0; 1454 inputNum = 0; 1455 startClock = clock(); 1456 do { 1457 for ( i = minIterations; i; --i ) { 1458 a.low = inputs_float128[ inputNum ].low; 1459 a.high = inputs_float128[ inputNum ].high; 1460 function( a ); 1461 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1462 } 1463 count += minIterations; 1464 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1465 inputNum = 0; 1466 startClock = clock(); 1467 for ( i = count; i; --i ) { 1468 a.low = inputs_float128[ inputNum ].low; 1469 a.high = inputs_float128[ inputNum ].high; 1470 function( a ); 1471 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1472 } 1473 endClock = clock(); 1474 reportTime( count, endClock - startClock ); 1475 1476 } 1477 1478 static void time_a_float128_z_int64( int64 function( float128 ) ) 1479 { 1480 clock_t startClock, endClock; 1481 int32 count, i; 1482 int8 inputNum; 1483 float128 a; 1484 1485 count = 0; 1486 inputNum = 0; 1487 startClock = clock(); 1488 do { 1489 for ( i = minIterations; i; --i ) { 1490 a.low = inputs_float128[ inputNum ].low; 1491 a.high = inputs_float128[ inputNum ].high; 1492 function( a ); 1493 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1494 } 1495 count += minIterations; 1496 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1497 inputNum = 0; 1498 startClock = clock(); 1499 for ( i = count; i; --i ) { 1500 a.low = inputs_float128[ inputNum ].low; 1501 a.high = inputs_float128[ inputNum ].high; 1502 function( a ); 1503 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1504 } 1505 endClock = clock(); 1506 reportTime( count, endClock - startClock ); 1507 1508 } 1509 1510 static void time_a_float128_z_float32( float32 function( float128 ) ) 1511 { 1512 clock_t startClock, endClock; 1513 int32 count, i; 1514 int8 inputNum; 1515 float128 a; 1516 1517 count = 0; 1518 inputNum = 0; 1519 startClock = clock(); 1520 do { 1521 for ( i = minIterations; i; --i ) { 1522 a.low = inputs_float128[ inputNum ].low; 1523 a.high = inputs_float128[ inputNum ].high; 1524 function( a ); 1525 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1526 } 1527 count += minIterations; 1528 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1529 inputNum = 0; 1530 startClock = clock(); 1531 for ( i = count; i; --i ) { 1532 a.low = inputs_float128[ inputNum ].low; 1533 a.high = inputs_float128[ inputNum ].high; 1534 function( a ); 1535 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1536 } 1537 endClock = clock(); 1538 reportTime( count, endClock - startClock ); 1539 1540 } 1541 1542 static void time_a_float128_z_float64( float64 function( float128 ) ) 1543 { 1544 clock_t startClock, endClock; 1545 int32 count, i; 1546 int8 inputNum; 1547 float128 a; 1548 1549 count = 0; 1550 inputNum = 0; 1551 startClock = clock(); 1552 do { 1553 for ( i = minIterations; i; --i ) { 1554 a.low = inputs_float128[ inputNum ].low; 1555 a.high = inputs_float128[ inputNum ].high; 1556 function( a ); 1557 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1558 } 1559 count += minIterations; 1560 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1561 inputNum = 0; 1562 startClock = clock(); 1563 for ( i = count; i; --i ) { 1564 a.low = inputs_float128[ inputNum ].low; 1565 a.high = inputs_float128[ inputNum ].high; 1566 function( a ); 1567 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1568 } 1569 endClock = clock(); 1570 reportTime( count, endClock - startClock ); 1571 1572 } 1573 1574 #ifdef FLOATX80 1575 1576 static void time_a_float128_z_floatx80( floatx80 function( float128 ) ) 1577 { 1578 clock_t startClock, endClock; 1579 int32 count, i; 1580 int8 inputNum; 1581 float128 a; 1582 1583 count = 0; 1584 inputNum = 0; 1585 startClock = clock(); 1586 do { 1587 for ( i = minIterations; i; --i ) { 1588 a.low = inputs_float128[ inputNum ].low; 1589 a.high = inputs_float128[ inputNum ].high; 1590 function( a ); 1591 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1592 } 1593 count += minIterations; 1594 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1595 inputNum = 0; 1596 startClock = clock(); 1597 for ( i = count; i; --i ) { 1598 a.low = inputs_float128[ inputNum ].low; 1599 a.high = inputs_float128[ inputNum ].high; 1600 function( a ); 1601 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1602 } 1603 endClock = clock(); 1604 reportTime( count, endClock - startClock ); 1605 1606 } 1607 1608 #endif 1609 1610 static void time_az_float128( float128 function( float128 ) ) 1611 { 1612 clock_t startClock, endClock; 1613 int32 count, i; 1614 int8 inputNum; 1615 float128 a; 1616 1617 count = 0; 1618 inputNum = 0; 1619 startClock = clock(); 1620 do { 1621 for ( i = minIterations; i; --i ) { 1622 a.low = inputs_float128[ inputNum ].low; 1623 a.high = inputs_float128[ inputNum ].high; 1624 function( a ); 1625 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1626 } 1627 count += minIterations; 1628 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1629 inputNum = 0; 1630 startClock = clock(); 1631 for ( i = count; i; --i ) { 1632 a.low = inputs_float128[ inputNum ].low; 1633 a.high = inputs_float128[ inputNum ].high; 1634 function( a ); 1635 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1636 } 1637 endClock = clock(); 1638 reportTime( count, endClock - startClock ); 1639 1640 } 1641 1642 static void time_ab_float128_z_flag( flag function( float128, float128 ) ) 1643 { 1644 clock_t startClock, endClock; 1645 int32 count, i; 1646 int8 inputNumA, inputNumB; 1647 float128 a, b; 1648 1649 count = 0; 1650 inputNumA = 0; 1651 inputNumB = 0; 1652 startClock = clock(); 1653 do { 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; 1659 function( a, b ); 1660 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 ); 1661 if ( inputNumA == 0 ) ++inputNumB; 1662 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 ); 1663 } 1664 count += minIterations; 1665 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1666 inputNumA = 0; 1667 inputNumB = 0; 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; 1674 function( a, b ); 1675 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 ); 1676 if ( inputNumA == 0 ) ++inputNumB; 1677 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 ); 1678 } 1679 endClock = clock(); 1680 reportTime( count, endClock - startClock ); 1681 1682 } 1683 1684 static void time_abz_float128( float128 function( float128, float128 ) ) 1685 { 1686 clock_t startClock, endClock; 1687 int32 count, i; 1688 int8 inputNumA, inputNumB; 1689 float128 a, b; 1690 1691 count = 0; 1692 inputNumA = 0; 1693 inputNumB = 0; 1694 startClock = clock(); 1695 do { 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; 1701 function( a, b ); 1702 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 ); 1703 if ( inputNumA == 0 ) ++inputNumB; 1704 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 ); 1705 } 1706 count += minIterations; 1707 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1708 inputNumA = 0; 1709 inputNumB = 0; 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; 1716 function( a, b ); 1717 inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 ); 1718 if ( inputNumA == 0 ) ++inputNumB; 1719 inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 ); 1720 } 1721 endClock = clock(); 1722 reportTime( count, endClock - startClock ); 1723 1724 } 1725 1726 static const struct { 1727 bits64 high, low; 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 ) } 1761 }; 1762 1763 static void time_az_float128_pos( float128 function( float128 ) ) 1764 { 1765 clock_t startClock, endClock; 1766 int32 count, i; 1767 int8 inputNum; 1768 float128 a; 1769 1770 count = 0; 1771 inputNum = 0; 1772 startClock = clock(); 1773 do { 1774 for ( i = minIterations; i; --i ) { 1775 a.low = inputs_float128_pos[ inputNum ].low; 1776 a.high = inputs_float128_pos[ inputNum ].high; 1777 function( a ); 1778 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1779 } 1780 count += minIterations; 1781 } while ( clock() - startClock < CLOCKS_PER_SEC ); 1782 inputNum = 0; 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; 1787 function( a ); 1788 inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 ); 1789 } 1790 endClock = clock(); 1791 reportTime( count, endClock - startClock ); 1792 1793 } 1794 1795 #endif 1796 1797 enum { 1798 INT32_TO_FLOAT32 = 1, 1799 INT32_TO_FLOAT64, 1800 #ifdef FLOATX80 1801 INT32_TO_FLOATX80, 1802 #endif 1803 #ifdef FLOAT128 1804 INT32_TO_FLOAT128, 1805 #endif 1806 INT64_TO_FLOAT32, 1807 INT64_TO_FLOAT64, 1808 #ifdef FLOATX80 1809 INT64_TO_FLOATX80, 1810 #endif 1811 #ifdef FLOAT128 1812 INT64_TO_FLOAT128, 1813 #endif 1814 FLOAT32_TO_INT32, 1815 FLOAT32_TO_INT32_ROUND_TO_ZERO, 1816 FLOAT32_TO_INT64, 1817 FLOAT32_TO_INT64_ROUND_TO_ZERO, 1818 FLOAT32_TO_FLOAT64, 1819 #ifdef FLOATX80 1820 FLOAT32_TO_FLOATX80, 1821 #endif 1822 #ifdef FLOAT128 1823 FLOAT32_TO_FLOAT128, 1824 #endif 1825 FLOAT32_ROUND_TO_INT, 1826 FLOAT32_ADD, 1827 FLOAT32_SUB, 1828 FLOAT32_MUL, 1829 FLOAT32_DIV, 1830 FLOAT32_REM, 1831 FLOAT32_SQRT, 1832 FLOAT32_EQ, 1833 FLOAT32_LE, 1834 FLOAT32_LT, 1835 FLOAT32_EQ_SIGNALING, 1836 FLOAT32_LE_QUIET, 1837 FLOAT32_LT_QUIET, 1838 FLOAT64_TO_INT32, 1839 FLOAT64_TO_INT32_ROUND_TO_ZERO, 1840 FLOAT64_TO_INT64, 1841 FLOAT64_TO_INT64_ROUND_TO_ZERO, 1842 FLOAT64_TO_FLOAT32, 1843 #ifdef FLOATX80 1844 FLOAT64_TO_FLOATX80, 1845 #endif 1846 #ifdef FLOAT128 1847 FLOAT64_TO_FLOAT128, 1848 #endif 1849 FLOAT64_ROUND_TO_INT, 1850 FLOAT64_ADD, 1851 FLOAT64_SUB, 1852 FLOAT64_MUL, 1853 FLOAT64_DIV, 1854 FLOAT64_REM, 1855 FLOAT64_SQRT, 1856 FLOAT64_EQ, 1857 FLOAT64_LE, 1858 FLOAT64_LT, 1859 FLOAT64_EQ_SIGNALING, 1860 FLOAT64_LE_QUIET, 1861 FLOAT64_LT_QUIET, 1862 #ifdef FLOATX80 1863 FLOATX80_TO_INT32, 1864 FLOATX80_TO_INT32_ROUND_TO_ZERO, 1865 FLOATX80_TO_INT64, 1866 FLOATX80_TO_INT64_ROUND_TO_ZERO, 1867 FLOATX80_TO_FLOAT32, 1868 FLOATX80_TO_FLOAT64, 1869 #ifdef FLOAT128 1870 FLOATX80_TO_FLOAT128, 1871 #endif 1872 FLOATX80_ROUND_TO_INT, 1873 FLOATX80_ADD, 1874 FLOATX80_SUB, 1875 FLOATX80_MUL, 1876 FLOATX80_DIV, 1877 FLOATX80_REM, 1878 FLOATX80_SQRT, 1879 FLOATX80_EQ, 1880 FLOATX80_LE, 1881 FLOATX80_LT, 1882 FLOATX80_EQ_SIGNALING, 1883 FLOATX80_LE_QUIET, 1884 FLOATX80_LT_QUIET, 1885 #endif 1886 #ifdef FLOAT128 1887 FLOAT128_TO_INT32, 1888 FLOAT128_TO_INT32_ROUND_TO_ZERO, 1889 FLOAT128_TO_INT64, 1890 FLOAT128_TO_INT64_ROUND_TO_ZERO, 1891 FLOAT128_TO_FLOAT32, 1892 FLOAT128_TO_FLOAT64, 1893 #ifdef FLOATX80 1894 FLOAT128_TO_FLOATX80, 1895 #endif 1896 FLOAT128_ROUND_TO_INT, 1897 FLOAT128_ADD, 1898 FLOAT128_SUB, 1899 FLOAT128_MUL, 1900 FLOAT128_DIV, 1901 FLOAT128_REM, 1902 FLOAT128_SQRT, 1903 FLOAT128_EQ, 1904 FLOAT128_LE, 1905 FLOAT128_LT, 1906 FLOAT128_EQ_SIGNALING, 1907 FLOAT128_LE_QUIET, 1908 FLOAT128_LT_QUIET, 1909 #endif 1910 NUM_FUNCTIONS 1911 }; 1912 1913 static struct { 1914 char *name; 1915 int8 numInputs; 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 }, 1922 #ifdef FLOATX80 1923 { "int32_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE }, 1924 #endif 1925 #ifdef FLOAT128 1926 { "int32_to_float128", 1, FALSE, FALSE, FALSE, FALSE }, 1927 #endif 1928 { "int64_to_float32", 1, FALSE, TRUE, FALSE, FALSE }, 1929 { "int64_to_float64", 1, FALSE, TRUE, FALSE, FALSE }, 1930 #ifdef FLOATX80 1931 { "int64_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE }, 1932 #endif 1933 #ifdef FLOAT128 1934 { "int64_to_float128", 1, FALSE, FALSE, FALSE, FALSE }, 1935 #endif 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 }, 1941 #ifdef FLOATX80 1942 { "float32_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE }, 1943 #endif 1944 #ifdef FLOAT128 1945 { "float32_to_float128", 1, FALSE, FALSE, FALSE, FALSE }, 1946 #endif 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 }, 1965 #ifdef FLOATX80 1966 { "float64_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE }, 1967 #endif 1968 #ifdef FLOAT128 1969 { "float64_to_float128", 1, FALSE, FALSE, FALSE, FALSE }, 1970 #endif 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 }, 1984 #ifdef FLOATX80 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 }, 1991 #ifdef FLOAT128 1992 { "floatx80_to_float128", 1, FALSE, FALSE, FALSE, FALSE }, 1993 #endif 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 }, 2007 #endif 2008 #ifdef FLOAT128 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 }, 2015 #ifdef FLOATX80 2016 { "float128_to_floatx80", 1, FALSE, TRUE, TRUE, FALSE }, 2017 #endif 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 }, 2031 #endif 2032 }; 2033 2034 enum { 2035 ROUND_NEAREST_EVEN = 1, 2036 ROUND_TO_ZERO, 2037 ROUND_DOWN, 2038 ROUND_UP, 2039 NUM_ROUNDINGMODES 2040 }; 2041 enum { 2042 TININESS_BEFORE_ROUNDING = 1, 2043 TININESS_AFTER_ROUNDING, 2044 NUM_TININESSMODES 2045 }; 2046 2047 static void 2048 timeFunctionVariety( 2049 uint8 functionCode, 2050 int8 roundingPrecision, 2051 int8 roundingMode, 2052 int8 tininessMode 2053 ) 2054 { 2055 uint8 roundingCode; 2056 int8 tininessCode; 2057 2058 functionName = functions[ functionCode ].name; 2059 if ( roundingPrecision == 32 ) { 2060 roundingPrecisionName = "32"; 2061 } 2062 else if ( roundingPrecision == 64 ) { 2063 roundingPrecisionName = "64"; 2064 } 2065 else if ( roundingPrecision == 80 ) { 2066 roundingPrecisionName = "80"; 2067 } 2068 else { 2069 roundingPrecisionName = NULL; 2070 } 2071 #ifdef FLOATX80 2072 floatx80_rounding_precision = roundingPrecision; 2073 #endif 2074 switch ( roundingMode ) { 2075 case 0: 2076 roundingModeName = NULL; 2077 roundingCode = float_round_nearest_even; 2078 break; 2079 case ROUND_NEAREST_EVEN: 2080 roundingModeName = "nearest_even"; 2081 roundingCode = float_round_nearest_even; 2082 break; 2083 case ROUND_TO_ZERO: 2084 roundingModeName = "to_zero"; 2085 roundingCode = float_round_to_zero; 2086 break; 2087 case ROUND_DOWN: 2088 roundingModeName = "down"; 2089 roundingCode = float_round_down; 2090 break; 2091 case ROUND_UP: 2092 roundingModeName = "up"; 2093 roundingCode = float_round_up; 2094 break; 2095 } 2096 float_rounding_mode = roundingCode; 2097 switch ( tininessMode ) { 2098 case 0: 2099 tininessModeName = NULL; 2100 tininessCode = float_tininess_after_rounding; 2101 break; 2102 case TININESS_BEFORE_ROUNDING: 2103 tininessModeName = "before"; 2104 tininessCode = float_tininess_before_rounding; 2105 break; 2106 case TININESS_AFTER_ROUNDING: 2107 tininessModeName = "after"; 2108 tininessCode = float_tininess_after_rounding; 2109 break; 2110 } 2111 float_detect_tininess = tininessCode; 2112 switch ( functionCode ) { 2113 case INT32_TO_FLOAT32: 2114 time_a_int32_z_float32( int32_to_float32 ); 2115 break; 2116 case INT32_TO_FLOAT64: 2117 time_a_int32_z_float64( int32_to_float64 ); 2118 break; 2119 #ifdef FLOATX80 2120 case INT32_TO_FLOATX80: 2121 time_a_int32_z_floatx80( int32_to_floatx80 ); 2122 break; 2123 #endif 2124 #ifdef FLOAT128 2125 case INT32_TO_FLOAT128: 2126 time_a_int32_z_float128( int32_to_float128 ); 2127 break; 2128 #endif 2129 case INT64_TO_FLOAT32: 2130 time_a_int64_z_float32( int64_to_float32 ); 2131 break; 2132 case INT64_TO_FLOAT64: 2133 time_a_int64_z_float64( int64_to_float64 ); 2134 break; 2135 #ifdef FLOATX80 2136 case INT64_TO_FLOATX80: 2137 time_a_int64_z_floatx80( int64_to_floatx80 ); 2138 break; 2139 #endif 2140 #ifdef FLOAT128 2141 case INT64_TO_FLOAT128: 2142 time_a_int64_z_float128( int64_to_float128 ); 2143 break; 2144 #endif 2145 case FLOAT32_TO_INT32: 2146 time_a_float32_z_int32( float32_to_int32 ); 2147 break; 2148 case FLOAT32_TO_INT32_ROUND_TO_ZERO: 2149 time_a_float32_z_int32( float32_to_int32_round_to_zero ); 2150 break; 2151 case FLOAT32_TO_INT64: 2152 time_a_float32_z_int64( float32_to_int64 ); 2153 break; 2154 case FLOAT32_TO_INT64_ROUND_TO_ZERO: 2155 time_a_float32_z_int64( float32_to_int64_round_to_zero ); 2156 break; 2157 case FLOAT32_TO_FLOAT64: 2158 time_a_float32_z_float64( float32_to_float64 ); 2159 break; 2160 #ifdef FLOATX80 2161 case FLOAT32_TO_FLOATX80: 2162 time_a_float32_z_floatx80( float32_to_floatx80 ); 2163 break; 2164 #endif 2165 #ifdef FLOAT128 2166 case FLOAT32_TO_FLOAT128: 2167 time_a_float32_z_float128( float32_to_float128 ); 2168 break; 2169 #endif 2170 case FLOAT32_ROUND_TO_INT: 2171 time_az_float32( float32_round_to_int ); 2172 break; 2173 case FLOAT32_ADD: 2174 time_abz_float32( float32_add ); 2175 break; 2176 case FLOAT32_SUB: 2177 time_abz_float32( float32_sub ); 2178 break; 2179 case FLOAT32_MUL: 2180 time_abz_float32( float32_mul ); 2181 break; 2182 case FLOAT32_DIV: 2183 time_abz_float32( float32_div ); 2184 break; 2185 case FLOAT32_REM: 2186 time_abz_float32( float32_rem ); 2187 break; 2188 case FLOAT32_SQRT: 2189 time_az_float32_pos( float32_sqrt ); 2190 break; 2191 case FLOAT32_EQ: 2192 time_ab_float32_z_flag( float32_eq ); 2193 break; 2194 case FLOAT32_LE: 2195 time_ab_float32_z_flag( float32_le ); 2196 break; 2197 case FLOAT32_LT: 2198 time_ab_float32_z_flag( float32_lt ); 2199 break; 2200 case FLOAT32_EQ_SIGNALING: 2201 time_ab_float32_z_flag( float32_eq_signaling ); 2202 break; 2203 case FLOAT32_LE_QUIET: 2204 time_ab_float32_z_flag( float32_le_quiet ); 2205 break; 2206 case FLOAT32_LT_QUIET: 2207 time_ab_float32_z_flag( float32_lt_quiet ); 2208 break; 2209 case FLOAT64_TO_INT32: 2210 time_a_float64_z_int32( float64_to_int32 ); 2211 break; 2212 case FLOAT64_TO_INT32_ROUND_TO_ZERO: 2213 time_a_float64_z_int32( float64_to_int32_round_to_zero ); 2214 break; 2215 case FLOAT64_TO_INT64: 2216 time_a_float64_z_int64( float64_to_int64 ); 2217 break; 2218 case FLOAT64_TO_INT64_ROUND_TO_ZERO: 2219 time_a_float64_z_int64( float64_to_int64_round_to_zero ); 2220 break; 2221 case FLOAT64_TO_FLOAT32: 2222 time_a_float64_z_float32( float64_to_float32 ); 2223 break; 2224 #ifdef FLOATX80 2225 case FLOAT64_TO_FLOATX80: 2226 time_a_float64_z_floatx80( float64_to_floatx80 ); 2227 break; 2228 #endif 2229 #ifdef FLOAT128 2230 case FLOAT64_TO_FLOAT128: 2231 time_a_float64_z_float128( float64_to_float128 ); 2232 break; 2233 #endif 2234 case FLOAT64_ROUND_TO_INT: 2235 time_az_float64( float64_round_to_int ); 2236 break; 2237 case FLOAT64_ADD: 2238 time_abz_float64( float64_add ); 2239 break; 2240 case FLOAT64_SUB: 2241 time_abz_float64( float64_sub ); 2242 break; 2243 case FLOAT64_MUL: 2244 time_abz_float64( float64_mul ); 2245 break; 2246 case FLOAT64_DIV: 2247 time_abz_float64( float64_div ); 2248 break; 2249 case FLOAT64_REM: 2250 time_abz_float64( float64_rem ); 2251 break; 2252 case FLOAT64_SQRT: 2253 time_az_float64_pos( float64_sqrt ); 2254 break; 2255 case FLOAT64_EQ: 2256 time_ab_float64_z_flag( float64_eq ); 2257 break; 2258 case FLOAT64_LE: 2259 time_ab_float64_z_flag( float64_le ); 2260 break; 2261 case FLOAT64_LT: 2262 time_ab_float64_z_flag( float64_lt ); 2263 break; 2264 case FLOAT64_EQ_SIGNALING: 2265 time_ab_float64_z_flag( float64_eq_signaling ); 2266 break; 2267 case FLOAT64_LE_QUIET: 2268 time_ab_float64_z_flag( float64_le_quiet ); 2269 break; 2270 case FLOAT64_LT_QUIET: 2271 time_ab_float64_z_flag( float64_lt_quiet ); 2272 break; 2273 #ifdef FLOATX80 2274 case FLOATX80_TO_INT32: 2275 time_a_floatx80_z_int32( floatx80_to_int32 ); 2276 break; 2277 case FLOATX80_TO_INT32_ROUND_TO_ZERO: 2278 time_a_floatx80_z_int32( floatx80_to_int32_round_to_zero ); 2279 break; 2280 case FLOATX80_TO_INT64: 2281 time_a_floatx80_z_int64( floatx80_to_int64 ); 2282 break; 2283 case FLOATX80_TO_INT64_ROUND_TO_ZERO: 2284 time_a_floatx80_z_int64( floatx80_to_int64_round_to_zero ); 2285 break; 2286 case FLOATX80_TO_FLOAT32: 2287 time_a_floatx80_z_float32( floatx80_to_float32 ); 2288 break; 2289 case FLOATX80_TO_FLOAT64: 2290 time_a_floatx80_z_float64( floatx80_to_float64 ); 2291 break; 2292 #ifdef FLOAT128 2293 case FLOATX80_TO_FLOAT128: 2294 time_a_floatx80_z_float128( floatx80_to_float128 ); 2295 break; 2296 #endif 2297 case FLOATX80_ROUND_TO_INT: 2298 time_az_floatx80( floatx80_round_to_int ); 2299 break; 2300 case FLOATX80_ADD: 2301 time_abz_floatx80( floatx80_add ); 2302 break; 2303 case FLOATX80_SUB: 2304 time_abz_floatx80( floatx80_sub ); 2305 break; 2306 case FLOATX80_MUL: 2307 time_abz_floatx80( floatx80_mul ); 2308 break; 2309 case FLOATX80_DIV: 2310 time_abz_floatx80( floatx80_div ); 2311 break; 2312 case FLOATX80_REM: 2313 time_abz_floatx80( floatx80_rem ); 2314 break; 2315 case FLOATX80_SQRT: 2316 time_az_floatx80_pos( floatx80_sqrt ); 2317 break; 2318 case FLOATX80_EQ: 2319 time_ab_floatx80_z_flag( floatx80_eq ); 2320 break; 2321 case FLOATX80_LE: 2322 time_ab_floatx80_z_flag( floatx80_le ); 2323 break; 2324 case FLOATX80_LT: 2325 time_ab_floatx80_z_flag( floatx80_lt ); 2326 break; 2327 case FLOATX80_EQ_SIGNALING: 2328 time_ab_floatx80_z_flag( floatx80_eq_signaling ); 2329 break; 2330 case FLOATX80_LE_QUIET: 2331 time_ab_floatx80_z_flag( floatx80_le_quiet ); 2332 break; 2333 case FLOATX80_LT_QUIET: 2334 time_ab_floatx80_z_flag( floatx80_lt_quiet ); 2335 break; 2336 #endif 2337 #ifdef FLOAT128 2338 case FLOAT128_TO_INT32: 2339 time_a_float128_z_int32( float128_to_int32 ); 2340 break; 2341 case FLOAT128_TO_INT32_ROUND_TO_ZERO: 2342 time_a_float128_z_int32( float128_to_int32_round_to_zero ); 2343 break; 2344 case FLOAT128_TO_INT64: 2345 time_a_float128_z_int64( float128_to_int64 ); 2346 break; 2347 case FLOAT128_TO_INT64_ROUND_TO_ZERO: 2348 time_a_float128_z_int64( float128_to_int64_round_to_zero ); 2349 break; 2350 case FLOAT128_TO_FLOAT32: 2351 time_a_float128_z_float32( float128_to_float32 ); 2352 break; 2353 case FLOAT128_TO_FLOAT64: 2354 time_a_float128_z_float64( float128_to_float64 ); 2355 break; 2356 #ifdef FLOATX80 2357 case FLOAT128_TO_FLOATX80: 2358 time_a_float128_z_floatx80( float128_to_floatx80 ); 2359 break; 2360 #endif 2361 case FLOAT128_ROUND_TO_INT: 2362 time_az_float128( float128_round_to_int ); 2363 break; 2364 case FLOAT128_ADD: 2365 time_abz_float128( float128_add ); 2366 break; 2367 case FLOAT128_SUB: 2368 time_abz_float128( float128_sub ); 2369 break; 2370 case FLOAT128_MUL: 2371 time_abz_float128( float128_mul ); 2372 break; 2373 case FLOAT128_DIV: 2374 time_abz_float128( float128_div ); 2375 break; 2376 case FLOAT128_REM: 2377 time_abz_float128( float128_rem ); 2378 break; 2379 case FLOAT128_SQRT: 2380 time_az_float128_pos( float128_sqrt ); 2381 break; 2382 case FLOAT128_EQ: 2383 time_ab_float128_z_flag( float128_eq ); 2384 break; 2385 case FLOAT128_LE: 2386 time_ab_float128_z_flag( float128_le ); 2387 break; 2388 case FLOAT128_LT: 2389 time_ab_float128_z_flag( float128_lt ); 2390 break; 2391 case FLOAT128_EQ_SIGNALING: 2392 time_ab_float128_z_flag( float128_eq_signaling ); 2393 break; 2394 case FLOAT128_LE_QUIET: 2395 time_ab_float128_z_flag( float128_le_quiet ); 2396 break; 2397 case FLOAT128_LT_QUIET: 2398 time_ab_float128_z_flag( float128_lt_quiet ); 2399 break; 2400 #endif 2401 } 2402 2403 } 2404 2405 static void 2406 timeFunction( 2407 uint8 functionCode, 2408 int8 roundingPrecisionIn, 2409 int8 roundingModeIn, 2410 int8 tininessModeIn 2411 ) 2412 { 2413 int8 roundingPrecision, roundingMode, tininessMode; 2414 2415 roundingPrecision = 32; 2416 for (;;) { 2417 if ( ! functions[ functionCode ].roundingPrecision ) { 2418 roundingPrecision = 0; 2419 } 2420 else if ( roundingPrecisionIn ) { 2421 roundingPrecision = roundingPrecisionIn; 2422 } 2423 for ( roundingMode = 1; 2424 roundingMode < NUM_ROUNDINGMODES; 2425 ++roundingMode 2426 ) { 2427 if ( ! functions[ functionCode ].roundingMode ) { 2428 roundingMode = 0; 2429 } 2430 else if ( roundingModeIn ) { 2431 roundingMode = roundingModeIn; 2432 } 2433 for ( tininessMode = 1; 2434 tininessMode < NUM_TININESSMODES; 2435 ++tininessMode 2436 ) { 2437 if ( ( roundingPrecision == 32 ) 2438 || ( roundingPrecision == 64 ) ) { 2439 if ( ! functions[ functionCode ] 2440 .tininessModeAtReducedPrecision 2441 ) { 2442 tininessMode = 0; 2443 } 2444 else if ( tininessModeIn ) { 2445 tininessMode = tininessModeIn; 2446 } 2447 } 2448 else { 2449 if ( ! functions[ functionCode ].tininessMode ) { 2450 tininessMode = 0; 2451 } 2452 else if ( tininessModeIn ) { 2453 tininessMode = tininessModeIn; 2454 } 2455 } 2456 timeFunctionVariety( 2457 functionCode, roundingPrecision, roundingMode, tininessMode 2458 ); 2459 if ( tininessModeIn || ! tininessMode ) break; 2460 } 2461 if ( roundingModeIn || ! roundingMode ) break; 2462 } 2463 if ( roundingPrecisionIn || ! roundingPrecision ) break; 2464 if ( roundingPrecision == 80 ) { 2465 break; 2466 } 2467 else if ( roundingPrecision == 64 ) { 2468 roundingPrecision = 80; 2469 } 2470 else if ( roundingPrecision == 32 ) { 2471 roundingPrecision = 64; 2472 } 2473 } 2474 2475 } 2476 2477 main( int argc, char **argv ) 2478 { 2479 char *argPtr; 2480 flag functionArgument; 2481 uint8 functionCode; 2482 int8 operands, roundingPrecision, roundingMode, tininessMode; 2483 2484 if ( argc <= 1 ) goto writeHelpMessage; 2485 functionArgument = FALSE; 2486 functionCode = 0; 2487 operands = 0; 2488 roundingPrecision = 0; 2489 roundingMode = 0; 2490 tininessMode = 0; 2491 --argc; 2492 ++argv; 2493 while ( argc && ( argPtr = argv[ 0 ] ) ) { 2494 if ( argPtr[ 0 ] == '-' ) ++argPtr; 2495 if ( strcmp( argPtr, "help" ) == 0 ) { 2496 writeHelpMessage: 2497 fputs( 2498 "timesoftfloat [<option>...] <function>\n" 2499 " <option>: (* is default)\n" 2500 " -help --Write this message and exit.\n" 2501 #ifdef FLOATX80 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" 2505 #endif 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" 2512 " <function>:\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" 2521 " <float>_sqrt\n" 2522 " -all1 --All 1-operand functions.\n" 2523 " -all2 --All 2-operand functions.\n" 2524 " -all --All functions.\n" 2525 " <float>:\n" 2526 " float32 --Single precision.\n" 2527 " float64 --Double precision.\n" 2528 #ifdef FLOATX80 2529 " floatx80 --Extended double precision.\n" 2530 #endif 2531 #ifdef FLOAT128 2532 " float128 --Quadruple precision.\n" 2533 #endif 2534 , 2535 stdout 2536 ); 2537 return EXIT_SUCCESS; 2538 } 2539 #ifdef FLOATX80 2540 else if ( strcmp( argPtr, "precision32" ) == 0 ) { 2541 roundingPrecision = 32; 2542 } 2543 else if ( strcmp( argPtr, "precision64" ) == 0 ) { 2544 roundingPrecision = 64; 2545 } 2546 else if ( strcmp( argPtr, "precision80" ) == 0 ) { 2547 roundingPrecision = 80; 2548 } 2549 #endif 2550 else if ( ( strcmp( argPtr, "nearesteven" ) == 0 ) 2551 || ( strcmp( argPtr, "nearest_even" ) == 0 ) ) { 2552 roundingMode = ROUND_NEAREST_EVEN; 2553 } 2554 else if ( ( strcmp( argPtr, "tozero" ) == 0 ) 2555 || ( strcmp( argPtr, "to_zero" ) == 0 ) ) { 2556 roundingMode = ROUND_TO_ZERO; 2557 } 2558 else if ( strcmp( argPtr, "down" ) == 0 ) { 2559 roundingMode = ROUND_DOWN; 2560 } 2561 else if ( strcmp( argPtr, "up" ) == 0 ) { 2562 roundingMode = ROUND_UP; 2563 } 2564 else if ( strcmp( argPtr, "tininessbefore" ) == 0 ) { 2565 tininessMode = TININESS_BEFORE_ROUNDING; 2566 } 2567 else if ( strcmp( argPtr, "tininessafter" ) == 0 ) { 2568 tininessMode = TININESS_AFTER_ROUNDING; 2569 } 2570 else if ( strcmp( argPtr, "all1" ) == 0 ) { 2571 functionArgument = TRUE; 2572 functionCode = 0; 2573 operands = 1; 2574 } 2575 else if ( strcmp( argPtr, "all2" ) == 0 ) { 2576 functionArgument = TRUE; 2577 functionCode = 0; 2578 operands = 2; 2579 } 2580 else if ( strcmp( argPtr, "all" ) == 0 ) { 2581 functionArgument = TRUE; 2582 functionCode = 0; 2583 operands = 0; 2584 } 2585 else { 2586 for ( functionCode = 1; 2587 functionCode < NUM_FUNCTIONS; 2588 ++functionCode 2589 ) { 2590 if ( strcmp( argPtr, functions[ functionCode ].name ) == 0 ) { 2591 break; 2592 } 2593 } 2594 if ( functionCode == NUM_FUNCTIONS ) { 2595 fail( "Invalid option or function `%s'", argv[ 0 ] ); 2596 } 2597 functionArgument = TRUE; 2598 } 2599 --argc; 2600 ++argv; 2601 } 2602 if ( ! functionArgument ) fail( "Function argument required" ); 2603 if ( functionCode ) { 2604 timeFunction( 2605 functionCode, roundingPrecision, roundingMode, tininessMode ); 2606 } 2607 else if ( operands == 1 ) { 2608 for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode 2609 ) { 2610 if ( functions[ functionCode ].numInputs == 1 ) { 2611 timeFunction( 2612 functionCode, roundingPrecision, roundingMode, tininessMode 2613 ); 2614 } 2615 } 2616 } 2617 else if ( operands == 2 ) { 2618 for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode 2619 ) { 2620 if ( functions[ functionCode ].numInputs == 2 ) { 2621 timeFunction( 2622 functionCode, roundingPrecision, roundingMode, tininessMode 2623 ); 2624 } 2625 } 2626 } 2627 else { 2628 for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode 2629 ) { 2630 timeFunction( 2631 functionCode, roundingPrecision, roundingMode, tininessMode ); 2632 } 2633 } 2634 return EXIT_SUCCESS; 2635 2636 } 2637 2638