开发者

CUDA Floating Point Compare

I was wondering if anybody has a good implementation of floating point/ double comparison for CUDA. I'd like to use something (semi) standard, instead of writing my own. I couldn't find something standard, or endorsed by CUDA. But here are some g开发者_StackOverflow中文版ood resources on the topic:

http://developer.download.nvidia.com/assets/NVIDIA-CUDA-Floating-Point.pdf

http://www.mrupp.info/Data/2007floatingcomp.pdf

something with following header, optimized for running on CUDA // Usable AlmostEqual function bool fcmp(double a, double b)

cheers, Ashkan


There are several ways to compare floating point numbers. You can look at the absolute difference between the numbers. You can look at the relative difference between the numbers, taking the absolute difference divided by whichever number is the reference. You can look at bitwise equality of the floating point representations.

Without knowing why you're comparing two numbers it's hard to say which is best for you. There is no official CUDA-endorsed way to compare floating point numbers, other than the == operator which is defined by IEEE-754.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