linux-mips
[Top] [All Lists]

Re: memcpy prefetch

To: Greg Weeks <greg.weeks@timesys.com>
Subject: Re: memcpy prefetch
From: Ralf Baechle <ralf@linux-mips.org>
Date: Wed, 6 Apr 2005 21:08:48 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <4253D67C.4010705@timesys.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <4253D67C.4010705@timesys.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.4.1i
On Wed, Apr 06, 2005 at 08:30:52AM -0400, Greg Weeks wrote:

> In trying to understand the prefetch code in memcpy it looks like it's 
> prefetching too far out in front of the loop. In the main aligned loop 
> the loop copies 32 or 64 bytes of data and the prefetch is trying to 
> prefetch 256 bytes ahead of the current copy. The prefetches should also 
> pay attention to cache line size and they currently don't. If the line 
> size is less than the copy size we are skipping prefetches that should 
> be done. For the 4kc the line size is only 16 bytes. We should be doing 
> a prefetch for each line. The src_unaligned_dst_aligned loop is even 
> worse as it prefetches 288 bytes ahead of the copy and only copies 16 or 
> 32 bytes at a time.
> 
> Have I totally misunderstood the code?

Nope, you've understood that perfectly right.  The messy thing is that on
a whole bunch of system we don't know the cacheline size before runtime
so we have two choices a) work under worst case assumptions which would be
16 bytes.  Or do the same thing as we're already doing it for a bunch of
other performance sensitive functions, generating them at runtime.  Choose
your poison ;-)

  Ralf

<Prev in Thread] Current Thread [Next in Thread>