[x264-devel] [PATCH 2/3] RFC: checkasm: Warn if a better SIMD function is slower than the simpler one

Martin Storsjö martin at martin.st
Thu Aug 13 23:00:58 CEST 2015


---
This naively assumes that a later tested SIMD function is supposed
to be better than the earlier ones - this probably doesn't
hold for all x86 SIMD flags.
---
 tools/checkasm.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/checkasm.c b/tools/checkasm.c
index 185b98b..bc7f8ff 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -162,15 +162,19 @@ static void print_bench(void)
     for( nfuncs = 0; nfuncs < MAX_FUNCS && benchs[nfuncs].name; nfuncs++ );
     qsort( benchs, nfuncs, sizeof(bench_func_t), cmp_bench );
     for( int i = 0; i < nfuncs; i++ )
+    {
+        int64_t best_cycles = 0;
         for( int j = 0; j < MAX_CPUS && (!j || benchs[i].vers[j].cpu); j++ )
         {
             int k;
             bench_t *b = &benchs[i].vers[j];
+            int64_t cycles;
             if( !b->den )
                 continue;
             for( k = 0; k < j && benchs[i].vers[k].pointer != b->pointer; k++ );
             if( k < j )
                 continue;
+            cycles = (10*b->cycles/b->den - nop_time)/4;
             printf( "%s_%s%s: %"PRId64"\n", benchs[i].name,
 #if HAVE_MMX
                     b->cpu&X264_CPU_AVX2 ? "avx2" :
@@ -213,8 +217,13 @@ static void print_bench(void)
                     b->cpu&X264_CPU_FAST_NEON_MRC ? "_fast_mrc" :
 #endif
                     "",
-                    (int64_t)(10*b->cycles/b->den - nop_time)/4 );
+                    cycles );
+            if( best_cycles == 0 || cycles < best_cycles )
+                best_cycles = cycles;
+            if( cycles > best_cycles )
+                printf( "WARNING, slower than simpler version\n" );
         }
+    }
 }
 
 #if ARCH_X86 || ARCH_X86_64
-- 
1.7.10.4



More information about the x264-devel mailing list