[Paper Review] Strategy Preserving Compilation for Parallel Functional Code
This paper presents a formal, strategy-preserving compilation pipeline from high-level functional code to low-level data-race-free parallel imperative code using a novel dialect of Idealised Algol called Data Parallel Idealised Algol (DPIA). The approach ensures correctness and performance portability by leveraging a substructural type system to enforce data race freedom, achieving performance on par with hand-optimized OpenCL code while preserving the intended parallelization strategy from functional rewrite systems.
Graphics Processing Units (GPUs) and other parallel devices are widely available and have the potential for accelerating a wide class of algorithms. However, expert programming skills are required to achieving maximum performance. hese devices expose low-level hardware details through imperative programming interfaces where programmers explicity encode device-specific optimisation strategies. This inevitably results in non-performance-portable programs delivering suboptimal performance on other devices. Functional programming models have recently seen a renaissance in the systems community as they offer possible solutions for tackling the performance portability challenge. Recent work has shown how to automatically choose high-performance parallelisation strategies for a wide range of hardware architectures encoded in a functional representation. However, the translation of such functional representations to the imperative program expected by the hardware interface is typically performed ad hoc with no correctness guarantees and no guarantees to preserve the intended parallelisation strategy. In this paper, we present a formalised strategy-preserving translation from high-level functional code to low-level data race free parallel imperative code. This translation is formulated and proved correct within a language we call Data Parallel Idealised Algol (DPIA), a dialect of Reynolds' Idealised Algol. Performance results on GPUs and a multicore CPU show that the formalised translation process generates low-level code with performance on a par with code generated from ad hoc approaches.
Motivation & Objective
- To address the performance portability problem in parallel functional programming, where hand-optimized imperative code is required for high performance but lacks portability across devices.
- To close the gap between high-level functional abstractions and low-level imperative code generation, which currently lacks correctness guarantees and strategy preservation.
- To formalize a translation from functional code to data-race-free imperative code that preserves the intended parallelization strategy, ensuring correctness and performance portability.
- To demonstrate that a formally verified compilation pipeline can achieve performance comparable to ad hoc, hand-tuned OpenCL implementations.
Proposed method
- Introduce Data Parallel Idealised Algol (DPIA), a substructural, interference-controlled variant of Reynolds’ Idealised Algol, to combine functional and imperative programming with strong safety guarantees.
- Use a syntactic control of interference type system inspired by Reynolds’ work to ensure data race freedom in the generated imperative code.
- Formalize a semantics-preserving and strategy-preserving translation from functional code to imperative code within DPIA, enabling systematic compilation to OpenCL.
- Leverage existing functional rewrite systems (e.g., Steuwer et al. 2015) to automatically explore and select high-performance parallelization strategies before compilation.
- Map the resulting imperative DPIA code directly to C-like OpenCL code, ensuring a straightforward and predictable compilation path.
- Use relational parametricity and automata-theoretic models to formally verify correctness and non-interference properties of the compilation process.
Experimental results
Research questions
- RQ1Can a formal compilation pipeline preserve the intended parallelization strategy when translating high-level functional code to low-level imperative code?
- RQ2Is it possible to generate data-race-free imperative code from functional abstractions while maintaining high performance across diverse architectures?
- RQ3Does a formally verified compilation process achieve performance comparable to hand-optimized, ad hoc OpenCL implementations?
- RQ4Can a substructural type system in a functional-impure language like DPIA effectively enforce data race freedom in parallel code generation?
Key findings
- The formalized compilation pipeline from functional to imperative code preserves the intended parallelization strategy, ensuring that optimization choices made at the functional level are faithfully reflected in the generated low-level code.
- The generated imperative code is provably data race free due to the substructural type system in DPIA, providing strong correctness guarantees.
- Performance evaluation on GPUs and a multicore CPU shows that the generated code achieves performance on par with hand-tuned OpenCL code, demonstrating no significant overhead from formal verification.
- The approach enables reuse of automated strategy search techniques (e.g., from Steuwer et al. 2015) in a formally correct compilation pipeline, enhancing both portability and reliability.
- The formal framework supports predictable and composable compilation, making it suitable for heterogeneous architectures beyond GPUs, including FPGAs and multi-core systems.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.