From seth at userprimary.net  Wed Apr 21 20:15:08 2010
From: seth at userprimary.net (Seth Falcon)
Date: Wed, 21 Apr 2010 11:15:08 -0700
Subject: [Rd] suggestion how to use memcpy in duplicate.c
In-Reply-To: <2AEC193A-10E8-4D25-89E3-38238E7F16E1@r-project.org>
References: <hqn72q$uev$1@dough.gmane.org>
	<2AEC193A-10E8-4D25-89E3-38238E7F16E1@r-project.org>
Message-ID: <4BCF40AC.1070408@userprimary.net>

On 4/21/10 10:45 AM, Simon Urbanek wrote:
> Won't that miss the last incomplete chunk? (and please don't use
> DATAPTR on INTSXP even though the effect is currently the same)
>
> In general it seems that the it depends on nt whether this is
> efficient or not since calls to short memcpy are expensive (very
> small nt that is).
>
> I ran some empirical tests to compare memcpy vs for() (x86_64, OS X)
> and the results were encouraging - depending on the size of the
> copied block the difference could be quite big: tiny block (ca. n =
> 32 or less) - for() is faster small block (n ~ 1k) - memcpy is ca. 8x
> faster as the size increases the gap closes (presumably due to RAM
> bandwidth limitations) so for n = 512M it is ~30%.
>

> Of course this is contingent on the implementation of memcpy,
> compiler, architecture etc. And will only matter if copying is what
> you do most of the time ...

Copying of vectors is something that I would expect to happen fairly 
often in many applications of R.

Is for() faster on small blocks by enough that one would want to branch 
based on size?

+ seth

-- 
Seth Falcon | @sfalcon | http://userprimary.net/



[Rd] suggestion how to use memcpy in duplicate.c
Seth Falcon