Now, almost every processor architecture has added support for SIMD (single instruction multiple data) instructions. SIMD instructions can perform the same operation on a set of data simultaneously, enhancing the processing performance of the processor through data parallelism. However, most dynamic binary translators ignore the use of native SIMD instructions and instead simulate floating-point computations in software languages. This paper proposes a framework called FP-QEMU, based on QEMU translation system. FP-QEMU adopts SIMD instructions to optimize and replace floating-point calculation instructions, and completes a complete floating-point implementation on X86 and ARM benchmark platforms. The framework can identify the optimization opportunities of floating-point computation acceleration in dynamic binary translation system and use SIMD instructions to achieve the effect of improving the translation performance of dynamic binary translation system. Using SPEC 2006 as the benchmark, experiments show that compared with QEMU, FP-QEMU cross-platform ARM applications running on X86 computers can achieve a maximum speedup of 51.5% and an average speedup of 37.42%.
综上所述,通过研究SPEC CPU 2006中不同浮点型课题的加速比,可以发现采用FP-QEMU框架对于QEMU翻译的性能有较大的提升.X86架构作为基准平台,平均加速比可达37.42%,是本地执行效率的1.6倍.ARM架构作为基准平台,平均加速比可达52.72%,是本地执行效率的2.25倍,大幅度提高了QEMU的执行效率.以ARM架构为例,根据数据统计,434课题中浮点计算占比约16.01%,433课题中浮点计算占比约21.06%,因此433课题的SIMD指令替换率比434课题要高,从而433课题的加速比要高于434课题.此外,本地计算机平台的性能同样对于最后的统计结果有影响,但本文暂不考虑本地计算机性能不同带来的结果差异.
4 结 论
本文针对动态二进制翻译中浮点计算指令处理翻译模式中的开销,给出了一种优化的处理框架FP-QEMU.FP-QEMU框架充分解析了本地平台SIMD指令的性质和功能并将SIMD指令分析利用,通过不同本地平台采用不同对应SIMD指令替换浮点计算指令的方法达到优化浮点计算进而提高动态二进制翻译效率的目的.通过动态二进制翻译器QEMU的实验验证,本文采用SPEC CPU 2006测试基准,实验结果表明FP-QEMU框架对动态二进制翻译的优化是有效的.此外,FP-QEMU框架提供了一个清晰的设计思路,研究人员可以根据自己的需求,在该框架的基础上添加新的功能、优化算法或者改进性能.该框架为研究人员提供了一个起点和参考,使他们能够在此基础上开展深入研究,并为未来的相关工作做出更多的贡献.
FUL G, PANGJ M, WANGJ,et al .Optimization of library function disposing in dynamic binary translation[J].Journal of Computer Research and Development,2019,56(8):1783-1791.(in Chinese)
[3]
BELLARDF .QEMU,a fast and portable dynamic translator[C]//Proceedings of the Annual Conference on USENIX Annual Technical Conference. Anaheim,CA. ACM,2005:41.
HUW W, WANGW X, WUR Y,et al .Loongson instruction set architecture technology[J].Journal of Computer Research and Development,2023,60(1):2-16.(in Chinese)
SHIQ .Research on key optimization technologies of binary translation for the domestic CPU[D].Zhengzhou:PLA Information Engineering University,2017:19-34.(in Chinese)
LIN, PANGJ M .Intermediate code optimization method for binary translation based on intermediate representation rule replacement[J].Journal of National University of Defense Technology,2021,43(4):156-162.(in Chinese)
[10]
HONGD Y, HSUC C, YEWP C,et al .HQEMU:a multi-threaded and retargetable dynamic binary translator on multicores[C]//Proceedings of the Tenth International Symposium on Code Generation and Optimization. San Jose,California. ACM,2012:104-113.
[11]
WANGZ G, LIUR, CHENY F,et al .COREMU:a scalable and portable parallel full-system emulator[C]//Proceedings of the 16th ACM Symposium on Principles and Practice of Parallel Programming.San Antonio TX USA.ACM,2011:213-222.
[12]
DINGJ H, CHANGP C, HSUW C,et al .PQEMU:a parallel system emulator based on QEMU[C]//2011 IEEE 17th International Conference on Parallel and Distributed Systems.Tainan,Taiwan,China. IEEE,2011:276-283.
[13]
POEPLAUS, FRANCILLONA .SymQEMU:compilation-based symbolic execution for binaries[C]//Proceedings 2021 Network and Distributed System Security Symposium.Virtual.Reston,VA:Internet Society,2021.
[14]
ZHAOZ Y, JIANGZ, LIUX M,et al .DQEMU:a scalable emulator with retargetable DBT on distributed platforms[C]//Proceedings of the 49th International Conference on Parallel Processing. Edmonton,AB,Canada. ACM,2020:1–11.
[15]
LUKC K, COHNR, MUTHR,et al .Pin:building customized program analysis tools with dynamic instrumentation[C]//Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation.Chicago IL USA.ACM,2005:190-200.
[16]
ZENGJ Y, FUY C, LINZ Q .PEMU:a pin highly compatible out-of-VM dynamic binary instrumentation framework[C]//Proceedings of the 11th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments. Istanbul Turkey.ACM,2015:147-160.
[17]
LIM L, PANGJ M, YUEF, et al. Enhancing dynamic binary translation in mobile computing by leveraging polyhedral optimization[J]. Wireless Communications and Mobile Computing, 2021:6611867.
[18]
DOLAN-GAVITTB, HODOSHJ, HULINP,et al .Repeatable reverse engineering with PANDA[C]//Proceedings of the 5th Program Protection and Reverse Engineering Workshop. Los Angeles,CA,USA. ACM, 2015: 1-11.
LIB J. SIMD instructions generated on the dynamic binary translation engine of the HQEMU system simulator[D]. Shanghai: Shanghai Jiaotong University,2012.(in Chinese)
[21]
LIJ H, ZHANGQ, XUS,et al .Optimizing dynamic binary translation for SIMD instructions[C]//International Symposium on Code Generation and Optimization (CGO’ 06.NewYork,NY,USA.IEEE,2006.