|
| 1 | +# Intel® Graphics Compiler for OpenCL™ |
| 2 | + |
| 3 | +## Ubuntu build section |
| 4 | + |
| 5 | +### 1. Prepare workspace |
| 6 | + |
| 7 | +Building IGC needs flex, bison, libz and cmake version at least 3.4.3. You can install required packages on Ubuntu using this command: |
| 8 | + |
| 9 | +```shell |
| 10 | +$ sudo apt-get install flex bison libz-dev cmake |
| 11 | +``` |
| 12 | + |
| 13 | +Some of the incoming git operations will try to download and apply patches. For this purpose it is necessary to setup git credentials if they are not already in the git configuration: |
| 14 | +```shell |
| 15 | +$ git config --global user.name "FirstName LastName" |
| 16 | +$ git config --global user.email "[email protected]" |
| 17 | +``` |
| 18 | + |
| 19 | +### 2. Install LLVM, Clang and OpenCL Clang |
| 20 | + |
| 21 | +> <span style="color: firebrick; font-weight: 600;">Important notice</span> |
| 22 | +Every LLVM/Clang version brings some restrictions and in some cases needs different configuration. Please refer to [LLVM/Clang caveats](#LLVM/Clang-version-specific-caveats) section for more information. |
| 23 | + |
| 24 | +In this step you need to prepare LLVM, OpenCL-Clang libraries and Clang for IGC. |
| 25 | +It can be done either by using packaged releases or building those yourself: |
| 26 | + |
| 27 | +#### Use preinstalled packages |
| 28 | + |
| 29 | +For **LLVM** and **Clang** packages please visit this [link](https://apt.llvm.org/) to download and install desired version. |
| 30 | +As of now **OpenCL Clang** is still needed to be built and installed manually. Sources are available [here](https://github.com/intel/opencl-clang). You can use out-of-tree build method with LLVM and Clang preinstalled. |
| 31 | + |
| 32 | +Installing these three components (LLVM, Clang, and OpenCL Clang) means you no longer have to download their sources alongside IGC, so the workspace tree in the next step may look like this: |
| 33 | +``` |
| 34 | +<workspace> |
| 35 | + |- igc https://github.com/intel/intel-graphics-compiler |
| 36 | +``` |
| 37 | + |
| 38 | +#### Build from sources |
| 39 | + |
| 40 | +Download all dependencies and create workspace folder as below: |
| 41 | +``` |
| 42 | +<workspace> |
| 43 | + |- igc https://github.com/intel/intel-graphics-compiler |
| 44 | + |- llvm_patches https://github.com/intel/llvm-patches |
| 45 | + |- llvm_source https://github.com/llvm-mirror/llvm |
| 46 | + |- projects/opencl-clang https://github.com/intel/opencl-clang |
| 47 | + |- projects/llvm-spirv https://github.com/KhronosGroup/SPIRV-LLVM-Translator |
| 48 | + |- tools/clang https://github.com/llvm-mirror/clang |
| 49 | +``` |
| 50 | + |
| 51 | +You can use following commands: |
| 52 | +```shell |
| 53 | +$ cd <workspace> |
| 54 | +$ git clone -b release_80 https://github.com/llvm-mirror/llvm llvm_source |
| 55 | +$ git clone -b release_80 https://github.com/llvm-mirror/clang llvm_source/tools/clang |
| 56 | +$ git clone -b ocl-open-80 https://github.com/intel/opencl-clang llvm_source/projects/opencl-clang |
| 57 | +$ git clone -b llvm_release_80 https://github.com/KhronosGroup/SPIRV-LLVM-Translator llvm_source/projects/llvm-spirv |
| 58 | +$ git clone https://github.com/intel/llvm-patches llvm_patches |
| 59 | +``` |
| 60 | + |
| 61 | +Make sure to specify correct branch for desired version. In this example we use LLVM8/Clang8. |
| 62 | +All dependencies will be build in the next step. |
| 63 | + |
| 64 | +### 3. Build and install IGC |
| 65 | + |
| 66 | +1. Download sources: |
| 67 | +```shell |
| 68 | +$ cd <workspace> |
| 69 | +$ git clone https://github.com/intel/intel-graphics-compiler igc |
| 70 | + [If using specific release] |
| 71 | +$ cd igc && git checkout -b tag igc_release_2019-01-15 |
| 72 | +``` |
| 73 | + |
| 74 | +2. Prepare workspace and build |
| 75 | + |
| 76 | +If you are using [Use preinstalled packages](#use-preinstalled-packages) method IGC will link with installed dependencies dynamically. |
| 77 | +If you are using [Build from sources](#build-from-sources) method IGC will automatically build all dependencies (provided that the workspace structure is preserved) and link statically to LLVM and OpenCL Clang. |
| 78 | + |
| 79 | +You can use following commands to build IGC: |
| 80 | + |
| 81 | +```shell |
| 82 | +$ cd <workspace> |
| 83 | +$ mkdir build |
| 84 | +$ cd build |
| 85 | +$ cmake ../igc/IGC |
| 86 | +$ make -j`nproc` |
| 87 | +``` |
| 88 | + |
| 89 | +3. Install IGC: |
| 90 | +```shell |
| 91 | +$ sudo make install |
| 92 | +``` |
| 93 | + |
| 94 | +*** |
| 95 | + |
| 96 | +## LLVM/Clang version specific caveats |
| 97 | + |
| 98 | +### LLVM7/Clang7 |
| 99 | + |
| 100 | +In the **OpenCL Clang** project there are patches for Clang. |
| 101 | +If the Clang you are using to build IGC does not have these patches (for example, when you are using prebuilt packages) it is necessary to add ```-DVME_TYPES_DEFINED=FALSE``` to IGC cmake flags. |
| 102 | + |
| 103 | +### LLVM8/Clang8 |
| 104 | + |
| 105 | +We recommend building LLVM8/Clang8 from sources instead for using prebuilds, because packaged Clang8 is missing these patches: |
| 106 | +* [0001-OpenCL-Change-type-of-block-pointer-for-OpenCL.patch](https://github.com/intel/opencl-clang/blob/ocl-open-80/patches/clang/0001-OpenCL-Change-type-of-block-pointer-for-OpenCL.patch) |
| 107 | +* [0002-OpenCL-Simplify-LLVM-IR-generated-for-OpenCL-blocks.patch](https://github.com/intel/opencl-clang/blob/ocl-open-80/patches/clang/0002-OpenCL-Simplify-LLVM-IR-generated-for-OpenCL-blocks.patch) |
| 108 | +* [0003-OpenCL-Fix-assertion-due-to-blocks.patch](https://github.com/intel/opencl-clang/blob/ocl-open-80/patches/clang/0003-OpenCL-Fix-assertion-due-to-blocks.patch) |
| 109 | + |
| 110 | +which are needed for [enqueue_kernel](https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/enqueue_kernel.html). |
| 111 | + |
| 112 | +### LLVM9/Clang9 |
| 113 | + |
| 114 | +You can either use prebuilt packages or build from sources: |
| 115 | +```shell |
| 116 | +$ cd <workspace> |
| 117 | +$ git clone -b master https://github.com/llvm-mirror/llvm llvm_source |
| 118 | +$ git clone -b master https://github.com/llvm-mirror/clang llvm_source/tools/clang |
| 119 | +$ git clone -b master https://github.com/intel/opencl-clang llvm_source/projects/opencl-clang |
| 120 | +$ git clone -b master https://github.com/KhronosGroup/SPIRV-LLVM-Translator llvm_source/projects/llvm-spirv |
| 121 | +$ git clone https://github.com/intel/llvm-patches llvm_patches |
| 122 | +$ git clone https://github.com/intel/intel-graphics-compiler igc |
| 123 | +``` |
| 124 | + |
| 125 | +Keep in mind that this configuration is experimental and problems with compilation and functionality are to be expected. |
| 126 | + |
| 127 | +Latest known configuration that compiles successfully: |
| 128 | + |
| 129 | +``` |
| 130 | +<workspace> |
| 131 | + |- igc (master/8cb64241) |
| 132 | + |- llvm_patches (master/cac8d77) |
| 133 | + |- llvm_source (master/541ca56bcf2) |
| 134 | + |- projects/opencl-clang (master/faa242c) |
| 135 | + |- projects/llvm-spirv (master/365675f) |
| 136 | + |- tools/clang (master/203bf9fe94) |
| 137 | +``` |
| 138 | + |
| 139 | +- https://github.com/intel/intel-graphics-compiler/commit/8cb64241 |
| 140 | +- https://github.com/intel/llvm-patches/commit/cac8d77 |
| 141 | +- https://github.com/llvm-mirror/llvm/commit/541ca56bcf2 |
| 142 | +- https://github.com/intel/opencl-clang/commit/faa242c |
| 143 | +- https://github.com/KhronosGroup/SPIRV-LLVM-Translator/commit/365675f |
| 144 | +- https://github.com/llvm-mirror/clang/commit/203bf9fe94 |
0 commit comments