Complex math on GPU v CPU

3 views (last 30 days)
Rodrigo
Rodrigo on 23 Sep 2012
I am using complex step derivatives to compute gradients of an otherwise real and analytic function, but I get different answers when running the exact same code on the GPU as on the CPU. Most differences are small (<.1%), but some can be off by more than a factor of 2. All GPU computations are done using double precision on a GTX 580 running 2012a.
When I use John D'Errico's DERIVEST to compute the same thing using real finite differences (awesome program by the way) CPU and GPU produce pretty much identical answers. Is there some subtle difference in the way the GPU handles complex numbers that would cause this?
Thanks, Rodrigo

Answers (1)

Andy
Andy on 24 Sep 2012
hello Rodrigo,
first, thanks for trying the MathWorks GPU offering.
the GPU math library has been written to give results as close to the CPU as reasonably possible. most functions and arithmetic operators are off only a couple ulps. your comments/questions are somewhat surprising. would you mind posting some more details such as example code with inputs? also what OS are you using to run CPU MATLAB?
thanks,
Andy
.
  2 Comments
Rodrigo
Rodrigo on 24 Sep 2012
I can post the code, but it operates on image stacks that are several GB in size, so that would be a problem. More generally, the code tries to simulate the shadow of an object that is spinning. This requires finding distances and evaluating spline fits. So each result averages over millions of pixel values, uses sqrt's where the argument can have a small imaginary part (for the CSD), runs an gpu adapted version of ppval, and does a lot of trivial arithmetic. Could accumulated round-off from the millions of averaged pixels really be that bad?
Rodrigo
Rodrigo on 24 Sep 2012
Both versions run on the same machine, which runs 64bit Ubuntu 12.04

Sign in to comment.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!