4 ms·
Not only that, but, Matlab? Seriously? I don't know the internals, but I'm fairly sure that there's going to be some switching between the CPU and GPU for Matla
by StavrosK 15y ago
Not only that, but, Matlab? Seriously? I don't know the internals, but I'm fairly sure that there's going to be some switching between the CPU and GPU for Matlab to be able to run code there.
If you want something to run fast on the GPU, you code it in a language that can run entirely on the GPU. Not Matlab.
- andrewcooke 15y agothe code i ported was originally matlab. if you can write the operations without explicit loops (using matlab's builtins) then it should be able to translate things fairly well to multiple processors. i don't know much about matlab's gpu support (when i looked, you needed third party libs - looks like that has changed?) but again, if it's standard transforms and matrix operations they should be able to make it fairly efficient. in our case the matlab code had explicit loops (in a sense i was lucky - the inner kernel operations were messy enough to need explicit coding, but regular enough to be handled efficiently on a gpu) and that's what really kills you (because you're bouncing out of optimised c code into their interpreter). just moving from matlab to c (on the cpu) also gave us a significant speedup. what i'm saying, in a slow rambling way, is that calculating a bunch of sines should be as fast in matlab as in hand-coded c or opencl (on gpu and cpu respectively). because that can be expressed as a vector operation and matlab will have invested a lot of time and effort into making that code fast.
- StavrosK 15y agoInteresting. I checked the manual after my post above and they do execute sines entirely on the GPU, however you do still need to jump in and out for most coding. It does invalidate my point for his example, though (but it doesn't invalidate any of the other points).
- melonakos 15y agoIf in MATLAB, use Jacket. It's better than what MathWorks offers, http://accelereyes.com/compare http://accelereyes.com/compare If in C, C++, Fortran, Python, use LibJacket. Learn more, http://accelereyes.com/libjacket_tour http://accelereyes.com/libjacket_tour Disclaimer: yes, i work on both of those :)
- andrewcooke 15y agoso the matlab solution ships data back and forth for each line of the code? ouch. i looked at your package back then and got the impression you mapped variables to the GPU main memory, which i agree makes more sense.