public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Ondřej Bílka" <neleai@seznam.cz>
To: Will Newton <will.newton@linaro.org>
Cc: "Måns Rullgård" <mans@mansr.com>,
	libc-ports@sourceware.org, "Patch Tracking" <patches@linaro.org>
Subject: Re: [PATCH] ARM: Add Cortex-A15 optimized NEON and VFP memcpy routines, with IFUNC.
Date: Thu, 18 Apr 2013 11:56:00 -0000	[thread overview]
Message-ID: <20130418115604.GA31357@domone.kolej.mff.cuni.cz> (raw)
In-Reply-To: <CANu=DmiVS4y6Cmdw_K8Gpbp=LjkaQ8Pf6eDvjBfsTcKLmcue3g@mail.gmail.com>

On Thu, Apr 18, 2013 at 10:47:26AM +0100, Will Newton wrote:
> On 18 April 2013 10:39, Ondřej Bílka <neleai@seznam.cz> wrote:
> > On Mon, Apr 15, 2013 at 11:38:49AM +0100, Will Newton wrote:
> >> On 15 April 2013 11:06, Måns Rullgård <mans@mansr.com> wrote:
> >>
> >> Hi MÃ¥ns,
> >>
> >> >> Add a high performance memcpy routine optimized for Cortex-A15 with
> >> >> variants for use in the presence of NEON and VFP hardware, selected
> >> >> at runtime using indirect function support.
> >> >
> >> > How does this perform on Cortex-A9?
> >>
> >> The code is also faster on A9 although the gains are not quite as
> >> pronounced. A set of numbers is attached (they linewrap pretty
> >> horribly inline).
> >>
> >>
> > I forget to ask where to get benchmark source. Without it there is no
> > way to tell if it was done correctly.
> > You must randomly vary sizes in range n..2n and also vary alignments.
> 
> The benchmark is taken from the cortex-strings package:
> 
> https://launchpad.net/cortex-strings
> 
> I wrote a wrapper around the benchmark to vary alignment in {1, 2, 4,
> 8} and a variety of block lengths between 8 and 200.
> 
Could you post wrapper?

I could find there only following if it is what you meant:
http://bazaar.launchpad.net/~linaro-toolchain-dev/cortex-strings/trunk/view/head:/tests/test-memcpy.c

If this is a case then benchmark contains several serious mistake and data 
generated by it cannot be accepted.

I attached a modification of simple benchmark used by gcc. Could you try
it and post results to be sure.

First put your need place neon implementation into neon.s file with
function name memcpy_neon. 
Then run
./memcpy_test 64 6000000000 gcc 

Mistakes in http://bazaar.launchpad.net/~linaro-toolchain-dev/cortex-strings/trunk/view/head:/tests/test-memcpy.c
follow.

First is that original benchmark did not vary sizes and alignments. 

Second is timing is in loop over same data (see code below). 
Even if you vary lengths this loop will undo all your work on
randomizing inputs. 
Every branch becomes predicted. All data it kept in cache. 

These conditions cause performance to be far from performance on real
inputs. 

 for (i = 0; i < 32; ++i)
	{
	  HP_TIMING_NOW (start);
	  CALL (impl, dst, src, len);
	  HP_TIMING_NOW (stop);
	  HP_TIMING_BEST (best_time, start, stop);
	}

Third problem is that benchmark takes minimum over times. 
This obviously does not measure average time but minimal time.

This is statisticaly unsound practice. Any article that would used minimum in
benchmark would immidietaly get rejected on review.

Reason is easy, consider function.

if (rand()%4<1) 
 sleep(1);
else 
 sleep(15000);

Which is according to minimum metric 100 times faster than one below
despite opposite is true.

if (rand()%2<1)
 sleep(100);
else
 sleep(200);



  reply	other threads:[~2013-04-18 11:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15  9:57 Will Newton
2013-04-15 10:01 ` Will Newton
2013-04-15 10:23   ` Ondřej Bílka
2013-04-15 10:59     ` Will Newton
2013-04-15 13:38       ` Ondřej Bílka
2013-04-15 10:06 ` Måns Rullgård
2013-04-15 10:38   ` Will Newton
2013-04-15 10:46     ` Måns Rullgård
2013-04-15 10:49       ` Will Newton
2013-04-18  9:39     ` Ondřej Bílka
2013-04-18  9:47       ` Will Newton
2013-04-18 11:56         ` Ondřej Bílka [this message]
2013-04-15 17:14 ` Richard Henderson
2013-04-15 17:44   ` Will Newton
2013-04-15 18:22     ` Richard Henderson
2013-04-15 18:31       ` Will Newton
2013-04-15 18:37         ` Richard Henderson
2013-04-15 18:48           ` Will Newton
2013-04-15 19:12             ` Richard Henderson
2013-04-15 19:47               ` Will Newton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130418115604.GA31357@domone.kolej.mff.cuni.cz \
    --to=neleai@seznam.cz \
    --cc=libc-ports@sourceware.org \
    --cc=mans@mansr.com \
    --cc=patches@linaro.org \
    --cc=will.newton@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).