在图形硬件上浮动vs双倍 [英] float vs double on graphics hardware

查看:173
本文介绍了在图形硬件上浮动vs双倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找到在图形硬件上使用float vs double的性能的信息。我已经找到了很多有关浮点数和CPU数的双重信息,但是这些信息对于GPU来说更为稀缺。



我使用OpenGL进行编码,所以如果有任何特定的信息那你觉得应该知道的API,让我们来看看。



据我所知,如果程序正在向图形硬件移动大量数据,可能会更好地使用浮动因为双打需要两倍的带宽。我的查询更多的是如何处理图形硬件。据我了解,现代英特尔CPU将float / double转换为80位实数进行计算(不包括SSE指令),因此这两种类型的处理速度大致相同。现代显卡是否可以做这样的事情?是现在浮动和双重表现?有什么强有力的理由使用其中一个吗?

解决方案

在速度方面,GPU对于浮点数进行了优化。我对Nvidia硬件更为熟悉,但在当代硬件中,每8个SP FPU就有1个DP FPU。在下一代硬件中,他们预计会有更多的1比2的比例。

我的建议是查看您的算法是否需要双精度。许多算法并不需要额外的位。运行一些测试来确定你得到的单精度的平均误差,并确定它是否有效。如果不是,只使用单个。

如果您的算法纯粹用于图形,则可能不需要双精度。如果您正在进行通用计算,请考虑使用OpenCL或CUDA。


I've been trying to find info on performance of using float vs double on graphics hardware. I've found plenty of info on float vs double on CPUs, but such info is more scarce for GPUs.

I code with OpenGL, so if there's any info specific to that API that you feel should be known, let's have at it.

I understand that if the program is moving a lot of data to/from the graphics hardware, then it would probably be better to use floats as doubles would require twice the bandwidth. My inquiries are more towards how the graphics hardware does it's processing. As I understand it, modern Intel CPUs convert float/double to an 80-bit real for calculations (SSE instructions excluded) and both types are thus about equally fast. Do modern graphics cards do any such thing? is float and double performance about equal now? Are there any strong reasons to use one over the other?

解决方案

In terms of speed, GPUs are optimized for floats. I'm much more familiar with Nvidia hardware, but in current generation hardware, there is 1 DP FPU for every 8 SP FPU. In next generation hardware, they're expected to have more of a 1 to 2 ratio instead.

My recommendation would be to see if your algorithm needs double precision. Many algorithms don't really need the extra bits. Run some tests to determine the average error that you get by going to single precision and figure out if it's significant. If not, just use single.

If your algorithm is purely for graphics, you probably don't need double precision. If you are doing general purpose computation, consider using OpenCL or CUDA.

这篇关于在图形硬件上浮动vs双倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