Messages in this thread | | | Subject | RE: [Fwd: Re: [PATCH v2 2/2] x86: add prefetching to do_csum] | Date | Wed, 13 Nov 2013 13:32:50 -0000 | From | "David Laight" <> |
| |
> > I'm not sure, whats the typical capacity for the branch predictors > > ability to remember code paths? ... > > For such simple single-target branches it goes near or over a thousand for > recent Intel and AMD microarchitectures. Thousands for really recent CPUs.
IIRC the x86 can also correctly predict simple sequences - like a branch in a loop that is taken every other iteration, or only after a previous branch is taken.
Much simpler cpus may use a much simpler strategy. I think one I've used (a fpga soft-core cpu) just uses the low bits of the instruction address to index a single bit table. This means that branches alias each other. In order to get the consistent cycle counts in order to minimise the worst case code path we had to disable the dynamic prediction.
For the checksum code the loop branch isn't a problem. Tests on entry to the function might get mispredicted.
So if you have conditional prefetch when the buffer is long then time a short buffer after a 100 long ones you'll almost certainly see the mispredition penalty.
FWIW I remember speeding up a copy (I think) loop on a strongarm by adding an extra instruction to fetch a word from later in the buffer into a register I never otherwise used. (That was an unpaged system so I knew it couldn't fault.)
David
| |