Changeset 103003 in vbox for trunk/src/VBox/VMM/testcase/tstIEMAImpl.cpp
- Timestamp:
- Jan 23, 2024 4:19:17 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/tstIEMAImpl.cpp
r102896 r103003 44 44 #include <iprt/string.h> 45 45 #include <iprt/test.h> 46 #include <iprt/time.h> 47 #include <iprt/thread.h> 46 48 #include <VBox/version.h> 47 49 … … 160 162 static const char *g_apszIncludeTestPatterns[64]; 161 163 static const char *g_apszExcludeTestPatterns[64]; 164 165 /** Higher value, means longer benchmarking. */ 166 static uint64_t g_cPicoSecBenchmark = 0; 162 167 163 168 static unsigned g_cVerbosity = 0; … … 1381 1386 #endif 1382 1387 1388 1389 /** Based on a quick probe run, guess how long to run the benchmark. */ 1390 static uint32_t EstimateIterations(uint32_t cProbeIterations, uint64_t cNsProbe) 1391 { 1392 uint64_t cPicoSecPerIteration = cNsProbe * 1000 / cProbeIterations; 1393 uint64_t cIterations = g_cPicoSecBenchmark / cPicoSecPerIteration; 1394 if (cIterations > _2G) 1395 return _2G; 1396 if (cIterations < _4K) 1397 return _4K; 1398 return RT_ALIGN_32((uint32_t)cIterations, _4K); 1399 } 1400 1401 1383 1402 #define TEST_BINARY_OPS(a_cBits, a_uType, a_Fmt, a_TestType, a_aSubTests) \ 1384 1403 GEN_BINARY_TESTS(a_cBits, a_Fmt, a_TestType) \ 1404 \ 1405 static uint64_t BinU ## a_cBits ## Bench(uint32_t cIterations, PFNIEMAIMPLBINU ## a_cBits pfn, a_TestType const *pEntry) \ 1406 { \ 1407 uint32_t const fEflIn = pEntry->fEflIn; \ 1408 a_uType const uDstIn = pEntry->uDstIn; \ 1409 a_uType const uSrcIn = pEntry->uSrcIn; \ 1410 cIterations /= 4; \ 1411 RTThreadYield(); \ 1412 uint64_t const nsStart = RTTimeNanoTS(); \ 1413 for (uint32_t i = 0; i < cIterations; i++) \ 1414 { \ 1415 uint32_t fBenchEfl = fEflIn; \ 1416 a_uType uBenchDst = uDstIn; \ 1417 pfn(&uBenchDst, uSrcIn, &fBenchEfl); \ 1418 \ 1419 fBenchEfl = fEflIn; \ 1420 uBenchDst = uDstIn; \ 1421 pfn(&uBenchDst, uSrcIn, &fBenchEfl); \ 1422 \ 1423 fBenchEfl = fEflIn; \ 1424 uBenchDst = uDstIn; \ 1425 pfn(&uBenchDst, uSrcIn, &fBenchEfl); \ 1426 \ 1427 fBenchEfl = fEflIn; \ 1428 uBenchDst = uDstIn; \ 1429 pfn(&uBenchDst, uSrcIn, &fBenchEfl); \ 1430 } \ 1431 return RTTimeNanoTS() - nsStart; \ 1432 } \ 1385 1433 \ 1386 1434 static void BinU ## a_cBits ## Test(void) \ … … 1393 1441 PFNIEMAIMPLBINU ## a_cBits pfn = a_aSubTests[iFn].pfn; \ 1394 1442 uint32_t const cVars = COUNT_VARIATIONS(a_aSubTests[iFn]); \ 1395 if (!cTests) RTTestSkipped(g_hTest, "no tests");\1443 if (!cTests) { RTTestSkipped(g_hTest, "no tests"); continue; } \ 1396 1444 for (uint32_t iVar = 0; iVar < cVars; iVar++) \ 1397 1445 { \ … … 1402 1450 pfn(&uDst, paTests[iTest].uSrcIn, &fEfl); \ 1403 1451 if ( uDst != paTests[iTest].uDstOut \ 1404 || fEfl != paTests[iTest].fEflOut ) \1452 || fEfl != paTests[iTest].fEflOut ) \ 1405 1453 RTTestFailed(g_hTest, "#%u%s: efl=%#08x dst=" a_Fmt " src=" a_Fmt " -> efl=%#08x dst=" a_Fmt ", expected %#08x & " a_Fmt "%s - %s\n", \ 1406 1454 iTest, !iVar ? "" : "/n", paTests[iTest].fEflIn, paTests[iTest].uDstIn, paTests[iTest].uSrcIn, \ … … 1413 1461 *g_pfEfl = paTests[iTest].fEflIn; \ 1414 1462 pfn(g_pu ## a_cBits, paTests[iTest].uSrcIn, g_pfEfl); \ 1415 RTTEST_CHECK(g_hTest, *g_pu ## a_cBits == paTests[iTest].uDstOut); \1416 RTTEST_CHECK(g_hTest, *g_pfEfl 1463 RTTEST_CHECK(g_hTest, *g_pu ## a_cBits == paTests[iTest].uDstOut); \ 1464 RTTEST_CHECK(g_hTest, *g_pfEfl == paTests[iTest].fEflOut); \ 1417 1465 } \ 1418 1466 } \ 1467 \ 1468 /* Benchmark if all succeeded. */ \ 1469 if (g_cPicoSecBenchmark && RTTestSubErrorCount(g_hTest) == 0) \ 1470 { \ 1471 uint32_t const iTest = cTests / 2; \ 1472 uint32_t const cIterations = EstimateIterations(_64K, BinU ## a_cBits ## Bench(_64K, pfn, &paTests[iTest])); \ 1473 uint64_t const cNsRealRun = BinU ## a_cBits ## Bench(cIterations, pfn, &paTests[iTest]); \ 1474 RTTestValueF(g_hTest, cNsRealRun * 1000 / cIterations, RTTESTUNIT_PS_PER_CALL, \ 1475 "%s%s", a_aSubTests[iFn].pszName, iVar ? "-native" : ""); \ 1476 } \ 1477 \ 1478 /* Next variation is native. */ \ 1419 1479 pfn = a_aSubTests[iFn].pfnNative; \ 1420 1480 } \ … … 9390 9450 { "--generate", 'g', RTGETOPT_REQ_NOTHING }, 9391 9451 { "--test", 't', RTGETOPT_REQ_NOTHING }, 9452 { "--benchmark", 'b', RTGETOPT_REQ_NOTHING }, 9392 9453 // test selection (both) 9393 9454 { "--all", 'a', RTGETOPT_REQ_NOTHING }, … … 9423 9484 { 9424 9485 case 'g': 9425 enmMode = kModeGenerate; 9486 enmMode = kModeGenerate; 9487 g_cPicoSecBenchmark = 0; 9426 9488 break; 9427 9489 case 't': 9428 enmMode = kModeTest; 9490 enmMode = kModeTest; 9491 g_cPicoSecBenchmark = 0; 9492 break; 9493 case 'b': 9494 enmMode = kModeTest; 9495 g_cPicoSecBenchmark += RT_NS_1SEC / 2 * UINT64_C(1000); /* half a second in pico seconds */ 9429 9496 break; 9430 9497 … … 9517 9584 " -t, --test\n" 9518 9585 " Execute tests.\n" 9586 " -b, --benchmark\n" 9587 " Execute tests and do 1/2 seconds of benchmarking.\n" 9588 " Repeating the option increases the benchmark duration by 0.5 seconds.\n" 9519 9589 "\n" 9520 9590 "Test selection (both modes):\n"
Note:
See TracChangeset
for help on using the changeset viewer.