June 2019
Intermediate to advanced
218 pages
5h 19m
English
The Julia CUDA packages allow the programmer to create their own low-level kernels for the GPU, where you write code to manually handle the parallelism. This is something unique in Julia—the ability to use a high-level language to write these kernels. Previously, CUDA C++ was pretty much the only option to implement your own kernel.
As an example, consider a simple function that adds two vectors in place. A kernel can be written as follows:
function add_gpu!(y, x) index = threadIdx().x stride = blockDim().x for i = index:stride:length(y) @inbounds y[i] += x[i] end return nothing end
This is fairly low-level code, but is still recognizably Julia, while the semantics would be familiar to anyone who has written ...
Read now
Unlock full access