r3900 - in trunk/bse: . tests
- From: stw svn gnome org
- To: svn-commits-list gnome org
- Subject: r3900 - in trunk/bse: . tests
- Date: Tue, 26 Sep 2006 04:37:58 -0400 (EDT)
Author: stw
Date: 2006-09-26 04:37:55 -0400 (Tue, 26 Sep 2006)
New Revision: 3900
Modified:
trunk/bse/ChangeLog
trunk/bse/bseblockutils.cc
trunk/bse/bseblockutils.hh
trunk/bse/bseresamplerimpl.hh
trunk/bse/tests/testresampler.cc
Log:
Tue Sep 26 10:34:03 2006 Stefan Westerfeld <stefan space twc de>
* bseblockutils.cc bseblockutils.hh: Provide hook for testing the
resampler2 implementation.
* tests/testresampler.cc bseresamplerimpl.hh: Moved SSE filter
implementation test to the new function fir_test_filter_sse, which
can then be properly compiled using -msse within the bseblockutils
plugin for the SSE case.
Modified: trunk/bse/ChangeLog
===================================================================
--- trunk/bse/ChangeLog 2006-09-25 00:11:59 UTC (rev 3899)
+++ trunk/bse/ChangeLog 2006-09-26 08:37:55 UTC (rev 3900)
@@ -1,3 +1,13 @@
+Tue Sep 26 10:34:03 2006 Stefan Westerfeld <stefan space twc de>
+
+ * bseblockutils.cc bseblockutils.hh: Provide hook for testing the
+ resampler2 implementation.
+
+ * tests/testresampler.cc bseresamplerimpl.hh: Moved SSE filter
+ implementation test to the new function fir_test_filter_sse, which
+ can then be properly compiled using -msse within the bseblockutils
+ plugin for the SSE case.
+
Fri Sep 22 15:25:19 2006 Stefan Westerfeld <stefan space twc de>
* tests/testresampler.cc: Make resampler more user friendly, by using
Modified: trunk/bse/bseblockutils.cc
===================================================================
--- trunk/bse/bseblockutils.cc 2006-09-25 00:11:59 UTC (rev 3899)
+++ trunk/bse/bseblockutils.cc 2006-09-26 08:37:55 UTC (rev 3900)
@@ -160,6 +160,14 @@
};
return FPUResampler2::create_resampler (mode, precision);
}
+ virtual bool
+ test_resampler2()
+ {
+ /* there is currently only a test for the SSE filter code, so in the
+ * non-SSE-case we simply always return true
+ */
+ return true;
+ }
};
static BlockImpl default_block_impl;
} // Anon
Modified: trunk/bse/bseblockutils.hh
===================================================================
--- trunk/bse/bseblockutils.hh 2006-09-25 00:11:59 UTC (rev 3899)
+++ trunk/bse/bseblockutils.hh 2006-09-26 08:37:55 UTC (rev 3900)
@@ -131,6 +131,8 @@
static inline
Resampler2* create_resampler2 (BseResampler2Mode mode,
BseResampler2Precision precision) { return singleton->create_resampler2 (mode, precision); }
+ static inline
+ bool test_resampler2 () { return singleton->test_resampler2(); }
@@ -171,6 +173,7 @@
virtual
Resampler2* create_resampler2 (BseResampler2Mode mode,
BseResampler2Precision precision) = 0;
+ virtual bool test_resampler2 () = 0;
friend class Block;
static void substitute (Impl *substitute_impl);
};
Modified: trunk/bse/bseresamplerimpl.hh
===================================================================
--- trunk/bse/bseresamplerimpl.hh 2006-09-25 00:11:59 UTC (rev 3899)
+++ trunk/bse/bseresamplerimpl.hh 2006-09-26 08:37:55 UTC (rev 3900)
@@ -22,6 +22,7 @@
#include <vector>
#include <bse/bseresampler.hh>
#include <birnet/birnet.h>
+#include <math.h>
#ifdef __SSE__
#include <xmmintrin.h>
#endif
@@ -208,6 +209,69 @@
};
/**
+ * This function tests the SSEified FIR filter code (that is, the reordering
+ * done by fir_compute_sse_taps and the actual computation implemented in
+ * fir_process_4samples_sse).
+ *
+ * It prints diagnostic information, and returns true if the filter
+ * implementation works correctly, and false otherwise. The maximum filter
+ * order to be tested can be optionally specified as argument.
+ */
+static inline bool
+fir_test_filter_sse (const guint max_order = 64)
+{
+ int errors = 0;
+ printf ("testing SSE filter implementation:\n\n");
+
+ for (guint order = 0; order < max_order; order++)
+ {
+ vector<float> taps (order);
+ for (guint i = 0; i < order; i++)
+ taps[i] = i + 1;
+
+ AlignedArray<float,16> sse_taps (fir_compute_sse_taps (taps));
+ for (unsigned int i = 0; i < sse_taps.size(); i++)
+ {
+ printf ("%3d", (int) (sse_taps[i] + 0.5));
+ if (i % 4 == 3)
+ printf (" |");
+ if (i % 16 == 15)
+ printf (" ||| upper bound = %d\n", (order + 6) / 4);
+ }
+ printf ("\n\n");
+
+ AlignedArray<float,16> random_mem (order + 4);
+ for (guint i = 0; i < order + 4; i++)
+ random_mem[i] = 1.0 - rand() / (0.5 * RAND_MAX);
+
+ /* FIXME: the problem with this test is that we explicitely test SSE code
+ * here, but the test case is not compiled with -msse within the BEAST tree
+ */
+ float out[4];
+ fir_process_4samples_sse (&random_mem[0], &sse_taps[0], order,
+ &out[0], &out[1], &out[2], &out[3]);
+
+ double adiff = 0.0;
+ for (int i = 0; i < 4; i++)
+ {
+ double diff = fir_process_one_sample<double> (&random_mem[i], &taps[0], order) - out[i];
+ adiff += fabs (diff);
+ }
+ if (adiff > 0.0001)
+ {
+ printf ("*** order = %d, adiff = %f\n", order, adiff);
+ errors++;
+ }
+ }
+ if (errors)
+ printf ("*** %d errors detected\n", errors);
+ else
+ printf ("filter implementation ok.\n");
+
+ return (errors == 0);
+}
+
+/**
* Factor 2 upsampling of a data stream
*
* Template arguments:
Modified: trunk/bse/tests/testresampler.cc
===================================================================
--- trunk/bse/tests/testresampler.cc 2006-09-25 00:11:59 UTC (rev 3899)
+++ trunk/bse/tests/testresampler.cc 2006-09-26 08:37:55 UTC (rev 3900)
@@ -94,7 +94,8 @@
printf (" error-table print sine signals (index, resampled-value, ideal-value,\n");
printf (" diff-value)\n");
printf (" dirac print impulse response (response-value)\n");
- printf (" F undocumented development feature\n"); /* FIXME: fix and document */
+ printf (" filter-impl tests SSE filter implementation for correctness\n");
+ printf (" doesn't test anything when running without SSE support\n");
printf ("\n");
printf ("Resample options:\n");
printf (" --up use upsampling by a factor of 2 as resampler [default]\n");
@@ -297,6 +298,11 @@
*argc_p = e;
}
+int
+test_filter_impl()
+{
+ return Bse::Block::test_resampler2() ? 0 : 1;
+}
double
gettime ()
@@ -307,60 +313,6 @@
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
-int
-test_filter_impl()
-{
- int errors = 0;
- printf ("testing filter implementation:\n\n");
-
- for (guint order = 0; order < 64; order++)
- {
- vector<float> taps (order);
- for (guint i = 0; i < order; i++)
- taps[i] = i + 1;
-
- AlignedArray<float,16> sse_taps (fir_compute_sse_taps (taps));
- for (unsigned int i = 0; i < sse_taps.size(); i++)
- {
- printf ("%3d", (int) (sse_taps[i] + 0.5));
- if (i % 4 == 3)
- printf (" |");
- if (i % 16 == 15)
- printf (" ||| upper bound = %d\n", (order + 6) / 4);
- }
- printf ("\n\n");
-
- AlignedArray<float,16> random_mem (order + 4);
- for (guint i = 0; i < order + 4; i++)
- random_mem[i] = 1.0 - rand() / (0.5 * RAND_MAX);
-
- /* FIXME: the problem with this test is that we explicitely test SSE code
- * here, but the test case is not compiled with -msse within the BEAST tree
- */
- float out[4];
- fir_process_4samples_sse (&random_mem[0], &sse_taps[0], order,
- &out[0], &out[1], &out[2], &out[3]);
-
- double adiff = 0.0;
- for (int i = 0; i < 4; i++)
- {
- double diff = fir_process_one_sample<double> (&random_mem[i], &taps[0], order) - out[i];
- adiff += fabs (diff);
- }
- if (adiff > 0.0001)
- {
- printf ("*** order = %d, adiff = %f\n", order, adiff);
- errors++;
- }
- }
- if (errors)
- printf ("*** %d errors detected\n", errors);
- else
- printf ("filter implementation ok.\n");
-
- return errors ? 1 : 0;
-}
-
template <int TEST, int RESAMPLE> int
perform_test()
{
@@ -628,7 +580,7 @@
test_type = TEST_ERROR_TABLE;
else if (command == "dirac")
test_type = TEST_IMPULSE;
- else if (command == "F")
+ else if (command == "filter-impl")
test_type = TEST_FILTER_IMPL;
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]