CUDA 中 exp() expf() 和 __expf() 之间的区别
如何优化CUDA中的exp函数?
CUDA 中以下各项有什么区别?
exp()
expf()
__expf()
How to optimize the exp function in CUDA?
What are the differences between the following in CUDA?
exp()
expf()
__expf()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CUDA C 编程中解释了这些差异指南,附录 D。
exp()
应该用于双精度,尽管应该为单个重载expf()
应该用于单精度(float
)__expf()
是快速数学版本,性能更快,但会损失一些精度(取决于输入值,请参阅 指南了解更多详细信息)。The differences are explained in the CUDA C Programming Guide, appendix D.
exp()
should be used for double precision, although should be overloaded for singleexpf()
should be used for single precision (float
)__expf()
is the fast-math version, the performance is faster with some loss of precision (dependent on the input value, see the guide for more details).一般来说,
exp()
用于双精度数,expf()
用于浮点数,两者都比可用作硬件操作的__exp()
稍慢。性能提升通常是以牺牲准确性为代价的,但除非您真的关心准确性,否则这不应该成为问题。Generally
exp()
is for doubles,expf()
for floats and both are slightly slower than__exp()
which is available as a hardware operation. The performance gain usually comes at the cost of accuracy but unless you are really concerned about accuracy it shouldn't be a problem.