Re:Compiling Julia for NVIDIA GPUs
by unfamiliar on Tuesday February 03, 2015 @02:46PM
(#8992801)
Since I only have one GPU usually, I'm still waiting for the day I can do this:
i.e. no set up, no "cuda context" (whatever that is), and no tear down afterwards. I understand that manual memory management is almost necessary with this application, but it seems that most of it could be automated in the most common case of "I have a couple of large arrays and a few operations I want to perform."
[ Parent
| on HN ]
Writing backend agnostic code (CPU and GPU) jitted to fast LLVM is on the roadmap for python's Numba: https://github.com/numba/numba/issues/545
Currently supports both including multithreading. Its just he unified interface that is in the works.
You can do that in Mathematica. http://www.wolfram.com/products/cuda-opencl-programming-math...
Torch7 has amazing GPU support. If you wanna send a tensor (array) to the GPU, you just type array:cuda(). All operations you do from now on will be on the GPU.
More involved example using a neural network: http://code.cogbits.com/wiki/doku.php?id=tutorial_cuda
I have seen a couple of Clojure based GPU compilers, although they seemed to be sort of proof-of-concepts, and I'm not sure how general purpose they were. It would be nice to possibly get out of the mode of it being a whole other computer and compiler, but maybe that distinction is for the best for the time being.
Instead of @kernel and @cuda, you might want to use defkernel and with-cuda... See the example files for cl-cuda:
https://github.com/takagi/cl-cuda/blob/master/examples/vecto...
I though that Julia had macros, so I don't understand why what you propose is not possible (note to self: find time to learn Julia).
It is definitely possible to do that in Julia. The reason a didn't yet is purely a manner of priorities, I first focused on wrapping the basic primitives (calling a kernel, marshalling arguments, etc) in a user-friendly way.
Have you tried thrust? For a limited but very useful set of operations, it is nearly that painless, as long as you don't mind a generous helping of C++ template boilerplate.
For single GPU stuff, I find myself writing the performance critical kernels in cuda, and using thrust for nearly all the easy stuff.