4 ms·
While having a Torch-esque GPU ndarray is great, the ability to easily write your own kernels without having to compile gnarly C++ code is what sets Julia apart
by currymj 8y ago
While having a Torch-esque GPU ndarray is great, the ability to easily write your own kernels without having to compile gnarly C++ code is what sets Julia apart from competitors IMO. Not sure if there's any other dynamic language offering anything like this.
- pjmlp 8y ago"Parallel computations on the GPU with CUDA in Clojure" https://clojurecuda.uncomplicate.org/ https://clojurecuda.uncomplicate.org/
- imtringued 8y agoThe article is about compiling a restricted subset of Julia code to run on a GPU and accelerate your project without leaving the language. The library you linked doesn't compile clojure code to run on the GPU. It's basically just a FFI wrapper to pass C/C++ kernels to CUDA.
- pjmlp 8y agoYeah, I missed that part.
- dragandj 8y agoClojureCL and ClojureCUDA have been doing it for 4 years now. https://clojurecl.uncomplicate.org https://clojurecl.uncomplicate.org https://clojurecuda.uncomplicate.org https://clojurecuda.uncomplicate.org
- KenoFischer 8y agoAm I missing something? I was excited about other languages doing the same as Julia, but the first example for ClojureCUDA has (def kernel-source "extern \"C\" __global__ void increment (int n, float *a) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n) { a[i] = a[i] + 1.0f; } };") Is there an example where the kernel is written in Clojure?
- dragandj 8y agoYou can of course create Clojure/lisp code that would generate kernel code, but I am strongly against it as the default option, since I find plain C much better suited to small kernels close to hardware (which are only a small proportion of the overall code) than either lisp or Julia. Please note that there is no need for out-of process compilation step. You compile this by calling a Clojure function, interactively from the REPL.
- KenoFischer 8y agoSure, but that's a completely separate thing from what Julia is doing here. The whole point of the GPU backend is that you get almost the full flexibility of the Julia language at your disposal, without having to fall back to C code. As a result, not only is your code more familiar to Julia programmers, but you also get to share large amounts of code between CPU/GPU/TPU. If all you're doing is super small kernels that may not matter much, but GPUs are so powerful these days that it's perfectly sensible to offload rather large programs that you may not want to write in C anymore.
- byt143 8y agoAlso that exact C example can be written almost verbatim in Julia, so C isn't "better suited" for even these small kernels, because one can drop to low level with even clearer syntax in julia
- 3rdAccount 8y agoIt's not just easier to read for Julia programmers. Any pythonista can mostly read Julia without significant issue. They're both high level and syntactically similar enough. I know Python is a lot more OO, but when you're just writing a short script it looks a lot like Julia if Julia didn't need you to specify types.
- schmudde 8y agoClojureCL has already been mentioned, but I found the author's interview on the Defn podcast particularly enlightening: https://soundcloud.com/defn-771544745/defn-24-v3 https://soundcloud.com/defn-771544745/defn-24-v3