標題: | 轉換OpenACC到LLVM中間轉換碼同Metadata在Clang上 Translating OpenACC to LLVM IR with Metadata on Clang |
作者: | 朱靖宇 Chu, Ching-Yu 單智君 Shann, Jyh-Jiun 資訊科學與工程研究所 |
關鍵字: | 異質性多處理器平台;OpenACC 編譯器;OpenCL;LLVM;Clang;LLVM metadata;heterogeneous multiprocessor platforms;OpenACC compiler;OpenCL;LLVM;Clang;LLVM metadata |
公開日期: | 2015 |
摘要: | 近年來,多處理器平台(Multiprocessor Platform)已經成為加速程式的一種趨勢。多處理器平台一般可以分為兩種形式: 同質(homogeneous)和異質(heterogeneous)。對於某些可以平行化的程式而言,異質多處理器平台通常可以得到比同質多處理器平台更高的效能和能源效率。然而,由於資料的管理和各個處理器之間的溝通,撰寫異質多核心程式會比同質多核心程式來的更加困難。雖然 Knronos Group 新釋出了 OpenCL 標準,改善了異質多核心程式的可攜性,但使用 OpenCL 來撰寫異質多核心程式依然是複雜且容易出錯的。因此,我們打算設計一個基於 LLVM 的 OpenACC 編譯器來自動轉換 OpenACC 的程式成 OpenCL 的程式。在本篇論文中,我們設計並且實作 LLVM 的其中一個前端 Clang 的一個延伸版本,藉由 LLVM metadata 來保留關於 OpenACC directives 和 clauses 的資訊,因為這些資訊將會被原本的 Clang 忽略。我們修改後的 Clang 將會把一個 OpenACC 的程式轉換成 LLVM IR 附上 metadata 。而後,透過本實驗室之前設計的 OCLHKIR generator 和 LLVM OpenCL Backend 將會分析這些 metadata ,進而產生 host LLVM IR 和 OpenCL核心函數(kernel function),再利用 LLVM 之即時編譯器(Just-in-time Compiler, JIT Compiler)執行 host LLVM IR。實驗結果顯示出,我們的 OpenACC 編譯器可以產生出效能接近 PGI OpenACC 編譯器與手寫 OpenCL 程式的程式碼。因此,我們提出的 OpenACC 編譯器不僅可以降低撰寫 OpenCL 程式的難度,也同時轉換出具有高效能的 OpenCL 程式。 Recently, multiprocessor platforms has become trends for accelerating programs. It generally can be divided into two types: homogeneous and heterogeneous. Heterogeneous multiprocessor platforms usually get higher performance and energy efficiency than homogeneous ones on the programs which can be parallelized. However, it is more difficult to write programs for heterogeneous multiprocessor platforms than for homogeneous ones due to data management and communication between various processors. Although newly-released OpenCL standard from Khronos Group offers improves portability among heterogeneous multiprocessor platforms, programming on such platforms using OpenCL is still complex and error-prone. Therefore, we intend to design an OpenACC compiler based on LLVM for automatically translating the OpenACC program into OpenCL program. In this thesis, we design and implement an extension version of Clang, one of the front-ends of LLVM, to preserve the information of OpenACC directives and clauses as LLVM metadata, since these information will be ignored by the original Clang. Our modified Clang will translate an OpenACC program into LLVM IR with metadata. After that, the OCLHKIR generator and the OpenCL Back-end, designed by our previous researches, will analyze the metadata and then generate the host LLVM IR and the OpenCL kernel functions. Then we execute the host LLVM IR by LLVM JIT-compiler. The experiment result shows that our OpenACC compiler can generate the codes with competitive performance to PGI OpenACC compiler and the manual OpenCL programs. Therefore, our proposed OpenACC compiler not only reduce the difficulty of writing OpenCL programs, but also translate the high performance OpenCL programs. |
URI: | http://140.113.39.130/cdrfb3/record/nctu/#GT070256127 http://hdl.handle.net/11536/127408 |
Appears in Collections: | Thesis |