Developer's Guide

tmcdonell edited this page Oct 21, 2014 · 5 revisions

TODO: developer's guide to hacking

Compiler Pipeline

  • Brief overview of what happens when you call "run"
  • Introduce the main steps and associated modules
    1. Conversion from HOAS -> de Bruijn. HOAS representation is defined in D.A.A.Smart.hs. Conversion happens in tandem with sharing recovery, implemented in D.A.A.Trafo.Sharing. The internal de Bruijn representation is defined in D.A.A.AST.
    2. Optimisation of the AST. Primarily this involves array fusion in D.A.A.Trafo.Fusion, and some scalar simplifications in D.A.A.Trafo.Simplify.
    3. The AST is then passed to each backend. In the CUDA backend, code generation and compilation is initiated for each node, via D.A.A.CUDA.Compile and D.A.A.CUDA.CodeGen. The AST is annotated with the compilation results. At the same time, we transfer input arrays to the GPU. Memory management is handled via finalisers defined in D.A.A.CUDA.Array.Table.
    4. The program is executed via D.A.A.CUDA.Execute. Concurrent execution is handled via D.A.A.CUDA.Execute.Stream and D.A.A.CUDA.Execute.Event.


  • D.A.A.Array.Sugar: surface (Elt, Array, Arrays) vs. representation (EltRepr, ArrRepr, ArrayData).
  • D.A.A.Type: reified dictionaries


  • D.A.A.Smart: Source representation: Exp and Acc types, stratified scalar vs. collective operations
  • D.A.A.AST: internal representation, explicit environments; use of representation types.


  • class instance reification
  • marshalling data (weak hash tables)
  • Traversing the AST, adding information to nodes using the knot-tying trick.