[x265] [PATCH 2 of 3] primitives: convert Setup_Assembly_Primitives to a CPU mask instead of ID
Steve Borho
steve at borho.org
Thu Sep 26 23:50:01 CEST 2013
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1380172344 18000
# Thu Sep 26 00:12:24 2013 -0500
# Node ID fdcde13221f28a86ebaa202d55cc79056df298b7
# Parent 8636384aba196197dbb6822ffc44d995e20bae99
primitives: convert Setup_Assembly_Primitives to a CPU mask instead of ID
This allows the testbench to isolate the functions added for a given arch
diff -r 8636384aba19 -r fdcde13221f2 source/common/primitives.cpp
--- a/source/common/primitives.cpp Thu Sep 26 00:00:53 2013 -0500
+++ b/source/common/primitives.cpp Thu Sep 26 00:12:24 2013 -0500
@@ -134,7 +134,7 @@
#endif
#if ENABLE_ASM_PRIMITIVES
- Setup_Assembly_Primitives(primitives, cpuid);
+ Setup_Assembly_Primitives(primitives, (1 << (cpuid + 1)) - 1);
if (param->logLevel >= X265_LOG_INFO) fprintf(stderr, " assembly");
#endif
diff -r 8636384aba19 -r fdcde13221f2 source/common/primitives.h
--- a/source/common/primitives.h Thu Sep 26 00:00:53 2013 -0500
+++ b/source/common/primitives.h Thu Sep 26 00:12:24 2013 -0500
@@ -305,7 +305,7 @@
void Setup_C_Primitives(EncoderPrimitives &p);
void Setup_Vector_Primitives(EncoderPrimitives &p, int cpuMask);
-void Setup_Assembly_Primitives(EncoderPrimitives &p, int cpuid);
+void Setup_Assembly_Primitives(EncoderPrimitives &p, int cpuMask);
}
#endif // ifndef X265_PRIMITIVES_H
diff -r 8636384aba19 -r fdcde13221f2 source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp Thu Sep 26 00:00:53 2013 -0500
+++ b/source/common/x86/asm-primitives.cpp Thu Sep 26 00:12:24 2013 -0500
@@ -99,10 +99,10 @@
p.sse_##type[PARTITION_##width##x8] = (pixelcmp_t) x265_pixel_ssd_##width##x8_##suffix; \
p.sse_##type[PARTITION_##width##x4] = (pixelcmp_t) x265_pixel_ssd_##width##x4_##suffix; \
-void Setup_Assembly_Primitives(EncoderPrimitives &p, int cpuid)
+void Setup_Assembly_Primitives(EncoderPrimitives &p, int cpuMask)
{
#if !HIGH_BIT_DEPTH
- if (cpuid >= 2)
+ if (cpuMask & (1 << 2))
{
INIT8_NAME( sse_pp, ssd, _mmx );
INIT8( sad, _mmx2 );
@@ -312,7 +312,7 @@
p.sse_pp[PARTITION_64x48] = cmp<64, 48, 32, 48, x265_pixel_ssd_32x48_sse2>;
p.sse_pp[PARTITION_64x64] = cmp<64, 64, 32, 64, x265_pixel_ssd_32x64_sse2>;
}
- if (cpuid >= 4)
+ if (cpuMask & (1 << 4))
{
p.frame_init_lowres_core = x265_frame_init_lowres_core_ssse3;
p.sa8d[BLOCK_8x8] = x265_pixel_sa8d_8x8_ssse3;
@@ -355,7 +355,7 @@
p.sse_pp[PARTITION_64x48] = cmp<64, 48, 32, 48, x265_pixel_ssd_32x48_ssse3>;
p.sse_pp[PARTITION_64x64] = cmp<64, 64, 32, 64, x265_pixel_ssd_32x64_ssse3>;
}
- if (cpuid >= 5)
+ if (cpuMask & (1 << 5))
{
p.sa8d[BLOCK_8x8] = x265_pixel_sa8d_8x8_sse4;
p.sa8d[BLOCK_16x16] = x265_pixel_sa8d_16x16_sse4;
@@ -371,7 +371,7 @@
p.satd[PARTITION_12x48] = cmp<12, 48, 4, 16, x265_pixel_satd_4x16_sse4>;
p.satd[PARTITION_12x64] = cmp<12, 64, 4, 16, x265_pixel_satd_4x16_sse4>;
}
- if (cpuid >= 7)
+ if (cpuMask & (1 << 7))
{
p.frame_init_lowres_core = x265_frame_init_lowres_core_avx;
p.sa8d[BLOCK_8x8] = x265_pixel_sa8d_8x8_avx;
@@ -461,7 +461,7 @@
p.satd[PARTITION_12x48] = cmp<12, 48, 4, 16, x265_pixel_satd_4x16_avx>;
p.satd[PARTITION_12x64] = cmp<12, 64, 4, 16, x265_pixel_satd_4x16_avx>;
}
- if (cpuid >= 7 && hasXOP())
+ if ((cpuMask & (1 << 7)) && hasXOP())
{
p.frame_init_lowres_core = x265_frame_init_lowres_core_xop;
p.sa8d[BLOCK_8x8] = x265_pixel_sa8d_8x8_xop;
@@ -574,7 +574,7 @@
p.satd[PARTITION_64x48] = cmp<64, 48, 16, 16, x265_pixel_satd_16x16_xop>;
p.satd[PARTITION_64x64] = cmp<64, 64, 16, 16, x265_pixel_satd_16x16_xop>;
}
- if (cpuid >= 8)
+ if (cpuMask & (1 << 8))
{
//INIT2( sad_x3, _avx2 );
INIT2( sad_x4, _avx2 );
@@ -583,7 +583,7 @@
p.sa8d[BLOCK_8x8] = x265_pixel_sa8d_8x8_avx2;
}
#endif
- if (cpuid > 1)
+ if (cpuMask > 2)
{
// SA8D devolves to SATD for blocks not even multiples of 8x8
p.sa8d_inter[PARTITION_4x4] = p.satd[PARTITION_4x4];
diff -r 8636384aba19 -r fdcde13221f2 source/test/testbench.cpp
--- a/source/test/testbench.cpp Thu Sep 26 00:00:53 2013 -0500
+++ b/source/test/testbench.cpp Thu Sep 26 00:12:24 2013 -0500
@@ -124,7 +124,7 @@
#if ENABLE_ASM_PRIMITIVES
EncoderPrimitives asmprim;
memset(&asmprim, 0, sizeof(asmprim));
- Setup_Assembly_Primitives(asmprim, i);
+ Setup_Assembly_Primitives(asmprim, 1 << i);
printf("Testing assembly primitives: %s (%d)\n", CpuType[i], i);
for (size_t h = 0; h < sizeof(harness) / sizeof(TestHarness*); h++)
{
@@ -149,7 +149,7 @@
Setup_Vector_Primitives(optprim, (1 << (cpuid + 1)) - 1);
#endif
#if ENABLE_ASM_PRIMITIVES
- Setup_Assembly_Primitives(optprim, cpuid);
+ Setup_Assembly_Primitives(optprim, (1 << (cpuid + 1)) - 1);
#endif
printf("\nTest performance improvement with full optimizations\n");
More information about the x265-devel
mailing list