一句话:提出原则性按位推测(PBS),通过将比特流程序建模为有限状态机来打破依赖并并行化顺序比特流处理。
许多性能关键应用(如多媒体处理、位图索引)以逐位计算遍历比特流,但逐位计算携带依赖时,整个遍历变得串行,从根本上限制了可扩展性。本文提出原则性按位推测(PBS),其核心类比是比特流程序与顺序电路均变换二进制序列,因此可用有限状态机(FSM)建模比特流程序中的依赖。PBS通过一组静态分析将程序推理到比特级,识别导致依赖的位,并将依赖位的取值组合视为状态来构造FSM;进而利用FSM状态收敛以更高准确率预测依赖位取值,并借助FSM推测技术并行化比特流程序。预测失败时,PBS基于按位逻辑直接修正错误输出,最小化误推测开销。作者用LLVM实现原型,在真实比特流程序上评估,在多核/众核机器上获得最高接近线性的加速。
Many performance-critical applications traverse bitstreams with bitwise computations for better performance or higher space efficiency, such as multimedia processing and bitmap indexing. However, when these bitwise computations carry dependences, the entire bitstream traversal becomes serial, fundamentally limiting the scalability. In this work, we show that bitstream-carried dependences are actually "breakable" in many cases, with the adoption of a systematic treatment - principled bitwise speculation (PBS). The core idea of PBS stems from an analogy drawn between bitstream programs and sequential circuits, both of which transform binary sequences. In this new perspective, it becomes natural to model the dependences in bitstream programs with finite-state machines (FSM), a basic model for sequential circuits. To achieve this, PBS features an assembly of static analyses that reason about bitstream programs down to the bit level to identify the bits causing dependences, then it treats the value combinations of dependent bits as states to construct FSMs. The modeling, for the first time, enables the use of FSM speculation techniques to parallelize bitstream programs. Basically, by leveraging the state convergence of FSMs, the values of dependent bits can be predicted with much higher accuracies. In cases the prediction fails, PBS tries to directly "rectify" the wrong outputs based on bitwise logic, minimizing the mis-speculation costs. In addition, FSM shows even higher execution efficiency than the original program in some cases, making itself an optimized version to accelerate serial bitstream processing. We prototyped PBS using LLVM. Evaluation with real-world bitstream programs confirms the effectiveness of PBS, showing up to near-linear speedup on multicore/manycore machines.