[论文解读] Strategy Preserving Compilation for Parallel Functional Code
本文提出了一种从高级函数式代码到低级无数据竞争并行指令式代码的正式、策略保持不变的编译流水线,采用一种名为数据并行理想化 Algol(DPIA)的新方言理想化 Algol。该方法通过子结构类型系统强制实现无数据竞争,确保正确性与性能可移植性,实现的性能与手工优化的 OpenCL 代码相当,同时保留了来自函数重写系统的预期并行化策略。
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.
研究动机与目标
- 为并行函数式编程中的性能可移植性问题提供解决方案,即需要手工优化的指令式代码才能实现高性能,但缺乏在不同设备间的可移植性。
- 弥合高级函数式抽象与低级指令式代码生成之间的差距,而当前的生成方式缺乏正确性保证与策略保持性。
- 形式化一种从函数式代码到无数据竞争指令式代码的翻译过程,保留预期的并行化策略,确保正确性与性能可移植性。
- 证明形式化验证的编译流水线可实现与临时定制、手工调优的 OpenCL 实现相当的性能。
提出的方法
- 引入数据并行理想化 Algol(DPIA),一种子结构化、干扰控制的 Reynolds 理想化 Algol 变体,将函数式与指令式编程结合,并提供强安全保证。
- 采用受 Reynolds 工作启发的语法干扰控制类型系统,确保生成的指令式代码无数据竞争。
- 在 DPIA 内形式化一种语义保持且策略保持的函数式代码到指令式代码的翻译,支持系统化地编译为 OpenCL。
- 利用现有的函数重写系统(例如 Steuwer 等人 2015)在编译前自动探索并选择高性能的并行化策略。
- 将生成的指令式 DPIA 代码直接映射为类 C 的 OpenCL 代码,确保编译路径直接且可预测。
- 使用关系式参数性与自动机理论模型,正式验证编译过程的正确性与非干扰性。
实验结果
研究问题
- RQ1当从高级函数式代码翻译为低级指令式代码时,形式化编译流水线是否能够保留预期的并行化策略?
- RQ2是否能够从函数抽象中生成无数据竞争的指令式代码,同时在多种异构架构上保持高性能?
- RQ3形式化验证的编译过程是否能够实现与手工优化、临时定制的 OpenCL 实现相当的性能?
- RQ4在像 DPIA 这类函数式-不纯语言中,子结构类型系统是否能够有效强制实现并行代码生成中的无数据竞争?
主要发现
- 从函数式代码到指令式代码的形式化编译流水线保留了预期的并行化策略,确保在函数级别做出的优化选择在生成的低级代码中得到忠实反映。
- 由于 DPIA 中的子结构类型系统,生成的指令式代码在形式上是无数据竞争的,提供了强正确性保证。
- 在 GPU 和多核 CPU 上的性能评估表明,生成的代码性能与手工调优的 OpenCL 代码相当,表明形式化验证未引入显著性能开销。
- 该方法使得可自动复用策略搜索技术(例如 Steuwer 等人 2015 提出的方法)于形式化正确编译流水线中,从而提升可移植性与可靠性。
- 该形式化框架支持可预测且可组合的编译,适用于 GPU 之外的异构架构,包括 FPGA 和多核系统。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。