Compiling a functional array language with non-semantic memory information

Philip Munksgaard, C. Oancea, Troels Henriksen
{"title":"Compiling a functional array language with non-semantic memory information","authors":"Philip Munksgaard, C. Oancea, Troels Henriksen","doi":"10.1145/3587216.3587218","DOIUrl":null,"url":null,"abstract":"We present a technique for introducing a notion of memory in the compiler representation for a parallel functional array language, in a way that allows for transformation and optimization of memory access patterns and uses, while preserving value-based semantics. Functional languages expose no notion of memory to the user. There is no explicit allocation or deallocation of memory, nor any mapping from arrays to memory locations. Instead, the compiler must infer when and where to perform allocations as well as how values should be represented in memory. Because this affects performance, an optimizing compiler will need freedom to express various memory optimizations. Typically this is done by lowering the functional language to an imperative intermediate representation with a direct notion of memory, losing the ability to use high-level functional reasoning while performing said optimizations. We present a compiler representation where memory information is non-semantic, in the sense that it does not affect the program result, but only the operational details. We start by defining a simple functional language without memory, Fun, and give it static and dynamic semantics. Next, we define an extended language, FunMem, which is Fun with non-semantic memory information in the form of lmads and an allocation statement. We give the extended language static and dynamic semantics and we provide an algorithm for transforming a Fun program into FunMem. We likewise introduce a simple imperative language Imp, which we use to illustrate how one might translate FunMem into lower-level code. Finally, we show an example of a useful transformation in FunMem, memory expansion, which is used to hoist allocations from parallel GPU kernels.","PeriodicalId":318613,"journal":{"name":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","volume":"9 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2022-08-31","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 34th Symposium on Implementation and Application of Functional Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3587216.3587218","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

We present a technique for introducing a notion of memory in the compiler representation for a parallel functional array language, in a way that allows for transformation and optimization of memory access patterns and uses, while preserving value-based semantics. Functional languages expose no notion of memory to the user. There is no explicit allocation or deallocation of memory, nor any mapping from arrays to memory locations. Instead, the compiler must infer when and where to perform allocations as well as how values should be represented in memory. Because this affects performance, an optimizing compiler will need freedom to express various memory optimizations. Typically this is done by lowering the functional language to an imperative intermediate representation with a direct notion of memory, losing the ability to use high-level functional reasoning while performing said optimizations. We present a compiler representation where memory information is non-semantic, in the sense that it does not affect the program result, but only the operational details. We start by defining a simple functional language without memory, Fun, and give it static and dynamic semantics. Next, we define an extended language, FunMem, which is Fun with non-semantic memory information in the form of lmads and an allocation statement. We give the extended language static and dynamic semantics and we provide an algorithm for transforming a Fun program into FunMem. We likewise introduce a simple imperative language Imp, which we use to illustrate how one might translate FunMem into lower-level code. Finally, we show an example of a useful transformation in FunMem, memory expansion, which is used to hoist allocations from parallel GPU kernels.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
编译具有非语义内存信息的函数式数组语言
我们提出了一种技术,用于在并行函数数组语言的编译器表示中引入内存的概念,以一种允许转换和优化内存访问模式和使用的方式,同时保留基于值的语义。函数式语言不向用户公开内存的概念。没有显式的内存分配或释放,也没有从数组到内存位置的任何映射。相反,编译器必须推断何时何地执行分配,以及值应该如何在内存中表示。因为这会影响性能,所以优化编译器需要自由地表达各种内存优化。通常,这是通过将函数式语言降低为具有直接内存概念的命令式中间表示来实现的,在执行上述优化时失去使用高级函数推理的能力。我们提出了一种编译器表示,其中内存信息是非语义的,在某种意义上,它不影响程序结果,而只影响操作细节。我们首先定义一个没有内存的简单函数式语言Fun,并赋予它静态和动态语义。接下来,我们定义一种扩展语言FunMem,它具有以lmad和分配语句形式表示的非语义内存信息。我们给出了扩展语言的静态和动态语义,并提供了将Fun程序转换为FunMem的算法。同样,我们将介绍一种简单的命令式语言Imp,用它来说明如何将FunMem转换为低级代码。最后,我们展示了FunMem中一个有用的转换示例,即内存扩展,它用于从并行GPU内核提升分配。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Compiling a functional array language with non-semantic memory information On Generating Out-Of-Core GPU Code for Multi-Dimensional Array Operations First-Class Data Types in Shallow Embedded Domain-Specific Languages using Metaprogramming Verified Technology Mapping in an Agda DSL for Circuit Design: Circuit refinement through gate and data concretisation Set-theoretic Types for Erlang
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1