I am happy to announce that after about two years of work, I have made the code for Harlan available to the public.

https://github.com/eholk/harlan

Harlan is a new programming language for GPU computing. Harlan aims to push the expressiveness of languages available for the GPU further than has been done before. Harlan already has native support for rich data structures, including trees and ragged arrays. Very soon the language will support higher order procedures.

To give an example of the look and feel of a Harlan program, below is a simple N-Body Simulation program.

(module

(extern nanotime () -> u64)

(define-datatype point3_t
(point3 float float float))

(define (make-points N)
(kernel ((i (iota N)))
(point3 (int->float i)
(int->float i)
(int->float i))))

(define (point-diff x y)
(match x
((point3 a b c)
(match y
((point3 d e f)
(point3 (- a d) (- b e) (- c f)))))))

(match x
((point3 a b c)
(match y
((point3 x y z)
(point3 (+ a x) (+ b y) (+ c z)))))))

(define (point-div a y)
(match a
((point3 a b c)
(point3 (/ a y) (/ b y) (/ c y)))))

(define (point-mag p)
(match p
((point3 a b c)
(sqrt (+ (* a a) (+ (* b b) (* c c)))))))

(define (nbody bodies)
(kernel ((i bodies))
(kernel ((j bodies))
(let* ((diff (point-diff i j))
(d (point-mag diff)))
(if (< 0 d)
(point-div diff (* (* d d) d))
(point3 0 0 0)))))))

(define (main)
(let* ((bodies (make-points 1000))
(start (nanotime))
(forces (nbody bodies))
(stop (nanotime)))
(print "Computed ")
(print (length forces))
(print " forces in ")
(print (/ (- stop start) 1000000))
(println "ms"))
(return 0)))


The language is still research quality, but I have worked hard to keep it fairly usable. I’d encourage you to try it out and let me know how it works for you!

This is work that I’ve done with my advisor, Andrew Lumsdaine of CREST, with significant contributions from Claire Alvis, Will Byrd, Ryan Newton, and Arun Chauhan.