SoCal:递归数据类型的内存布局因子化语言
SoCal: A Language for Memory-Layout Factorization of Recursive Datatypes
AI总结:
本文提出SoCal语言,用于生成因子化的代数数据类型表示,通过多缓冲布局提升树状数据结构的性能,实验显示在树处理基准上平均提速1.46倍。
摘要:
数组-结构(AoS)到结构-数组(SoA)是经典的编译器转换,能提升内存局部性并启用数据并行执行。现有AoS到SoA转换主要针对命令式语言中的规则数组程序。相比之下,许多应用处理树状数据结构,如编译器中的AST、浏览器中的DOM树和科学计算中的k-d树。先前工作通过将函数式程序操作此类数据的代数数据类型(ADTs)序列化为连续内存缓冲区来提高性能。然而,这些表示在单个缓冲区中交错字段,类似于AoS布局。我们引入了因子化、多缓冲布局,将不同的ADT字段存储在单独的缓冲区中,从而为序列化的递归数据结构实现SoA-like布局。我们通过SoCal语言形式化了这种方法,并在名为Colobus的编译器中实现了它。Colobus自动将函数式程序转换为操作序列化、因子化布局的递归ADTs。我们的评估显示,在树处理基准套件上平均提速1.46倍。
英文摘要:
Array-of-structures (AoS) to structure-of-arrays (SoA) is a classic compiler transformation that improves memory locality and enables data-parallel execution. Existing AoS-to-SoA transformations target regular, array-based programs in imperative languages, such as C. However, many applications traverse tree-shaped data such as ASTs in compilers, DOM trees in browsers, and k-d trees in scientific workloads. Prior work speeds up functional programs over trees by serializing algebraic datatypes (ADTs) into one contiguous buffer. Such a representation interleaves the fields of every node, similar to an AoS layout. We introduce a factored layout of ADTs, which stores its fields in separate buffers, producing a layout that resembles SoA. In a factored layout, a traversal can focus on relevant fields and ignore the rest, similar to extracting a column from a SoA representation; in this setting, traversals over scalar fields can be vectorized. Working with raw byte arrays is error-prone, though: wrong indexing can silently read bytes from a wrong field or write past the end of a value. We therefore introduce SoCal, a type-safe language for expressing traversals over factored ADTs. Our compiler, Colobus, transforms a simple functional language with ADTs reminiscent of Haskell to C, using SoCal as the intermediate representation. Colobus generates traversals over byte arrays in the factored representation and performs optimizations such as field skipping and vectorization. Across a suite of benchmarks, Colobus shows the average speedups of 3.8x and 5.2x over fold and map passes, respectively.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。