From 1acd136f85457f26c665ec00405f395188fafc17 Mon Sep 17 00:00:00 2001 From: Adam Wieckowski Date: Sat, 4 Oct 2025 11:18:45 +0200 Subject: [PATCH] Reduce memory sizes for CI unit testing --- cmake/modules/vvencTests.cmake | 2 +- test/vvenc_unit_test/vvenc_unit_test.cpp | 38 ++++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cmake/modules/vvencTests.cmake b/cmake/modules/vvencTests.cmake index 2ed98666..6703fce5 100644 --- a/cmake/modules/vvencTests.cmake +++ b/cmake/modules/vvencTests.cmake @@ -20,7 +20,7 @@ add_test( NAME Test_vvenclibtest-sdk_stringapi_interface COMMAND vvenclibtest 5 add_test( NAME Test_vvenclibtest-timestamps COMMAND vvenclibtest 6 ) if( NOT BUILD_SHARED_LIBS ) - add_test( NAME Test_vvenc_unit_test COMMAND vvenc_unit_test ) + add_test( NAME Test_vvenc_unit_test COMMAND vvenc_unit_test --fast ) endif() set( CLEANUP_TEST_FILES "" ) diff --git a/test/vvenc_unit_test/vvenc_unit_test.cpp b/test/vvenc_unit_test/vvenc_unit_test.cpp index 7b41d342..1b7828a9 100644 --- a/test/vvenc_unit_test/vvenc_unit_test.cpp +++ b/test/vvenc_unit_test/vvenc_unit_test.cpp @@ -71,6 +71,8 @@ namespace po = apputils::program_options; #define NUM_CASES 100 +static bool g_fastUnitTest = false; + template static inline bool compare_value( const std::string& context, const T ref, const T opt ) { @@ -756,8 +758,8 @@ static bool check_applyFrac( MCTF* ref, MCTF* opt, int w, int h ) for( int yIndex = 0; yIndex < motionVectorFactor; ++yIndex ) { // Stride is often the width of a video frame, so use the width of 8K as an upper bound. - unsigned orgStride = rng.get( w, 8192 ); - unsigned dstStride = rng.get( w, 8192 ); + unsigned orgStride = rng.get( w, g_fastUnitTest ? 512 : 8192 ); + unsigned dstStride = rng.get( w, g_fastUnitTest ? 512 : 8192 ); if( !check_one_applyFrac( ref, opt, orgStride, dstStride, w, h, xIndex, yIndex, bitDepth, g ) ) { return false; @@ -880,8 +882,8 @@ static bool check_motionErrorLumaFrac8( MCTF* ref, MCTF* opt, int w, int h ) for( unsigned yIndex = 1; yIndex < motionVectorFactor; ++yIndex ) { // Stride is often the width of a video frame, so use the width of 8K as an upper bound. - unsigned orgStride = rng.get( w, 8192 ); - unsigned bufStride = rng.get( w, 8192 ); + unsigned orgStride = rng.get( w, g_fastUnitTest ? 512 : 8192 ); + unsigned bufStride = rng.get( w, g_fastUnitTest ? 512 : 8192 ); unsigned besterror = INT_MAX; if( !check_one_motionErrorLumaFrac8( ref, opt, orgStride, bufStride, w, h, xIndex, yIndex, bitDepth, besterror, g ) ) @@ -1179,9 +1181,9 @@ static bool check_lumaWeightedSSE( RdCost* ref, RdCost* opt, unsigned num_cases, bool passed = true; for( unsigned i = 0; i < num_cases; i++ ) { - int org_stride = rng.get( width, 1024 ); - int cur_stride = rng.get( width, 1024 ); - int luma_stride = rng.get( width, 1024 ); + int org_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); + int cur_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); + int luma_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); std::vector orgBuf( org_stride * height ); std::vector curBuf( cur_stride * height ); std::vector orgLumaBuf( luma_stride * height * 2 ); @@ -1231,8 +1233,8 @@ static bool check_fixWeightedSSE( RdCost* ref, RdCost* opt, unsigned num_cases, bool passed = true; for( unsigned i = 0; i < num_cases; i++ ) { - int org_stride = rng.get( width, 1024 ); - int cur_stride = rng.get( width, 1024 ); + int org_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); + int cur_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); std::vector orgBuf( org_stride * height ); std::vector curBuf( cur_stride * height ); @@ -1269,9 +1271,9 @@ static bool check_SADwMask( RdCost* ref, RdCost* opt, unsigned num_cases, int wi bool passed = true; for( unsigned i = 0; i < num_cases; i++ ) { - int org_stride = rng.get( width, 1024 ); - int cur_stride = rng.get( width, 1024 ); - int mask_stride = rng.get( width, 1024 ); + int org_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); + int cur_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); + int mask_stride = rng.get( width, g_fastUnitTest ? 256 : 1024 ); std::vector orgBuf( org_stride * height ); std::vector curBuf( cur_stride * height ); std::vector maskBuf( mask_stride * height ); @@ -1955,9 +1957,9 @@ static bool check_xWeightedGeoBlk( InterpolationFilter* ref, InterpolationFilter { for( int bitDepth : { 8, 10 } ) { - unsigned src0Stride = rng.get( width, 128 ); - unsigned src1Stride = rng.get( width, 128 ); - unsigned dstStride = rng.get( width, 128 ); + unsigned src0Stride = rng.get( width, MAX_CU_SIZE ); + unsigned src1Stride = rng.get( width, MAX_CU_SIZE ); + unsigned dstStride = rng.get( width, MAX_CU_SIZE ); if( !check_one_xWeightedGeoBlk( ref, opt, src0Stride, src1Stride, dstStride, width, height, bitDepth, g ) ) { return false; @@ -2102,6 +2104,7 @@ static const UnitTestEntry test_suites[] = { struct UnitTestArgs { + bool isFast = false; bool show_help = false; int seed; std::string testcase; @@ -2133,11 +2136,14 @@ UnitTestArgs parse_args( int argc, char* argv[] ) opts.addOptions() ( "help,h", args.show_help, "Show help", true ) ( "seed", args.seed, "Set random seed for running tests" ) - ( "testcase,t", args.testcase, get_testcase_help_text(), false ); + ( "testcase,t", args.testcase, get_testcase_help_text(), false ) + ( "fast", args.isFast, "Run a fast but less real-world accurate version of the tests", false ); po::SilentReporter err; po::scanArgv( opts, argc, ( const char** )argv, err ); + g_fastUnitTest = args.isFast; + if( args.show_help ) { std::ostringstream help_sstm;