gpt4 book ai didi

c++ - 为什么将内存从 VRAM 复制到 RAM 比从 RAM 复制到 VRAM 慢? (OpenGL)

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:19:57 25 4
gpt4 key购买 nike

我正在创建类似于 CUDA 的东西,但我看到将内存从 RAM 复制到 VRAM 非常快,就像从 RAM 复制到自身一样。但是从 VRAM 复制到 RAM 比从 RAM 复制到 VRAM 慢。

顺便说一下,我正在使用 glTexSubImage2D 从 RAM 复制到 VRAM,使用 glGetTexImage 从 VRAM 复制到 RAM。

为什么?有没有办法提高它的性能,比如将 RAM 复制到 VRAM?

最佳答案

将数据从 GPU 传输到 CPU 总是非常缓慢的操作。

A GPU -> CPU readback introduces a "sync point" where the CPU must wait for the GPU to complete its calculations. During this time, the CPU stops feeding the GPU with data, causing it to stall.

Now, remember that a modern GPU is designed in a highly parallel manner, with thousand threads in flight at any given moment. The sync point must wait for all those threads to finish processing, before it can readback the result of their calculations. Once the readback is complete, all those threads must restart execution from zero... bad!

Reading back the results asynchronously (after a few frames), allows the GPU continue execution without its threads starving (the stop-and-resume issue outlined above). This improves performance tremendously - the more parallel the GPU, the higher the performance improvement.

根据您的图形芯片和驱动程序,使用 PBOs 可能会获得更好的性能.

关于c++ - 为什么将内存从 VRAM 复制到 RAM 比从 RAM 复制到 VRAM 慢? (OpenGL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13646401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com