[x265] [PATCH 3 of 3] primitives: build primitive list iteratively

Steve Borho steve at borho.org
Thu Sep 26 23:50:02 CEST 2013


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1380174078 18000
#      Thu Sep 26 00:41:18 2013 -0500
# Node ID 4313a7b09746fed2ef027253b5a908ae5035b134
# Parent  fdcde13221f28a86ebaa202d55cc79056df298b7
primitives: build primitive list iteratively

Rather than collect all intrinsic primitives and then collect all assembly
primitives, do the process iteratively for each CPU capability.  This plausibly
allows an SSE41 intrinsic primitive to have higher priority than an SSE assembly
primitive.

diff -r fdcde13221f2 -r 4313a7b09746 source/common/primitives.cpp
--- a/source/common/primitives.cpp	Thu Sep 26 00:12:24 2013 -0500
+++ b/source/common/primitives.cpp	Thu Sep 26 00:41:18 2013 -0500
@@ -128,13 +128,20 @@
 
     Setup_C_Primitives(primitives);
 
+    for (int i = 2; i < cpuid; i++)
+    {
 #if ENABLE_VECTOR_PRIMITIVES
-    Setup_Vector_Primitives(primitives, (1 << (cpuid + 1)) - 1);
+        Setup_Vector_Primitives(primitives, 1 << i);
+#endif
+#if ENABLE_ASM_PRIMITIVES
+        Setup_Assembly_Primitives(primitives, 1 << i);
+#endif
+    }
+
+#if ENABLE_VECTOR_PRIMITIVES
     if (param->logLevel >= X265_LOG_INFO) fprintf(stderr, " intrinsic");
 #endif
-
 #if ENABLE_ASM_PRIMITIVES
-    Setup_Assembly_Primitives(primitives, (1 << (cpuid + 1)) - 1);
     if (param->logLevel >= X265_LOG_INFO) fprintf(stderr, " assembly");
 #endif
 
diff -r fdcde13221f2 -r 4313a7b09746 source/test/testbench.cpp
--- a/source/test/testbench.cpp	Thu Sep 26 00:12:24 2013 -0500
+++ b/source/test/testbench.cpp	Thu Sep 26 00:41:18 2013 -0500
@@ -145,12 +145,15 @@
 
     EncoderPrimitives optprim;
     memset(&optprim, 0, sizeof(optprim));
+    for (int i = 2; i < cpuid; i++)
+    {
 #if ENABLE_VECTOR_PRIMITIVES
-    Setup_Vector_Primitives(optprim, (1 << (cpuid + 1)) - 1);
+        Setup_Vector_Primitives(optprim, 1 << i);
 #endif
 #if ENABLE_ASM_PRIMITIVES
-    Setup_Assembly_Primitives(optprim, (1 << (cpuid + 1)) - 1);
+        Setup_Assembly_Primitives(optprim, 1 << i);
 #endif
+    }
 
     printf("\nTest performance improvement with full optimizations\n");
 


More information about the x265-devel mailing list