GPU-accelerated array computations in Haskell

I just published stable release 0.12 of the embedded array language Accelerate for high-performance GPU computing on Hackage. The release includes example applications, such as a real-time Canny edge detector, a fluid flow simulator, and a quasicrystal animation, as well as example algorithms, such as radixsort, matrix computations, and a Black-Scholes option pricing model.

In the new modularised architecture, the Accelerate release comprises four packages:

  • accelerate (the main package providing the Accelerate language),
  • accelerate-io (conversion operations with other Haskell array libraries, including the data-parallel companion library Repa),
  • accelerate-cuda (backend targetting NVIDIA GPUs via the CUDA SDK), and
  • accelerate-examples (example applications and regression tests).

For more information, see Accelerate on GitHub. To use the CUDA backend, you need a CUDA-enabled NVIDIA GPU as well as having the CUDA SDK already installed.

Filed under  //  accelerate   gpgpu   haskell   parallelism  
Posted

Using the Glasgow Haskell Compiler (GHC) on OS X Lion with Xcode 4.3

Here is what you need to do if you want to use the Glasgow Haskell Compiler (GHC) on OS X Lion with a clean installation of Xcode 4.3.

Command line tools

You need to install the command line tools from Apple. You may do that in two ways (the second is faster as it is a much smaller download):

  1. Install all of Xcode:
    • Install Xcode from the Mac App Store.
    • Launch Xcode.
    • In the Preferences dialog of Xcode, select the "Downloads" pane and install "Command line tools".
  2. Install the command line tools only:

In both cases, you need to register as an Apple developer. (This is a free registration.)

Install GHC 7.4.1 (or later)

Older versions of GHC —including GHC 7.0.4, which is part of the Haskell Platform 2011.4.0.0 (December 2011)— won't work. They complain about not being able to execute '/Developer/usr/bin/gcc'. (You can fix this by modifying GHC's wrapper script as mentioned in the comments.)

Download and install GHC 7.4.1 (or a later version) — or install the Haskell Platform once a 2012 release has been made.

Install Cabal tools (optional)

To facilitate the easy installation of Haskell packages, you should get the cabal-install tool.

  • Download cabal-install-0.14.0.tar.gz
  • Unpack the tarball and, inside the created 'cabal-install-0.14.0' directory, run the following: 'sh bootstrap.sh'

Update: As @zmoazeni points out in the comments, Homebrew has now been updated, so that you can install both GHC and cabal-install version 0.14 by executing

brew install ghc --devel
brew install cabal-install

Using GHC's LLVM backend (optional)

If you like to use GHC's LLVM backend —which is more efficient for array-based and other loop-oriented code— you need to seperately install LLVM. (This is despite the Apple tools being based on LLVM as well.)

  • Install Homebrew (as per the instructions on that webpage).
  • Then, execute the following: 'brew install llvm'

Compiling GHC from the sources in the Git repositories (GHC developers only)

If you plan to work on GHC itself and you need to compile the develeopment version of GHC straight from the Git repositories, you need to install the GNU auto tools as well (which are no longer distributed by Apple).

  • Install Homebrew (as per the instructions on that webpage) — if you didn't do that already to install LLVM above.
  • Then, execute the following: 'brew install autoconf automake'

The GHC Trac has more information on Building and Porting GHC.

Filed under  //  ghc   haskell   lion   mac  
Posted

GPU computing in Haskell: version 0.10 of Data.Array.Accelerate

Accelerate is an embedded language for GPU-accelerated array computations in Haskell that targets NVIDIA's CUDA framework and also has an experimental OpenCL backend (that currently does not support the whole feature set of the language). I just released version 0.10.0.0 of Accelerate. A considerable amount of example code is in the companion package accelerate-examples. The main user-visible changes in this release are frontend bug fixes.

For more information, have a look at Accelerate on GitHub.

Filed under  //  accelerate   gpgpu   haskell  
Posted

Work Efficient Higher-Order Vectorisation

Our new draft paper on Work Efficient Higher-Order Vectorisation introduces a novel representation for nested, irregular parallel arrays that enables the work-efficient SIMD-ification of nested data parallelism — i.e., nested parallelism is transformed into flat parallelism, while maintaining the work complexity of a naive pointer-based representation of nested arrays. This solves a long standing problem that dates back to the original implementation of the language NESL.

