是否值得将 FFT 计算卸载到嵌入式 GPU?

发布于 2024-12-16 19:40:43 字数 425 浏览 1 评论 0原文

我们正在考虑将应用程序从专用数字信号处理芯片移植到通用 x86 硬件上运行。该应用程序执行大量傅里叶变换,从简短的研究来看,FFT 似乎相当适合在 GPU 而不是 CPU 上进行计算。例如,本页有一些使用 Core 2 Quad 和 GF 8800 GTX 的基准测试,显示使用 GPU 时计算时间减少了 10 倍:

http://www.cv.nrao.edu/~pdemores/gpu/

但是,在我们的产品中,尺寸限制将我们限制在较小的外形尺寸上例如 PC104 或 Mini-ITX,因此嵌入式 GPU 相当有限。

将计算卸载到 GPU 是否只值得在适当的 PCIe 总线上使用强大的显卡来完成,或者嵌入式 GPU 甚至会提供性能改进吗?

We are considering porting an application from a dedicated digital signal processing chip to run on generic x86 hardware. The application does a lot of Fourier transforms, and from brief research, it appears that FFTs are fairly well suited to computation on a GPU rather than a CPU. For example, this page has some benchmarks with a Core 2 Quad and a GF 8800 GTX that show a 10-fold decrease in calculation time when using the GPU:

http://www.cv.nrao.edu/~pdemores/gpu/

However, in our product, size constraints restrict us to small form factors such as PC104 or Mini-ITX, and thus to rather limited embedded GPUs.

Is offloading computation to the GPU something that is only worth doing with meaty graphics cards on a proper PCIe bus, or would even embedded GPUs offer performance improvements?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

沩ん囻菔务 2024-12-23 19:40:44

您需要将数据移入和移出 GPU 内存的成本与使用 GPU 带来的速度优势进行比较。尽管 I/O 和计算可能会有所重叠,但如果 I/O 带宽要求大于计算带宽,您可能仍然会受到影响。如果您可以在 FFT 数据驻留在 GPU 内存中时对其执行任何额外的计算,那么这有助于降低 I/O 成本。

还需要注意的是,基于 GPU 的 FFT 通常只能为单精度数据提供良好的性能。此外,您需要与可能最好的基于 CPU 的 FFT 进行比较,例如为单精度构建并使用 SSE 的 FFTW。

You need to compare the cost of moving data to and from GPU memory versus any speed benefit from using the GPU. Although it's possible to overlap the I/O and the computation somewhat, you may still suffer if the I/O bandwidth requirements are greater than the computational bandwidth. If you have any additional computation that can be performed on the FFT data while it's resident in GPU memory then this can help to mitigate the I/O cost.

It's also important to note that GPU based FFTs typically only give good performance for single precision data. Furthermore you need to compare against the best possible CPU-based FFT, e.g. FFTW built for single precision and using SSE.

ㄟ。诗瑗 2024-12-23 19:40:44

我想补充一下您具体关于嵌入式 GPU 的问题。

与桌面上的高端 GPU 相比,它们通常具有很少的着色器核心、更少的核心寄存器和更低的内存带宽。然而,与板载多核 CPU 相比,在嵌入式 GPU 上运行类似 FFT 的应用程序可以提供更好的性能[1]。嵌入式 GPU 的主要优点是它们与 CPU 共享公共内存,从而避免了从主机到设备的内存复制过程。

