Changeset 103747 in vbox for trunk/src/VBox/ValidationKit/bootsectors
- Timestamp:
- Mar 9, 2024 12:33:31 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-3.c32
r103746 r103747 548 548 549 549 /* 550 * Code to make testing the tests faster. `bs3CpuInstr3_SkipIt()' randomly 551 * skips a large fraction of the micro-tests. It is sufficiently random 552 * that over a large number of runs, all micro-tests will be hit. 553 * 554 * This improves the runtime of the worst case (`#define ALL_TESTS' on a 555 * debug build, run with '--execute-all-in-iem') from ~9000 to ~800 seconds 556 * (on an Intel Core i7-10700, fwiw). 557 * 558 * To activate this 'developer's speed-testing mode', turn on 559 * `#define BS3_SKIPIT_DO_SKIP' here. 560 * 561 * BS3_SKIPIT_AVG_SKIP governs approximately how many micro-tests are 562 * skipped in a row; e.g. the default of 26 means about every 27th 563 * micro-test is run during a particular test run. (This is not 27x 564 * faster due to other activities which are not skipped!) Note this is 565 * only an average; the actual skips are random. 566 * 567 * You can also modify bs3CpuInstr3_SkipIt() to focus on specific sub-tests, 568 * using its (currently ignored) `bRing, iCfg, iTest, iVal, iVariant' args 569 * (to enable this: turn on `#define BS3_SKIPIT_DO_ARGS': which costs about 570 * 3% performance). 571 */ 572 #define BS3_SKIPIT_AVG_SKIP 26 573 #undef BS3_SKIPIT_DO_SKIP 574 #undef BS3_SKIPIT_DO_ARGS 575 #define BS3_SKIPIT_DO_SKIP 576 577 #if defined(BS3_SKIPIT_DO_SKIP) 578 uint32_t BS3_ASMrdtsc_lo(); 579 #pragma aux BS3_ASMrdtsc_lo = \ 580 ".586" \ 581 "rdtsc" \ 582 modify [edx eax] value [eax]; 583 584 DECLINLINE(uint32_t) bs3CpuInstr3_SimpleRand() 585 { 586 /* 587 * A simple Lehmer linear congruential pseudo-random number 588 * generator using the constants suggested by Park & Miller: 589 * 590 * modulus = 2^31 - 1 (INT32_MAX) 591 * multiplier = 7^5 (16807) 592 * 593 * It produces numbers in the range [1..INT32_MAX-1] and is 594 * more chaotic in the higher bits. 595 */ 596 static uint32_t s_uSeedMemory = 0; 597 598 RTUINT64U uProduct; 599 uint32_t uHiMod, uLoMod; 600 601 if (!s_uSeedMemory) 602 s_uSeedMemory = BS3_ASMrdtsc_lo(); 603 604 uProduct.u = (uint64_t)s_uSeedMemory * 16807; 605 /* 606 * This piece-wise modulus operation is vastly faster 607 * than openwatcom's built-in 64-div-32 routine! 608 */ 609 uHiMod = (uProduct.au32[0] * 2) % INT32_MAX; 610 uLoMod = (uProduct.au32[1] & 0xFFFFFFFF) % INT32_MAX; 611 s_uSeedMemory = (uHiMod + uLoMod) % INT32_MAX; 612 return s_uSeedMemory; 613 } 614 #endif /* BS3_SKIPIT_DO_SKIP */ 615 616 static unsigned g_cSeen, g_cSkipped; 617 618 static void bs3CpuInstr3_ShowTallies() 619 { 620 Bs3TestPrintf("Micro-tests %d: tested %d / skipped %d\n", g_cSeen, g_cSeen - g_cSkipped, g_cSkipped); 621 } 622 623 #if defined(BS3_SKIPIT_DO_ARGS) 624 # define BS3_SKIPIT(bRing, iCfg, iTest, iVal, iVariant) bs3CpuInstr3_SkipIt(bRing, iCfg, iTest, iVal, iVariant) 625 static unsigned bs3CpuInstr3_SkipIt(uint8_t bRing, unsigned iCfg, unsigned iTest, unsigned iVal, unsigned iVariant) 626 #else 627 # define BS3_SKIPIT(bRing, iCfg, iTest, iVal, iVariant) bs3CpuInstr3_SkipIt() 628 static unsigned bs3CpuInstr3_SkipIt() 629 #endif 630 { 631 static unsigned s_uTimes = 0; 632 unsigned uRet; 633 634 ++g_cSeen; 635 #if !defined(BS3_SKIPIT_DO_SKIP) 636 return (uRet = s_uTimes); 637 #else 638 /* Cache calls to the relatively expensive random routine */ 639 if (!s_uTimes) { 640 s_uTimes = bs3CpuInstr3_SimpleRand() % (BS3_SKIPIT_AVG_SKIP * 2 + 1) + 1; 641 } 642 uRet = (--s_uTimes > 0); 643 if (uRet) 644 ++g_cSkipped; 645 if (g_cSeen % 25000 == 0) 646 bs3CpuInstr3_ShowTallies(); 647 return uRet; 648 #endif /* !BS3_SKIPIT_DO_SKIP */ 649 } 650 651 /* 550 652 * Test type #1. 551 653 */ … … 673 775 RTUINT256U uMemOpExpect; 674 776 777 if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue; 675 778 /* 676 779 * Set up the context and some expectations. … … 9146 9249 RTUINT256U uMemOpExpect; 9147 9250 9251 if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue; 9148 9252 /* 9149 9253 * Set up the context and some expectations. … … 9819 9923 RTUINT256U uMemOpExpect; 9820 9924 9925 if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue; 9821 9926 /* 9822 9927 * Set up the context and some expectations. … … 12027 12132 RTUINT256U uMemOpExpect; 12028 12133 12134 if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, iEflVariation)) continue; 12029 12135 /* 12030 12136 * Set up the context and some expectations. … … 12348 12454 RTUINT256U uMemOpExpect; 12349 12455 12456 if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue; 12350 12457 /* 12351 12458 * Set up the context and some expectations. … … 12911 13018 RTUINT256U uMemOpExpect; 12912 13019 13020 if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue; 12913 13021 /* 12914 13022 * Set up the context and some expectations. … … 13457 13565 */ 13458 13566 Bs3TestDoModesByOne_pe32(g_aTests, RT_ELEMENTS(g_aTests), BS3TESTMODEBYONEENTRY_F_REAL_MODE_READY); 13567 bs3CpuInstr3_ShowTallies(); 13459 13568 } 13460 13569 else
Note:
See TracChangeset
for help on using the changeset viewer.