Filed under  //  dph   haskell   parallelism   vectorisation  
Posted

Video and slides of "Data Parallelism in Haskell" @ Brisbane FP Group

The Brisbane FP Group (BFPG) kindly invited me to give a talk about our work on data parallel programming in Haskell. The talk motivates the use of functional programming for parallel, and in particular, data parallel programming and explains the difference between regular and irregular (or nested) data parallelism. It also discusses the Repa library (regular data parallelism for multicore CPUs), the embedded language Accelerate (regular data parallelism for GPUs), and Data Parallel Haskell (nested data parallelism for multicore CPUs).  The slides of the presentation are available in two formats: HTML5 slideshow and PDF. Thank you to everybody who attended. Special thanks go to OJ Reeves and Tony Morris for organising everything, to Rob Manthey for producing the video, to Mincom for the venue, and to Functional IO for the sponsorship.

Filed under  //  accelerate   dph   haskell   parallelism   repa  
Posted

Data.Array.Accelerate now on GitHub

Prompted by GHC's move to Git and the unreliability of the community.haskell.org infrastructure, I decided to move Data.Array.Accelerate to GitHub: mchakravarty/accelerate. The GitHub repository is now the main public repository for the project. I will also move the tickets of the old Trac bug tracker over to GitHub Issues.

Filed under  //  edsl   gpgpu   haskell   parallelism  
Posted

Final version of the Accelerate paper (GPGPU in Haskell)

We will present our paper Accelerating Haskell Array Codes with Multicore GPUs at ACM SIGLAN Declarative Aspects of Multicore Programming (DAMP 2011), which is co-located with POPL'11 in Austin, TX, in January. The final version of our paper is now available, and we plan to soon release a significantly improved version of the Accelerate library (matching the API used in the paper), which enables high-level GPGPU programming in Haskell based on NVIDIA's CUDA environment.

Filed under  //  edsl   gpgpu   haskell   parallelism  
Posted

Quickly searching Hackage and Hoogle on Mac OS X

Haskellers on Macs should check out Alfred App.  It's a launcher application that also does web searches and a few other things.  In particular, it enables you to define custom searches that you can quickly access with a hot key from wherever you are.  I am using the two following custom searches to quickly search through Hackage and Hoogle:

The strings "hackage" and "hoogle" are the keywords, followed by the query strings.

Filed under  //  alfredapp   haskell   mac  
Posted

Accelerating Haskell Array Codes with Multicore GPUs

In the paper Accelerating Haskell Array Codes with Multicore GPUs, we describe Accelerate, embedded language for array computations in Haskell, as well as a dynamic code generator targeting NVIDIA's CUDA GPGPU programming environment.  Our CUDA code generator is based on the idea of algorithmic skeletons for parallel programming, minimises re-compilation overheads, and overlaps host-to-device data transfers, code generation, and kernel execution.

The paper outlines our embedding in Haskell, details the design and implementation of the dynamic code generator, and reports on initial benchmark results.  These results indicate that we can compete with moderately optimised native CUDA code, while enabling much simpler source programs.

Filed under  //  edsl   gpgpu   haskell   parallelism  
Posted

Second beta release for the CUDA backend of Accelerate

The second beta release of Data.Array.Accelerate (version 0.8.0.0) includes support for all array operations in the CUDA backend — except for a new stencil operation that is new in this release and currently only supported by the interpreter.  The CUDA backend requires CUDA 3.x and has been tested on consumer-grade GeForce cards, TESLA high-performance GPUs, and the new Fermi cards.

If you are interested in general-purpose GPU programming in Haskell, give this release a spin — it is available on Hackage.  While it is far from perfect, it should already prove useful for a considerable range of applications.  Together with the other Accelerate developers, I would be very interested to hear what works for you and what doesn't.  We are also interested in suggestions for the future development of the library.  Accelerate has a mailing list and a bug tracker on which we also accept feature requests.

Filed under  //  edsl   gpgpu   haskell   parallelism  
Posted