我正在将 N 个字节从 pSrc 复制到 pDest.这可以在一个循环中完成:
I am copying N bytes from pSrc to pDest. This can be done in a single loop:
for (int i = 0; i < N; i++)
*pDest++ = *pSrc++
为什么这比 memcpy 或 memmove 慢?他们使用什么技巧来加快速度?
Why is this slower than memcpy or memmove? What tricks do they use to speed it up?
因为 memcpy 使用字指针而不是字节指针,所以 memcpy 的实现也经常用 SIMD 指令,可以一次对 128 位进行混洗.
Because memcpy uses word pointers instead of byte pointers, also the memcpy implementations are often written with SIMD instructions which makes it possible to shuffle 128 bits at a time.
SIMD 指令是汇编指令,可以对最多 16 字节长的向量中的每个元素执行相同的操作.这包括加载和存储指令.
SIMD instructions are assembly instructions that can perform the same operation on each element in a vector up to 16 bytes long. That includes load and store instructions.
这篇关于为什么 memcpy() 和 memmove() 比指针增量快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 C++ 中读取和操作 CSV 文件数据?How can I read and manipulate CSV file data in C++?(如何在 C++ 中读取和操作 CSV 文件数据?)
在 C++ 中,为什么我不能像这样编写 for() 循环:In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,为什么我不能像这样编写 for() 循环: for(
OpenMP 如何处理嵌套循环?How does OpenMP handle nested loops?(OpenMP 如何处理嵌套循环?)
在循环 C++ 中重用线程Reusing thread in loop c++(在循环 C++ 中重用线程)
需要精确的线程睡眠.最大 1ms 误差Precise thread sleep needed. Max 1ms error(需要精确的线程睡眠.最大 1ms 误差)
是否需要“do {...} while ()"?环形?Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?环形?)