![]() ![]() The accesses to memory need to be aligned on 32-bit addresses. On such systems it is often expensive to use data types like double and some systems doesn't have a FPU (Floating Point Unit).īy trying to read and write memory in 32 bit blocks as often as possible, the speed of the implementation is increased dramatically, especially when copying data that is not aligned on a 32-bit boundary. The goal with the C implementation of memcpy() was to get portable code mainly for embedded systems. It is of course possible to read larger chunks of data on some targets with wider data bus and wider data registers. My first improvement to my co-worker's original was to read 32 bits at the time from the memory. ![]() In most systems, the CPU clock runs at much higher frequency than the speed of the memory bus. The following paragraphs contain descriptions to some of the techniques used in the final implementation. Both our implementations got better and better and looked more alike and finally we had an implementation that was very fast and that beats both the native library routines in Windows and Linux, especially when the memory to be copied is not aligned on a 32 bit boundary. I made an implementation, which was quite a lot faster than my co-vorker's and this started a friendly competition to make the fastest portable C implementation of memcpy(). When looking at his code, I found several places where improvements could be made. His implementation was faster than many standardized C library routines found in the embedded market. ![]() The story began when a co-worker of mine made an implementation of memcpy that he was very proud of. This implementation has been used successfully in several project where performance needed a boost, including the iPod Linux port, the xHarbour Compiler, the pymat python-Matlab interface, the Inspire IRCd client, and various PSP games. This article describes a fast and portable memcpy implementation that can replace the standard library version of memcpy when higher performance is needed. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |