In this short paper, we explore a new way to refactor a simple but tricky-to-parallelize tree-traversal algorithm to harness multicore parallelism. Crucially, the refactoring draws from some classic techniques from programming-languages research, such as the continuation-passing-style transform and defunctionalization. The algorithm we consider faces a particularly acute granularity-control challenge, owing to the wide range of inputs it has to deal with. Our solution achieves efficiency from heartbeat scheduling, a recent approach to automatic granularity control. We present our solution in a series of individually simple refactoring steps, starting from a high-level, recursive specification of the algorithm. As such, our approach may prove useful as a teaching tool, and perhaps be used for one-off parallelizations, as the technique requires no special compiler support.
翻译:在这篇短文中,我们探索了一种重构简单但难以并行化的树遍历算法的新方法,以利用多核并行性。关键在于,该重构借鉴了编程语言研究中的经典技术,如续延传递风格变换和去函数化。由于算法需要处理范围广泛的输入,它面临一个尤为棘手的粒度控制挑战。我们的解决方案通过心跳调度(一种近期提出的自动粒度控制方法)实现了高效率。我们从算法的高层递归规范出发,通过一系列各自简单的重构步骤呈现了解决方案。因此,我们的方法可能作为教学工具有用,或许还可用于一次性并行化场景,因为该技术无需特殊的编译器支持。