arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.16437cs.PLmath.CTmath.LO
收藏

维度类型系统与确定性内存管理:原生编译中的设计时语义保留

Dimensional Type Systems and Deterministic Memory Management

Braidpoint

Houston Haynes

AI总结:

本文提出一种编译框架,通过多阶段MLIR降低保持维度类型注解,使编译器能联合解决数值表示选择和确定性内存管理作为程序语义图的共同效应。维度推断确定值范围,进而决定表示选择、字宽、内存占用、分配策略和跨目标传输保真度。

摘要:

我们提出一种编译框架,其中维度类型注解通过多阶段MLIR降低持续存在,使编译器能够将数值表示选择和确定性内存管理作为单一程序语义图(PSG)的共同效应进行联合解析。维度推断确定值范围,进而决定表示选择、字宽、内存占用、分配策略和跨目标传输保真度。维度类型系统(DTS)扩展了Hindley-Milner统一度量,引入来自有限生成阿贝尔群的约束,从而得到在多项式时间内可决定、完整(无需注解)且主的推断。与传统系统在代码生成前擦除维度注解不同,DTS在每个降低阶段都将它们作为编译元数据携带,使其在表示和内存放置决策发生时可用。确定性内存管理(DMM)作为同一图中的共同效应纪律,将值生命周期分为四类逃逸类别,每类映射到已验证的分配策略。维度代数在链式规则下封闭,前向模式梯度计算表现出特定的共同效应签名,该框架可以在编译时验证。实际后果是开发环境中的逃逸诊断、分配策略、表示保真度和缓存局部性估计都是编译图的设计时视图。

英文摘要:

We present a dimensional type system whose annotations remain available through the stages that require them, allowing numeric representation and deterministic memory management to be resolved within a single Program Semantic Graph (PSG). Based on Andrew Kennedy's Units of Measure, dimensions constrain admissible operations and the application of domain laws, forming our Native Type Universe (NTU). Range analysis combines those constraints with values, guards, and declared boundaries. A covering representation then determines word width and memory footprint, which participate in allocation and transfer decisions alongside lifetime and target constraints. Our Dimensional Type System (DTS) extends Hindley-Milner inference with abelian-group unification. Within that algebraic fragment, inference is decidable and admits principal types. Measures form part of source-level type identity, while numeric width and storage layout are coeffects resolved from context. A known range that exceeds every available representation produces an error at representation commitment. During program elaboration, unresolved facts can remain pending while further context is supplied. Deterministic Memory Management (DMM) uses the same graph to relate escape paths to storage lifetimes. Closure capture, return, and by-reference use supply different lifetime requirements. Allocation follows the lifetime classification and the platform's declared storage capabilities. Our unique implementation of a posit quire illustrates the interaction: exact accumulation requires a suitable numeric format, adequate capacity, and storage that persists across the accumulation. We also examine how these constraints would apply to automatic differentiation. A shared graph would allow language services to present dimensional resolution and proof status alongside the reasons for representation and placement decisions.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