简体   繁体   English

当执行memcpy()时,通常使用哪种硬件资源?

[英]What HW resource is mostly used when one does memcpy()?

This feels like a very newbie question, but I suddenly find myself clueless. 这似乎是一个非常新手的问题,但我突然发现自己毫无头绪。 I'm trying to profile ac application that does a lot of memory copies, and there is an option for me to reduce that number (requires some re-design). 我正在尝试分析执行大量内存复制的ac应用程序,并且我可以选择减少该数量的程序(需要重新设计)。 I'm trying to realize if it's worth it, but I have no idea what resource it will affect, or how to monitor it. 我想知道是否值得,但是我不知道它将影响什么资源或如何对其进行监视。

If someone knows what resource (and how to monitor it in Linux), and/or has a reference to a section in Agner or any other optimization manual I would very much appreciate it. 如果有人知道什么资源(以及如何在Linux中进行监视),并且/或者参考了Agner或其他优化手册中的部分,我将非常感激。 Thanks. 谢谢。

memcpy uses the CPU in order to copy memory from one buffer to the other. memcpy使用CPU以便将内存从一个缓冲区复制到另一个缓冲区。 Generally speaking, code doing lots of memcpy will be CPU bound. 一般来说,执行大量memcpy代码将受CPU限制。

With that said, some of the underlying design might make this different. 话虽如此,某些基础设计可能会有所不同。 In particular, if you're doing a lot of memory copying, it might be that you are using memory once and throwing it away. 特别是,如果您要进行大量内存复制,则可能是您一次使用了内存并将其丢弃。 If that's the case, you are making poor use of the CPU's data cache. 如果是这种情况,则说明您没有充分利用CPU的数据缓存。 Switching to an algorithm that keeps the memory where it is may give you a huge benefit on that front. 切换到将内存保持在原处的算法可能会给您带来巨大的好处。

As for profiling, I know valgrind has a tool for checking cache efficiency. 至于分析,我知道valgrind有一个检查缓存效率的工具。 Maybe others too. 也许也是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM