Automatic OpenCL Code Generation from LLVM-IR using Polyhedral Optimization

Lester Kalms, Tim Hebbeler, Diana Göhringer · 2018

Nowadays, developers can implement applications using OpenCL for all kinds of architectures, like CPUs, GPUs and FPGAs. In this work, we propose a source-to-source compiler that can transform C/C++ source code to optimized OpenCL kernel and host code. This eases the programmability of heterogeneous architectures, to apply different optimization techniques and let the programmer have access during the optimization process. We use polyhedral modeling, which is based on the Polly tool from the LLVM framework, to analysis the code. The information is transferred to the Polyhedral Parallel Code Generator (PPCG), which is a source-to-source compiler that generates OpenCL or CUDA code, since Polly is designed for CPUs. PPCG uses the Abstract Syntax Tree of the Clang for transformation and can thus only process C-code as input. Our approach opens up many new possibilities, like processing other input languages or applying different optimizations, since it works on the intermediate language of the LLVM framework. A main part of the work was the creation of valid C-code from LLVM-IR basic blocks and regions. In addition, a module for recognizing and transforming local variables was created.

Read the paper · More papers on PaperTik