configure.ac | 2 src/tests/cpu-test.c | 120 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 82 insertions(+), 40 deletions(-)
New commits: commit fb52466d6a484c13dbf459fc4e464e8485183b81 Author: Arun Raghavan <[email protected]> Date: Tue Oct 30 11:38:01 2012 +0530 build-sys: Drop -Wvla from compiler flags Since we mandate C99 support, not reason to keep this around. diff --git a/configure.ac b/configure.ac index c91c572..6425d1e 100644 --- a/configure.ac +++ b/configure.ac @@ -165,7 +165,7 @@ esac #### Compiler flags #### AX_APPEND_COMPILE_FLAGS( - [-Wall -W -Wextra -pipe -Wno-long-long -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option], + [-Wall -W -Wextra -pipe -Wno-long-long -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option], [], [-pedantic -Werror]) # Only enable fastpath asserts when doing a debug build, e.g. from bootstrap.sh. commit 03e9d3d0d7388d4b3151a59253fb8f746f00501e Author: Arun Raghavan <[email protected]> Date: Tue Oct 30 11:37:06 2012 +0530 tests: Fix a cpu-test debug message We align at sample granularity and not byte granularity (which might violate arch alignment requirements). diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c index 924807d..8f6f936 100644 --- a/src/tests/cpu-test.c +++ b/src/tests/cpu-test.c @@ -110,7 +110,7 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f } if (perf) { - pa_log_debug("Testing svolume %dch performance with %d byte alignment", channels, align); + pa_log_debug("Testing svolume %dch performance with %d sample alignment", channels, align); PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) { memcpy(samples, samples_orig, size); @@ -285,7 +285,7 @@ static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t } if (perf) { - pa_log_debug("Testing sconv performance with %d byte alignment", align); + pa_log_debug("Testing sconv performance with %d sample alignment", align); PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) { func(nsamples, floats, samples); @@ -331,7 +331,7 @@ static void run_conv_test_s16_to_float(pa_convert_func_t func, pa_convert_func_t } if (perf) { - pa_log_debug("Testing sconv performance with %d byte alignment", align); + pa_log_debug("Testing sconv performance with %d sample alignment", align); PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) { func(nsamples, samples, floats); commit f10e663d04e5cd047ac68daa5101f1928c36ba68 Author: Arun Raghavan <[email protected]> Date: Tue Oct 30 11:30:16 2012 +0530 tests: Run svolume on different channel counts This adds checks to run svolume tests with 1, 2 and 3 channels (we don't run Orc with 3 channels since only 1/2-ch are implemented there). diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c index 1b02ae1..924807d 100644 --- a/src/tests/cpu-test.c +++ b/src/tests/cpu-test.c @@ -64,18 +64,17 @@ } /* Common defines for svolume tests */ -#define CHANNELS 2 #define SAMPLES 1028 #define TIMES 1000 #define TIMES2 100 #define PADDING 16 -static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func, int align, pa_bool_t correct, - pa_bool_t perf) { +static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func, int align, int channels, + pa_bool_t correct, pa_bool_t perf) { PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 }; PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 }; PA_DECLARE_ALIGNED(8, int16_t, s_orig[SAMPLES]) = { 0 }; - int32_t volumes[CHANNELS + PADDING]; + int32_t volumes[channels + PADDING]; int16_t *samples, *samples_ref, *samples_orig; int i, padding, nsamples, size; @@ -84,43 +83,43 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f samples_ref = s_ref + (8 - align); samples_orig = s_orig + (8 - align); nsamples = SAMPLES - (8 - align); - nsamples += nsamples % CHANNELS; + nsamples += nsamples % channels; size = nsamples * sizeof(*samples); pa_random(samples, size); memcpy(samples_ref, samples, size); memcpy(samples_orig, samples, size); - for (i = 0; i < CHANNELS; i++) + for (i = 0; i < channels; i++) volumes[i] = PA_CLAMP_VOLUME((pa_volume_t)(rand() >> 15)); for (padding = 0; padding < PADDING; padding++, i++) volumes[i] = volumes[padding]; if (correct) { - orig_func(samples_ref, volumes, CHANNELS, size); - func(samples, volumes, CHANNELS, size); + orig_func(samples_ref, volumes, channels, size); + func(samples, volumes, channels, size); for (i = 0; i < nsamples; i++) { if (samples[i] != samples_ref[i]) { - pa_log_debug("Correctness test failed: align=%d", align); + pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels); pa_log_debug("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i], - samples_orig[i], volumes[i % CHANNELS]); + samples_orig[i], volumes[i % channels]); fail(); } } } if (perf) { - pa_log_debug("Testing svolume performance with %d byte alignment", align); + pa_log_debug("Testing svolume %dch performance with %d byte alignment", channels, align); PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) { memcpy(samples, samples_orig, size); - func(samples, volumes, CHANNELS, size); + func(samples, volumes, channels, size); } PA_CPU_TEST_RUN_STOP PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) { memcpy(samples_ref, samples_orig, size); - orig_func(samples_ref, volumes, CHANNELS, size); + orig_func(samples_ref, volumes, channels, size); } PA_CPU_TEST_RUN_STOP fail_unless(memcmp(samples_ref, samples, size) == 0); @@ -131,6 +130,7 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f START_TEST (svolume_mmx_test) { pa_do_volume_func_t orig_func, mmx_func; pa_cpu_x86_flag_t flags = 0; + int i, j; pa_cpu_get_x86_flags(&flags); @@ -144,20 +144,20 @@ START_TEST (svolume_mmx_test) { mmx_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking MMX svolume"); - run_volume_test(mmx_func, orig_func, 0, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 1, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 2, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 3, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 4, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 5, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 6, TRUE, FALSE); - run_volume_test(mmx_func, orig_func, 7, TRUE, TRUE); + for (i = 1; i <= 3; i++) { + for (j = 0; j < 7; j++) + run_volume_test(mmx_func, orig_func, j, i, TRUE, FALSE); + } + run_volume_test(mmx_func, orig_func, 7, 1, TRUE, TRUE); + run_volume_test(mmx_func, orig_func, 7, 2, TRUE, TRUE); + run_volume_test(mmx_func, orig_func, 7, 3, TRUE, TRUE); } END_TEST START_TEST (svolume_sse_test) { pa_do_volume_func_t orig_func, sse_func; pa_cpu_x86_flag_t flags = 0; + int i, j; pa_cpu_get_x86_flags(&flags); @@ -171,14 +171,13 @@ START_TEST (svolume_sse_test) { sse_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking SSE2 svolume"); - run_volume_test(sse_func, orig_func, 0, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 1, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 2, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 3, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 4, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 5, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 6, TRUE, FALSE); - run_volume_test(sse_func, orig_func, 7, TRUE, TRUE); + for (i = 1; i <= 3; i++) { + for (j = 0; j < 7; j++) + run_volume_test(sse_func, orig_func, j, i, TRUE, FALSE); + } + run_volume_test(sse_func, orig_func, 7, 1, TRUE, TRUE); + run_volume_test(sse_func, orig_func, 7, 2, TRUE, TRUE); + run_volume_test(sse_func, orig_func, 7, 3, TRUE, TRUE); } END_TEST #endif /* defined (__i386__) || defined (__amd64__) */ @@ -187,6 +186,7 @@ END_TEST START_TEST (svolume_arm_test) { pa_do_volume_func_t orig_func, arm_func; pa_cpu_arm_flag_t flags = 0; + int i, j; pa_cpu_get_arm_flags(&flags); @@ -200,14 +200,13 @@ START_TEST (svolume_arm_test) { arm_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking ARM svolume"); - run_volume_test(arm_func, orig_func, 0, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 1, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 2, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 3, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 4, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 5, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 6, TRUE, TRUE); - run_volume_test(arm_func, orig_func, 7, TRUE, TRUE); + for (i = 1; i <= 3; i++) { + for (j = 0; j < 7; j++) + run_volume_test(arm_func, orig_func, j, i, TRUE, FALSE); + } + run_volume_test(arm_func, orig_func, 7, 1, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 7, 2, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 7, 3, TRUE, TRUE); } END_TEST #endif /* defined (__arm__) && defined (__linux__) */ @@ -215,6 +214,7 @@ END_TEST START_TEST (svolume_orc_test) { pa_do_volume_func_t orig_func, orc_func; pa_cpu_info cpu_info; + int i, j; #if defined (__i386__) || defined (__amd64__) pa_zero(cpu_info); @@ -232,18 +232,15 @@ START_TEST (svolume_orc_test) { orc_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking Orc svolume"); - run_volume_test(orc_func, orig_func, 0, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 1, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 2, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 3, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 4, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 5, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 6, TRUE, FALSE); - run_volume_test(orc_func, orig_func, 7, TRUE, TRUE); + for (i = 1; i <= 2; i++) { + for (j = 0; j < 7; j++) + run_volume_test(orc_func, orig_func, j, i, TRUE, FALSE); + } + run_volume_test(orc_func, orig_func, 7, 1, TRUE, TRUE); + run_volume_test(orc_func, orig_func, 7, 2, TRUE, TRUE); } END_TEST -#undef CHANNELS #undef SAMPLES #undef TIMES #undef TIMES2 commit 58b61a9d16fa3b8bec22e726f0fdad375e7b0cef Author: Arun Raghavan <[email protected]> Date: Tue Oct 30 11:24:33 2012 +0530 tests: Make cpu-test less verbose Drops the correctness debug output since we want to run this several times, and the output becomes much more verbose than required. diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c index 82d8277..1b02ae1 100644 --- a/src/tests/cpu-test.c +++ b/src/tests/cpu-test.c @@ -97,14 +97,13 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f volumes[i] = volumes[padding]; if (correct) { - pa_log_debug("Testing svolume correctness with %d byte alignment", align); - orig_func(samples_ref, volumes, CHANNELS, size); func(samples, volumes, CHANNELS, size); for (i = 0; i < nsamples; i++) { if (samples[i] != samples_ref[i]) { - printf("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i], + pa_log_debug("Correctness test failed: align=%d", align); + pa_log_debug("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i], samples_orig[i], volumes[i % CHANNELS]); fail(); } @@ -276,13 +275,12 @@ static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t } if (correct) { - pa_log_debug("Testing sconv correctness with %d byte alignment", align); - orig_func(nsamples, floats, samples_ref); func(nsamples, floats, samples); for (i = 0; i < nsamples; i++) { if (abs(samples[i] - samples_ref[i]) > 1) { + pa_log_debug("Correctness test failed: align=%d", align); pa_log_debug("%d: %04x != %04x (%.24f)\n", i, samples[i], samples_ref[i], floats[i]); fail(); } @@ -323,13 +321,12 @@ static void run_conv_test_s16_to_float(pa_convert_func_t func, pa_convert_func_t pa_random(samples, nsamples * sizeof(int16_t)); if (correct) { - pa_log_debug("Testing sconv correctness with %d byte alignment", align); - orig_func(nsamples, samples, floats_ref); func(nsamples, samples, floats); for (i = 0; i < nsamples; i++) { if (abs(floats[i] - floats_ref[i]) > 1) { + pa_log_debug("Correctness test failed: align=%d", align); pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]); fail(); } commit a172db5c0da029dd3869069ec5683d236c3409e5 Author: Arun Raghavan <[email protected]> Date: Tue Oct 30 09:30:32 2012 +0530 tests: Run svolume test for various sample alignments Allows us to make sure that svolume works independently of sample alignment, and that performance doesn't degrade based on this. diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c index e38e632..82d8277 100644 --- a/src/tests/cpu-test.c +++ b/src/tests/cpu-test.c @@ -65,48 +65,67 @@ /* Common defines for svolume tests */ #define CHANNELS 2 -#define SAMPLES 1022 +#define SAMPLES 1028 #define TIMES 1000 #define TIMES2 100 #define PADDING 16 -static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func) { - int16_t samples[SAMPLES]; - int16_t samples_ref[SAMPLES]; - int16_t samples_orig[SAMPLES]; +static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_func, int align, pa_bool_t correct, + pa_bool_t perf) { + PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 }; + PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 }; + PA_DECLARE_ALIGNED(8, int16_t, s_orig[SAMPLES]) = { 0 }; int32_t volumes[CHANNELS + PADDING]; - int i, padding; + int16_t *samples, *samples_ref, *samples_orig; + int i, padding, nsamples, size; + + /* Force sample alignment as requested */ + samples = s + (8 - align); + samples_ref = s_ref + (8 - align); + samples_orig = s_orig + (8 - align); + nsamples = SAMPLES - (8 - align); + nsamples += nsamples % CHANNELS; + size = nsamples * sizeof(*samples); - pa_random(samples, sizeof(samples)); - memcpy(samples_ref, samples, sizeof(samples)); - memcpy(samples_orig, samples, sizeof(samples)); + pa_random(samples, size); + memcpy(samples_ref, samples, size); + memcpy(samples_orig, samples, size); for (i = 0; i < CHANNELS; i++) volumes[i] = PA_CLAMP_VOLUME((pa_volume_t)(rand() >> 15)); for (padding = 0; padding < PADDING; padding++, i++) volumes[i] = volumes[padding]; - orig_func(samples_ref, volumes, CHANNELS, sizeof(samples)); - func(samples, volumes, CHANNELS, sizeof(samples)); - for (i = 0; i < SAMPLES; i++) { - if (samples[i] != samples_ref[i]) { - printf("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i], - samples_orig[i], volumes[i % CHANNELS]); - fail(); + if (correct) { + pa_log_debug("Testing svolume correctness with %d byte alignment", align); + + orig_func(samples_ref, volumes, CHANNELS, size); + func(samples, volumes, CHANNELS, size); + + for (i = 0; i < nsamples; i++) { + if (samples[i] != samples_ref[i]) { + printf("%d: %04x != %04x (%04x * %08x)\n", i, samples[i], samples_ref[i], + samples_orig[i], volumes[i % CHANNELS]); + fail(); + } } } - PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) { - memcpy(samples, samples_orig, sizeof(samples)); - func(samples, volumes, CHANNELS, sizeof(samples)); - } PA_CPU_TEST_RUN_STOP + if (perf) { + pa_log_debug("Testing svolume performance with %d byte alignment", align); - PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) { - memcpy(samples_ref, samples_orig, sizeof(samples)); - orig_func(samples_ref, volumes, CHANNELS, sizeof(samples)); - } PA_CPU_TEST_RUN_STOP + PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) { + memcpy(samples, samples_orig, size); + func(samples, volumes, CHANNELS, size); + } PA_CPU_TEST_RUN_STOP - fail_unless(memcmp(samples_ref, samples, sizeof(samples)) == 0); + PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) { + memcpy(samples_ref, samples_orig, size); + orig_func(samples_ref, volumes, CHANNELS, size); + } PA_CPU_TEST_RUN_STOP + + fail_unless(memcmp(samples_ref, samples, size) == 0); + } } #if defined (__i386__) || defined (__amd64__) @@ -126,7 +145,14 @@ START_TEST (svolume_mmx_test) { mmx_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking MMX svolume"); - run_volume_test(mmx_func, orig_func); + run_volume_test(mmx_func, orig_func, 0, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 1, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 2, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 3, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 4, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 5, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 6, TRUE, FALSE); + run_volume_test(mmx_func, orig_func, 7, TRUE, TRUE); } END_TEST @@ -146,7 +172,14 @@ START_TEST (svolume_sse_test) { sse_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking SSE2 svolume"); - run_volume_test(sse_func, orig_func); + run_volume_test(sse_func, orig_func, 0, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 1, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 2, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 3, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 4, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 5, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 6, TRUE, FALSE); + run_volume_test(sse_func, orig_func, 7, TRUE, TRUE); } END_TEST #endif /* defined (__i386__) || defined (__amd64__) */ @@ -168,7 +201,14 @@ START_TEST (svolume_arm_test) { arm_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking ARM svolume"); - run_volume_test(arm_func, orig_func); + run_volume_test(arm_func, orig_func, 0, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 1, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 2, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 3, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 4, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 5, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 6, TRUE, TRUE); + run_volume_test(arm_func, orig_func, 7, TRUE, TRUE); } END_TEST #endif /* defined (__arm__) && defined (__linux__) */ @@ -193,7 +233,14 @@ START_TEST (svolume_orc_test) { orc_func = pa_get_volume_func(PA_SAMPLE_S16NE); pa_log_debug("Checking Orc svolume"); - run_volume_test(orc_func, orig_func); + run_volume_test(orc_func, orig_func, 0, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 1, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 2, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 3, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 4, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 5, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 6, TRUE, FALSE); + run_volume_test(orc_func, orig_func, 7, TRUE, TRUE); } END_TEST @@ -402,6 +449,7 @@ int main(int argc, char *argv[]) { tcase_add_test(tc, svolume_arm_test); #endif tcase_add_test(tc, svolume_orc_test); + tcase_set_timeout(tc, 120); suite_add_tcase(s, tc); /* Converstion tests */ _______________________________________________ pulseaudio-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pulseaudio-commits
