Re: Any unusual C++ implementations?
On Jan 5, 6:31 pm, "Tom=E1s =D3 h=C9ilidhe" <t...@lavabit.com> wrote:
James Kanze <james.ka...@gmail.com> wrote in comp.lang.c++:
On modern machines, the straightforward implementation is likely
to be just as fast as anything more complicated, because of the
way pipelining and the various caching work at the hardware
level: the limiting factor will be memory bandwidth, and the
memory interface pipelines will ensure that all writes and reads
are cache line width (e.g.64 bytes).
A more suitable set of functions would be:
memcpy_hmmmmm_about_10_bytes_maybe(void*,void const*,size_t);
memcpy_hmmmmm_about_30_bytes_maybe(void*,void const*,size_t);
memcpy_hmmmmm_about_100_bytes_maybe(void*,void const*,size_t);
memcpy_large(void*,void const*,size_t);
I'm sure sensible use of these would yield better performance :-D
Which is roughly what the compiler does when it encounters
__builtin_memcpy. If the size is a constant, or if the
addresses can be determined to be correctly aligned, it can
generate a lot better code than you could do in a general
algorithm.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34