Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

memcpy performance

This topic is 5931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there! I heard somewhere that memcpy only copies one byte at a time. If that is the case, then it would be very slow. Does anybody know if this is true and if so, what can you use instead? Thanks /Fredrik Olsson

Share this post


Link to post
Share on other sites
Advertisement
not true.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
The answer is yes, no, and maybe.

It all depends on optimization level, compiler used and platform. Any compiler is free to implement memcpy() however they want as long as it works according to the standard definition.

Share this post


Link to post
Share on other sites
Ive found memcpy and memset to be bloody fast, so dont worry about it.

-----------------------------
Damnit Dave, I would have a link to Graphics Wars here, but you haven''t put it up on GDNet yet!

The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Democracy is where you say what you want and do what you''re told.

Share this post


Link to post
Share on other sites
Sorry for the bad explanation.

I meant in MSVC6.0 with full optimization on.

And the reason why I asked is because I read a post on the OpenGL forum where sombody said something like:
"ill never use memcpy again, it only copies one byte at a time"

And if that would be the case, the compiler/function would not take full advantage of the memory bandwidth.

Thanks
/Fredrik Olsson

Share this post


Link to post
Share on other sites
It varies, but a good compiler should be able to unroll the loop and copy by registers if the size is small enough. Worst case is byte copy and the slighty better one is the "rep movsd" style, copying four bytes at a time.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!