提问人:JLo 提问时间:2/5/2020 最后编辑:CommunityJLo 更新时间:2/6/2020 访问量:1100
Vulkan 浮点行为问题
problem with vulkan floating point behavior
问:
我尝试实现论文 Extended-Precision Floating-Point Numbers 阿尔玛学院的 Andrew Thall 在 GLSL Vulkan 计算着色器中进行的 GPU 计算。 我需要这个,因为我的某些设备不支持双精度。
我的问题出在quickTwoSum函数中
vec2 quickTwoSum( float a , float b) {
float s = a + b;
float t = s - a;
float e = b - t;
return vec2(s, e);
}
例如
a = 114251.609
b = -0.00107500004
然后发生这种情况
s = 114251.609 // this is correct because b is to small
t = -0.00107500004 // <= why? (s - a) should be 0
e = 0.0 // <= this is wrong because t is wrong
为什么 t 不正确?GPU 在后台的存储似乎比 32 位浮点变量实际可以容纳的更精确。
是GPU问题吗?我使用的是 NVIDIA GeForce GT 750M。 在我的 CPU 上,这应该如何工作。
我找到了为 OpenGL https://www.thasler.com/blog/blog/glsl-part2-emu 实现它的人。因此,它也应该在 GPU 上运行。
如果有人能帮助我就好了。
更新:
这是我的程序文件
cbc.com:GLSL 着色器
glsl_compiler_output.txt:glslangValidator 的输出
cbc_comp.spv:编译为 SPIR-V 的着色器
main.cpp:是一个曼德布洛特 Vulkan 计算示例,我根据需要进行了更改
vulkantest_output.txt:我的程序的输出
答: 暂无答案
评论