本文介绍了在什么平台memmove与和memcpy可以有显著的性能差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知, memmove与的memcpy 不同的是, memmove与处理记忆的重叠情况。我已经检查libgcc中的执行情况,并得到了这个文章从英特尔的网站。

I understand that memmove and memcpy difference is that memmove handles the memory overlap case. I have checked the implementation in libgcc and got this article [memcpy performance] from the intel website.

在libgcc中,在 memmove与类似于的memcpy ,无论是刚去,虽然一个字节,字节,所以即使是经过优化的性能应该差不多一样的。

In libgcc, the memmove is similar to memcpy, both just go though one byte and byte, so the performance should be almost same even after optimization.

有人测得该,得到了本文的。即使我不认为 memmove与可以比的memcpy 较快,但应该有至少上没有大的区别英特尔的平台。

Someone has measured this and got this article memcopy, memmove, and Speed over Safety. Even I don't think the memmove can be faster than memcpy, but there should be no big difference at least on Intel platform.

于是在什么平台以及如何的memcpy 可显著快于 memmove与,如果没有,为什么提供两个similiar功能,而不是仅仅 memmove与,并导致大量的bug。

So in what platform and how, memcpy can be significantly faster than memmove, if there is none, why providing two similiar functions instead of just memmove, and lead to a lots of bug.

编辑:我不要求memmove与和memcpy的区别,我知道memmove与能处理重叠的问题。问题是关于是否确有平台,在这里的memcpy比快的memmove?

I'm not asking the difference of memmove and memcpy, I know memmove can handle overlap issue. The question is about is there really any platform where memcpy is faster than memmove?

推荐答案

有就是非重叠内存约束是用来生成速度更快code至少有一个最近的例子:

There is at least one recent case where the constraint of non-overlapping memory is used to generate faster code:

在Visual Studio中的memcpy 可使用的的,而 memmove与不能。这导致在的memcpy 是要快得多,因为去掉了函数调用和设置开销已知大小的小区域。使用实施 MOVSD / MOVSW / MOVSB​​ 不适合为重叠块,因为它开始于最低的地址复制,在复制过程中递增EDI / ESI。

In Visual Studio memcpy can be compiled using intrinsics, while memmove cannot. This leads in memcpy being much faster for small regions of a known size because of removing the function call and setup overhead. The implementation using movsd/movsw/movsb is not suitable for overlapping blocks, as it starts copying at the lowest address, incrementing the edi/esi during the copy.

另请参阅 href=\"http://stackoverflow.com/a/1137515/16673\">使编译器复制字符。

See also Make compiler copy characters using movsd.

借助的memcpy一样内置插件实现的,实施和动机很可能是类似的Visual Studio。

The GCC also lists memcpy as implemented as built-ins, the implementation and motivation is likely to be similar to that of Visual Studio.

这篇关于在什么平台memmove与和memcpy可以有显著的性能差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 09:29