MATLAB and Simulink results are different (GPU Coder)

7 views (last 30 days)
Hello all,
For my project I had integrated GPU coder into simulink for evaluvating State space equation and I got the output.
Also using the function in MATLAB, I got the results.
While comparing both the results, the difference should be 0, but I am getting the difference in output as 1e-13(approx.)
So can anyone please explain me why there is difference in the results???
Thanks in advance !!!

Accepted Answer

Walter Roberson
Walter Roberson on 6 Sep 2020
You should not expect the exact same results between CPU and GPU for floating point arithmetic.
CPU and GPU have different instruction sets. When you compile for GPU, the order of operations can be different than for CPU, including because of differences in the optimization capabilities of the different compilers. For efficiency, a number of operations on GPU use vendor high-performance libraries, which use different implementations than the high-performance libraries used for CPU. Whether the high performance libraries are even invoked on CPU depends on the problem size (there is a cost to starting up those library calls, so MATLAB does the calculations more directly for smaller calculations.)

More Answers (0)

Categories

Find more on Get Started with GPU Coder in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!