几乎所有嵌入式 GPU(例如 ARM 的 Mali、高通的 adreno 等)都支持 OpenCL,因此在嵌入式 GPU 上使用 OpenCL 库进行 FFT 可以提供更好的性能(AMD 的 clFFT 众所周知且开源)。针对嵌入式 GPU 架构调整 OpenCL 代码可以使其变得更好。(请参阅 ARM Mali-T600 系列 GPU OpenCL
开发人员指南位于 http://infocenter.arm.com )

[1] Arian Maghazeh、Unmesh、Bordoloi Petru、Eles彭.一般的
低功耗嵌入式 GPU 上的用途计算:有吗
成年了吗?

I would like to add on your question specifically about embedded GPUs.

They generally have very few shader cores, lesser registers for a core and lower memory bandwidth compared to high end GPUs seen on desktops. However, running FFT like applications on an embedded GPU can give a better performance compared to an onboard multicore CPU[1]. Major advantage in embedded GPUs is that they share a common memory with CPU thereby avoiding the memory copy process from host to device.

Almost all the embedded GPUs like Mali from ARM, adreno from Qualcomm etc support OpenCL, thus using an OpenCL library for your FFT on an embedded GPU can give a better performance (clFFT from AMD is well known and opensource). Tuning the OpenCL code for embedded GPU architecture can make it better.( please refer ARM Mali-T600 Series GPU OpenCL
Developer Guide at http://infocenter.arm.com )

[1] Arian Maghazeh,Unmesh, Bordoloi Petru, Eles Peng. General
Purpose Computing on Low-Power Embedded GPUs: Has It
Come of Age?

标点 2024-12-23 19:40:44

8800 有大约 100 个核心,运行频率约为 0.5 GHz。我认为当前任何小型嵌入式 GPU 都没有那么多的着色器/计算核心。

The 8800 has on the order of 100 cores running at around half a GHz. I don't think any of the current embedded GPUs for small form factors have anywhere near as many shader/compute cores.

惜醉颜 2024-12-23 19:40:44

其中一个问题可能是获取在 GPU 上加载和执行代码以及与 CPU 通信和交换数据所需的技术信息。 Nvidia 专门为此目的提供了一个名为 CUDA 的 API。因此,选择带有支持 CUDA 的 Nvidia GPU 的主板,您可能可以以极低的成本进行实验和基准测试,甚至可以在普通台式电脑上进行原型设计。

对于小型硬件,此讨论可能相关。

One problem might be getting the technical information you need to load and execute code on the GPU and communicate and exchange data with the CPU . Nvidia provide an API called CUDA specifically for this purpose. So choose a board with an Nvidia GPU that supports CUDA and you can probably experiment and benchmark at very little cost, and even prototype on a regular Desktop PC.

With respect to small form-factor hardware, this discussion may be relevant.

自找没趣 2024-12-23 19:40:43

在 x86 硬件和 GPU 上开发了 FFT 例程(在 CUDA 之前,7800 GTX 硬件< /a>) 我从自己的结果中发现,FFT 尺寸较小(低于 2^13)时,CPU 速度更快。超过这些大小,GPU 速度更快。例如,2^16 大小的 FFT 在 GPU 上的计算速度比 CPU 上的等效变换快 2-4 倍。请参阅下面的时间表(所有时间均以秒为单位,比较 3GHz Pentium 4 与 7800GTX。这项工作是在 2005 年完成的,所以硬件很旧,正如我所说,非 CUDA。较新的库可能会显示出更大的改进

N       FFTw (s)    GPUFFT (s)  GPUFFT MFLOPS   GPUFFT Speedup
8       0           0.00006     3.352705        0.006881
16      0.000001    0.000065    7.882117        0.010217
32      0.000001    0.000075    17.10887        0.014695
64      0.000002    0.000085    36.080118       0.026744
128     0.000004    0.000093    76.724324       0.040122
256     0.000007    0.000107    153.739856      0.066754
512     0.000015    0.000115    320.200892      0.134614
1024    0.000034    0.000125    657.735381      0.270512
2048    0.000076    0.000156    1155.151507     0.484331
4096    0.000173    0.000215    1834.212989     0.804558
8192    0.000483    0.00032     2664.042421     1.510011
16384   0.001363    0.000605    3035.4551       2.255411
32768   0.003168    0.00114     3450.455808     2.780041
65536   0.008694    0.002464    3404.628083     3.528726
131072  0.015363    0.005027    3545.850483     3.05604
262144  0.033223    0.012513    3016.885246     2.655183
524288  0.072918    0.025879    3079.443664     2.817667
1048576 0.173043    0.076537    2192.056517     2.260904
2097152 0.331553    0.157427    2238.01491      2.106081
4194304 0.801544    0.430518    1715.573229     1.861814

)其他海报 与 GPU 之间的数据传输是您所承受的损失。较小的 FFT 可以在 CPU 上执行,某些实现/大小完全在缓存中执行。这使得 CPU 成为小型 FFT(低于约 1024 点)的最佳选择。另一方面,如果您需要以最少的进出 GPU 的移动量对数据执行大批量工作,那么 GPU 将轻松击败 CPU。

如果您想要快速的 FFT 实现,我建议使用 FFTW;如果您想要更快的(商业)实现,我建议使用英特尔数学库。对于 FFTW,使用 FFTW_Measure 标志执行计划将为您的特定硬件测量和测试最快的 FFT 例程。我在这个问题。

对于 GPU 实现,没有比 NVidia CUDA 提供的更好的了。自从我在 7800GTX 上进行实验以来,GPU 的性能显着提高,因此我建议您尝试使用他们的 SDK 来满足您的特定要求。

Having developed FFT routines both on x86 hardware and GPUs (prior to CUDA, 7800 GTX Hardware) I found from my own results that with smaller sizes of FFT (below 2^13) that the CPU was faster. Above these sizes the GPU was faster. For instance, a 2^16 sized FFT computed an 2-4x more quickly on the GPU than the equivalent transform on the CPU. See a table of times below (All times are in seconds, comparing a 3GHz Pentium 4 vs. 7800GTX. This work was done back in 2005 so old hardware and as I said, non CUDA. Newer libraries may show larger improvements)

N       FFTw (s)    GPUFFT (s)  GPUFFT MFLOPS   GPUFFT Speedup
8       0           0.00006     3.352705        0.006881
16      0.000001    0.000065    7.882117        0.010217
32      0.000001    0.000075    17.10887        0.014695
64      0.000002    0.000085    36.080118       0.026744
128     0.000004    0.000093    76.724324       0.040122
256     0.000007    0.000107    153.739856      0.066754
512     0.000015    0.000115    320.200892      0.134614
1024    0.000034    0.000125    657.735381      0.270512
2048    0.000076    0.000156    1155.151507     0.484331
4096    0.000173    0.000215    1834.212989     0.804558
8192    0.000483    0.00032     2664.042421     1.510011
16384   0.001363    0.000605    3035.4551       2.255411
32768   0.003168    0.00114     3450.455808     2.780041
65536   0.008694    0.002464    3404.628083     3.528726
131072  0.015363    0.005027    3545.850483     3.05604
262144  0.033223    0.012513    3016.885246     2.655183
524288  0.072918    0.025879    3079.443664     2.817667
1048576 0.173043    0.076537    2192.056517     2.260904
2097152 0.331553    0.157427    2238.01491      2.106081
4194304 0.801544    0.430518    1715.573229     1.861814

As suggested by other posters the transfer of data to/from the GPU is the hit you take. Smaller FFTs can be performed on the CPU, some implementations/sizes entirely in the cache. This makes the CPU the best choice for small FFTs (below ~1024 points). If on the other hand you need to perform large batches of work on data with minimal moves to/from the GPU then the GPU will beat the CPU hands down.

I would suggest using FFTW if you want a fast FFT implementation, or the Intel Math Library if you want an even faster (commercial) implementation. For FFTW, performing plans using the FFTW_Measure flag will measure and test the fastest possible FFT routine for your specific hardware. I go into detail about this in this question.

For GPU implementations you can't get better than the one provided by NVidia CUDA. The performance of GPUs has increased significantly since I did my experiments on a 7800GTX so I would suggest giving their SDK a go for your specific requirement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文