Re: [OT] Re: memcpy() vs. for() performance

From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 07/01/04


Date: 1 Jul 2004 16:32:01 GMT

In <40e40d8c$0$93324$e4fe514c@news.xs4all.nl> Case <no@no.no> writes:

>Dan Pop wrote:
>>
>> When the size is unknown at compile time (or too large), the compiler
>> cannot inline the memcpy call, it will call the library version.
>
>When I had to make a choice between the two, I would call it
>call it optimization. I'm surprized that you seem to prefer the
>term inlining. Why?

Because this is the specific name of that particular optimisation.
What is so difficult to understand?

As I said, inlining is NOT the only way an implementation can optimise
a memcpy call. There are plenty of optimisations that can be applied
to the library version of memcpy (especially if it's not written in C).

>> If you want ultimate answers, benchmark the two versions yourself.
>> Keep in mind that they cannot be extrapolated to other implementations.
>
>Yep, one other good reason to always use memcpy(). However, how was
>the saying again .... "Never say always!" :-)

Another failed attempt at humour...

Dan

-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de


Relevant Pages

  • Re: Results of the memswap() smackdown from the thread "Sorting" assignment
    ... you used small strings for a reason. ... (but not as good as Ben's optimization) ... relying on the quality of whatever library does memcpy while at the ... a way that I can redefine any library function by a macro. ...
    (comp.programming)
  • Re: Tips on optimizing these functions
    ... specific-nested-loop solution, the functions take up to twice the time. ... However, turning on some optimization flags, specifically '-O3' with gcc, ... Some compilers automatically substitute a run-time library copy function ... If you wrote memcpy() in line, that would work well with certain ...
    (comp.lang.c)
  • Re: Double increment question.
    ... for the purpose of optimization experimentation. ... outside of system libraries (such as those that implement memcpy()). ... running MyProgram (allocating memory, loading code into memory, initialising ...
    (comp.lang.c)
  • Re: mutl ibyte to w i d e c h a r
    ... > This is what you get if you compile a call to memcpy() with optimization ... I bet it doesn't know how to produce the MMX instructions that Relivinian ...
    (microsoft.public.vc.language)
  • Re: Accessing via a pointer to 2d array.
    ... can be safely copied with memcpy. ... To preserve your sanity, restrict yourself to pointers to "unidimensional" ... Dan Pop ...
    (comp.lang.c)