什么是超级编译?

发布于 2024-12-31 22:19:41 字数 112 浏览 2 评论 0原文

简短而甜蜜:我见过几个来源谈论“超级编译”。但我还没有在互联网上找到任何一个文档来描述这是什么。大概是因为它对任何人来说似乎都很简单,甚至不值得解释。

有人知道这到底是什么吗?

Short and sweet: I've seen several sources talking about "supercompilation". But I have yet to find one single document anywhere on the face of the Internet which describes what this is. Presumably because it seems simple enough to whoever that it isn't even worth explaining.

Does anybody know what this actually is?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

关于从前 2025-01-07 22:19:41

超级编译可以视为部分评估的概括。部分求值背后的想法是,程序的许多部分可以在编译时求值,也应该如此。超级编译对此进行了扩展,还评估了编译时无法完全完成的事情,例如将 map f (map g xs) 转换为 map (f . g) xs除了 map 的定义之外没有任何东西(至少我认为我的部分评估是正确的 - 我只阅读了很多关于超级编译的内容)。

另一种看待它的方式是将其视为许多其他优化的组合,例如森林砍伐、专业化和内联。通过表现得好像它已经知道函数的输入并进行评估,它可以获得更直接的计算结果的方法 - 它可以通过查看中间数据结构将如何使用来摆脱中间数据结构,或者它可以插入所有可能的值和然后将结果包装在 case 中,或者用其假装值执行其他操作。

Max Bolingbroke 有许多关于该主题的有用论文 - 我推荐第一篇,评估超级编译,作为介绍。第 2 节通过示例介绍了该主题,其余部分虽然有点难以理解,但关于该过程的信息非常丰富。 Neil Mitchell 也有许多精彩的演示来描述它。

我希望这有帮助。

Supercompilation can be approached as a generalization of partial evaluation. The idea behind partial evaluation is that many parts of a program can be evaluated at compile time, and so should be. Supercompilation extends this, evaluating things that can't be fully done at compile time as well, like turning map f (map g xs) into map (f . g) xs without anything besides the definition of map (At least I think I got partial evaluation right - I've only read much about supercompilation).

Another way to look at it is as a combination of many other optimizations, like deforestation, specialization, and inlining. By acting as if it already knew the inputs to functions and evaluating, it can get a more direct method of calculating the result - it can get rid of intermediate data structures by seeing how they will be used or it can plug in all possible values and then wrap the result in a case, or do something else with its pretend values.

Max Bolingbroke has a number of useful papers on the subject - I recommend the first one, Supercompilation by Evaluation, as an introduction. Section 2 introduces the subject by example and the rest, while a bit difficult to get through, is very informative about the process. Neil Mitchell also has a number of good presentations describing it.

I hope that helps.

白色秋天 2025-01-07 22:19:41

来自元编译维基百科

元编译是一种涉及元系统转换的计算
(MST)从计算机 M 到控制元机器 M',
分析和模仿基于M. Semantics的程序的工作
转换,例如部分评估和超级编译(SCP),
是元计算。

有关维基百科上的元系统的更多信息。

我对这个主题不了解,但我会给出我对描述的理解。假设我们有一个简单的程序,可以将标准输入复制到标准输出。这将是我们的计算机 M。我们的元机器 M' 是第二个程序,它将 M 的源作为输入(或者以其他方式构建为固有地了解 M),因此不仅能够理解 M 的作用,而且能够理解 它是如何做到的。

如果我的理解是正确的,那么显而易见的问题是我们为什么关心 M'?我想到的是自动优化。如果我们能够理解 M 的工作原理以及 M 试图实现的目标,那么 M' 可能会找到改进 M 操作的方法,无论是在空间还是时间上。此外,重要的是,M'可以替代M,因为M'可以完成M所做的任何事情。这意味着M''可以改进M'优化M的方式,并随后取代M',依此类推。

From Wikipedia on Metacompilation:

Metacompilation is a computation which involves metasystem transitions
(MST) from a computing machine M to a metamachine M' which controls,
analyzes and imitates the work of M. Semantics-based program
transformation, such as partial evaluation and supercompilation (SCP),
is metacomputation.

More about Metasystems on Wikipedia.

I am not knowledgeable on the subject, but I'll give my understanding of the description. Say we had a simple program that could copy stdin to stdout. This would be our computing machine M. Our metamachine M' is a second program that takes the source of M as input (or is otherwise constructed to inherently know of M) and is therefore able to understand not only what M does, but how it does so.

If my understanding is correct, then the obvious question is why do we care about M'? What comes to my mind is automatic optimisations. If we can understand both how M works and what M is trying to accomplish, M' may solve ways to improve the operation of M, either in space or time. Furthermore, and importantly, M' may substitute M since M' can accomplish whatever M did. This means that M'' can improve on the ways M' optimised M, and subsequently replace M', and so on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文