r4028 - in trunk/bse: . tests



Author: timj
Date: 2006-10-24 17:55:43 -0400 (Tue, 24 Oct 2006)
New Revision: 4028

Modified:
   trunk/bse/ChangeLog
   trunk/bse/bseblockutils.cc
   trunk/bse/bseblockutils.hh
   trunk/bse/bsemain.c
   trunk/bse/tests/Makefile.am
   trunk/bse/tests/blocktests.cc
   trunk/bse/tests/resamplehandle.cc
Log:
Tue Oct 24 23:52:58 2006  Tim Janik  <timj gtk org>                                                                                                           
                                                                                                                                                              
        * bseblockutils.hh, bseblockutils.cc: provide an block utils                                                                                          
        implementation name. usually "FPU" or "SSE".                                                                                                          
                                                                                                                                                              
        * bsemain.c: add block utils implementaiton name as suffix to                                                                                         
        the treport_*() CPU name.                                                                                                                             
                                                                                                                                                              
        * tests/Makefile.am:                                                                                                                                  
        * tests/blocktests.cc: conditionalized benchmarks, use treport_*().                                                                                   
                                                                                                                                                              
        * tests/blocktests.cc, tests/resamplehandle.cc: CPU name fixups.                                                                                      
                                                                                                                                                              



Modified: trunk/bse/ChangeLog
===================================================================
--- trunk/bse/ChangeLog	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/ChangeLog	2006-10-24 21:55:43 UTC (rev 4028)
@@ -1,3 +1,16 @@
+Tue Oct 24 23:52:58 2006  Tim Janik  <timj gtk org>
+
+	* bseblockutils.hh, bseblockutils.cc: provide an block utils 
+	implementation name. usually "FPU" or "SSE".
+
+	* bsemain.c: add block utils implementaiton name as suffix to
+	the treport_*() CPU name.
+
+	* tests/Makefile.am:
+	* tests/blocktests.cc: conditionalized benchmarks, use treport_*().
+
+	* tests/blocktests.cc, tests/resamplehandle.cc: CPU name fixups.
+
 Sun Oct 22 00:22:27 2006  Tim Janik  <timj gtk org>
 
 	* bsemain.c: let allow_randomization default to TRUE, added

