Using Futhark makes it easier to program for GPUs that speed up machine learning and other math-intensive apps

Researchers at the University of Copenhagen’s Department of Computer Science recently unveiled Futhark, an open source functional programming language designed for creating code that runs on GPUs, for use in machine learning and other high-performance applications.

The researchers said that Futhark is meant to be more convenient to use than standard C/C++ frameworks for programming GPUs. The primary feature of Futhark is that it can automatically generate both C and Python code to be integrated with existing apps. Futhark is written in Haskell.

As of today, most GPU programming involves using frameworks like OpenCL or CUDA, both of which use variations of C or C++ to generate code that runs on the GPU. Instead of using any framework, Futhark can generate C code, but is its own language, more similar to Haskell or Standard ML than C.

Futhark’s creators claim that the expressiveness of the language makes it easier to describe complex operations that use parallelism. This includes the ability to support nested parallelizations (parallel operations inside other parallel operations). Futhark can do this “despite the complexities of efficiently mapping to the flat parallelism supported by hardware, as a great many programs depend on this feature.”

The researchers claims are not unfounded. Preliminary benchmarks pitting Futhark GPU programs against other GPU libraries showed promising results. For a maximum segment sum test, Futhark was nearly twice as fast as a competing open source project. In other cases, it matched or was only slightly slower than the competition. Futhark’s developers attributed this to the newness of the language and its unrefined approach to allocating and reusing memory.

The current Futhark toolchain can generate code capable of running on either the CPU or GPU, with a variety of targets. For the former, it generates C code compiled by the GCC; for the latter, it generates C code that uses the OpenCL platform. Thus, the same code run on whatever hardware is available to support it, in much the same manner GPU-accelerated apps like the MapD database can fall back to using the CPU if needed.

Python users who want a speed boost can generate code with Futhark wrapped automatically in a Python module. The GPU code runs via PyOpenCL, which is a library for interfacing with GPUs. There are examples of this, such as a Futhark-driven GPU implementation of Conway’s Game of Life.

Futhark is still a work in progress and the developers have put the code on GitHub for other researchers and developers.

LEAVE A REPLY

Please enter your comment!
Please enter your name here