cblas_dgemm - 仅当(beta)是二的幂时才有效
我完全被难住了。我有一个用 c 编写的相当大的递归程序,它调用 cblas_dgemm()。结果由正确运行的程序独立验证。
C = alpha*A*B + beta*C
在使用随机矩阵和所有可能的参数组合进行重复测试时,只有当 abs(beta) = 2^n (1,2,4,8..) 时,程序才会给出正确答案。任何值都适用于 alpha。任何其他正/负、奇/偶的 beta 值在 10-30% 的时间内给出正确的黑白答案。
我使用的是Ubuntu 10.04,GCC 4.4.x,我尝试过系统安装blas/cblas/atlas以及手动编译的atlas。
任何提示或建议将不胜感激。我对潜伏在这个网站上的非常慷慨(而且聪明)的人们感到惊讶。
预先感谢大家,
拉斯
I am totally stumped. I have a fairly large recursive program written in c that calls cblas_dgemm(). The result is verified independently by a program that works correctly.
C = alpha*A*B + beta*C
On repeated tests using random matrices and all possible combination of parameters the program gives correct answer ONLY if abs(beta) = 2^n (1,2,4,8..). Any value works for alpha. Any other positive/negative, odd/even value for beta gives correct answer b/w 10-30% of the time.
I am using Ubuntu 10.04, GCC 4.4.x, I have tried system installed blas/cblas/atlas as well as manually compiled atlas.
Any hints or suggestions would be greatly appreciated. I am amazed at the wonderfully generous (and smart) folks lurking at this site.
Thanking you all in advance,
Russ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两个完全不相关的错误共同产生了一幅虚幻的画面。这让我在错误的地方寻找问题。
(1) 调用 dgemm 的函数逻辑存在简单错误。如果我没有追寻错误的问题,本来很容易解决。
(2)我的双重比较函数:AlmostEqual2sComplement()的双重版本(http: //www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm)使用了错误大小的整数 - 在某些罕见的情况下导致错误的 TRUE。这是我第一次被这个错误咬到!
再次感谢您在尝试调试程序时使用科学方法的有用建议。
拉斯
Two completely unrelated errors conspired to produce an illusive picture. It made me look for problems in the wrong place.
(1) There was a simple error in the logic of the function calling dgemm. Would have been easily fixed if I was not chasing the wrong problem.
(2) My double-compare function: double version of AlmostEqual2sComplement() (http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm) used incorrect sized integer - resulting in an incorrect TRUE under certain rare circumstances. This was the first time the error bit me!
Thanks again for the useful suggestion of using the scientific method when trying to debug a program.
Russ
是的,一个完整的例子会很方便。这是我使用 GSL 的 sgemm 变体的一个旧示例;应该很容易修复为 double 。请尝试看看这是否给出了 GSL 手册中显示的结果:
Yes, a full example would be handy. Here is an old example I had hanging around using GSL's
sgemm
variant; should be easy to fix todouble
. Please try and see if this gives the result shown in the GSL manual: