標題: | 可自動將被註解低階虛擬機器中間表示碼轉換到OpenCL核心函數的轉換框架 A Translation Framework for Automatic Translation of Annotated LLVM IR into OpenCL Kernel Function |
作者: | 張鎮庭 Jhang, Jhen-Ting 單智君 Shann, Jyh-Jiun 資訊科學與工程研究所 |
關鍵字: | OpenCL;OpenCL backend;LLVM;轉換器;LLVM IR;annotated LLVM IR;OpenCL;OpenCL backend;LLVM;Translator;LLVM IR;annotated LLVM IR |
公開日期: | 2012 |
摘要: | 在現代多處理器平台架構上,平行處理為提升效能的主要方式之一。多處理器平台可以分為異質多處理器平台與同質多處理器平台兩大類。一般而言,同質多處理器的應用程式較容易編程,但是對於一些特殊應用的程式其效能表現並不突出,例如:數位信號處理。與同質多處理器平台相比,異質多處理器平台有較高的潛在效能增益,但程式撰寫較難且容易出錯。近年來,很多平行編程標準陸續被提出,OpenCL就是其中之一。OpenCL是Knronos Group釋出的編程標準規範,可以在多種不同的異質多處理器平台上執行。LLVM是一個編譯器的基礎架構,支援很多前端的程式語言以及後端的目標平台。因LLVM的中間表示碼具有跨平台的性質,所以如能在LLVM代碼產生器中建構一個OpenCL後端,應能更容易地實現source to source的OpenCL轉換。因此。在這篇論文內,我們設計且實作一個自動轉換Annotated LLVM IR到OpenCL核心函數的OpenCL後端,稱為Annotated LLVM IR to OpenCL Kernel Function Translation Framework。我們提出的OpenCL後端是根據LLVM中的C back-end修改而來;其輸入為annotated LLVM IR,輸出為OpenCL核心函數。此OpenCL 後端的主要修改項目包含OpenCL特有資料型態的識別、內建函數名稱對應、OpenCL擴展等。在實驗中我們將OpenCL benchmark的核心函數透過LLVM前端轉換成annotated LLVM IR;之後,透過提出的OpenCL後端將annotated LLVM IR轉換成OpenCL核心函數,並將轉換出的OpenCL核心函數與原來的OpenCL benchmark作比較,執行結果正確且效能幾乎一樣。此外,我們也將轉換出的OpenCL核心函數與相對的C code作比較,大部分效能都比C code好。 Parallel processing is regarded as one of the most important techniques to achieve high performance for modern multi-processor platforms. Multiprocessor platforms can be classified into two categories: namely heterogeneous and homogenous ones. A homogenous multiprocessor is easily to program, but usually achieves less performance on some application-specific applications, such as digital signal processing. Compared with homogenous multiprocessor platform, a heterogeneous one may achieve higher performance in many applications, but is more difficult to program. Recently, many parallel programming standards have been proposed, and one of the standards is OpenCL (Open Computing Language). The OpenCL standard was released by the Knronos Group. It improves the portability for heterogeneous multiprocessor platforms. LLVM is a complier infrastructure which supports many programming languages in its front-ends and target platforms in its back-ends. Because LLVM IR possesses property of cross-platform, constructing an OpenCL back-end in LLVM code generator may be valuable to implement source-to-source OpenCL translation. Therefore, in this thesis, we design and implement a translation framework to automatically transform annotated LLVM IR into OpenCL kernel function. The OpenCL back-end is designed based on the existing C back-end of LLVM. The input and output of the OpenCL back-end are annotated LLVM IR and OpenCL kernel function, respectively. The modifications of the OpenCL back-end with respect to the C back-end include the identification of the special data types of OpenCL, the mapping for built-in function names, insertion of the OpenCL extensions, and so on. In the experiments of this thesis, the kernel function of OpenCL benchmarks are translated into annotated LLVM IR by an existing LLVM front-end. Then, the annotated LLVM IR is translated into OpenCL kernel function by our proposed OpenCL back-end. Comparing the translated OpenCL kernel functions with the original OpenCL benchmarks, the execution results are correct without performance loss. In addition, some of the translated OpenCL kernel functions are also compares with their corresponding C code benchmarks, and the execution results show better performance. |
URI: | http://140.113.39.130/cdrfb3/record/nctu/#GT079855548 http://hdl.handle.net/11536/48283 |
顯示於類別: | 畢業論文 |