CHR中运行时重复递归展开:一种可实现超线性加速的即时在线程序优化策略
Runtime Repeated Recursion Unfolding in CHR: A Just-In-Time Online Program Optimization Strategy That Can Achieve Super-Linear Speedup
AI总结:
提出一种基于重复递归展开的即时在线程序优化策略,通过运行时生成特化规则将递归调用次数降至对数级别,在CHR中实现并证明了其正确性及超线性加速条件。
摘要:
我们引入了一种基于重复递归展开的即时运行时程序转换策略。我们的在线程序优化生成多个递归版本,这些版本由所覆盖的最小递归步骤数区分。在我们的技术中,递归的基例被忽略。我们的方法在此基于单一直接递归规则引入。当在运行时遇到递归调用时,首先由展开器即时创建关联递归规则的特化,然后由解释器将这些规则应用于该调用。我们的方法将递归规则应用次数减少至其对数级别,代价是引入对数数量的通用展开规则。我们证明了该在线优化技术的正确性,并确定了其时间复杂度。对于具有足够可简化展开的递归,可能实现超线性加速,即加速超过常数因子。必要的简化是特定于问题的,必须在编译时提供。在我们的加速分析中,我们证明了超线性加速的充分条件以及充分必要条件,这些条件将原始规则的递归步骤复杂度与展开规则的复杂度关联起来。我们实现了一个展开器和元解释器,用于运行时重复递归展开,仅使用嵌入在Prolog中的Constraint Handling Rules(CHR)中的五条规则。我们通过简化、时间复杂度结果和一些基本易处理算法的基准测试来说明我们方法的可行性。这些简化需要一些洞察力,并且是手动推导的。运行时改进迅速达到几个数量级,与我们的定理预测的超线性加速一致。
英文摘要:
We introduce a just-in-time runtime program transformation strategy based on repeated recursion unfolding. Our online program optimization generates several versions of a recursion differentiated by the minimal number of recursive steps covered. The base case of the recursion is ignored in our technique. Our method is introduced here on the basis of single linear direct recursive rules. When a recursive call is encountered at runtime, first an unfolder creates specializations of the associated recursive rule on-the-fly and then an interpreter applies these rules to the call. Our approach reduces the number of recursive rule applications to its logarithm at the expense of introducing a logarithmic number of generic unfolded rules. We prove correctness of our online optimization technique and determine its time complexity. For recursions which have enough simplifyable unfoldings, a super-linear is possible, i.e. speedup by more than a constant factor. The necessary simplification is problem-specific and has to be provided at compile-time. In our speedup analysis, we prove a sufficient condition as well as a sufficient and necessary condition for super-linear speedup relating the complexity of the recursive steps of the original rule and the unfolded rules. We have implemented an unfolder and meta-interpreter for runtime repeated recursion unfolding with just five rules in Constraint Handling Rules (CHR) embedded in Prolog. We illustrate the feasibility of our approach with simplifications, time complexity results and benchmarks for some basic tractable algorithms. The simplifications require some insight and were derived manually. The runtime improvement quickly reaches several orders of magnitude, consistent with the super-linear speedup predicted by our theorems.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。