Type-safe Runtime Code Generation: Accelerate to LLVM
Indiana University Bloomington
Indiana University Bloomington, 2015
@article{mcdonell2015type,
title={Type-safe Runtime Code Generation: Accelerate to LLVM},
author={McDonell, Trevor L and Chakravarty, Manuel MT and Grover, Vinod and Newton, Ryan R},
year={2015}
}
Embedded languages are often compiled at application runtime; thus, embedded compile-time errors become application runtime errors. We argue that advanced type system features, such as GADTs and type families, play a crucial role in minimising such runtime errors. Specifically, a rigorous type discipline reduces runtime errors due to bugs in both embedded language applications and the implementation of the embedded language compiler itself. In this paper, we focus on the safety guarantees achieved by type preserving compilation. We discuss the compilation pipeline of Accelerate, a high-performance array language targeting both multicore CPUs and GPUs, where we are able to preserve types from the source language down to a low-level register language in SSA form. Specifically, we demonstrate the practicability of our approach by creating a new type-safe interface to the industrial-strength LLVM compiler infrastructure, which we used to build two new Accelerate backends that show competitive runtimes on a set of benchmarks across both CPUs and GPUs.
June 14, 2015 by hgpu