VirtualBox

Ignore:
Timestamp:
Mar 9, 2024 12:33:31 PM (11 months ago)
Author:
vboxsync
Message:

ValidationKit/bootsectors: developer flag to speed up 'bs3-cpu-instr-3' boot tests, bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-instr-3.c32

    r103746 r103747  
    548548
    549549/*
     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)
     578uint32_t BS3_ASMrdtsc_lo();
     579#pragma aux BS3_ASMrdtsc_lo = \
     580    ".586" \
     581    "rdtsc" \
     582    modify [edx eax] value [eax];
     583
     584DECLINLINE(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
     616static unsigned g_cSeen, g_cSkipped;
     617
     618static 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)
     625static 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()
     628static 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/*
    550652 * Test type #1.
    551653 */
     
    673775                    RTUINT256U uMemOpExpect;
    674776
     777                    if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue;
    675778                    /*
    676779                     * Set up the context and some expectations.
     
    91469249                    RTUINT256U uMemOpExpect;
    91479250
     9251                    if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue;
    91489252                    /*
    91499253                     * Set up the context and some expectations.
     
    98199923                    RTUINT256U uMemOpExpect;
    98209924
     9925                    if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue;
    98219926                    /*
    98229927                     * Set up the context and some expectations.
     
    1202712132                        RTUINT256U uMemOpExpect;
    1202812133
     12134                        if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, iEflVariation)) continue;
    1202912135                        /*
    1203012136                         * Set up the context and some expectations.
     
    1234812454                    RTUINT256U uMemOpExpect;
    1234912455
     12456                    if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue;
    1235012457                    /*
    1235112458                     * Set up the context and some expectations.
     
    1291113018                    RTUINT256U uMemOpExpect;
    1291213019
     13020                    if (BS3_SKIPIT(bRing, iCfg, iTest, iVal, 0)) continue;
    1291313021                    /*
    1291413022                     * Set up the context and some expectations.
     
    1345713565         */
    1345813566        Bs3TestDoModesByOne_pe32(g_aTests, RT_ELEMENTS(g_aTests), BS3TESTMODEBYONEENTRY_F_REAL_MODE_READY);
     13567        bs3CpuInstr3_ShowTallies();
    1345913568    }
    1346013569    else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette