OpenCL-backed GPU Arrays
Author JuliaGPU
58 Stars
Updated Last
2 Years Ago
Started In
September 2017


Build status:

Implementation of the abstract GPU Array Interface

CLArray uses Transpiler.jl to compile Julia functions for the GPU using OpenCL.

It implements the full abstract gpu interface from GPUArrays, and most interactions will be through those functions. To learn how to use it, please refer to the GPUArray documentation:

CLArrays includes several other OpenCL-specific functions:

  • CLArrays.devices() returns a list of the OpenCL compute devices (CPU and GPU) available on the system.
  • CLArrays.init( will set the given device to be the active device. If you do not initialize a device explicitly, a default device will be chosen automatically, prioritizing GPU devices over CPU devices.
  • is_gpu( returns true if the given device is a GPU.
  • is_cpu( returns true if the given device is a CPU.
  • gpu_call(kernel::Function, A::GPUArray, args::Tuple, configuration = length(A)) calls the given function on the GPU. See the function documentation for more details.


using CLArrays

for dev in CLArrays.devices()
    x = zeros(CLArray{Float32}, 5, 5) # create a CLArray on device `dev`

# you can also filter with is_gpu, is_cpu
gpu_devices = CLArrays.devices(is_gpu)

Note that CLArrays.jl does not handle installing OpenCL drivers for your machine. You will need to make sure you have the appropriate drivers installed for your hardware.

Install OpenCL drivers for intel graphics in Linux

cd $HOME
git clone
cd $HOME/beignet
sudo apt-get install cmake pkg-config python ocl-icd-dev libegl1-mesa-dev ocl-icd-opencl-dev libdrm-dev libxfixes-dev libxext-dev llvm-3.6-dev clang-3.6 libclang-3.6-dev libtinfo-dev libedit-dev zlib1g-devD
mkdir build; cd build; cmake ..
make utest; . utests/; utests/utest_run
sudo make install