Abstract
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.
- T. Altenkirch and B. Reus. Monadic Presentation of Lambda Terms Using Generalised Inductive Types. In CSL ’99: Computer Science Logic, pages 453–468, 1999. Google Scholar
Digital Library
- A. W. Appel. SSA is functional programming. ACM SIGPLAN Notices, 33(4):17–20, 1998. Google Scholar
Digital Library
- R. Atkey, S. Lindley, and J. Yallop. Unembedding domain-specific languages. In Haskell Symposium, pages 37–48, 2009. Google Scholar
Digital Library
- R. D. Blumofe and C. E. Leiserson. Scheduling multithreaded computations by work stealing. Journal of the ACM, 46(5):720–748, 1999. Google Scholar
Digital Library
- B. Catanzaro, M. Garland, and K. Keutzer. Copperhead: Compiling an embedded data parallel language. In PPoPP: Principles and Practice of Parallel Programming, 2011. Google Scholar
Digital Library
- H. Chafi, Z. DeVito, A. Moors, T. Rompf, A. K. Sujeeth, P. Hanrahan, M. Odersky, and K. Olukotun. Language virtualization for heterogeneous parallel computing. In OOPSLA: Object Oriented Programming Systems & Applications, pages 835––847, 2010. Google Scholar
Digital Library
- M. M. T. Chakravarty. Converting a HOAS term GADT into a de Bruijn term GADT, 2009. URL http://www.cse.unsw.edu.au/ ~chak/haskell/term-conv/.Google Scholar
- M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Associated type synonyms. In POPL: Principles of Programming Languages, pages 241–253, 2005. Google Scholar
Digital Library
- M. M. T. Chakravarty, G. Keller, S. Lee, T. L. McDonell, and V. Grover. Accelerating Haskell array codes with multicore GPUs. In DAMP: Declarative Aspects of Multicore Programming, 2011. Google Scholar
Digital Library
- S. Chatterjee, G. E. Blelloch, and M. Zagha. Scan primitives for vector computers. In Supercomputing, pages 666–675, 1990. Google Scholar
Digital Library
- N. Chong, A. F. Donaldson, A. Lascu, and C. Lidbury. Many-Core Compiler Fuzzing. In PLDI: Programming Language Design and Implementation, 2015. Google Scholar
Digital Library
- M. I. Cole. Algorithmic Skeletons: Structured Management of Parallel Computation. The MIT Press, 1989. Google Scholar
Digital Library
- D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: from lists to streams to nothing at all. In ICFP: International Conference on Functional Programming, pages 315–326, 2007. Google Scholar
Digital Library
- R. Cryton, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451–490, 1991. Google Scholar
Digital Library
- C. Elliott. Functional Images. In The Fun of Programming. Palgrave, 2003.Google Scholar
- C. Elliott. Programming graphics processors functionally. In Haskell Symposium, 2004. Google Scholar
Digital Library
- A. Foltzer, A. Kulkarni, R. Swords, S. Sasidharan, E. Jiang, and R. Newton. A meta-scheduler for the par-monad: composable scheduling for the heterogeneous cloud. In ICFP: International Conference on Functional Programming, 2012. Google Scholar
Digital Library
- N. Geoffray, G. Thomas, J. Lawall, G. Muller, and B. Folliot. VMKit: a substrate for managed runtime environments. In Virtual Execution Environments, 2010. Google Scholar
Digital Library
- L. J. Guibas and D. K. Wyatt. Compilation and Delayed Evaluation in APL. In POPL: Principles of Programming Languages, pages 1–8, 1978. Google Scholar
Digital Library
- L.-J. Guillemette and S. Monnier. A type-preserving compiler in Haskell. In ICFP: International conference on Functional programming, pages 75–86, 2008. Google Scholar
Digital Library
- C. V. Hall, K. Hammond, S. L. Peyton Jones, and P. L. Wadler. Type classes in Haskell. ACM Transactions on Programming Languages and Systems, 18(2):109–138, 1996. Google Scholar
Digital Library
- S. Herhut, R. L. Hudson, T. Shpeisman, and J. Sreeram. River trail: a path to parallelism in JavaScript. In OOPSLA: Object Oriented Programming Systems & Applications, pages 729––744, 2013. Google Scholar
Digital Library
- G. Keller, M. M. T. Chakravarty, R. Leshchinskiy, S. Peyton Jones, and B. Lippmeier. Regular, shape-polymorphic, parallel arrays in Haskell. In ICFP: International Conference on Functional Programming, pages 261–272, 2010. Google Scholar
Digital Library
- R. A. Kelsey. A correspondence between continuation passing style and static single assignment form. In Workshop on Intermediate Representations, pages 13–22, 1995. Google Scholar
Digital Library
- G. Klein, K. Elphinstone, G. Heiser, J. Andronick, D. Cock, P. Derrin, D. Elkaduwe, K. Engelhardt, R. Kolanski, M. Norrish, T. Sewell, H. Tuch, and S. Winwood. seL4: Formal Verification of an OS Kernel. In SOSP: Symposium on Operating Systems Principles, pages 207– 220. ACM, 2009. Google Scholar
Digital Library
- C. Lattner and V. Adve. Architecture for a Next-Generation GCC. In GCC Developers’ Summit, 2003.Google Scholar
- X. Leroy. Formal verification of a realistic compiler. Communications of the ACM, 52(7):107, 2009. Google Scholar
Digital Library
- B. Lippmeier, M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Guiding parallel array fusion with indexed types. In Haskell Symposium, 2012. Google Scholar
Digital Library
- W. Ma and G. Agrawal. An integer programming framework for optimizing shared memory use on GPUs. In HiPC ’10: The International Conference on High Performance Computing, pages 1–10, 2010.Google Scholar
- G. Mainland and G. Morrisett. Nikola: Embedding Compiled GPU Functions in Haskell. In Haskell Symposium, 2010. Google Scholar
Digital Library
- C. McBride. Type-Preserving Renaming and Substitution. Journal of Functional Programming, 2006.Google Scholar
- T. L. McDonell, M. M. T. Chakravarty, G. Keller, and B. Lippmeier. Optimising Purely Functional GPU Programs. In ICFP: International Conference on Functional Programming, 2013. Google Scholar
Digital Library
- G. Morrisett, D. Walker, K. Crary, and N. Glew. From System F to Typed Assembly Language. In POPL: Principles of Programming Languages, 1998. Google Scholar
Digital Library
- NVIDIA. CUDA LLVM Compiler. URL https://developer. nvidia.com/cuda-llvm-compiler.Google Scholar
- J. Peterson and M. Jones. Implementing type classes. In PLDI: Programming Language Design and Implementation, pages 227–236, 1993. Google Scholar
Digital Library
- S. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In ICFP: International Conference on Functional Programming, pages 50–61, 2006. Google Scholar
Digital Library
- M. Pharr and W. R. Mark. ispc: A SPMD compiler for highperformance CPU programming. In Innovative Parallel Computing, pages 1–13, 2012.Google Scholar
- R. Rivest. The MD5 Message-Digest Algorithm, 1992.Google Scholar
- T. Rompf, A. K. Sujeeth, N. Amin, K. J. Brown, V. Jovanovic, H. Lee, M. Jonnalagedda, K. Olukotun, and M. Odersky. Optimizing data structures in high-level programs: new directions for extensible compilers based on staging. In POPL: Principles of Programming Languages, 2013. Google Scholar
Digital Library
- T. Rompf, A. K. Sujeeth, K. J. Brown, H. Lee, H. Chafi, and K. Olukotun. Surgical precision JIT compilers. In PLDI: Programming Language Design and Implementation, pages 41–52, 2014. Google Scholar
Digital Library
- T. Schrijvers, S. Peyton Jones, M. M. T. Chakravarty, and M. Sulzmann. Type checking with open type functions. In ICFP: International Conference on Functional Programming, pages 51–62, 2008. Google Scholar
Digital Library
- S. Sengupta, M. Harris, Y. Zhang, and J. D. Owens. Scan primitives for GPU computing. In Graphics Hardware, pages 97–106, 2007. Google Scholar
Digital Library
- B. J. Svensson and R. Newton. Programming Future Parallel Architectures with Haskell and Intel ArBB. In FASPP ’11: Future Architectural Support for Parallel Programming, pages 3–14, 2011.Google Scholar
- B. J. Svensson, M. Sheeran, and K. Claessen. Obsidian: A domain specific embedded language for parallel programming of graphics processors. In IFL: Implementation and Application of Functional Languages, 2008. Google Scholar
Digital Library
- D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: a type-directed optimizing compiler for ML. In PLDI: Programming Language Design and Implementation, pages 181–192, 1996. Google Scholar
Digital Library
- D. A. Terei and M. M. T. Chakravarty. An LLVM backend for GHC. In Haskell Symposium, pages 109–120, 2010. Google Scholar
Digital Library
- A. Tzannes, G. C. Caragea, R. Barua, and U. Vishkin. Lazy binarysplitting: a run-time adaptive work-stealing scheduler. In PPoPP: Principles and Practice of Parallel Programming, pages 179–190, 2010. Google Scholar
Digital Library
- X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in C compilers. In PLDI: Programming Language Design and Implementation, pages 283–294, 2011. Google Scholar
Digital Library
Index Terms
Type-safe runtime code generation: accelerate to LLVM
Recommendations
Type-safe runtime code generation: accelerate to LLVM
Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on HaskellEmbedded 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 ...
Accelerating Haskell array codes with multicore GPUs
DAMP '11: Proceedings of the sixth workshop on Declarative aspects of multicore programmingCurrent GPUs are massively parallel multicore processors optimised for workloads with a large degree of SIMD parallelism. Good performance requires highly idiomatic programs, whose development is work intensive and requires expert knowledge.
To raise ...
Bringing low-level languages to the JVM: efficient execution of LLVM IR on Truffle
VMIL 2016: Proceedings of the 8th International Workshop on Virtual Machines and Intermediate LanguagesAlthough the Java platform has been used as a multi-language platform, most of the low-level languages (such as C, Fortran, and C++) cannot be executed efficiently on the JVM. We propose Sulong, a system that can execute LLVM-based languages on the ...






Comments