標題: 圖形處理器之著色中介碼研究
Shader Form: an Intermediate Representation for Optimizing Compilers on GPU Shader Architectures
作者: 林聖偉
Lin, Sheng-Wei
游逸平
You, Yi-Ping
資訊科學與工程研究所
關鍵字: 編譯氣最佳化;著色器;靜態單賦值形式;compiler optimizations;shader processors;SSA form
公開日期: 2012
摘要: 圖形處理器(GPU)由於其高度平性化的特性,使它不僅可以運用在圖學運算,甚至也可以應用於一般的運算上。圖形處理器的架構從過去的固定管線(fixed function pipeline)演進到了可程式化管線(programmable pipeline),其中可程式化的部分分別是頂點著色器(vertex shader)和片段著色器(fragment shader)。程式設計者可以藉由寫著色程式達到繪圖的效果。一般的圖形處理器在執行圖學應用程式時,會先載入應用程式裡的著色原始碼並將其編譯成目的碼,在連結成可執行的二進制檔,最後再將此二進制檔送到圖形處理器執行,然而在這過程中,由於圖形處理器採用即時編譯(JIT compilation)的方式,整個編譯的過程都是在執行階段(runtime)下執行,所以圖形處理器往往為了要降低執行時所帶來的負擔而不對任何程式作優化,如何在執行時期降低優化的成本,是圖形處理器一個重要的議題。在此篇論文我們提出一適用於著色編譯器(Shader compiler)的中介碼(IR),使得許多程式的優化不僅可以以較簡化的方式應用於此中介碼上,還可以節省許多時間,大幅地降低了執行時期所需的負擔。我們將研究成果實作在一私有之 ESSL 編譯器,與傳統的最佳化方法之編譯器比較,平均而言,我們省下了81.8%的優化時間。
Modern graphics processing units (GPUs) are not only powerful graphics-rendering engines but also used for general-purpose computing due to their highly parallel structures. A just-in-time compilation is adopted in GPUs to compile shader programs at runtime. However, such model disables many compiler optimizations for reducing runtime overhead. In this thesis, we use the concept of static single-assignment (SSA) form in the shader compiler in order to simplify compiler optimizations. Unlike other single instruction, multiple data (SIMD) architectures, shader processors allow components of a register to be separately accessed; therefore, a variable may refer to multiple definitions. This property leads a correctness problem to occur in a program when converting the program into SSA form. In general, the correct SSA form in shader compilers is to treat each component as an individual register by decomposing each operation. Although the SSA form with decomposition operations could be applied correctly, it brings some side-effects of code size expansion in the SSA form transformation and unnecessary JIT optimizations. For this reason, we present a representation, called shader form, to support GPU shader architectures for simplifying compiler optimizations. Since a variable may refer to multiple definitions, we group such definitions as a single definition for some variable in shader form. Experiments demonstrated that shader form solved the problems encountered in SSA form and efficiently simplified compiler optimizations. Furthermore, shader form could be adopted to any SIMD architectures that allows the components of a register could be separately accessed.
URI: http://140.113.39.130/cdrfb3/record/nctu/#GT079955634
http://hdl.handle.net/11536/50538
顯示於類別:畢業論文