summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2012-10-24 12:48:02 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2012-10-25 10:11:24 +0530
commitfe0ba245e54bdc729d1e96ca503f6a0d3de22b3d (patch)
tree56a8cc40f05dae737a6ac12bf597789beb2085fc
parent63ddc0e426845d3016d34a7dd8785ce559d63116 (diff)
tests: Run sconv tests with multiple alignments
This allows us to test the sconv code with the incoming samples at various byte alignments. The test is also now split into correctness and performance checks.
-rw-r--r--src/tests/cpu-test.c72
1 files changed, 46 insertions, 26 deletions
diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index f0ab56c91..5b83d84c6 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -201,43 +201,56 @@ END_TEST
/* End svolume tests */
/* Start conversion tests */
-#define SAMPLES 1022
+#define SAMPLES 1028
#define TIMES 1000
#define TIMES2 100
-static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_func_t orig_func) {
- int16_t samples[SAMPLES];
- int16_t samples_ref[SAMPLES];
- float floats[SAMPLES];
- int i;
-
- memset(samples_ref, 0, sizeof(samples_ref));
- memset(samples, 0, sizeof(samples));
-
- for (i = 0; i < SAMPLES; i++) {
+static void run_conv_test_float_to_s16(pa_convert_func_t func, pa_convert_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, float, f[SAMPLES]);
+ int16_t *samples, *samples_ref;
+ float *floats;
+ int i, nsamples;
+
+ /* Force sample alignment as requested */
+ samples = s + (8 - align);
+ samples_ref = s_ref + (8 - align);
+ floats = f + (8 - align);
+ nsamples = SAMPLES - (8 - align);
+
+ for (i = 0; i < nsamples; i++) {
floats[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
}
- orig_func(SAMPLES, floats, samples_ref);
- func(SAMPLES, floats, samples);
+ if (correct) {
+ pa_log_debug("Testing sconv correctness with %d byte alignment", align);
- for (i = 0; i < SAMPLES; i++) {
- if (samples[i] != samples_ref[i]) {
- printf ("%d: %04x != %04x (%f)\n", i, samples[i], samples_ref[i],
- floats[i]);
- fail();
+ orig_func(nsamples, floats, samples_ref);
+ func(nsamples, floats, samples);
+
+ for (i = 0; i < nsamples; i++) {
+ if (samples[i] != samples_ref[i]) {
+ pa_log_debug("%d: %04x != %04x (%f)\n", i, samples[i], samples_ref[i], floats[i]);
+ fail();
+ }
}
}
- PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
- func(SAMPLES, floats, samples);
- } PA_CPU_TEST_RUN_STOP
+ if (perf) {
+ pa_log_debug("Testing sconv performance with %d byte alignment", align);
- PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
- orig_func(SAMPLES, floats, samples_ref);
- } PA_CPU_TEST_RUN_STOP
+ PA_CPU_TEST_RUN_START("func", TIMES, TIMES2) {
+ func(nsamples, floats, samples);
+ } PA_CPU_TEST_RUN_STOP
- fail_unless(memcmp(samples_ref, samples, sizeof(samples)) == 0);
+ PA_CPU_TEST_RUN_START("orig", TIMES, TIMES2) {
+ orig_func(nsamples, floats, samples_ref);
+ } PA_CPU_TEST_RUN_STOP
+
+ fail_unless(memcmp(samples_ref, samples, sizeof(nsamples)) == 0);
+ }
}
#if defined (__i386__) || defined (__amd64__)
@@ -257,7 +270,14 @@ START_TEST (sconv_sse_test) {
sse_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
pa_log_debug("Checking SSE sconv (s16 -> float)");
- run_conv_test_float_to_s16(sse_func, orig_func);
+ run_conv_test_float_to_s16(sse_func, orig_func, 0, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 1, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 2, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 3, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 4, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 5, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 6, TRUE, FALSE);
+ run_conv_test_float_to_s16(sse_func, orig_func, 7, TRUE, TRUE);
}
END_TEST
#endif /* defined (__i386__) || defined (__amd64__) */