A bug in Mathematica’s CUDADot in version 8.0.1
After writing my recent article on GPU accelerated Matrix-Matrix multiplication using Maple, I thought that I’d try the same thing in Mathematica. However, I instantly hit a problem on my 64bit Windows 7 machine running version 8.0.1 of Mathematica.
In[1]:= a = RandomReal[1, {2, 2}] Out[1]= {{0.363441, 0.528656}, {0.208881, 0.510232}} In[2]:= b = RandomReal[1, {2, 2}] Out[2]= {{0.33536, 0.77615}, {0.537533, 0.788522}} In[3]:= Dot[a, b] Out[3]= {{0.406054, 0.698942}, {0.344317, 0.564452}} In[4]:= Needs["CUDALink`"] CUDADot[a, b] Out[5]= {{0.741414, 1.47509}, {0.881849, 1.35297}}
In short, CUDADot gives the wrong result for floating point numbers (on my machine at least). An upgrade to version 8.0.4 fixed the problem
That is a pretty impressive wrong answer. No resemblance to the truth. Some test suite should have caught it before release. This is not very reassuring. I certainly don’t expect to have to check Mathematica’s arithmetic. Besides, how could I, even if I wanted to? All the intermediate steps are hidden. Typically we only see the final answer.
Say, how did you manage to find that?
Ralph