pixman: Branch 'master' - 9 commits

Pekka Paalanen pq at kemper.freedesktop.org
Mon Jul 6 02:49:58 PDT 2015


 test/lowlevel-blt-bench.c |  243 ++++++++++++++++++++++++++++++----------------
 1 file changed, 163 insertions(+), 80 deletions(-)

New commits:
commit e2d211ac491cd9884aae7ccaf18e5b3042469cf2
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 13:54:01 2015 +0300

    lowlevel-blt-bench: add option to skip memcpy measurement
    
    The memcpy speed measurement takes several seconds. When you are running
    single tests in a harness that iterates dozens or hundreds of times, the
    repeated measurements are redundant and take a lot of time. It is also
    an open question whether the measured speed changes over long test runs
    due to unidentified platform reasons (Raspberry Pi).
    
    Add a command line option to set the reference memcpy speed, skipping
    the measuring.
    
    The speed is mainly used to compute how many iterations do run inside
    the bench_*() functions, so for repeated testing on the same hardware,
    it makes sense to lock that number to a constant.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 17e5ec4..fc7472f 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -55,7 +55,7 @@ uint32_t *dst;
 uint32_t *src;
 uint32_t *mask;
 
-double bandwidth = 0;
+double bandwidth = 0.0;
 
 double
 bench_memcpy ()
@@ -1086,10 +1086,11 @@ print_speed_scaling (double bw)
 static void
 usage (const char *progname)
 {
-    printf ("Usage: %s [-b] [-n] [-c] pattern\n", progname);
+    printf ("Usage: %s [-b] [-n] [-c] [-m M] pattern\n", progname);
     printf ("  -n : benchmark nearest scaling\n");
     printf ("  -b : benchmark bilinear scaling\n");
     printf ("  -c : print output as CSV data\n");
+    printf ("  -m M : set reference memcpy speed to M MB/s instead of measuring it\n");
 }
 
 int
@@ -1115,6 +1116,9 @@ main (int argc, char *argv[])
 
 	    if (strchr (argv[i] + 1, 'c'))
 		use_csv_output = TRUE;
+
+	    if (strcmp (argv[i], "-m") == 0 && i + 1 < argc)
+		bandwidth = atof (argv[++i]) * 1e6;
 	}
 	else
 	{
@@ -1138,7 +1142,8 @@ main (int argc, char *argv[])
     if (!use_csv_output)
         print_explanation ();
 
-    bandwidth = bench_memcpy ();
+    if (bandwidth < 1.0)
+        bandwidth = bench_memcpy ();
     if (!use_csv_output)
         print_speed_scaling (bandwidth);
 
commit 31cb0d4267f4f358b62f75fd42c4b1ae625be7ee
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 13:20:47 2015 +0300

    lowlevel-blt-bench: add CSV output mode
    
    Add a command line option for choosing CSV output mode.
    
    In CSV mode, only the results in Mpixels/s are printed in an easily
    machine-parseable format. All user-friendly printing is suppressed.
    
    This is intended for cases where you benchmark one particular operation
    at a time. Running the "all" set of benchmarks will print just fine, but
    you may have trouble matching rows to operations as you have to look at
    the tests_tbl[] to see what row is which.
    
    Reviewed-by: Ben Avison <bavison at riscosopen.org>
    
    v2: don't add a space after comma in CSV.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 33d3ba2..17e5ec4 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -90,6 +90,7 @@ bench_memcpy ()
 
 static pixman_bool_t use_scaling = FALSE;
 static pixman_filter_t filter = PIXMAN_FILTER_NEAREST;
+static pixman_bool_t use_csv_output = FALSE;
 
 /* nearly 1x scale factor */
 static pixman_transform_t m =
@@ -474,9 +475,9 @@ bench_composite (const char *testname,
                                          dst,
                                          XWIDTH * 4);
 
-
-    printf ("%24s %c", testname, func != pixman_image_composite_wrapper ?
-            '-' : '=');
+    if (!use_csv_output)
+        printf ("%24s %c", testname, func != pixman_image_composite_wrapper ?
+                '-' : '=');
 
     memcpy (dst, src, BUFSIZE);
     memcpy (src, dst, BUFSIZE);
@@ -494,7 +495,10 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1);
     t3 = gettime ();
-    printf ("  L1:%7.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    if (use_csv_output)
+        printf ("%g,", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  L1:%7.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -512,7 +516,10 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines);
     t3 = gettime ();
-    printf ("  L2:%7.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    if (use_csv_output)
+        printf ("%g,", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  L2:%7.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -526,9 +533,11 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_M (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
-    printf ("  M:%6.2f (%6.2f%%)",
-        Mpx_per_sec (pix_cnt, t1, t2, t3),
-        (pix_cnt / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
+    if (use_csv_output)
+        printf ("%g,", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  M:%6.2f (%6.2f%%)", Mpx_per_sec (pix_cnt, t1, t2, t3),
+                (pix_cnt / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -542,7 +551,10 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
-    printf ("  HT:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    if (use_csv_output)
+        printf ("%g,", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  HT:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -556,7 +568,10 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
-    printf ("  VT:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    if (use_csv_output)
+        printf ("%g,", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  VT:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -570,7 +585,10 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
     t3 = gettime ();
-    printf ("  R:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    if (use_csv_output)
+        printf ("%g,", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  R:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -584,7 +602,10 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
     t3 = gettime ();
-    printf ("  RT:%6.2f (%4.0fKops/s)\n", Mpx_per_sec (pix_cnt, t1, t2, t3), (double) n / ((t3 - t2) * 1000));
+    if (use_csv_output)
+        printf ("%g\n", Mpx_per_sec (pix_cnt, t1, t2, t3));
+    else
+        printf ("  RT:%6.2f (%4.0fKops/s)\n", Mpx_per_sec (pix_cnt, t1, t2, t3), (double) n / ((t3 - t2) * 1000));
 
     if (mask_img) {
 	pixman_image_unref (mask_img);
@@ -956,7 +977,8 @@ parser_self_test (void)
         exit (EXIT_FAILURE);
     }
 
-    printf ("Parser self-test complete.\n");
+    if (!use_csv_output)
+        printf ("Parser self-test complete.\n");
 }
 
 static void
@@ -1064,9 +1086,10 @@ print_speed_scaling (double bw)
 static void
 usage (const char *progname)
 {
-    printf ("Usage: %s [-b] [-n] pattern\n", progname);
+    printf ("Usage: %s [-b] [-n] [-c] pattern\n", progname);
     printf ("  -n : benchmark nearest scaling\n");
     printf ("  -b : benchmark bilinear scaling\n");
+    printf ("  -c : print output as CSV data\n");
 }
 
 int
@@ -1074,6 +1097,7 @@ main (int argc, char *argv[])
 {
     int i;
     const char *pattern = NULL;
+
     for (i = 1; i < argc; i++)
     {
 	if (argv[i][0] == '-')
@@ -1088,6 +1112,9 @@ main (int argc, char *argv[])
 		use_scaling = TRUE;
 		filter = PIXMAN_FILTER_NEAREST;
 	    }
+
+	    if (strchr (argv[i] + 1, 'c'))
+		use_csv_output = TRUE;
 	}
 	else
 	{
@@ -1108,18 +1135,17 @@ main (int argc, char *argv[])
     dst = src + (BUFSIZE / 4);
     mask = dst + (BUFSIZE / 4);
 
-    print_explanation ();
+    if (!use_csv_output)
+        print_explanation ();
+
     bandwidth = bench_memcpy ();
-    print_speed_scaling (bandwidth);
+    if (!use_csv_output)
+        print_speed_scaling (bandwidth);
 
     if (strcmp (pattern, "all") == 0)
-    {
         run_default_tests (bandwidth);
-    }
     else
-    {
-        run_one_test (pattern, bandwidth, TRUE);
-    }
+        run_one_test (pattern, bandwidth, !use_csv_output);
 
     free (src);
     return 0;
commit 9a7e0bc6d08c0324f09d6440270cd07201929f3f
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 12:41:57 2015 +0300

    lowlevel-blt-bench: refactor to Mpx_per_sec()
    
    Refactor the Mpixels/s computations into a function. Easier to read and
    better documents what is being computed.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 99f8352..33d3ba2 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -370,6 +370,15 @@ bench_RT (pixman_op_t              op,
     return pix_cnt;
 }
 
+static double
+Mpx_per_sec (double pix_cnt, double t1, double t2, double t3)
+{
+    double overhead = t2 - t1;
+    double testtime = t3 - t2;
+
+    return pix_cnt / (testtime - overhead) / 1e6;
+}
+
 void
 bench_composite (const char *testname,
                  int         src_fmt,
@@ -485,7 +494,7 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1);
     t3 = gettime ();
-    printf ("  L1:%7.2f", pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  L1:%7.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -503,7 +512,7 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines);
     t3 = gettime ();
-    printf ("  L2:%7.2f", pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  L2:%7.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -518,7 +527,7 @@ bench_composite (const char *testname,
     pix_cnt = bench_M (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
     printf ("  M:%6.2f (%6.2f%%)",
-        (pix_cnt / ((t3 - t2) - (t2 - t1))) / 1000000.,
+        Mpx_per_sec (pix_cnt, t1, t2, t3),
         (pix_cnt / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
     fflush (stdout);
 
@@ -533,7 +542,7 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
-    printf ("  HT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  HT:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -547,7 +556,7 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
-    printf ("  VT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  VT:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -561,7 +570,7 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
     t3 = gettime ();
-    printf ("  R:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  R:%6.2f", Mpx_per_sec (pix_cnt, t1, t2, t3));
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -575,7 +584,7 @@ bench_composite (const char *testname,
     t2 = gettime ();
     pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
     t3 = gettime ();
-    printf ("  RT:%6.2f (%4.0fKops/s)\n", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000., (double) n / ((t3 - t2) * 1000));
+    printf ("  RT:%6.2f (%4.0fKops/s)\n", Mpx_per_sec (pix_cnt, t1, t2, t3), (double) n / ((t3 - t2) * 1000));
 
     if (mask_img) {
 	pixman_image_unref (mask_img);
commit 6e9c48c579e3325506234fa2ee7635f08f2c5a33
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 12:53:09 2015 +0300

    lowlevel-blt-bench: all bench funcs to return pix_cnt
    
    The bench_* functions, that did not already do it, are modified to
    return the number of pixels processed during the benchmark. This moves
    the computation to the site that actually determines the number, and
    simplifies bench_composite() a bit.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 8ad4ebb..99f8352 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -165,7 +165,7 @@ call_func (pixman_composite_func_t func,
     func (0, &info);
 }
 
-void
+double
 noinline
 bench_L  (pixman_op_t              op,
           pixman_image_t *         src_img,
@@ -204,9 +204,11 @@ bench_L  (pixman_op_t              op,
 	call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 63 - x, 0, width, lines_count);
     }
     qx = q;
+
+    return (double)n * lines_count * width;
 }
 
-void
+double
 noinline
 bench_M (pixman_op_t              op,
          pixman_image_t *         src_img,
@@ -224,6 +226,8 @@ bench_M (pixman_op_t              op,
 	    x = 0;
 	call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 1, 0, WIDTH - 64, HEIGHT);
     }
+
+    return (double)n * (WIDTH - 64) * HEIGHT;
 }
 
 double
@@ -476,13 +480,12 @@ bench_composite (const char *testname,
     n = 1 + npix / (l1test_width * 8);
     t1 = gettime ();
 #if EXCLUDE_OVERHEAD
-    bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, 1);
+    pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, 1);
 #endif
     t2 = gettime ();
-    bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1);
+    pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1);
     t3 = gettime ();
-    printf ("  L1:%7.2f", (double)n * l1test_width * 1 /
-            ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  L1:%7.2f", pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -495,13 +498,12 @@ bench_composite (const char *testname,
     n = 1 + npix / (l1test_width * nlines);
     t1 = gettime ();
 #if EXCLUDE_OVERHEAD
-    bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, nlines);
+    pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, nlines);
 #endif
     t2 = gettime ();
-    bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines);
+    pix_cnt = bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines);
     t3 = gettime ();
-    printf ("  L2:%7.2f", (double)n * l1test_width * nlines /
-            ((t3 - t2) - (t2 - t1)) / 1000000.);
+    printf ("  L2:%7.2f", pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
@@ -510,14 +512,14 @@ bench_composite (const char *testname,
     n = 1 + npix / (WIDTH * HEIGHT);
     t1 = gettime ();
 #if EXCLUDE_OVERHEAD
-    bench_M (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
+    pix_cnt = bench_M (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
 #endif
     t2 = gettime ();
-    bench_M (op, src_img, mask_img, dst_img, n, func);
+    pix_cnt = bench_M (op, src_img, mask_img, dst_img, n, func);
     t3 = gettime ();
     printf ("  M:%6.2f (%6.2f%%)",
-        ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1))) / 1000000.,
-        ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
+        (pix_cnt / ((t3 - t2) - (t2 - t1))) / 1000000.,
+        (pix_cnt / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
     fflush (stdout);
 
     memcpy (dst, src, BUFSIZE);
commit 9e8f2bcaf5fabd3729ee0ecc90009fd6cea9e8e9
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 12:02:17 2015 +0300

    lowlevel-blt-bench: move speed and scaling printing
    
    Move the printing of the memory speed and scaling mode into a new
    function. This will help with implementing a machine-readable output
    option.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index aca1819..8ad4ebb 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -1031,6 +1031,26 @@ print_explanation (void)
 }
 
 static void
+print_speed_scaling (double bw)
+{
+    printf ("reference memcpy speed = %.1fMB/s (%.1fMP/s for 32bpp fills)\n",
+            bw / 1000000., bw / 4000000);
+
+    if (use_scaling)
+    {
+	printf ("---\n");
+	if (filter == PIXMAN_FILTER_BILINEAR)
+	    printf ("BILINEAR scaling\n");
+	else if (filter == PIXMAN_FILTER_NEAREST)
+	    printf ("NEAREST scaling\n");
+	else
+	    printf ("UNKNOWN scaling\n");
+    }
+
+    printf ("---\n");
+}
+
+static void
 usage (const char *progname)
 {
     printf ("Usage: %s [-b] [-n] pattern\n", progname);
@@ -1041,7 +1061,6 @@ usage (const char *progname)
 int
 main (int argc, char *argv[])
 {
-    double x;
     int i;
     const char *pattern = NULL;
     for (i = 1; i < argc; i++)
@@ -1079,20 +1098,8 @@ main (int argc, char *argv[])
     mask = dst + (BUFSIZE / 4);
 
     print_explanation ();
-    bandwidth = x = bench_memcpy ();
-    printf ("reference memcpy speed = %.1fMB/s (%.1fMP/s for 32bpp fills)\n",
-            x / 1000000., x / 4000000);
-    if (use_scaling)
-    {
-	printf ("---\n");
-	if (filter == PIXMAN_FILTER_BILINEAR)
-	    printf ("BILINEAR scaling\n");
-	else if (filter == PIXMAN_FILTER_NEAREST)
-	    printf ("NEAREST scaling\n");
-	else
-	    printf ("UNKNOWN scaling\n");
-    }
-    printf ("---\n");
+    bandwidth = bench_memcpy ();
+    print_speed_scaling (bandwidth);
 
     if (strcmp (pattern, "all") == 0)
     {
commit a33c2e6853fe0a76da42a43ed7ed9095e2dbe6a2
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 11:56:39 2015 +0300

    lowlevel-blt-bench: print single pattern details
    
    When given just a single test pattern instead of "all", print the test
    details. This can be used to verify the pattern parser agrees with the
    user, just like scaling settings are printed.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 866dedd..aca1819 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -822,6 +822,8 @@ parse_test_pattern (test_entry_t *test, const char *pattern)
         }
     }
 
+    test->testname = pattern;
+
     /* Extract operator, may contain delimiters,
      * so take the longest string that matches.
      */
@@ -947,7 +949,21 @@ parser_self_test (void)
 }
 
 static void
-run_one_test (const char *pattern, double bandwidth_)
+print_test_details (const test_entry_t *test)
+{
+    printf ("%s: %s, src %s%s, mask %s%s%s, dst %s\n",
+            test->testname,
+            operator_name (test->op),
+            format_name (test->src_fmt),
+            test->src_flags & SOLID_FLAG ? " solid" : "",
+            format_name (test->mask_fmt),
+            test->mask_flags & SOLID_FLAG ? " solid" : "",
+            test->mask_flags & CA_FLAG ? " CA" : "",
+            format_name (test->dst_fmt));
+}
+
+static void
+run_one_test (const char *pattern, double bandwidth_, pixman_bool_t prdetails)
 {
     test_entry_t test;
 
@@ -957,6 +973,12 @@ run_one_test (const char *pattern, double bandwidth_)
         return;
     }
 
+    if (prdetails)
+    {
+        print_test_details (&test);
+        printf ("---\n");
+    }
+
     bench_composite (pattern,
                      test.src_fmt,
                      test.src_flags,
@@ -973,7 +995,7 @@ run_default_tests (double bandwidth_)
     int i;
 
     for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
-        run_one_test (tests_tbl[i].testname, bandwidth_);
+        run_one_test (tests_tbl[i].testname, bandwidth_, FALSE);
 }
 
 static void
@@ -1078,7 +1100,7 @@ main (int argc, char *argv[])
     }
     else
     {
-        run_one_test (pattern, bandwidth);
+        run_one_test (pattern, bandwidth, TRUE);
     }
 
     free (src);
commit 3ac7ae201758fe99627fdb2adf783be4063a9b1f
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 11:34:45 2015 +0300

    lowlevel-blt-bench: make test_entry::testname const
    
    We assign string literals to it, so it better be const.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 993f5db..866dedd 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -589,13 +589,13 @@ bench_composite (const char *testname,
 
 struct test_entry
 {
-    char *testname;
-    int   src_fmt;
-    int   src_flags;
-    int   op;
-    int   mask_fmt;
-    int   mask_flags;
-    int   dst_fmt;
+    const char *testname;
+    int         src_fmt;
+    int         src_flags;
+    int         op;
+    int         mask_fmt;
+    int         mask_flags;
+    int         dst_fmt;
 };
 
 typedef struct test_entry test_entry_t;
commit 56d8b365f5944bf78a427ac65c5a0d0311e0da5e
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 11:21:14 2015 +0300

    lowlevel-blt-bench: move explanation printing
    
    Move explanation printing to a new function. This will help with
    implementing a machine-readable output option.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 69202ee..993f5db 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -977,6 +977,38 @@ run_default_tests (double bandwidth_)
 }
 
 static void
+print_explanation (void)
+{
+    printf ("Benchmark for a set of most commonly used functions\n");
+    printf ("---\n");
+    printf ("All results are presented in millions of pixels per second\n");
+    printf ("L1  - small Xx1 rectangle (fitting L1 cache), always blitted at the same\n");
+    printf ("      memory location with small drift in horizontal direction\n");
+    printf ("L2  - small XxY rectangle (fitting L2 cache), always blitted at the same\n");
+    printf ("      memory location with small drift in horizontal direction\n");
+    printf ("M   - large %dx%d rectangle, always blitted at the same\n",
+            WIDTH - 64, HEIGHT);
+    printf ("      memory location with small drift in horizontal direction\n");
+    printf ("HT  - random rectangles with %dx%d average size are copied from\n",
+            TILEWIDTH, TILEWIDTH);
+    printf ("      one %dx%d buffer to another, traversing from left to right\n",
+            WIDTH, HEIGHT);
+    printf ("      and from top to bottom\n");
+    printf ("VT  - random rectangles with %dx%d average size are copied from\n",
+            TILEWIDTH, TILEWIDTH);
+    printf ("      one %dx%d buffer to another, traversing from top to bottom\n",
+            WIDTH, HEIGHT);
+    printf ("      and from left to right\n");
+    printf ("R   - random rectangles with %dx%d average size are copied from\n",
+            TILEWIDTH, TILEWIDTH);
+    printf ("      random locations of one %dx%d buffer to another\n",
+            WIDTH, HEIGHT);
+    printf ("RT  - as R, but %dx%d average sized rectangles are copied\n",
+            TINYWIDTH, TINYWIDTH);
+    printf ("---\n");
+}
+
+static void
 usage (const char *progname)
 {
     printf ("Usage: %s [-b] [-n] pattern\n", progname);
@@ -1024,33 +1056,7 @@ main (int argc, char *argv[])
     dst = src + (BUFSIZE / 4);
     mask = dst + (BUFSIZE / 4);
 
-    printf ("Benchmark for a set of most commonly used functions\n");
-    printf ("---\n");
-    printf ("All results are presented in millions of pixels per second\n");
-    printf ("L1  - small Xx1 rectangle (fitting L1 cache), always blitted at the same\n");
-    printf ("      memory location with small drift in horizontal direction\n");
-    printf ("L2  - small XxY rectangle (fitting L2 cache), always blitted at the same\n");
-    printf ("      memory location with small drift in horizontal direction\n");
-    printf ("M   - large %dx%d rectangle, always blitted at the same\n",
-            WIDTH - 64, HEIGHT);
-    printf ("      memory location with small drift in horizontal direction\n");
-    printf ("HT  - random rectangles with %dx%d average size are copied from\n",
-            TILEWIDTH, TILEWIDTH);
-    printf ("      one %dx%d buffer to another, traversing from left to right\n",
-            WIDTH, HEIGHT);
-    printf ("      and from top to bottom\n");
-    printf ("VT  - random rectangles with %dx%d average size are copied from\n",
-            TILEWIDTH, TILEWIDTH);
-    printf ("      one %dx%d buffer to another, traversing from top to bottom\n",
-            WIDTH, HEIGHT);
-    printf ("      and from left to right\n");
-    printf ("R   - random rectangles with %dx%d average size are copied from\n",
-            TILEWIDTH, TILEWIDTH);
-    printf ("      random locations of one %dx%d buffer to another\n",
-            WIDTH, HEIGHT);
-    printf ("RT  - as R, but %dx%d average sized rectangles are copied\n",
-            TINYWIDTH, TINYWIDTH);
-    printf ("---\n");
+    print_explanation ();
     bandwidth = x = bench_memcpy ();
     printf ("reference memcpy speed = %.1fMB/s (%.1fMP/s for 32bpp fills)\n",
             x / 1000000., x / 4000000);
commit bddff993ed734f4b9030c1960bcb3ebe1caca807
Author: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Date:   Wed Jun 10 11:14:38 2015 +0300

    lowlevel-blt-bench: move usage to a function
    
    Move printing of usage into a new function and use argv[0] as the
    program name. This will help printing usage from multiple places.
    
    Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
    Reviewed-by: Ben Avison <bavison at riscosopen.org>

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index aff4608..69202ee 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -976,6 +976,14 @@ run_default_tests (double bandwidth_)
         run_one_test (tests_tbl[i].testname, bandwidth_);
 }
 
+static void
+usage (const char *progname)
+{
+    printf ("Usage: %s [-b] [-n] pattern\n", progname);
+    printf ("  -n : benchmark nearest scaling\n");
+    printf ("  -b : benchmark bilinear scaling\n");
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1005,9 +1013,7 @@ main (int argc, char *argv[])
 
     if (!pattern)
     {
-	printf ("Usage: lowlevel-blt-bench [-b] [-n] pattern\n");
-	printf ("  -n : benchmark nearest scaling\n");
-	printf ("  -b : benchmark bilinear scaling\n");
+	usage (argv[0]);
 	return 1;
     }
 


More information about the xorg-commit mailing list