|
| 1 | +# Overview |
| 2 | + |
| 3 | +The SYCL* Compiler contains many options to generate the desired binaries for |
| 4 | +your application. |
| 5 | + |
| 6 | +## SYCL specific command line options |
| 7 | + |
| 8 | +**`-fsycl`** |
| 9 | + |
| 10 | + General enabling option for SYCL compilation mode. This option enables |
| 11 | + offload compilation for a given target using the `-fsycl-targets` option. |
| 12 | + When the `-fsycl-targets` option is not provided, the default triple is |
| 13 | + `spir64-unknown-[linux,windows]-sycldevice`. |
| 14 | + |
| 15 | +**`-fsycl-targets=<value>`** |
| 16 | + |
| 17 | + A comma separated list of triples to specify the device target(s) to generate |
| 18 | + code for. This option is only valid when used with `-fsycl`. |
| 19 | + |
| 20 | +### Target toolchain options. |
| 21 | + |
| 22 | +**`-Xsycl-target-backend=<triple> <arg>`** |
| 23 | + |
| 24 | + Pass <arg> to the SYCL based backend identified by <triple>. |
| 25 | + |
| 26 | +**`-Xsycl-target-backend <arg>`** |
| 27 | + |
| 28 | + Pass <arg> to the SYCL based target backend. |
| 29 | + |
| 30 | +**`-Xsycl-target-frontend=<triple> <arg>`** |
| 31 | + |
| 32 | + Pass <arg> to the SYCL based target frontend identified by <triple>. |
| 33 | + |
| 34 | +**`-Xsycl-target-frontend <arg>`** |
| 35 | + |
| 36 | + Pass <arg> to the SYCL based target frontend. |
| 37 | + |
| 38 | +**`-Xsycl-target-linker=<triple> <arg>`** |
| 39 | + |
| 40 | + Pass <arg> to the SYCL based target linker identified by <triple>. |
| 41 | + |
| 42 | +**`-Xsycl-target-linker <arg>`** |
| 43 | + |
| 44 | + Pass <arg> to the SYCL based target linker. |
| 45 | + |
| 46 | +### Link options |
| 47 | + |
| 48 | +**`-fsycl-link`** |
| 49 | + |
| 50 | + Generate partially linked device object to be used with the host link. |
| 51 | + |
| 52 | +**`-fsycl-link-targets=<T1,...,Tn>`** |
| 53 | + |
| 54 | + Specify comma-separated list of triples SYCL offloading targets to produce |
| 55 | + linked device images. Used in a link step to link device code for given |
| 56 | + targets and output multiple linked device code images, whose names consist |
| 57 | + of the common prefix taken from the -o option and the triple string. |
| 58 | + Does not produce fat binary and must be used together with -fsycl. |
| 59 | + |
| 60 | +**`-fsycl-add-targets=<T1:file1...Tn:filen>`** |
| 61 | + |
| 62 | + Add arbitrary device images to the fat binary being linked |
| 63 | + |
| 64 | + Specify comma-separated list of triple and device binary image file name |
| 65 | + pairs to add to the final SYCL binary. Tells clang to include given set of |
| 66 | + device binaries into the fat SYCL binary when linking; the option value is |
| 67 | + a set of pairs triple,filename - filename is treated as the device binary |
| 68 | + image for the target triple it is paired with, and offload bundler is |
| 69 | + invoked to do the actual bundling. |
| 70 | + |
| 71 | +**`-foffload-static-lib=<lib>`** |
| 72 | + |
| 73 | + Link with fat static library. |
| 74 | + |
| 75 | + Link with <lib>, which is a fat static archive containing fat objects which |
| 76 | + correspond to the target device. When linking clang will extract the device |
| 77 | + code from the objects contained in the library and link it with other |
| 78 | + device objects coming from the individual fat objects passed on the command |
| 79 | + line. |
| 80 | + NOTE: Any libraries that are passed on the command line which are not |
| 81 | + specified with `-foffload-static-lib` are treated as host libraries and are |
| 82 | + only used during the final host link. |
| 83 | + |
| 84 | +### Intel FPGA specific options |
| 85 | + |
| 86 | +**`-fintelfpga`** |
| 87 | + |
| 88 | + Perform ahead of time compilation for FPGA. |
| 89 | + |
| 90 | +**`-fsycl-link=<value>`** |
| 91 | + |
| 92 | + Generate partially linked device and host object to be used at various |
| 93 | + stages of compilation. Takes the device binary(s) generated from a `-fsycl` |
| 94 | + enabled compilation and wrap to create a host linkable object. This option |
| 95 | + is enabled only in ahead of time compilation mode fore FPGA (i.e. when |
| 96 | + `-fintelfpga` is set). |
| 97 | + |
| 98 | +**`-reuse-exe=<exe>`** |
| 99 | + |
| 100 | + Speed up FPGA aoc compile if the device code in <exe> is unchanged. |
| 101 | + |
| 102 | +### Other options |
| 103 | + |
| 104 | +**`-fsycl-device-only`** |
| 105 | + |
| 106 | + Compile only SYCL device code. |
| 107 | + |
| 108 | +**`-fsycl-use-bitcode`** |
| 109 | + |
| 110 | + Emit SYCL device code in LLVM-IR bitcode format. When disabled, SPIR-V is |
| 111 | + emitted. Default is true. |
| 112 | + |
| 113 | +**`-fno-sycl-use-bitcode`** |
| 114 | + |
| 115 | + Use SPIR-V instead of LLVM bitcode in fat objects. |
| 116 | + |
| 117 | +**`-sycl-std=<value>`** |
| 118 | + |
| 119 | + SYCL language standard to compile for. |
| 120 | + |
| 121 | +**`-fsycl-help`** |
| 122 | + |
| 123 | + Emit help information from all of the offline compilation tools. |
| 124 | + |
| 125 | +**`-fsycl-help=<value>`** |
| 126 | + |
| 127 | + Emit help information from the offline compilation tool associated with the |
| 128 | + given architecture argument. Supported architectures: `x86_64`, `fpga` and |
| 129 | + `gen`. |
| 130 | + |
| 131 | +**`-fsycl-unnamed-lambda`** |
| 132 | + |
| 133 | + Allow unnamed SYCL lambda kernels. |
| 134 | + |
| 135 | +# SYCL device code compilation |
| 136 | + |
| 137 | +To invoke SYCL device compiler set `-fsycl-device-only` flag. |
| 138 | + |
| 139 | +```console |
| 140 | +$ clang++ -fsycl-device-only sycl-app.cpp -o sycl-app.bc |
| 141 | +``` |
| 142 | + |
| 143 | +By default the output format for SYCL device is LLVM bytecode. |
| 144 | + |
| 145 | +`-fno-sycl-use-bitcode` can be used to emit device code in SPIR-V format. |
| 146 | + |
| 147 | +```console |
| 148 | +$ clang++ -fsycl-device-only -fno-sycl-use-bitcode sycl-app.cpp -o sycl-app.spv |
| 149 | +``` |
| 150 | + |
| 151 | +# Static archives with SYCL device code |
| 152 | + |
| 153 | +The SYCL Compiler contains support to create and use static archives that |
| 154 | +contain device enabled fat objects. |
| 155 | + |
| 156 | +## Build your objects |
| 157 | + |
| 158 | +```console |
| 159 | +$ clang++ -fsycl sycl-app1.cpp sycl-app2.cpp -c |
| 160 | +``` |
| 161 | + |
| 162 | +## Create the static archive |
| 163 | + |
| 164 | +Build the static archive in the same manner as you would any other normal |
| 165 | +static archive, using the objects that were created using the above step. |
| 166 | + |
| 167 | +```console |
| 168 | +$ ar cr libsyclapp.a sycl-app1.o sycl-app2.o |
| 169 | +``` |
| 170 | + |
| 171 | +## Use the static archive |
| 172 | + |
| 173 | +Once you have created the archive, you can use it when creating your final |
| 174 | +application. The fat archives are treated differently than a regular archive |
| 175 | +so the option `-foffload-static-lib` is used to signify the needed behavior. |
| 176 | + |
| 177 | +```console |
| 178 | +$ clang++ -fsycl sycl-main.cpp -foffload-static-lib=libsyclapp.a |
| 179 | +``` |
| 180 | + |
| 181 | +Use of `-foffload-static-lib` is required or the library will be treated as |
| 182 | +a normal archive. |
0 commit comments