[pulseaudio-commits] 5 commits - src/pulsecore src/tests

Arun Raghavan arun at kemper.freedesktop.org
Fri Oct 19 07:14:43 PDT 2012


 src/pulsecore/cpu-arm.c     |   12 +++-
 src/pulsecore/cpu-arm.h     |    1 
 src/pulsecore/svolume_arm.c |  121 ++++++++++----------------------------------
 src/tests/cpu-test.c        |   43 +++++++++++++++
 4 files changed, 81 insertions(+), 96 deletions(-)

New commits:
commit 97f2d6b347982eb2ffa9b1a14ae5ffd8a875f423
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Thu Oct 18 10:43:17 2012 +0530

    core: Fix a litte-endian bug in ARM svolume code
    
    The old code seems to be written for big-endian code.

diff --git a/src/pulsecore/svolume_arm.c b/src/pulsecore/svolume_arm.c
index b5ccc67..f06a702 100644
--- a/src/pulsecore/svolume_arm.c
+++ b/src/pulsecore/svolume_arm.c
@@ -75,13 +75,22 @@ static void pa_volume_s16ne_arm(int16_t *samples, const int32_t *volumes, unsign
         " ldrd r2, [r6], #8               \n\t" /* 2 samples at a time */
         " ldr  r0, [%0]                   \n\t"
 
+#ifdef WORDS_BIGENDIAN
         " smulwt r2, r2, r0               \n\t"
         " smulwb r3, r3, r0               \n\t"
+#else
+        " smulwb r2, r2, r0               \n\t"
+        " smulwt r3, r3, r0               \n\t"
+#endif
 
         " ssat r2, #16, r2                \n\t"
         " ssat r3, #16, r3                \n\t"
 
+#ifdef WORDS_BIGENDIAN
         " pkhbt r0, r3, r2, LSL #16       \n\t"
+#else
+        " pkhbt r0, r2, r3, LSL #16       \n\t"
+#endif
         " str  r0, [%0], #4               \n\t"
 
         MOD_INC()
@@ -95,18 +104,30 @@ static void pa_volume_s16ne_arm(int16_t *samples, const int32_t *volumes, unsign
         " ldrd r4, [r6], #8               \n\t"
         " ldrd r0, [%0]                   \n\t"
 
+#ifdef WORDS_BIGENDIAN
         " smulwt r2, r2, r0               \n\t"
         " smulwb r3, r3, r0               \n\t"
         " smulwt r4, r4, r1               \n\t"
         " smulwb r5, r5, r1               \n\t"
+#else
+        " smulwb r2, r2, r0               \n\t"
+        " smulwt r3, r3, r0               \n\t"
+        " smulwb r4, r4, r1               \n\t"
+        " smulwt r5, r5, r1               \n\t"
+#endif
 
         " ssat r2, #16, r2                \n\t"
         " ssat r3, #16, r3                \n\t"
         " ssat r4, #16, r4                \n\t"
         " ssat r5, #16, r5                \n\t"
 
+#ifdef WORDS_BIGENDIAN
         " pkhbt r0, r3, r2, LSL #16       \n\t"
         " pkhbt r1, r5, r4, LSL #16       \n\t"
+#else
+        " pkhbt r0, r2, r3, LSL #16       \n\t"
+        " pkhbt r1, r4, r5, LSL #16       \n\t"
+#endif
         " strd  r0, [%0], #8              \n\t"
 
         MOD_INC()

commit 600e3daa56394364f6f2497d55bbaea8bee0bec9
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Thu Oct 18 10:42:48 2012 +0530

    core: Document ARM-optimised svolume code a bit

diff --git a/src/pulsecore/svolume_arm.c b/src/pulsecore/svolume_arm.c
index 92b05a4..b5ccc67 100644
--- a/src/pulsecore/svolume_arm.c
+++ b/src/pulsecore/svolume_arm.c
@@ -50,19 +50,19 @@ static void pa_volume_s16ne_arm(int16_t *samples, const int32_t *volumes, unsign
     ve = volumes + channels;
 
     __asm__ __volatile__ (
-        " mov r6, %1                      \n\t"
+        " mov r6, %1                      \n\t" /* r6 = volumes */
         " mov %3, %3, LSR #1              \n\t" /* length /= sizeof (int16_t) */
         " tst %3, #1                      \n\t" /* check for odd samples */
         " beq  2f                         \n\t"
 
-        "1:                               \n\t"
-        " ldr  r0, [r6], #4               \n\t" /* odd samples volumes */
-        " ldrh r2, [%0]                   \n\t"
+        "1:                               \n\t" /* odd samples volumes */
+        " ldr  r0, [r6], #4               \n\t" /* r0 = volume */
+        " ldrh r2, [%0]                   \n\t" /* r2 = sample */
 
-        " smulwb r0, r0, r2               \n\t"
-        " ssat r0, #16, r0                \n\t"
+        " smulwb r0, r0, r2               \n\t" /* r0 = (r0 * r2) >> 16 */
+        " ssat r0, #16, r0                \n\t" /* r0 = PA_CLAMP(r0, 0x7FFF) */
 
-        " strh r0, [%0], #2               \n\t"
+        " strh r0, [%0], #2               \n\t" /* sample = r0 */
 
         MOD_INC()
 

commit b87067a007b7a957bd5c30eb0ef24d380c41c06f
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Fri Oct 19 18:43:17 2012 +0530

    tests: Minor cpu-test reorganisation
    
    Make volume and conversion tests separate test cases.

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index e23bfe5..e8ece7f 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -261,9 +261,9 @@ int main(int argc, char *argv[]) {
         pa_log_set_level(PA_LOG_DEBUG);
 
     s = suite_create("CPU");
-    tc = tcase_create("x86");
 
     /* Volume tests */
+    tc = tcase_create("svolume");
 #if defined (__i386__) || defined (__amd64__)
     tcase_add_test(tc, svolume_mmx_test);
     tcase_add_test(tc, svolume_sse_test);
@@ -272,8 +272,10 @@ int main(int argc, char *argv[]) {
     tcase_add_test(tc, svolume_arm_test);
 #endif
     tcase_add_test(tc, svolume_orc_test);
+    suite_add_tcase(s, tc);
 
     /* Converstion tests */
+    tc = tcase_create("sconv");
 #if defined (__i386__) || defined (__amd64__)
     tcase_add_test(tc, sconv_sse_test);
 #endif

commit f8017bb19d6eb815b2dafed521f7a0447b6d5501
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Tue Oct 16 12:23:19 2012 +0530

    tests: Factor out ARM svolume test into cpu-test
    
    This allows us to run the testing code separately from the PulseAudio
    daemon, which makes developing / regression testing this code a lot
    easier.

diff --git a/src/pulsecore/svolume_arm.c b/src/pulsecore/svolume_arm.c
index 79ed830..92b05a4 100644
--- a/src/pulsecore/svolume_arm.c
+++ b/src/pulsecore/svolume_arm.c
@@ -121,98 +121,12 @@ static void pa_volume_s16ne_arm(int16_t *samples, const int32_t *volumes, unsign
     );
 }
 
-#undef RUN_TEST
-
-#ifdef RUN_TEST
-#define CHANNELS 2
-#define SAMPLES 1022
-#define TIMES 1000
-#define TIMES2 100
-#define PADDING 16
-
-static void run_test(void) {
-    int16_t samples[SAMPLES];
-    int16_t samples_ref[SAMPLES];
-    int16_t samples_orig[SAMPLES];
-    int32_t volumes[CHANNELS + PADDING];
-    int i, j, padding;
-    pa_do_volume_func_t func;
-    pa_usec_t start, stop;
-    int k;
-    pa_usec_t min = INT_MAX, max = 0;
-    double s1 = 0, s2 = 0;
-
-    func = pa_get_volume_func(PA_SAMPLE_S16NE);
-
-    printf("checking ARM %zd\n", sizeof(samples));
-
-    pa_random(samples, sizeof(samples));
-    memcpy(samples_ref, samples, sizeof(samples));
-    memcpy(samples_orig, samples, sizeof(samples));
-
-    for (i = 0; i < CHANNELS; i++)
-        volumes[i] = PA_CLAMP_VOLUME(rand() >> 15);
-    for (padding = 0; padding < PADDING; padding++, i++)
-        volumes[i] = volumes[padding];
-
-    func(samples_ref, volumes, CHANNELS, sizeof(samples));
-    pa_volume_s16ne_arm(samples, volumes, CHANNELS, sizeof(samples));
-    for (i = 0; i < SAMPLES; i++) {
-        if (samples[i] != samples_ref[i]) {
-            printf ("%d: %04x != %04x (%04x * %04x)\n", i, samples[i], samples_ref[i],
-                      samples_orig[i], volumes[i % CHANNELS]);
-        }
-    }
-
-    for (k = 0; k < TIMES2; k++) {
-        start = pa_rtclock_now();
-        for (j = 0; j < TIMES; j++) {
-            memcpy(samples, samples_orig, sizeof(samples));
-            pa_volume_s16ne_arm(samples, volumes, CHANNELS, sizeof(samples));
-        }
-        stop = pa_rtclock_now();
-
-        if (min > (stop - start)) min = stop - start;
-        if (max < (stop - start)) max = stop - start;
-        s1 += stop - start;
-        s2 += (stop - start) * (stop - start);
-    }
-    pa_log_info("ARM: %llu usec (min = %llu, max = %llu, stddev = %g).", (long long unsigned int)s1,
-            (long long unsigned int)min, (long long unsigned int)max, sqrt(TIMES2 * s2 - s1 * s1) / TIMES2);
-
-    min = INT_MAX; max = 0;
-    s1 = s2 = 0;
-    for (k = 0; k < TIMES2; k++) {
-        start = pa_rtclock_now();
-        for (j = 0; j < TIMES; j++) {
-            memcpy(samples_ref, samples_orig, sizeof(samples));
-            func(samples_ref, volumes, CHANNELS, sizeof(samples));
-        }
-        stop = pa_rtclock_now();
-
-        if (min > (stop - start)) min = stop - start;
-        if (max < (stop - start)) max = stop - start;
-        s1 += stop - start;
-        s2 += (stop - start) * (stop - start);
-    }
-    pa_log_info("ref: %llu usec (min = %llu, max = %llu, stddev = %g).", (long long unsigned int)s1,
-            (long long unsigned int)min, (long long unsigned int)max, sqrt(TIMES2 * s2 - s1 * s1) / TIMES2);
-
-    pa_assert_se(memcmp(samples_ref, samples, sizeof(samples)) == 0);
-}
-#endif
-
 #endif /* defined (__arm__) && defined (HAVE_ARMV6) */
 
-
 void pa_volume_func_init_arm(pa_cpu_arm_flag_t flags) {
 #if defined (__arm__) && defined (HAVE_ARMV6)
     pa_log_info("Initialising ARM optimized volume functions.");
 
-#ifdef RUN_TEST
-    run_test();
-#endif
-
     pa_set_volume_func(PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_arm);
 #endif /* defined (__arm__) && defined (HAVE_ARMV6) */
 }
diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index ac4312e..e23bfe5 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -90,6 +90,7 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f
     fail_unless(memcmp(samples_ref, samples, sizeof(samples)) == 0);
 }
 
+#if defined (__i386__) || defined (__amd64__)
 START_TEST (svolume_mmx_test) {
     pa_do_volume_func_t orig_func, mmx_func;
     pa_cpu_x86_flag_t flags = 0;
@@ -129,6 +130,29 @@ START_TEST (svolume_sse_test) {
     run_volume_test(sse_func, orig_func);
 }
 END_TEST
+#endif /* defined (__i386__) || defined (__amd64__) */
+
+#if defined (__arm__) && defined (__linux__)
+START_TEST (svolume_arm_test) {
+    pa_do_volume_func_t orig_func, arm_func;
+    pa_cpu_arm_flag_t flags = 0;
+
+    pa_cpu_get_arm_flags(&flags);
+
+    if (!(flags & PA_CPU_ARM_V6)) {
+        pa_log_info("ARMv6 instructions not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+    pa_volume_func_init_arm(flags);
+    arm_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking ARM svolume");
+    run_volume_test(arm_func, orig_func);
+}
+END_TEST
+#endif /* defined (__arm__) && defined (__linux__) */
 
 START_TEST (svolume_orc_test) {
     pa_do_volume_func_t orig_func, orc_func;
@@ -161,6 +185,8 @@ END_TEST
 #undef PADDING
 /* End svolume tests */
 
+/* Start conversion tests */
+#if defined (__i386__) || defined (__amd64__)
 START_TEST (sconv_sse_test) {
 #define SAMPLES 1019
 #define TIMES 1000
@@ -222,6 +248,8 @@ START_TEST (sconv_sse_test) {
 #undef TIMES
 }
 END_TEST
+#endif /* defined (__i386__) || defined (__amd64__) */
+/* End conversion tests */
 
 int main(int argc, char *argv[]) {
     int failed = 0;
@@ -234,10 +262,21 @@ int main(int argc, char *argv[]) {
 
     s = suite_create("CPU");
     tc = tcase_create("x86");
+
+    /* Volume tests */
+#if defined (__i386__) || defined (__amd64__)
     tcase_add_test(tc, svolume_mmx_test);
     tcase_add_test(tc, svolume_sse_test);
+#endif
+#if defined (__arm__) && defined (__linux__)
+    tcase_add_test(tc, svolume_arm_test);
+#endif
     tcase_add_test(tc, svolume_orc_test);
+
+    /* Converstion tests */
+#if defined (__i386__) || defined (__amd64__)
     tcase_add_test(tc, sconv_sse_test);
+#endif
     suite_add_tcase(s, tc);
 
     sr = srunner_create(s);

commit 60660a1aecadb48f01e0e52fe0faf8e450d1e865
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Tue Oct 16 12:00:19 2012 +0530

    core: Separate ARM CPU detection from initialisation
    
    This separate the ARM CPU feature detection code from the initialisation
    so that we can reuse it in tests, like we did for x86 a while back.

diff --git a/src/pulsecore/cpu-arm.c b/src/pulsecore/cpu-arm.c
index a724309..934c7fe 100644
--- a/src/pulsecore/cpu-arm.c
+++ b/src/pulsecore/cpu-arm.c
@@ -79,7 +79,7 @@ static char *get_cpuinfo(void) {
 }
 #endif /* defined (__arm__) && defined (__linux__) */
 
-pa_bool_t pa_cpu_init_arm(pa_cpu_arm_flag_t *flags) {
+void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags) {
 #if defined (__arm__)
 #if defined (__linux__)
     char *cpuinfo, *line;
@@ -89,7 +89,7 @@ pa_bool_t pa_cpu_init_arm(pa_cpu_arm_flag_t *flags) {
      * space support to get the CPU features. This only works on linux AFAIK. */
     if (!(cpuinfo = get_cpuinfo())) {
         pa_log("Can't read cpuinfo");
-        return FALSE;
+        return;
     }
 
     *flags = 0;
@@ -131,6 +131,14 @@ pa_bool_t pa_cpu_init_arm(pa_cpu_arm_flag_t *flags) {
           (*flags & PA_CPU_ARM_EDSP) ? "EDSP " : "",
           (*flags & PA_CPU_ARM_NEON) ? "NEON " : "",
           (*flags & PA_CPU_ARM_VFPV3) ? "VFPV3 " : "");
+#endif
+#endif
+}
+
+pa_bool_t pa_cpu_init_arm(pa_cpu_arm_flag_t *flags) {
+#if defined (__arm__)
+#if defined (__linux__)
+    pa_cpu_get_arm_flags(flags);
 
     if (*flags & PA_CPU_ARM_V6)
         pa_volume_func_init_arm(*flags);
diff --git a/src/pulsecore/cpu-arm.h b/src/pulsecore/cpu-arm.h
index f0f49ef..91aa659 100644
--- a/src/pulsecore/cpu-arm.h
+++ b/src/pulsecore/cpu-arm.h
@@ -35,6 +35,7 @@ typedef enum pa_cpu_arm_flag {
     PA_CPU_ARM_VFPV3    = (1 << 5)
 } pa_cpu_arm_flag_t;
 
+void pa_cpu_get_arm_flags(pa_cpu_arm_flag_t *flags);
 pa_bool_t pa_cpu_init_arm(pa_cpu_arm_flag_t *flags);
 
 /* some optimized functions */



More information about the pulseaudio-commits mailing list