0
$\begingroup$

I'm reading through CUDAlink's documentation, but I can't quite understand if with I'll boost my code, that I've already written, or if I'll need to rewrite my code in C to take advantage of CUDA's functions.

Ideally CUDA would be enabled and Mathematica's base functions would use CUDA methods to execute them, instead of CPU.

$\endgroup$
  • 1
    $\begingroup$ You need to use CUDA*[] functions explicitly in your code to be able to exploit your GPU. The built-in functions do not automagically detect if you want to use a GPU. $\endgroup$ – J. M. will be back soon Nov 8 '17 at 14:37
  • $\begingroup$ Thanks. But as far as I can tell, I can use CUDAFunctionLoad[] to load a function I write in C, which can be anything, right? $\endgroup$ – A. Vieira Nov 8 '17 at 15:05
  • 2
    $\begingroup$ Yes and no. You have to write C code which is well-adapted to CUDA. If you have no idea about CUDA, if you cannot push your whole project onto the GPU because there are parts that cannot be parallelized, or if you require double precision and don't have a high-end GPGPU, it is most likely not worth the effort. And even if these requirements are met: It's most likely not worth the effort. It is more likely that you will obtain the same speed-up with a thorough refactorization of your existing code. $\endgroup$ – Henrik Schumacher Nov 8 '17 at 15:52
  • $\begingroup$ That's what I thought. Thanks. I know what CUDA is and maybe it will be worthwhile some day, but for now Parallelize[] and ParallelizeDo[] plus a multi-core will do the job. $\endgroup$ – A. Vieira Nov 8 '17 at 16:50
  • $\begingroup$ Usually CUDA helps when you have large matricies that need a lot of processing. Even better you have little matrices on the RAM and many lengthy calcuations possible on the GPU. The reason is the memory reading time. If you have to calculate e.g. a determinat CUDA would be rather slow. Usually re-thinking the code and partically Compile and parallelize it in Mathematica would give speed ups. With GPU would certainly need to add own functions to the once Mathematica provides. This also works but additional knowledge and effort is needed. $\endgroup$ – Eisbär Nov 10 '17 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.