Modified: trunk/bse/bseblockutils.cc
===================================================================
--- trunk/bse/bseblockutils.cc	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/bseblockutils.cc	2006-10-24 21:55:43 UTC (rev 4028)
@@ -23,6 +23,11 @@
 
 namespace {
 class BlockImpl : virtual public Bse::Block::Impl {
+  virtual const char*
+  impl_name ()
+  {
+    return "FPU";
+  }
   virtual void
   add (guint        n_values,
        float       *ovalues,
@@ -202,6 +207,12 @@
 
 } // Bse
 
+extern "C" const char*
+bse_block_impl_name (void)
+{
+  return Bse::Block::impl_name();
+}
+
 extern "C" void
 bse_block_add_floats (guint          n_values,
                       float         *ovalues,

Modified: trunk/bse/bseblockutils.hh
===================================================================
--- trunk/bse/bseblockutils.hh	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/bseblockutils.hh	2006-10-24 21:55:43 UTC (rev 4028)
@@ -26,6 +26,8 @@
 G_BEGIN_DECLS
 
 /* --- C API --- */
+const
+char*   bse_block_impl_name                       (void);
 static inline
 void    bse_block_fill_uint32                     (guint          n_values,       /* 4-byte variant of memset for ints */
                                                    guint32       *values,
@@ -83,6 +85,7 @@
 /* --- C++ API --- */
 class Block {
 public:
+  static const char*    impl_name            ()                              { return singleton->impl_name (); }
   static inline   void	fill                 (guint           n_values,
 					      float          *values,
 					      float           value);
@@ -139,6 +142,7 @@
   class Impl {
   protected:
     virtual      ~Impl                  ();
+    virtual const char* impl_name       () = 0;
     virtual void  add                   (guint	         n_values,
                                          float          *ovalues,
                                          const float    *ivalues) = 0;

Modified: trunk/bse/bsemain.c
===================================================================
--- trunk/bse/bsemain.c	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/bsemain.c	2006-10-24 21:55:43 UTC (rev 4028)
@@ -28,6 +28,7 @@
 #include "bsepcmdevice.h"
 #include "bsemididevice.h"
 #include "bseengine.h"
+#include "bseblockutils.hh" /* bse_block_impl_name() */
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -305,7 +306,7 @@
 
   /* paranoid assertions */
   g_assert (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
-
+  
   /* initialize submodules */
   if (as_test)
     sfi_init_test (argc, argv, values);
@@ -313,7 +314,7 @@
     sfi_init (argc, argv, app_name, values);
   bse_main_args = &default_main_args;
   bse_main_args->birnet = sfi_init_settings();
-
+  
   /* early argument handling */
   if (argc && argv)
     {
@@ -351,6 +352,13 @@
           // sfi_glue_gc_run ();
         }
     }
+  if (as_test)
+    {
+      SfiCPUInfo ci = sfi_cpu_info();
+      char *cname = g_strdup_printf ("%s+%s", ci.machine, bse_block_impl_name());
+      treport_cpu_name (cname);
+      g_free (cname);
+    }
   // sfi_glue_gc_run ();
 }
 

Modified: trunk/bse/tests/Makefile.am
===================================================================
--- trunk/bse/tests/Makefile.am	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/tests/Makefile.am	2006-10-24 21:55:43 UTC (rev 4028)
@@ -34,6 +34,7 @@
 loophandle_LDADD   = $(progs_ldadd)
 
 TESTS             += blocktests
+PERFTESTS         += blocktests
 blocktests_SOURCES = blocktests.cc
 blocktests_LDADD   = $(progs_ldadd)
 

Modified: trunk/bse/tests/blocktests.cc
===================================================================
--- trunk/bse/tests/blocktests.cc	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/tests/blocktests.cc	2006-10-24 21:55:43 UTC (rev 4028)
@@ -79,7 +79,7 @@
   TSTART ("BlockFill");
   float fblock1[1024];
 
-  bse_block_fill_uint32 (1024, (guint32*) fblock1, 0);
+  bse_block_fill_uint32 (1024, (uint32*) (void*) fblock1, 0);
   TASSERT (block_check (1024, fblock1, 0.f) == true);
 
   bse_block_fill_float (1024, fblock1, 17.786);
@@ -88,7 +88,7 @@
   Bse::Block::fill (1024, fblock1, 17.786f);
   TASSERT (block_check (1024, fblock1, 17.786f) == true);
 
-  Bse::Block::fill (1024, (guint32*) fblock1, 0);
+  Bse::Block::fill (1024, (uint32*) (void*) fblock1, 0);
   TASSERT (block_check (1024, fblock1, 0.f) == true);
 
   TDONE();
@@ -108,7 +108,7 @@
   TASSERT (block_check (1024, fblock1, -213e+3F) == true);
 
   Bse::Block::fill (1024, fblock1, -8763e-4f);
-  bse_block_copy_uint32 (1024, (guint32*) fblock1, (guint32*) fblock2);
+  bse_block_copy_uint32 (1024, (uint32*) (void*) fblock1, (uint32*) (void*) fblock2);
   TASSERT (block_check (1024, fblock1, -213e+3F) == true);
 
   Bse::Block::fill (1024, fblock1, -8763e-4f);
@@ -116,7 +116,7 @@
   TASSERT (block_check (1024, fblock1, -213e+3F) == true);
 
   Bse::Block::fill (1024, fblock1, -8763e-4f);
-  Bse::Block::copy (1024, (guint32*) fblock1, (guint32*) fblock2);
+  Bse::Block::copy (1024, (uint32*) (void*) fblock1, (uint32*) (void*) fblock2);
   TASSERT (block_check (1024, fblock1, -213e+3F) == true);
 
   TDONE();
@@ -307,8 +307,10 @@
       if (e < m)
         m = e;
     }
-  g_print ("FillBench:            %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::fill", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("FillBench:            %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -335,8 +337,10 @@
         m = e;
     }
   g_assert (dest_fblock[0] == 2.f);
-  g_print ("CopyBench:            %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::copy", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("CopyBench:            %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -362,8 +366,10 @@
       if (e < m)
         m = e;
     }
-  g_print ("AddBench:             %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::add", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("AddBench:             %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -389,8 +395,10 @@
       if (e < m)
         m = e;
     }
-  g_print ("SubBench:             %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::sub", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("SubBench:             %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -417,8 +425,10 @@
         m = e;
     }
   g_assert (fblock1[0] < 1e30); /* not close to infinity */
-  g_print ("MulBench:             %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::mul", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("MulBench:             %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -444,8 +454,10 @@
       if (e < m)
         m = e;
     }
-  g_print ("ScaleBench:           %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::scale", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("ScaleBench:           %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -480,8 +492,10 @@
     }
   g_assert (min_value == correct_min_value);
   g_assert (max_value == correct_max_value);
-  g_print ("RangeBench:           %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::range", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("RangeBench:           %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -506,8 +520,10 @@
       if (e < m)
         m = e;
     }
-  g_print ("SquareSumBench:       %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::square_sum", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("SquareSumBench:       %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static inline void
@@ -542,8 +558,10 @@
     }
   g_assert (min_value == correct_min_value);
   g_assert (max_value == correct_max_value);
-  g_print ("Range+SquareSumBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
-           1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
+  treport_minimized ("Block::range_and_square_sum", 1000000.0 * m / dups * BENCH_SCALE, TUNIT_USEC);
+  if (0)
+    g_print ("Range+SquareSumBench: %.6f msecs (test-duration: %.6f calibration: %.6f)\n",
+             1000.0 * m / dups * BENCH_SCALE, m * RUNS, c);
 }
 
 static void
@@ -559,15 +577,18 @@
   test_range();
   test_square_sum();
 
-  bench_fill();
-  bench_copy();
-  bench_add();
-  bench_sub();
-  bench_mul();
-  bench_scale();
-  bench_range();
-  bench_square_sum();
-  bench_range_and_square_sum();
+  if (sfi_init_settings().test_perf)
+    {
+      bench_fill();
+      bench_copy();
+      bench_add();
+      bench_sub();
+      bench_mul();
+      bench_scale();
+      bench_range();
+      bench_square_sum();
+      bench_range_and_square_sum();
+    }
 }
 
 int
@@ -576,7 +597,13 @@
 {
   /* usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded */
   sfi_init_test (&argc, &argv, NULL);
-
+  { /* bse_init_test() usually does this for us */
+    SfiCPUInfo ci = sfi_cpu_info();
+    char *cname = g_strdup_printf ("%s+%s", ci.machine, bse_block_impl_name());
+    treport_cpu_name (cname);
+    g_free (cname);
+  }
+  
   TSTART ("Running Default Block Ops");
   TASSERT (Bse::Block::default_singleton() == Bse::Block::current_singleton());
   TDONE();

Modified: trunk/bse/tests/resamplehandle.cc
===================================================================
--- trunk/bse/tests/resamplehandle.cc	2006-10-24 21:52:35 UTC (rev 4027)
+++ trunk/bse/tests/resamplehandle.cc	2006-10-24 21:55:43 UTC (rev 4028)
@@ -58,9 +58,9 @@
        int                   precision_bits,
        double                max_db)
 {
-  char *samplestr = g_strdup_printf ("%s-ResampleHandle-%s%02d%s", cpu_type, up_down, bits, channels);
-  char *streamstr = g_strdup_printf ("CPU Resampling %s-%s%02d%s", cpu_type, up_down, bits, channels);
-  TSTART ("%s", samplestr);
+  char *samplestr = g_strdup_printf ("ResampleHandle-%s%02d%s", up_down, bits, channels);
+  char *streamstr = g_strdup_printf ("CPU Resampling %s%02d%s", up_down, bits, channels);
+  TSTART ("%s (%s)", samplestr, cpu_type);
 
   TASSERT (input.size() % n_channels == 0);
   
@@ -376,6 +376,12 @@
       char *argv[])
 {
   sfi_init_test (&argc, &argv, NULL);
+  { /* bse_init_test() usually does this for us */
+    SfiCPUInfo ci = sfi_cpu_info();
+    char *cname = g_strdup_printf ("%s+%s", ci.machine, bse_block_impl_name());
+    treport_cpu_name (cname);
+    g_free (cname);
+  }
   
   test_c_api ("FPU");
   test_delay_compensation ("FPU");




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]