11.6. Futhark

11.6.1. Futhark backends and GPU devices

Futhark kernels are the first structured consumer of build parameters. Two keys are recognized:

  • backend — the Futhark compilation backend: one of c (the default, sequential CPU), multicore (parallel CPU), opencl, cuda, hip, or ispc. The GPU backends (opencl, cuda, hip) are what make Futhark run on a GPU.

  • device — which device to run on, for a GPU backend, using Futhark’s device selector syntax (#0, #1, …​). It is only valid together with a GPU backend.

# build the Futhark kernels for CUDA and run on the second GPU
morloc make -X futhark:backend=cuda -X futhark:device=#1 -o nexus main.loc

A GPU build runs on the single selected device, and calls into the Futhark context are serialized. The required GPU runtime libraries (for example -lcuda -lnvrtc for CUDA) are linked automatically; if your toolchain lives in a non-standard location, add the paths with the C++ escape hatch, e.g. -X cpp:flags=-L/usr/local/cuda/lib64.