研究生: |
王孟婷 Wang, Meng-Ting |
---|---|
論文名稱: |
Compilers for code size optimization on embedded processors 支援程式碼縮減最佳化之嵌入式編譯器設計 |
指導教授: |
李政崑
Lee, Jenq-Kuen |
口試委員: |
蘇泓萌
Su, Charlie 黃錫瑜 Huang, Shi-Yu |
學位類別: |
碩士 Master |
系所名稱: |
電機資訊學院 - 資訊工程學系 Computer Science |
論文出版年: | 2011 |
畢業學年度: | 99 |
語文別: | 英文 |
論文頁數: | 27 |
中文關鍵詞: | 編譯器最佳化 、程式碼縮減 、低階虛擬機器 、函式抽出 、基因演算法 |
外文關鍵詞: | Compiler optimization, Code size reduction, Low level virtual machine, Procedural abstraction, Genetic algorithm |
相關次數: | 點閱:1 下載:0 |
分享至: |
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報 |
Embedded system software and user application programs are gaining more and more powerful, complex, and require more computing resource. Nevertheless, with regards to the portability, more and more electronic products are designed to be light-weighted and relatively small in size which implies more critical limits of the resource.
Constrained to the limited available resource, embedded systems usually suffer from constrains of storage space, computing resource, and even system power. In this
study, we set an optimization goal to minimize code size within a given performance cost constrain.
We introduce an approach to heuristically select and order the Low Level Virtual Machine (LLVM) optimization passes for code size optimization so that the users can fully exploit the compiler optimization passes provided by the compiler system. Our work employed genetic algorithm to accelerate the search for good pass sequence.
To further enhance the compression ability of our work, we equip the LLVM system with a new optimization pass using procedural abstraction scheme. The implementation of our works with procedural abstraction is devised on the basis of common code elimination to reduce code size and keep the performance in an acceptable range. After converting the code into native arm executable file, we found that the GA suggested optimization sequences leads to 88% less LLVM IR instruction counts(compared with O0). By integrating our works about GA and procedural abstraction the overall
code compression rate can reaches as much as 17% more to both O0 and O2 in native code averagely. In the best case, the code size reduction ratio even reaches about
30% over O2. Our design results in better code size over the O0 and O2 options, and experiential data indicates that it is profitable to fine tune compiler optimization
sequence using genetic algorithm with little amount of compilation time increment.
According to further discussion and analysis, the calling convention and SSA from attribution of LLVM assembly code explains the data we derived from our design. The experiment results support that our code size reduction scheme works and also propose future works on performance concerns.
近年嵌入式系統程式與應用軟體的快速發展,使其具備更加完備且複雜的功能,也因此這些軟體有更高的計算資源需求。然而,消費性電子產品之設計考量到可攜性,朝輕量發展,體積亦愈趨縮小。這同時意味著此一嵌入式系統中之計算資源更有限,如記憶體、儲存空間、甚至是系統能源。為了讓嵌入式手持式設備上的軟體都能有效的利用有限的資源以發揮效用,在本論文中,我們以「在有限的效能影響下,最佳化程式碼大小」為研究目標,進行討論。我們提出應用基因演算法選擇、排列編譯器所提供之最佳化選項之機制,達到程式碼縮減之效果。本論文以低階虛擬機器(LLVM)之編譯器架構為主要研究環境,充分使用其所提供之最佳化技術。另外,為了增進低階虛擬機器之程式碼最佳化的效果,我們亦提出以抽出函式之方法,基於消除重複之程式碼片段,縮減程式碼之大小。並經由估算額外成本之方式,控制抽出函式所造成的額外效能影響。
將低階虛擬機器之中介表示式程式碼、轉換成ARM 平台之原生碼後,實驗結果顯示
使用基因演算法所挑選出之編譯器最佳化選項序列可將程式碼大小減至O0 所產生之84% ,O2 所產生之84%。實驗數據也指出經由我們所提出之抽出函式的作法,與以基因演算法挑選編譯器最佳化序列之機制整合,可以更進一步的縮減約10%之原生程式碼尺寸。最佳情況下,可以比O2 多縮減30%之程式碼大小。基本上,我們所提出的方法可以產生出比O0及O2 更佳的編譯結果,但所需之額外編譯時間在合理之範圍內。本論文進一步討論關於低階虛擬機器之函式呼叫協定,以及低階虛擬機器之中介表示式之靜態單一指值之型態,對於函式抽出效率上的影響。實驗結果亦指出,未來的研究可以朝向如何更精準的估算對程式碼大小最佳化之後,對於程式效能之改變發展。
[1] K.D. Cooper, P.J. Schielke, and D. Subramanian. Optimizing for reduced code space using genetic algorithms. In ACM SIGPLAN Notices, volume 34, pages
1–9. ACM, 1999.
[2] S. Adve, D. Burger, R. Eigenmann, A. Rawsthorne, M. Smith, C. Gebotys, M. Kandemir, D. Lilja, A. Choudhary, J. Fang, et al. The interaction of architecture
and compilation technology for high-performance processor design. IEEE Computer Magazine, 30(12):51–58, 1997.
[3] C.W. Fraser, E.W. Myers, and A.L.Wendt. Analyzing and compressing assembly code. ACM SIGPLAN Notices, 19(6):117–121, 1984.
[4] C.A. Lattner. LLVM: An infrastructure for multi-stage optimization. PhD thesis, Citeseer, 2002.
[5] C. Lattner and V. Adve. The llvm instruction set and compilation strategy. CS Dept., Univ. of Illinois at Urbana-Champaign, Tech. Report UIUCDCS.
[6] A. Halambi, A. Shrivastava, P. Biswas, N. Dutt, and A. Nicolau. An efficient
compiler technique for code size reduction using reduced bit-width isas. In Proceedings of the conference on Design, automation and test in Europe, DATE ’02,
pages 402–, Washington, DC, USA, 2002. IEEE Computer Society.
[7] ’A. Besz’edes, R. Ferenc, T. Gyim’othy, A. Dolenc, and K. Karsisto. Survey of code-size reduction methods. ACM Computing Surveys (CSUR), 35(3):223–267, 2003.
[8] Martin Thuresson and Per Stenstrom. Evaluation of extended dictionary-based static code compression schemes. In Proceedings of the 2nd conference on Computing frontiers, CF ’05, pages 77–86, New York, NY, USA, 2005. ACM.
[9] N.J. Larsson and A. Moffat. Off-line dictionary-based compression. Proceedings of the IEEE, 88(11):1722–1732, 2000.
[10] M.J. Zastre. Compacting object code via parameterized procedural abstraction. PhD thesis, Citeseer, 1995.
[11] Dae-Hwan Kim and Hyuk Jae Lee. Iterative procedural abstraction for code size reduction. In Proceedings of the 2002 international conference on Compilers, architecture, and synthesis for embedded systems, CASES ’02, pages 277–279, New York, NY, USA, 2002. ACM.
[12] A. Dreweke, M. Worlein, I. Fischer, D. Schell, Th. Meinl, and M. Philippsen.
Graph-based procedural abstraction. In Proceedings of the International Symposium on Code Generation and Optimization, CGO ’07, pages 259–270, Washington,
DC, USA, 2007. IEEE Computer Society.
[13] J. Cavazos, G. Fursin, F. Agakov, E. Bonilla, M.F.P. O’Boyle, and O. Temam. Rapidly selecting good compiler optimizations using performance counters. In Proceedings of the International Symposium on Code Generation and Optimiza
tion, pages 185–197. IEEE Computer Society, 2007.
[14] J. Kukunas, R.D. Cupper, and G.M. Kapfhammer. A genetic algorithm to improve linux kernel performance on resource-constrained devices. In Proceedings of the 12th annual conference comp on Genetic and evolutionary computation,
pages 2095–2096. ACM, 2010.
[15] P.A. Kulkarni, D.B. Whalley, G.S. Tyson, and J.W. Davidson. Practical exhaustive optimization phase order exploration and evaluation. ACM Transactions on Architecture and Code Optimization, 6(1):1–36, 2009.
[16] Z. Rozenshein, D. Halahmi, A. Mordoh, and Y. Ronen. Speed and code-size trade-off with the starcore sc140. Application Note, AN1838/D, Rev 0, Motorola, Atlanta, GA, 2000.
[17] N.E. Johnson. Code size optimization for embedded processors. month, 2004.